api_op_CreateContactMethod.go raw
1 // Code generated by smithy-go-codegen DO NOT EDIT.
2
3 package lightsail
4
5 import (
6 "context"
7 "fmt"
8 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
9 "github.com/aws/aws-sdk-go-v2/service/lightsail/types"
10 "github.com/aws/smithy-go/middleware"
11 smithyhttp "github.com/aws/smithy-go/transport/http"
12 )
13
14 // Creates an email or SMS text message contact method.
15 //
16 // A contact method is used to send you notifications about your Amazon Lightsail
17 // resources. You can add one email address and one mobile phone number contact
18 // method in each Amazon Web Services Region. However, SMS text messaging is not
19 // supported in some Amazon Web Services Regions, and SMS text messages cannot be
20 // sent to some countries/regions. For more information, see [Notifications in Amazon Lightsail].
21 //
22 // [Notifications in Amazon Lightsail]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-notifications
23 func (c *Client) CreateContactMethod(ctx context.Context, params *CreateContactMethodInput, optFns ...func(*Options)) (*CreateContactMethodOutput, error) {
24 if params == nil {
25 params = &CreateContactMethodInput{}
26 }
27
28 result, metadata, err := c.invokeOperation(ctx, "CreateContactMethod", params, optFns, c.addOperationCreateContactMethodMiddlewares)
29 if err != nil {
30 return nil, err
31 }
32
33 out := result.(*CreateContactMethodOutput)
34 out.ResultMetadata = metadata
35 return out, nil
36 }
37
38 type CreateContactMethodInput struct {
39
40 // The destination of the contact method, such as an email address or a mobile
41 // phone number.
42 //
43 // Use the E.164 format when specifying a mobile phone number. E.164 is a standard
44 // for the phone number structure used for international telecommunication. Phone
45 // numbers that follow this format can have a maximum of 15 digits, and they are
46 // prefixed with the plus character (+) and the country code. For example, a U.S.
47 // phone number in E.164 format would be specified as +1XXX5550100. For more
48 // information, see [E.164]on Wikipedia.
49 //
50 // [E.164]: https://en.wikipedia.org/wiki/E.164
51 //
52 // This member is required.
53 ContactEndpoint *string
54
55 // The protocol of the contact method, such as Email or SMS (text messaging).
56 //
57 // The SMS protocol is supported only in the following Amazon Web Services Regions.
58 //
59 // - US East (N. Virginia) ( us-east-1 )
60 //
61 // - US West (Oregon) ( us-west-2 )
62 //
63 // - Europe (Ireland) ( eu-west-1 )
64 //
65 // - Asia Pacific (Tokyo) ( ap-northeast-1 )
66 //
67 // - Asia Pacific (Singapore) ( ap-southeast-1 )
68 //
69 // - Asia Pacific (Sydney) ( ap-southeast-2 )
70 //
71 // For a list of countries/regions where SMS text messages can be sent, and the
72 // latest Amazon Web Services Regions where SMS text messaging is supported, see [Supported Regions and Countries]
73 // in the Amazon SNS Developer Guide.
74 //
75 // For more information about notifications in Amazon Lightsail, see [Notifications in Amazon Lightsail].
76 //
77 // [Supported Regions and Countries]: https://docs.aws.amazon.com/sns/latest/dg/sns-supported-regions-countries.html
78 // [Notifications in Amazon Lightsail]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-notifications
79 //
80 // This member is required.
81 Protocol types.ContactProtocol
82
83 noSmithyDocumentSerde
84 }
85
86 type CreateContactMethodOutput struct {
87
88 // An array of objects that describe the result of the action, such as the status
89 // of the request, the timestamp of the request, and the resources affected by the
90 // request.
91 Operations []types.Operation
92
93 // Metadata pertaining to the operation's result.
94 ResultMetadata middleware.Metadata
95
96 noSmithyDocumentSerde
97 }
98
99 func (c *Client) addOperationCreateContactMethodMiddlewares(stack *middleware.Stack, options Options) (err error) {
100 if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
101 return err
102 }
103 err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateContactMethod{}, middleware.After)
104 if err != nil {
105 return err
106 }
107 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateContactMethod{}, middleware.After)
108 if err != nil {
109 return err
110 }
111 if err := addProtocolFinalizerMiddlewares(stack, options, "CreateContactMethod"); err != nil {
112 return fmt.Errorf("add protocol finalizers: %v", err)
113 }
114
115 if err = addlegacyEndpointContextSetter(stack, options); err != nil {
116 return err
117 }
118 if err = addSetLoggerMiddleware(stack, options); err != nil {
119 return err
120 }
121 if err = addClientRequestID(stack); err != nil {
122 return err
123 }
124 if err = addComputeContentLength(stack); err != nil {
125 return err
126 }
127 if err = addResolveEndpointMiddleware(stack, options); err != nil {
128 return err
129 }
130 if err = addComputePayloadSHA256(stack); err != nil {
131 return err
132 }
133 if err = addRetry(stack, options); err != nil {
134 return err
135 }
136 if err = addRawResponseToMetadata(stack); err != nil {
137 return err
138 }
139 if err = addRecordResponseTiming(stack); err != nil {
140 return err
141 }
142 if err = addSpanRetryLoop(stack, options); err != nil {
143 return err
144 }
145 if err = addClientUserAgent(stack, options); err != nil {
146 return err
147 }
148 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
149 return err
150 }
151 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
152 return err
153 }
154 if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
155 return err
156 }
157 if err = addTimeOffsetBuild(stack, c); err != nil {
158 return err
159 }
160 if err = addUserAgentRetryMode(stack, options); err != nil {
161 return err
162 }
163 if err = addCredentialSource(stack, options); err != nil {
164 return err
165 }
166 if err = addOpCreateContactMethodValidationMiddleware(stack); err != nil {
167 return err
168 }
169 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateContactMethod(options.Region), middleware.Before); err != nil {
170 return err
171 }
172 if err = addRecursionDetection(stack); err != nil {
173 return err
174 }
175 if err = addRequestIDRetrieverMiddleware(stack); err != nil {
176 return err
177 }
178 if err = addResponseErrorMiddleware(stack); err != nil {
179 return err
180 }
181 if err = addRequestResponseLogging(stack, options); err != nil {
182 return err
183 }
184 if err = addDisableHTTPSMiddleware(stack, options); err != nil {
185 return err
186 }
187 if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
188 return err
189 }
190 if err = addInterceptAttempt(stack, options); err != nil {
191 return err
192 }
193 if err = addInterceptors(stack, options); err != nil {
194 return err
195 }
196 return nil
197 }
198
199 func newServiceMetadataMiddleware_opCreateContactMethod(region string) *awsmiddleware.RegisterServiceMetadata {
200 return &awsmiddleware.RegisterServiceMetadata{
201 Region: region,
202 ServiceID: ServiceID,
203 OperationName: "CreateContactMethod",
204 }
205 }
206