in alibabacloudstack/resource_apsarastack_cloudmonitorservice_metricalarmrule.go [21:233]
func resourceAlibabacloudStackCmsAlarm() *schema.Resource {
resource := &schema.Resource{
Schema: map[string]*schema.Schema{
"rule_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ConflictsWith: []string{"name"},
},
"rule_id": {
Type: schema.TypeString,
Computed: true,
},
"name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Deprecated: "Field 'name' is deprecated and will be removed in a future release. Please use new field 'rule_name' instead.",
ConflictsWith: []string{"rule_name"},
},
"namespace": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ConflictsWith: []string{"project"},
},
"project": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
Deprecated: "Field 'project' is deprecated and will be removed in a future release. Please use new field 'namespace' instead.",
ConflictsWith: []string{"namespace"},
},
"metric_name": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
ConflictsWith: []string{"metric"},
},
"metric": {
Type: schema.TypeString,
Optional: true,
Computed: true,
ForceNew: true,
Deprecated: "Field 'metric' is deprecated and will be removed in a future release. Please use new field 'metric_name' instead.",
ConflictsWith: []string{"metric_name"},
},
"dimensions": {
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Elem: schema.TypeString,
Deprecated: "Field 'dimensions' is deprecated and will be removed in a future release. Please use new field 'resources' instead.",
ConflictsWith: []string{"resources"},
},
"resources": {
Type: schema.TypeMap,
Optional: true,
ForceNew: true,
Elem: &schema.Schema{
Type: schema.TypeString,
Elem: &schema.Schema{
Type: schema.TypeString,
},
ValidateFunc: func(i interface{}, k string) ([]string, []error) {
m := i.(map[string]interface{})
if len(m) > 1 {
return nil, []error{fmt.Errorf("too large map")}
}
return nil, nil
},
},
},
"period": {
Type: schema.TypeInt,
Optional: true,
},
"escalations_critical": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"statistics": {
Type: schema.TypeString,
Optional: true,
Default: Average,
ValidateFunc: validation.StringInSlice([]string{Average, Minimum, Maximum, ErrorCodeMaximum, Value}, false),
},
"comparison_operator": {
Type: schema.TypeString,
Optional: true,
Default: Equal,
ValidateFunc: validation.StringInSlice([]string{
MoreThan, MoreThanOrEqual, LessThan, LessThanOrEqual, NotEqual,
}, false),
},
"threshold": {
Type: schema.TypeString,
Optional: true,
},
"times": {
Type: schema.TypeInt,
Optional: true,
Default: 3,
},
},
},
DiffSuppressFunc: cmsClientCriticalSuppressFunc,
MaxItems: 1,
},
"escalations_warn": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"statistics": {
Type: schema.TypeString,
Optional: true,
Default: Average,
ValidateFunc: validation.StringInSlice([]string{Average, Minimum, Maximum, ErrorCodeMaximum, Value}, false),
},
"comparison_operator": {
Type: schema.TypeString,
Optional: true,
Default: Equal,
ValidateFunc: validation.StringInSlice([]string{
MoreThan, MoreThanOrEqual, LessThan, LessThanOrEqual, NotEqual,
}, false),
},
"threshold": {
Type: schema.TypeString,
Optional: true,
},
"times": {
Type: schema.TypeInt,
Optional: true,
Default: 3,
},
},
},
DiffSuppressFunc: cmsClientWarnSuppressFunc,
MaxItems: 1,
},
"escalations_info": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"statistics": {
Type: schema.TypeString,
Optional: true,
Default: Average,
ValidateFunc: validation.StringInSlice([]string{Average, Minimum, Maximum, ErrorCodeMaximum, Value}, false),
},
"comparison_operator": {
Type: schema.TypeString,
Optional: true,
Default: Equal,
ValidateFunc: validation.StringInSlice([]string{
MoreThan, MoreThanOrEqual, LessThan, LessThanOrEqual, NotEqual,
}, false),
},
"threshold": {
Type: schema.TypeString,
Optional: true,
},
"times": {
Type: schema.TypeInt,
Optional: true,
Default: 3,
},
},
},
DiffSuppressFunc: cmsClientInfoSuppressFunc,
MaxItems: 1,
},
"contact_groups": {
Type: schema.TypeList,
Required: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"effective_interval": {
Type: schema.TypeString,
Optional: true,
Default: "00:00-23:59",
},
"silence_time": {
Type: schema.TypeInt,
Optional: true,
Default: 86400,
ValidateFunc: validation.IntBetween(300, 86400),
},
"enabled": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"status": {
Type: schema.TypeString,
Computed: true,
},
"webhook": {
Type: schema.TypeString,
Optional: true,
},
},
}
setResourceFunc(resource, resourceAlibabacloudStackCmsAlarmCreate, resourceAlibabacloudStackCmsAlarmRead, resourceAlibabacloudStackCmsAlarmUpdate, resourceAlibabacloudStackCmsAlarmDelete)
return resource
}