1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package storagegateway 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/smithy-go/middleware" 10 smithyhttp "github.com/aws/smithy-go/transport/http" 11) 12 13// Connects a volume to an iSCSI connection and then attaches the volume to the 14// specified gateway. Detaching and attaching a volume enables you to recover your 15// data from one gateway to a different gateway without creating a snapshot. It 16// also makes it easier to move your volumes from an on-premises gateway to a 17// gateway hosted on an Amazon EC2 instance. 18func (c *Client) AttachVolume(ctx context.Context, params *AttachVolumeInput, optFns ...func(*Options)) (*AttachVolumeOutput, error) { 19 if params == nil { 20 params = &AttachVolumeInput{} 21 } 22 23 result, metadata, err := c.invokeOperation(ctx, "AttachVolume", params, optFns, c.addOperationAttachVolumeMiddlewares) 24 if err != nil { 25 return nil, err 26 } 27 28 out := result.(*AttachVolumeOutput) 29 out.ResultMetadata = metadata 30 return out, nil 31} 32 33// AttachVolumeInput 34type AttachVolumeInput struct { 35 36 // The Amazon Resource Name (ARN) of the gateway that you want to attach the volume 37 // to. 38 // 39 // This member is required. 40 GatewayARN *string 41 42 // The network interface of the gateway on which to expose the iSCSI target. Only 43 // IPv4 addresses are accepted. Use DescribeGatewayInformation to get a list of the 44 // network interfaces available on a gateway. Valid Values: A valid IP address. 45 // 46 // This member is required. 47 NetworkInterfaceId *string 48 49 // The Amazon Resource Name (ARN) of the volume to attach to the specified gateway. 50 // 51 // This member is required. 52 VolumeARN *string 53 54 // The unique device ID or other distinguishing data that identifies the local disk 55 // used to create the volume. This value is only required when you are attaching a 56 // stored volume. 57 DiskId *string 58 59 // The name of the iSCSI target used by an initiator to connect to a volume and 60 // used as a suffix for the target ARN. For example, specifying TargetName as 61 // myvolume results in the target ARN of 62 // arn:aws:storagegateway:us-east-2:111122223333:gateway/sgw-12A3456B/target/iqn.1997-05.com.amazon:myvolume. 63 // The target name must be unique across all volumes on a gateway. If you don't 64 // specify a value, Storage Gateway uses the value that was previously used for 65 // this volume as the new target name. 66 TargetName *string 67 68 noSmithyDocumentSerde 69} 70 71// AttachVolumeOutput 72type AttachVolumeOutput struct { 73 74 // The Amazon Resource Name (ARN) of the volume target, which includes the iSCSI 75 // name for the initiator that was used to connect to the target. 76 TargetARN *string 77 78 // The Amazon Resource Name (ARN) of the volume that was attached to the gateway. 79 VolumeARN *string 80 81 // Metadata pertaining to the operation's result. 82 ResultMetadata middleware.Metadata 83 84 noSmithyDocumentSerde 85} 86 87func (c *Client) addOperationAttachVolumeMiddlewares(stack *middleware.Stack, options Options) (err error) { 88 err = stack.Serialize.Add(&awsAwsjson11_serializeOpAttachVolume{}, middleware.After) 89 if err != nil { 90 return err 91 } 92 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpAttachVolume{}, middleware.After) 93 if err != nil { 94 return err 95 } 96 if err = addSetLoggerMiddleware(stack, options); err != nil { 97 return err 98 } 99 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 100 return err 101 } 102 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 103 return err 104 } 105 if err = addResolveEndpointMiddleware(stack, options); err != nil { 106 return err 107 } 108 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 109 return err 110 } 111 if err = addRetryMiddlewares(stack, options); err != nil { 112 return err 113 } 114 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 115 return err 116 } 117 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 118 return err 119 } 120 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 121 return err 122 } 123 if err = addClientUserAgent(stack); err != nil { 124 return err 125 } 126 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 127 return err 128 } 129 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 130 return err 131 } 132 if err = addOpAttachVolumeValidationMiddleware(stack); err != nil { 133 return err 134 } 135 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opAttachVolume(options.Region), middleware.Before); err != nil { 136 return err 137 } 138 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 139 return err 140 } 141 if err = addResponseErrorMiddleware(stack); err != nil { 142 return err 143 } 144 if err = addRequestResponseLogging(stack, options); err != nil { 145 return err 146 } 147 return nil 148} 149 150func newServiceMetadataMiddleware_opAttachVolume(region string) *awsmiddleware.RegisterServiceMetadata { 151 return &awsmiddleware.RegisterServiceMetadata{ 152 Region: region, 153 ServiceID: ServiceID, 154 SigningName: "storagegateway", 155 OperationName: "AttachVolume", 156 } 157} 158