1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package ebs 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/aws-sdk-go-v2/service/ebs/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12 "io" 13) 14 15// Writes a block of data to a snapshot. If the specified block contains data, the 16// existing data is overwritten. The target snapshot must be in the pending state. 17// Data written to a snapshot must be aligned with 512-byte sectors. 18func (c *Client) PutSnapshotBlock(ctx context.Context, params *PutSnapshotBlockInput, optFns ...func(*Options)) (*PutSnapshotBlockOutput, error) { 19 if params == nil { 20 params = &PutSnapshotBlockInput{} 21 } 22 23 result, metadata, err := c.invokeOperation(ctx, "PutSnapshotBlock", params, optFns, addOperationPutSnapshotBlockMiddlewares) 24 if err != nil { 25 return nil, err 26 } 27 28 out := result.(*PutSnapshotBlockOutput) 29 out.ResultMetadata = metadata 30 return out, nil 31} 32 33type PutSnapshotBlockInput struct { 34 35 // The data to write to the block. The block data is not signed as part of the 36 // Signature Version 4 signing process. As a result, you must generate and provide 37 // a Base64-encoded SHA256 checksum for the block data using the x-amz-Checksum 38 // header. Also, you must specify the checksum algorithm using the 39 // x-amz-Checksum-Algorithm header. The checksum that you provide is part of the 40 // Signature Version 4 signing process. It is validated against a checksum 41 // generated by Amazon EBS to ensure the validity and authenticity of the data. If 42 // the checksums do not correspond, the request fails. For more information, see 43 // Using checksums with the EBS direct APIs 44 // (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-accessing-snapshot.html#ebsapis-using-checksums) 45 // in the Amazon Elastic Compute Cloud User Guide. 46 // 47 // This member is required. 48 BlockData io.Reader 49 50 // The block index of the block in which to write the data. A block index is a 51 // logical index in units of 512 KiB blocks. To identify the block index, divide 52 // the logical offset of the data in the logical volume by the block size (logical 53 // offset of data/524288). The logical offset of the data must be 512 KiB aligned. 54 // 55 // This member is required. 56 BlockIndex *int32 57 58 // A Base64-encoded SHA256 checksum of the data. Only SHA256 checksums are 59 // supported. 60 // 61 // This member is required. 62 Checksum *string 63 64 // The algorithm used to generate the checksum. Currently, the only supported 65 // algorithm is SHA256. 66 // 67 // This member is required. 68 ChecksumAlgorithm types.ChecksumAlgorithm 69 70 // The size of the data to write to the block, in bytes. Currently, the only 71 // supported size is 524288. Valid values: 524288 72 // 73 // This member is required. 74 DataLength *int32 75 76 // The ID of the snapshot. 77 // 78 // This member is required. 79 SnapshotId *string 80 81 // The progress of the write process, as a percentage. 82 Progress *int32 83} 84 85type PutSnapshotBlockOutput struct { 86 87 // The SHA256 checksum generated for the block data by Amazon EBS. 88 Checksum *string 89 90 // The algorithm used by Amazon EBS to generate the checksum. 91 ChecksumAlgorithm types.ChecksumAlgorithm 92 93 // Metadata pertaining to the operation's result. 94 ResultMetadata middleware.Metadata 95} 96 97func addOperationPutSnapshotBlockMiddlewares(stack *middleware.Stack, options Options) (err error) { 98 err = stack.Serialize.Add(&awsRestjson1_serializeOpPutSnapshotBlock{}, middleware.After) 99 if err != nil { 100 return err 101 } 102 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpPutSnapshotBlock{}, middleware.After) 103 if err != nil { 104 return err 105 } 106 if err = addSetLoggerMiddleware(stack, options); err != nil { 107 return err 108 } 109 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 110 return err 111 } 112 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 113 return err 114 } 115 if err = addResolveEndpointMiddleware(stack, options); err != nil { 116 return err 117 } 118 if err = v4.AddUnsignedPayloadMiddleware(stack); err != nil { 119 return err 120 } 121 if err = v4.AddContentSHA256HeaderMiddleware(stack); err != nil { 122 return err 123 } 124 if err = addRetryMiddlewares(stack, options); err != nil { 125 return err 126 } 127 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 128 return err 129 } 130 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 131 return err 132 } 133 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 134 return err 135 } 136 if err = addClientUserAgent(stack); err != nil { 137 return err 138 } 139 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 140 return err 141 } 142 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 143 return err 144 } 145 if err = addOpPutSnapshotBlockValidationMiddleware(stack); err != nil { 146 return err 147 } 148 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPutSnapshotBlock(options.Region), middleware.Before); err != nil { 149 return err 150 } 151 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 152 return err 153 } 154 if err = addResponseErrorMiddleware(stack); err != nil { 155 return err 156 } 157 if err = addRequestResponseLogging(stack, options); err != nil { 158 return err 159 } 160 return nil 161} 162 163func newServiceMetadataMiddleware_opPutSnapshotBlock(region string) *awsmiddleware.RegisterServiceMetadata { 164 return &awsmiddleware.RegisterServiceMetadata{ 165 Region: region, 166 ServiceID: ServiceID, 167 SigningName: "ebs", 168 OperationName: "PutSnapshotBlock", 169 } 170} 171