1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package iotevents
4
5import (
6	"context"
7	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
8	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
9	"github.com/aws/aws-sdk-go-v2/service/iotevents/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12	"time"
13)
14
15// Creates an alarm model to monitor an AWS IoT Events input attribute. You can use
16// the alarm to get notified when the value is outside a specified range. For more
17// information, see Create an alarm model
18// (https://docs.aws.amazon.com/iotevents/latest/developerguide/create-alarms.html)
19// in the AWS IoT Events Developer Guide.
20func (c *Client) CreateAlarmModel(ctx context.Context, params *CreateAlarmModelInput, optFns ...func(*Options)) (*CreateAlarmModelOutput, error) {
21	if params == nil {
22		params = &CreateAlarmModelInput{}
23	}
24
25	result, metadata, err := c.invokeOperation(ctx, "CreateAlarmModel", params, optFns, c.addOperationCreateAlarmModelMiddlewares)
26	if err != nil {
27		return nil, err
28	}
29
30	out := result.(*CreateAlarmModelOutput)
31	out.ResultMetadata = metadata
32	return out, nil
33}
34
35type CreateAlarmModelInput struct {
36
37	// A unique name that helps you identify the alarm model. You can't change this
38	// name after you create the alarm model.
39	//
40	// This member is required.
41	AlarmModelName *string
42
43	// Defines when your alarm is invoked.
44	//
45	// This member is required.
46	AlarmRule *types.AlarmRule
47
48	// The ARN of the IAM role that allows the alarm to perform actions and access AWS
49	// resources. For more information, see Amazon Resource Names (ARNs)
50	// (https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) in
51	// the AWS General Reference.
52	//
53	// This member is required.
54	RoleArn *string
55
56	// Contains the configuration information of alarm state changes.
57	AlarmCapabilities *types.AlarmCapabilities
58
59	// Contains information about one or more alarm actions.
60	AlarmEventActions *types.AlarmEventActions
61
62	// A description that tells you what the alarm model detects.
63	AlarmModelDescription *string
64
65	// Contains information about one or more notification actions.
66	AlarmNotification *types.AlarmNotification
67
68	// An input attribute used as a key to create an alarm. AWS IoT Events routes
69	// inputs
70	// (https://docs.aws.amazon.com/iotevents/latest/apireference/API_Input.html)
71	// associated with this key to the alarm.
72	Key *string
73
74	// A non-negative integer that reflects the severity level of the alarm.
75	Severity *int32
76
77	// A list of key-value pairs that contain metadata for the alarm model. The tags
78	// help you manage the alarm model. For more information, see Tagging your AWS IoT
79	// Events resources
80	// (https://docs.aws.amazon.com/iotevents/latest/developerguide/tagging-iotevents.html)
81	// in the AWS IoT Events Developer Guide. You can create up to 50 tags for one
82	// alarm model.
83	Tags []types.Tag
84
85	noSmithyDocumentSerde
86}
87
88type CreateAlarmModelOutput struct {
89
90	// The ARN of the alarm model. For more information, see Amazon Resource Names
91	// (ARNs)
92	// (https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) in
93	// the AWS General Reference.
94	AlarmModelArn *string
95
96	// The version of the alarm model.
97	AlarmModelVersion *string
98
99	// The time the alarm model was created, in the Unix epoch format.
100	CreationTime *time.Time
101
102	// The time the alarm model was last updated, in the Unix epoch format.
103	LastUpdateTime *time.Time
104
105	// The status of the alarm model. The status can be one of the following values:
106	//
107	// *
108	// ACTIVE - The alarm model is active and it's ready to evaluate data.
109	//
110	// *
111	// ACTIVATING - AWS IoT Events is activating your alarm model. Activating an alarm
112	// model can take up to a few minutes.
113	//
114	// * INACTIVE - The alarm model is inactive,
115	// so it isn't ready to evaluate data. Check your alarm model information and
116	// update the alarm model.
117	//
118	// * FAILED - You couldn't create or update the alarm
119	// model. Check your alarm model information and try again.
120	Status types.AlarmModelVersionStatus
121
122	// Metadata pertaining to the operation's result.
123	ResultMetadata middleware.Metadata
124
125	noSmithyDocumentSerde
126}
127
128func (c *Client) addOperationCreateAlarmModelMiddlewares(stack *middleware.Stack, options Options) (err error) {
129	err = stack.Serialize.Add(&awsRestjson1_serializeOpCreateAlarmModel{}, middleware.After)
130	if err != nil {
131		return err
132	}
133	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpCreateAlarmModel{}, middleware.After)
134	if err != nil {
135		return err
136	}
137	if err = addSetLoggerMiddleware(stack, options); err != nil {
138		return err
139	}
140	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
141		return err
142	}
143	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
144		return err
145	}
146	if err = addResolveEndpointMiddleware(stack, options); err != nil {
147		return err
148	}
149	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
150		return err
151	}
152	if err = addRetryMiddlewares(stack, options); err != nil {
153		return err
154	}
155	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
156		return err
157	}
158	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
159		return err
160	}
161	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
162		return err
163	}
164	if err = addClientUserAgent(stack); err != nil {
165		return err
166	}
167	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
168		return err
169	}
170	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
171		return err
172	}
173	if err = addOpCreateAlarmModelValidationMiddleware(stack); err != nil {
174		return err
175	}
176	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateAlarmModel(options.Region), middleware.Before); err != nil {
177		return err
178	}
179	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
180		return err
181	}
182	if err = addResponseErrorMiddleware(stack); err != nil {
183		return err
184	}
185	if err = addRequestResponseLogging(stack, options); err != nil {
186		return err
187	}
188	return nil
189}
190
191func newServiceMetadataMiddleware_opCreateAlarmModel(region string) *awsmiddleware.RegisterServiceMetadata {
192	return &awsmiddleware.RegisterServiceMetadata{
193		Region:        region,
194		ServiceID:     ServiceID,
195		SigningName:   "iotevents",
196		OperationName: "CreateAlarmModel",
197	}
198}
199