api_op_CreateDisk.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 a block storage disk that can be attached to an Amazon Lightsail
  15  // instance in the same Availability Zone ( us-east-2a ).
  16  //
  17  // The create disk operation supports tag-based access control via request tags.
  18  // For more information, see the [Amazon Lightsail Developer Guide].
  19  //
  20  // [Amazon Lightsail Developer Guide]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-controlling-access-using-tags
  21  func (c *Client) CreateDisk(ctx context.Context, params *CreateDiskInput, optFns ...func(*Options)) (*CreateDiskOutput, error) {
  22  	if params == nil {
  23  		params = &CreateDiskInput{}
  24  	}
  25  
  26  	result, metadata, err := c.invokeOperation(ctx, "CreateDisk", params, optFns, c.addOperationCreateDiskMiddlewares)
  27  	if err != nil {
  28  		return nil, err
  29  	}
  30  
  31  	out := result.(*CreateDiskOutput)
  32  	out.ResultMetadata = metadata
  33  	return out, nil
  34  }
  35  
  36  type CreateDiskInput struct {
  37  
  38  	// The Availability Zone where you want to create the disk ( us-east-2a ). Use the
  39  	// same Availability Zone as the Lightsail instance to which you want to attach the
  40  	// disk.
  41  	//
  42  	// Use the get regions operation to list the Availability Zones where Lightsail is
  43  	// currently available.
  44  	//
  45  	// This member is required.
  46  	AvailabilityZone *string
  47  
  48  	// The unique Lightsail disk name ( my-disk ).
  49  	//
  50  	// This member is required.
  51  	DiskName *string
  52  
  53  	// The size of the disk in GB ( 32 ).
  54  	//
  55  	// This member is required.
  56  	SizeInGb *int32
  57  
  58  	// An array of objects that represent the add-ons to enable for the new disk.
  59  	AddOns []types.AddOnRequest
  60  
  61  	// The tag keys and optional values to add to the resource during create.
  62  	//
  63  	// Use the TagResource action to tag a resource after it's created.
  64  	Tags []types.Tag
  65  
  66  	noSmithyDocumentSerde
  67  }
  68  
  69  type CreateDiskOutput struct {
  70  
  71  	// An array of objects that describe the result of the action, such as the status
  72  	// of the request, the timestamp of the request, and the resources affected by the
  73  	// request.
  74  	Operations []types.Operation
  75  
  76  	// Metadata pertaining to the operation's result.
  77  	ResultMetadata middleware.Metadata
  78  
  79  	noSmithyDocumentSerde
  80  }
  81  
  82  func (c *Client) addOperationCreateDiskMiddlewares(stack *middleware.Stack, options Options) (err error) {
  83  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
  84  		return err
  85  	}
  86  	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateDisk{}, middleware.After)
  87  	if err != nil {
  88  		return err
  89  	}
  90  	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateDisk{}, middleware.After)
  91  	if err != nil {
  92  		return err
  93  	}
  94  	if err := addProtocolFinalizerMiddlewares(stack, options, "CreateDisk"); err != nil {
  95  		return fmt.Errorf("add protocol finalizers: %v", err)
  96  	}
  97  
  98  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
  99  		return err
 100  	}
 101  	if err = addSetLoggerMiddleware(stack, options); err != nil {
 102  		return err
 103  	}
 104  	if err = addClientRequestID(stack); err != nil {
 105  		return err
 106  	}
 107  	if err = addComputeContentLength(stack); err != nil {
 108  		return err
 109  	}
 110  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
 111  		return err
 112  	}
 113  	if err = addComputePayloadSHA256(stack); err != nil {
 114  		return err
 115  	}
 116  	if err = addRetry(stack, options); err != nil {
 117  		return err
 118  	}
 119  	if err = addRawResponseToMetadata(stack); err != nil {
 120  		return err
 121  	}
 122  	if err = addRecordResponseTiming(stack); err != nil {
 123  		return err
 124  	}
 125  	if err = addSpanRetryLoop(stack, options); err != nil {
 126  		return err
 127  	}
 128  	if err = addClientUserAgent(stack, options); err != nil {
 129  		return err
 130  	}
 131  	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
 132  		return err
 133  	}
 134  	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
 135  		return err
 136  	}
 137  	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 138  		return err
 139  	}
 140  	if err = addTimeOffsetBuild(stack, c); err != nil {
 141  		return err
 142  	}
 143  	if err = addUserAgentRetryMode(stack, options); err != nil {
 144  		return err
 145  	}
 146  	if err = addCredentialSource(stack, options); err != nil {
 147  		return err
 148  	}
 149  	if err = addOpCreateDiskValidationMiddleware(stack); err != nil {
 150  		return err
 151  	}
 152  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateDisk(options.Region), middleware.Before); err != nil {
 153  		return err
 154  	}
 155  	if err = addRecursionDetection(stack); err != nil {
 156  		return err
 157  	}
 158  	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
 159  		return err
 160  	}
 161  	if err = addResponseErrorMiddleware(stack); err != nil {
 162  		return err
 163  	}
 164  	if err = addRequestResponseLogging(stack, options); err != nil {
 165  		return err
 166  	}
 167  	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
 168  		return err
 169  	}
 170  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 171  		return err
 172  	}
 173  	if err = addInterceptAttempt(stack, options); err != nil {
 174  		return err
 175  	}
 176  	if err = addInterceptors(stack, options); err != nil {
 177  		return err
 178  	}
 179  	return nil
 180  }
 181  
 182  func newServiceMetadataMiddleware_opCreateDisk(region string) *awsmiddleware.RegisterServiceMetadata {
 183  	return &awsmiddleware.RegisterServiceMetadata{
 184  		Region:        region,
 185  		ServiceID:     ServiceID,
 186  		OperationName: "CreateDisk",
 187  	}
 188  }
 189