// Code generated by smithy-go-codegen DO NOT EDIT.

package ec2

import (
	"context"
	"github.com/aws/smithy-go/middleware"
)

// Unlocks a snapshot that is locked in governance mode or that is locked in
// compliance mode but still in the cooling-off period. You can't unlock a snapshot
// that is locked in compliance mode after the cooling-off period has expired.
func (c *Client) UnlockSnapshot(ctx context.Context, params *UnlockSnapshotInput, optFns ...func(*Options)) (*UnlockSnapshotOutput, error) {
	if params == nil {
		params = &UnlockSnapshotInput{}
	}

	result, metadata, err := c.invokeOperation(ctx, "UnlockSnapshot", params, optFns, c.addOperationUnlockSnapshotMiddlewares)
	if err != nil {
		return nil, err
	}

	out := result.(*UnlockSnapshotOutput)
	out.ResultMetadata = metadata
	return out, nil
}

type UnlockSnapshotInput struct {

	// The ID of the snapshot to unlock.
	//
	// This member is required.
	SnapshotId *string

	// Checks whether you have the required permissions for the action, without
	// actually making the request, and provides an error response. If you have the
	// required permissions, the error response is DryRunOperation . Otherwise, it is
	// UnauthorizedOperation .
	DryRun *bool

	noSmithyDocumentSerde
}

type UnlockSnapshotOutput struct {

	// The ID of the snapshot.
	SnapshotId *string

	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func (c *Client) addOperationUnlockSnapshotMiddlewares(stack *middleware.Stack, options Options) (err error) {
	err = stack.Serialize.Add(&awsEc2query_serializeOpUnlockSnapshot{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsEc2query_deserializeOpUnlockSnapshot{}, middleware.After)
	if err != nil {
		return err
	}

	if err = addResolveEndpointMiddleware(stack, options); err != nil {
		return err
	}
	if err = addComputePayloadSHA256(stack); err != nil {
		return err
	}
	if err = addRecordResponseTiming(stack, options); err != nil {
		return err
	}
	if err = addCredentialSource(stack, options); err != nil {
		return err
	}
	if err = addOpUnlockSnapshotValidationMiddleware(stack); err != nil {
		return err
	}
	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
		return err
	}
	if err = addResponseErrorMiddleware(stack); err != nil {
		return err
	}
	if err = addRequestResponseLogging(stack, options); err != nil {
		return err
	}
	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
		return err
	}
	if err = addInterceptors(stack, options); err != nil {
		return err
	}
	return nil
}
