api_op_SendContactMethodVerification.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  // Sends a verification request to an email contact method to ensure it's owned by
  15  // the requester. SMS contact methods don't need to be verified.
  16  //
  17  // A contact method is used to send you notifications about your Amazon Lightsail
  18  // resources. You can add one email address and one mobile phone number contact
  19  // method in each Amazon Web Services Region. However, SMS text messaging is not
  20  // supported in some Amazon Web Services Regions, and SMS text messages cannot be
  21  // sent to some countries/regions. For more information, see [Notifications in Amazon Lightsail].
  22  //
  23  // A verification request is sent to the contact method when you initially create
  24  // it. Use this action to send another verification request if a previous
  25  // verification request was deleted, or has expired.
  26  //
  27  // Notifications are not sent to an email contact method until after it is
  28  // verified, and confirmed as valid.
  29  //
  30  // [Notifications in Amazon Lightsail]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-notifications
  31  func (c *Client) SendContactMethodVerification(ctx context.Context, params *SendContactMethodVerificationInput, optFns ...func(*Options)) (*SendContactMethodVerificationOutput, error) {
  32  	if params == nil {
  33  		params = &SendContactMethodVerificationInput{}
  34  	}
  35  
  36  	result, metadata, err := c.invokeOperation(ctx, "SendContactMethodVerification", params, optFns, c.addOperationSendContactMethodVerificationMiddlewares)
  37  	if err != nil {
  38  		return nil, err
  39  	}
  40  
  41  	out := result.(*SendContactMethodVerificationOutput)
  42  	out.ResultMetadata = metadata
  43  	return out, nil
  44  }
  45  
  46  type SendContactMethodVerificationInput struct {
  47  
  48  	// The protocol to verify, such as Email or SMS (text messaging).
  49  	//
  50  	// This member is required.
  51  	Protocol types.ContactMethodVerificationProtocol
  52  
  53  	noSmithyDocumentSerde
  54  }
  55  
  56  type SendContactMethodVerificationOutput struct {
  57  
  58  	// An array of objects that describe the result of the action, such as the status
  59  	// of the request, the timestamp of the request, and the resources affected by the
  60  	// request.
  61  	Operations []types.Operation
  62  
  63  	// Metadata pertaining to the operation's result.
  64  	ResultMetadata middleware.Metadata
  65  
  66  	noSmithyDocumentSerde
  67  }
  68  
  69  func (c *Client) addOperationSendContactMethodVerificationMiddlewares(stack *middleware.Stack, options Options) (err error) {
  70  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
  71  		return err
  72  	}
  73  	err = stack.Serialize.Add(&awsAwsjson11_serializeOpSendContactMethodVerification{}, middleware.After)
  74  	if err != nil {
  75  		return err
  76  	}
  77  	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpSendContactMethodVerification{}, middleware.After)
  78  	if err != nil {
  79  		return err
  80  	}
  81  	if err := addProtocolFinalizerMiddlewares(stack, options, "SendContactMethodVerification"); err != nil {
  82  		return fmt.Errorf("add protocol finalizers: %v", err)
  83  	}
  84  
  85  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
  86  		return err
  87  	}
  88  	if err = addSetLoggerMiddleware(stack, options); err != nil {
  89  		return err
  90  	}
  91  	if err = addClientRequestID(stack); err != nil {
  92  		return err
  93  	}
  94  	if err = addComputeContentLength(stack); err != nil {
  95  		return err
  96  	}
  97  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
  98  		return err
  99  	}
 100  	if err = addComputePayloadSHA256(stack); err != nil {
 101  		return err
 102  	}
 103  	if err = addRetry(stack, options); err != nil {
 104  		return err
 105  	}
 106  	if err = addRawResponseToMetadata(stack); err != nil {
 107  		return err
 108  	}
 109  	if err = addRecordResponseTiming(stack); err != nil {
 110  		return err
 111  	}
 112  	if err = addSpanRetryLoop(stack, options); err != nil {
 113  		return err
 114  	}
 115  	if err = addClientUserAgent(stack, options); err != nil {
 116  		return err
 117  	}
 118  	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
 119  		return err
 120  	}
 121  	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
 122  		return err
 123  	}
 124  	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 125  		return err
 126  	}
 127  	if err = addTimeOffsetBuild(stack, c); err != nil {
 128  		return err
 129  	}
 130  	if err = addUserAgentRetryMode(stack, options); err != nil {
 131  		return err
 132  	}
 133  	if err = addCredentialSource(stack, options); err != nil {
 134  		return err
 135  	}
 136  	if err = addOpSendContactMethodVerificationValidationMiddleware(stack); err != nil {
 137  		return err
 138  	}
 139  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opSendContactMethodVerification(options.Region), middleware.Before); err != nil {
 140  		return err
 141  	}
 142  	if err = addRecursionDetection(stack); err != nil {
 143  		return err
 144  	}
 145  	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
 146  		return err
 147  	}
 148  	if err = addResponseErrorMiddleware(stack); err != nil {
 149  		return err
 150  	}
 151  	if err = addRequestResponseLogging(stack, options); err != nil {
 152  		return err
 153  	}
 154  	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
 155  		return err
 156  	}
 157  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 158  		return err
 159  	}
 160  	if err = addInterceptAttempt(stack, options); err != nil {
 161  		return err
 162  	}
 163  	if err = addInterceptors(stack, options); err != nil {
 164  		return err
 165  	}
 166  	return nil
 167  }
 168  
 169  func newServiceMetadataMiddleware_opSendContactMethodVerification(region string) *awsmiddleware.RegisterServiceMetadata {
 170  	return &awsmiddleware.RegisterServiceMetadata{
 171  		Region:        region,
 172  		ServiceID:     ServiceID,
 173  		OperationName: "SendContactMethodVerification",
 174  	}
 175  }
 176