api_op_ExportSnapshot.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  // Exports an Amazon Lightsail instance or block storage disk snapshot to Amazon
  15  // Elastic Compute Cloud (Amazon EC2). This operation results in an export snapshot
  16  // record that can be used with the create cloud formation stack operation to
  17  // create new Amazon EC2 instances.
  18  //
  19  // Exported instance snapshots appear in Amazon EC2 as Amazon Machine Images
  20  // (AMIs), and the instance system disk appears as an Amazon Elastic Block Store
  21  // (Amazon EBS) volume. Exported disk snapshots appear in Amazon EC2 as Amazon EBS
  22  // volumes. Snapshots are exported to the same Amazon Web Services Region in Amazon
  23  // EC2 as the source Lightsail snapshot.
  24  //
  25  // The export snapshot operation supports tag-based access control via resource
  26  // tags applied to the resource identified by source snapshot name . For more
  27  // information, see the [Amazon Lightsail Developer Guide].
  28  //
  29  // Use the get instance snapshots or get disk snapshots operations to get a list
  30  // of snapshots that you can export to Amazon EC2.
  31  //
  32  // [Amazon Lightsail Developer Guide]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-controlling-access-using-tags
  33  func (c *Client) ExportSnapshot(ctx context.Context, params *ExportSnapshotInput, optFns ...func(*Options)) (*ExportSnapshotOutput, error) {
  34  	if params == nil {
  35  		params = &ExportSnapshotInput{}
  36  	}
  37  
  38  	result, metadata, err := c.invokeOperation(ctx, "ExportSnapshot", params, optFns, c.addOperationExportSnapshotMiddlewares)
  39  	if err != nil {
  40  		return nil, err
  41  	}
  42  
  43  	out := result.(*ExportSnapshotOutput)
  44  	out.ResultMetadata = metadata
  45  	return out, nil
  46  }
  47  
  48  type ExportSnapshotInput struct {
  49  
  50  	// The name of the instance or disk snapshot to be exported to Amazon EC2.
  51  	//
  52  	// This member is required.
  53  	SourceSnapshotName *string
  54  
  55  	noSmithyDocumentSerde
  56  }
  57  
  58  type ExportSnapshotOutput struct {
  59  
  60  	// An array of objects that describe the result of the action, such as the status
  61  	// of the request, the timestamp of the request, and the resources affected by the
  62  	// request.
  63  	Operations []types.Operation
  64  
  65  	// Metadata pertaining to the operation's result.
  66  	ResultMetadata middleware.Metadata
  67  
  68  	noSmithyDocumentSerde
  69  }
  70  
  71  func (c *Client) addOperationExportSnapshotMiddlewares(stack *middleware.Stack, options Options) (err error) {
  72  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
  73  		return err
  74  	}
  75  	err = stack.Serialize.Add(&awsAwsjson11_serializeOpExportSnapshot{}, middleware.After)
  76  	if err != nil {
  77  		return err
  78  	}
  79  	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpExportSnapshot{}, middleware.After)
  80  	if err != nil {
  81  		return err
  82  	}
  83  	if err := addProtocolFinalizerMiddlewares(stack, options, "ExportSnapshot"); err != nil {
  84  		return fmt.Errorf("add protocol finalizers: %v", err)
  85  	}
  86  
  87  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
  88  		return err
  89  	}
  90  	if err = addSetLoggerMiddleware(stack, options); err != nil {
  91  		return err
  92  	}
  93  	if err = addClientRequestID(stack); err != nil {
  94  		return err
  95  	}
  96  	if err = addComputeContentLength(stack); err != nil {
  97  		return err
  98  	}
  99  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
 100  		return err
 101  	}
 102  	if err = addComputePayloadSHA256(stack); err != nil {
 103  		return err
 104  	}
 105  	if err = addRetry(stack, options); err != nil {
 106  		return err
 107  	}
 108  	if err = addRawResponseToMetadata(stack); err != nil {
 109  		return err
 110  	}
 111  	if err = addRecordResponseTiming(stack); err != nil {
 112  		return err
 113  	}
 114  	if err = addSpanRetryLoop(stack, options); err != nil {
 115  		return err
 116  	}
 117  	if err = addClientUserAgent(stack, options); err != nil {
 118  		return err
 119  	}
 120  	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
 121  		return err
 122  	}
 123  	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
 124  		return err
 125  	}
 126  	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 127  		return err
 128  	}
 129  	if err = addTimeOffsetBuild(stack, c); err != nil {
 130  		return err
 131  	}
 132  	if err = addUserAgentRetryMode(stack, options); err != nil {
 133  		return err
 134  	}
 135  	if err = addCredentialSource(stack, options); err != nil {
 136  		return err
 137  	}
 138  	if err = addOpExportSnapshotValidationMiddleware(stack); err != nil {
 139  		return err
 140  	}
 141  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opExportSnapshot(options.Region), middleware.Before); err != nil {
 142  		return err
 143  	}
 144  	if err = addRecursionDetection(stack); err != nil {
 145  		return err
 146  	}
 147  	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
 148  		return err
 149  	}
 150  	if err = addResponseErrorMiddleware(stack); err != nil {
 151  		return err
 152  	}
 153  	if err = addRequestResponseLogging(stack, options); err != nil {
 154  		return err
 155  	}
 156  	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
 157  		return err
 158  	}
 159  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 160  		return err
 161  	}
 162  	if err = addInterceptAttempt(stack, options); err != nil {
 163  		return err
 164  	}
 165  	if err = addInterceptors(stack, options); err != nil {
 166  		return err
 167  	}
 168  	return nil
 169  }
 170  
 171  func newServiceMetadataMiddleware_opExportSnapshot(region string) *awsmiddleware.RegisterServiceMetadata {
 172  	return &awsmiddleware.RegisterServiceMetadata{
 173  		Region:        region,
 174  		ServiceID:     ServiceID,
 175  		OperationName: "ExportSnapshot",
 176  	}
 177  }
 178