templates

package
v0.9.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 27, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(client *golangsdk.ServiceClient, opts CreateOpts) (string, error)

Create creates a new custom alarm template.

func Update

func Update(client *golangsdk.ServiceClient, templateId string, opts UpdateOpts) error

Update modifies a custom alarm template.

Types

type AssociationAlarm

type AssociationAlarm struct {
	// Specifies the alarm rule ID.
	AlarmId string `json:"alarm_id"`
	// Specifies the alarm rule name.
	Name string `json:"name"`
	// Specifies the alarm rule description.
	Description string `json:"description"`
}

AssociationAlarm represents an alarm rule associated with an alarm template.

type CreateOpts

type CreateOpts struct {
	// Specifies the alarm template name.
	// It must start with a letter and can contain letters, digits, underscores (_),
	// hyphens (-), parentheses, and periods (.).
	// Enter 1 to 128 characters.
	TemplateName string `json:"template_name" required:"true"`
	// Specifies the alarm template type.
	// 0: metric alarm template
	// 2: event alarm template
	TemplateType int `json:"template_type,omitempty"`
	// Provides supplementary information about the alarm template.
	// Enter 0 to 256 characters.
	TemplateDescription string `json:"template_description,omitempty"`
	// Specifies the alarm policies. A maximum of 50 policies are supported.
	Policies []Policy `json:"policies" required:"true"`
}

CreateOpts contains the options for creating a custom alarm template.

type DeleteOpts

type DeleteOpts struct {
	// Specifies the list of alarm template IDs to delete.
	// A maximum of 100 templates can be deleted at a time.
	TemplateIds []string `json:"template_ids" required:"true"`
	// Specifies whether to delete the alarm rules associated with the alarm template.
	// true: The alarm rules are also deleted.
	// false: The alarm rules are not deleted.
	DeleteAssociateAlarm bool `json:"delete_associate_alarm"`
}

DeleteOpts contains the options for batch deleting custom alarm templates.

type DeleteResponse

type DeleteResponse struct {
	// Specifies the list of deleted alarm template IDs.
	TemplateIds []string `json:"template_ids"`
}

DeleteResponse contains the response from the batch delete request.

func Delete

func Delete(client *golangsdk.ServiceClient, opts DeleteOpts) (*DeleteResponse, error)

Delete batch deletes custom alarm templates.

type ListAssociationAlarmsOpts

type ListAssociationAlarmsOpts struct {
	// Specifies the pagination offset. Default: 0, Range: 0-10000
	Offset int `q:"offset,omitempty"`
	// Specifies the number of records on each page. Default: 100, Range: 1-100
	Limit int `q:"limit,omitempty"`
}

ListAssociationAlarmsOpts contains the options for querying alarm rules associated with an alarm template.

type ListAssociationAlarmsResponse

type ListAssociationAlarmsResponse struct {
	// Specifies the list of alarm rules associated with the alarm template.
	Alarms []AssociationAlarm `json:"alarms"`
	// Specifies the total number of alarm rules.
	Count int `json:"count"`
}

ListAssociationAlarmsResponse contains the response from the ListAssociationAlarms request.

func ListAssociationAlarms

func ListAssociationAlarms(client *golangsdk.ServiceClient, templateId string, opts ListAssociationAlarmsOpts) (*ListAssociationAlarmsResponse, error)

ListAssociationAlarms returns a list of alarm rules associated with an alarm template.

type ListOpts

type ListOpts struct {
	// Specifies the pagination offset. Default: 0, Range: 0-10000
	Offset int `q:"offset,omitempty"`
	// Specifies the number of records on each page. Default: 100, Range: 1-100
	Limit int `q:"limit,omitempty"`
	// Specifies the namespace of a service.
	// The value must be in the service.item format and can contain 3 to 32 characters.
	Namespace string `q:"namespace"`
	// Specifies the resource dimension.
	// Multiple values can be separated by commas.
	DimName string `q:"dim_name"`
	// Specifies the alarm template type.
	// Possible values: system, custom, system_event, custom_event, system_custom_event
	TemplateType string `q:"template_type"`
	// Specifies the alarm template name. Fuzzy matching is supported.
	// Enter 1 to 128 characters.
	TemplateName string `q:"template_name"`
}

ListOpts contains the options for querying alarm templates.

type ListResponse

type ListResponse struct {
	// Specifies the list of alarm templates.
	AlarmTemplates []Template `json:"alarm_templates"`
	// Specifies the total number of alarm templates.
	Count int `json:"count"`
}

ListResponse contains the response from the List request.

func List

func List(client *golangsdk.ServiceClient, opts ListOpts) (*ListResponse, error)

List returns a list of alarm templates.

type Policy

