api_op_AllocateStaticIp.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  // Allocates a static IP address.
  15  func (c *Client) AllocateStaticIp(ctx context.Context, params *AllocateStaticIpInput, optFns ...func(*Options)) (*AllocateStaticIpOutput, error) {
  16  	if params == nil {
  17  		params = &AllocateStaticIpInput{}
  18  	}
  19  
  20  	result, metadata, err := c.invokeOperation(ctx, "AllocateStaticIp", params, optFns, c.addOperationAllocateStaticIpMiddlewares)
  21  	if err != nil {
  22  		return nil, err
  23  	}
  24  
  25  	out := result.(*AllocateStaticIpOutput)
  26  	out.ResultMetadata = metadata
  27  	return out, nil
  28  }
  29  
  30  type AllocateStaticIpInput struct {
  31  
  32  	// The name of the static IP address.
  33  	//
  34  	// This member is required.
  35  	StaticIpName *string
  36  
  37  	noSmithyDocumentSerde
  38  }
  39  
  40  type AllocateStaticIpOutput struct {
  41  
  42  	// An array of objects that describe the result of the action, such as the status
  43  	// of the request, the timestamp of the request, and the resources affected by the
  44  	// request.
  45  	Operations []types.Operation
  46  
  47  	// Metadata pertaining to the operation's result.
  48  	ResultMetadata middleware.Metadata
  49  
  50  	noSmithyDocumentSerde
  51  }
  52  
  53  func (c *Client) addOperationAllocateStaticIpMiddlewares(stack *middleware.Stack, options Options) (err error) {
  54  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
  55  		return err
  56  	}
  57  	err = stack.Serialize.Add(&awsAwsjson11_serializeOpAllocateStaticIp{}, middleware.After)
  58  	if err != nil {
  59  		return err
  60  	}
  61  	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpAllocateStaticIp{}, middleware.After)
  62  	if err != nil {
  63  		return err
  64  	}
  65  	if err := addProtocolFinalizerMiddlewares(stack, options, "AllocateStaticIp"); err != nil {
  66  		return fmt.Errorf("add protocol finalizers: %v", err)
  67  	}
  68  
  69  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
  70  		return err
  71  	}
  72  	if err = addSetLoggerMiddleware(stack, options); err != nil {
  73  		return err
  74  	}
  75  	if err = addClientRequestID(stack); err != nil {
  76  		return err
  77  	}
  78  	if err = addComputeContentLength(stack); err != nil {
  79  		return err
  80  	}
  81  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
  82  		return err
  83  	}
  84  	if err = addComputePayloadSHA256(stack); err != nil {
  85  		return err
  86  	}
  87  	if err = addRetry(stack, options); err != nil {
  88  		return err
  89  	}
  90  	if err = addRawResponseToMetadata(stack); err != nil {
  91  		return err
  92  	}
  93  	if err = addRecordResponseTiming(stack); err != nil {
  94  		return err
  95  	}
  96  	if err = addSpanRetryLoop(stack, options); err != nil {
  97  		return err
  98  	}
  99  	if err = addClientUserAgent(stack, options); err != nil {
 100  		return err
 101  	}
 102  	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
 103  		return err
 104  	}
 105  	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
 106  		return err
 107  	}
 108  	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 109  		return err
 110  	}
 111  	if err = addTimeOffsetBuild(stack, c); err != nil {
 112  		return err
 113  	}
 114  	if err = addUserAgentRetryMode(stack, options); err != nil {
 115  		return err
 116  	}
 117  	if err = addCredentialSource(stack, options); err != nil {
 118  		return err
 119  	}
 120  	if err = addOpAllocateStaticIpValidationMiddleware(stack); err != nil {
 121  		return err
 122  	}
 123  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opAllocateStaticIp(options.Region), middleware.Before); err != nil {
 124  		return err
 125  	}
 126  	if err = addRecursionDetection(stack); err != nil {
 127  		return err
 128  	}
 129  	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
 130  		return err
 131  	}
 132  	if err = addResponseErrorMiddleware(stack); err != nil {
 133  		return err
 134  	}
 135  	if err = addRequestResponseLogging(stack, options); err != nil {
 136  		return err
 137  	}
 138  	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
 139  		return err
 140  	}
 141  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 142  		return err
 143  	}
 144  	if err = addInterceptAttempt(stack, options); err != nil {
 145  		return err
 146  	}
 147  	if err = addInterceptors(stack, options); err != nil {
 148  		return err
 149  	}
 150  	return nil
 151  }
 152  
 153  func newServiceMetadataMiddleware_opAllocateStaticIp(region string) *awsmiddleware.RegisterServiceMetadata {
 154  	return &awsmiddleware.RegisterServiceMetadata{
 155  		Region:        region,
 156  		ServiceID:     ServiceID,
 157  		OperationName: "AllocateStaticIp",
 158  	}
 159  }
 160