1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package ec2
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/ec2/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// Adds or removes permission settings for the specified snapshot. You may add or
15// remove specified AWS account IDs from a snapshot's list of create volume
16// permissions, but you cannot do both in a single operation. If you need to both
17// add and remove account IDs for a snapshot, you must use multiple operations. You
18// can make up to 500 modifications to a snapshot in a single operation. Encrypted
19// snapshots and snapshots with AWS Marketplace product codes cannot be made
20// public. Snapshots encrypted with your default CMK cannot be shared with other
21// accounts. For more information about modifying snapshot permissions, see Sharing
22// snapshots
23// (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-modifying-snapshot-permissions.html)
24// in the Amazon Elastic Compute Cloud User Guide.
25func (c *Client) ModifySnapshotAttribute(ctx context.Context, params *ModifySnapshotAttributeInput, optFns ...func(*Options)) (*ModifySnapshotAttributeOutput, error) {
26	if params == nil {
27		params = &ModifySnapshotAttributeInput{}
28	}
29
30	result, metadata, err := c.invokeOperation(ctx, "ModifySnapshotAttribute", params, optFns, addOperationModifySnapshotAttributeMiddlewares)
31	if err != nil {
32		return nil, err
33	}
34
35	out := result.(*ModifySnapshotAttributeOutput)
36	out.ResultMetadata = metadata
37	return out, nil
38}
39
40type ModifySnapshotAttributeInput struct {
41
42	// The ID of the snapshot.
43	//
44	// This member is required.
45	SnapshotId *string
46
47	// The snapshot attribute to modify. Only volume creation permissions can be
48	// modified.
49	Attribute types.SnapshotAttributeName
50
51	// A JSON representation of the snapshot attribute modification.
52	CreateVolumePermission *types.CreateVolumePermissionModifications
53
54	// Checks whether you have the required permissions for the action, without
55	// actually making the request, and provides an error response. If you have the
56	// required permissions, the error response is DryRunOperation. Otherwise, it is
57	// UnauthorizedOperation.
58	DryRun bool
59
60	// The group to modify for the snapshot.
61	GroupNames []string
62
63	// The type of operation to perform to the attribute.
64	OperationType types.OperationType
65
66	// The account ID to modify for the snapshot.
67	UserIds []string
68}
69
70type ModifySnapshotAttributeOutput struct {
71	// Metadata pertaining to the operation's result.
72	ResultMetadata middleware.Metadata
73}
74
75func addOperationModifySnapshotAttributeMiddlewares(stack *middleware.Stack, options Options) (err error) {
76	err = stack.Serialize.Add(&awsEc2query_serializeOpModifySnapshotAttribute{}, middleware.After)
77	if err != nil {
78		return err
79	}
80	err = stack.Deserialize.Add(&awsEc2query_deserializeOpModifySnapshotAttribute{}, middleware.After)
81	if err != nil {
82		return err
83	}
84	if err = addSetLoggerMiddleware(stack, options); err != nil {
85		return err
86	}
87	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
88		return err
89	}
90	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
91		return err
92	}
93	if err = addResolveEndpointMiddleware(stack, options); err != nil {
94		return err
95	}
96	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
97		return err
98	}
99	if err = addRetryMiddlewares(stack, options); err != nil {
100		return err
101	}
102	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
103		return err
104	}
105	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
106		return err
107	}
108	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
109		return err
110	}
111	if err = addClientUserAgent(stack); err != nil {
112		return err
113	}
114	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
115		return err
116	}
117	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
118		return err
119	}
120	if err = addOpModifySnapshotAttributeValidationMiddleware(stack); err != nil {
121		return err
122	}
123	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opModifySnapshotAttribute(options.Region), middleware.Before); err != nil {
124		return err
125	}
126	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
127		return err
128	}
129	if err = addResponseErrorMiddleware(stack); err != nil {
130		return err
131	}
132	if err = addRequestResponseLogging(stack, options); err != nil {
133		return err
134	}
135	return nil
136}
137
138func newServiceMetadataMiddleware_opModifySnapshotAttribute(region string) *awsmiddleware.RegisterServiceMetadata {
139	return &awsmiddleware.RegisterServiceMetadata{
140		Region:        region,
141		ServiceID:     ServiceID,
142		SigningName:   "ec2",
143		OperationName: "ModifySnapshotAttribute",
144	}
145}
146