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, 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 69// AttachVolumeOutput 70type AttachVolumeOutput struct { 71 72 // The Amazon Resource Name (ARN) of the volume target, which includes the iSCSI 73 // name for the initiator that was used to connect to the target. 74 TargetARN *string 75 76 // The Amazon Resource Name (ARN) of the volume that was attached to the gateway. 77 VolumeARN *string 78 79 // Metadata pertaining to the operation's result. 80 ResultMetadata middleware.Metadata 81} 82 83func addOperationAttachVolumeMiddlewares(stack *middleware.Stack, options Options) (err error) { 84 err = stack.Serialize.Add(&awsAwsjson11_serializeOpAttachVolume{}, middleware.After) 85 if err != nil { 86 return err 87 } 88 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpAttachVolume{}, middleware.After) 89 if err != nil { 90 return err 91 } 92 if err = addSetLoggerMiddleware(stack, options); err != nil { 93 return err 94 } 95 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 96 return err 97 } 98 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 99 return err 100 } 101 if err = addResolveEndpointMiddleware(stack, options); err != nil { 102 return err 103 } 104 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 105 return err 106 } 107 if err = addRetryMiddlewares(stack, options); err != nil { 108 return err 109 } 110 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 111 return err 112 } 113 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 114 return err 115 } 116 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 117 return err 118 } 119 if err = addClientUserAgent(stack); err != nil { 120 return err 121 } 122 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 123 return err 124 } 125 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 126 return err 127 } 128 if err = addOpAttachVolumeValidationMiddleware(stack); err != nil { 129 return err 130 } 131 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opAttachVolume(options.Region), middleware.Before); err != nil { 132 return err 133 } 134 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 135 return err 136 } 137 if err = addResponseErrorMiddleware(stack); err != nil { 138 return err 139 } 140 if err = addRequestResponseLogging(stack, options); err != nil { 141 return err 142 } 143 return nil 144} 145 146func newServiceMetadataMiddleware_opAttachVolume(region string) *awsmiddleware.RegisterServiceMetadata { 147 return &awsmiddleware.RegisterServiceMetadata{ 148 Region: region, 149 ServiceID: ServiceID, 150 SigningName: "storagegateway", 151 OperationName: "AttachVolume", 152 } 153} 154