type Policy struct {
	// Specifies the namespace of a service.
	// The value must be in the service.item format and can contain 3 to 32 characters.
	Namespace string `json:"namespace" required:"true"`
	// Specifies the resource dimension.
	// The value can contain a maximum of 32 characters.
	// Leave this parameter blank for an event alarm template.
	DimensionName string `json:"dimension_name,omitempty"`
	// Specifies the metric name of a resource.
	// It must start with a letter and can contain 1 to 96 characters.
	MetricName string `json:"metric_name" required:"true"`
	// Specifies the aggregation period in seconds.
	// Possible values: 0, 1, 300, 1200, 3600, 14400, 86400
	Period int `json:"period" required:"true"`
	// Specifies the data aggregation method.
	// Possible values: average, max, min, sum, variance
	Filter string `json:"filter" required:"true"`
	// Specifies the comparison operator.
	// Possible values: >, <, >=, <=, =, !=
	ComparisonOperator string `json:"comparison_operator" required:"true"`
	// Specifies the alarm threshold.
	Value float64 `json:"value,omitempty"`
	// Specifies the data unit.
	// Enter 0 to 32 characters.
	Unit string `json:"unit,omitempty"`
	// Specifies the number of consecutive times that the alarm condition is met.
	// For event alarms: 1-180
	// For metric alarms: 1, 2, 3, 4, 5, 10, 15, 30, 60, 90, 120, or 180
	Count int `json:"count" required:"true"`
	// Specifies the alarm severity.
	// 1: critical, 2: major, 3: minor, 4: informational
	// Default value: 2
	AlarmLevel int `json:"alarm_level,omitempty"`
	// Specifies the interval for triggering an alarm if the alarm persists in seconds.
	// Possible values: 0, 300, 600, 900, 1800, 3600, 10800, 21600, 43200, 86400
	SuppressDuration int `json:"suppress_duration" required:"true"`
}

Policy represents an alarm policy in the template.

type PolicyResp

type PolicyResp struct {
	// Specifies the namespace of a service.
	Namespace string `json:"namespace"`
	// Specifies the resource dimension.
	DimensionName string `json:"dimension_name"`
	// Specifies the metric name of a resource.
	MetricName string `json:"metric_name"`
	// Specifies the aggregation period in seconds.
	Period int `json:"period"`
	// Specifies the data aggregation method.
	Filter string `json:"filter"`
	// Specifies the comparison operator.
	ComparisonOperator string `json:"comparison_operator"`
	// Specifies the alarm threshold.
	Value float64 `json:"value"`
	// Specifies the data unit.
	Unit string `json:"unit"`
	// Specifies the number of consecutive times that the alarm condition is met.
	Count int `json:"count"`
	// Specifies the alarm severity.
	// 1: critical, 2: major, 3: minor, 4: informational
	AlarmLevel int `json:"alarm_level"`
	// Specifies the interval for triggering an alarm if the alarm persists in seconds.
	SuppressDuration int `json:"suppress_duration"`
}

PolicyResp represents an alarm policy in the response.

type Template

type Template struct {
	// Specifies the alarm template ID.
	TemplateId string `json:"template_id"`
	// Specifies the alarm template name.
	TemplateName string `json:"template_name"`
	// Specifies the alarm template type.
	// Possible values: system, custom
	TemplateType string `json:"template_type"`
	// Specifies the time when the alarm template was created.
	// The value is in UTC format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
	CreateTime string `json:"create_time"`
	// Provides supplementary information about the alarm template.
	TemplateDescription string `json:"template_description"`
}

Template represents an alarm template in the list response.

type TemplateDetail

type TemplateDetail struct {
	// Specifies the alarm template ID.
	TemplateId string `json:"template_id"`
	// Specifies the alarm template name.
	TemplateName string `json:"template_name"`
	// Specifies the alarm template type.
	// Possible values: system, custom
	TemplateType string `json:"template_type"`
	// Specifies the time when the alarm template was created.
	// The value is in UTC format: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
	CreateTime string `json:"create_time"`
	// Provides supplementary information about the alarm template.
	TemplateDescription string `json:"template_description"`
	// Specifies the alarm policies.
	Policies []PolicyResp `json:"policies"`
}

TemplateDetail represents the detailed information of an alarm template.

func Get

func Get(client *golangsdk.ServiceClient, templateId string) (*TemplateDetail, error)

Get retrieves details of an alarm template.

type UpdateOpts

type UpdateOpts struct {
	// Specifies the alarm template name.
	// It must start with a letter and can contain letters, digits, underscores (_),
	// hyphens (-), parentheses, and periods (.).
	// Enter 1 to 128 characters.
	TemplateName string `json:"template_name" required:"true"`
	// Specifies the alarm template type.
	// 0: metric alarm template
	// 2: event alarm template
	TemplateType int `json:"template_type,omitempty"`
	// Provides supplementary information about the alarm template.
	// Enter 0 to 256 characters.
	TemplateDescription string `json:"template_description,omitempty"`
	// Specifies the alarm policies. A maximum of 50 policies are supported.
	Policies []Policy `json:"policies" required:"true"`
}

UpdateOpts contains the options for modifying a custom alarm template.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL