1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package cloudformation
4
5import (
6	"context"
7	"fmt"
8	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
9	"github.com/aws/aws-sdk-go-v2/aws/signer/v4"
10	"github.com/aws/aws-sdk-go-v2/service/cloudformation/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Deletes stack instances for the specified accounts, in the specified Regions.
16func (c *Client) DeleteStackInstances(ctx context.Context, params *DeleteStackInstancesInput, optFns ...func(*Options)) (*DeleteStackInstancesOutput, error) {
17	if params == nil {
18		params = &DeleteStackInstancesInput{}
19	}
20
21	result, metadata, err := c.invokeOperation(ctx, "DeleteStackInstances", params, optFns, addOperationDeleteStackInstancesMiddlewares)
22	if err != nil {
23		return nil, err
24	}
25
26	out := result.(*DeleteStackInstancesOutput)
27	out.ResultMetadata = metadata
28	return out, nil
29}
30
31type DeleteStackInstancesInput struct {
32
33	// The Regions where you want to delete stack set instances.
34	//
35	// This member is required.
36	Regions []string
37
38	// Removes the stack instances from the specified stack set, but doesn't delete the
39	// stacks. You can't reassociate a retained stack or add an existing, saved stack
40	// to a new stack set. For more information, see Stack set operation options
41	// (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-concepts.html#stackset-ops-options).
42	//
43	// This member is required.
44	RetainStacks bool
45
46	// The name or unique ID of the stack set that you want to delete stack instances
47	// for.
48	//
49	// This member is required.
50	StackSetName *string
51
52	// [Self-managed permissions] The names of the AWS accounts that you want to delete
53	// stack instances for. You can specify Accounts or DeploymentTargets, but not
54	// both.
55	Accounts []string
56
57	// [Service-managed permissions] Specifies whether you are acting as an account
58	// administrator in the organization's management account or as a delegated
59	// administrator in a member account. By default, SELF is specified. Use SELF for
60	// stack sets with self-managed permissions.
61	//
62	// * If you are signed in to the
63	// management account, specify SELF.
64	//
65	// * If you are signed in to a delegated
66	// administrator account, specify DELEGATED_ADMIN. Your AWS account must be
67	// registered as a delegated administrator in the management account. For more
68	// information, see Register a delegated administrator
69	// (https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/stacksets-orgs-delegated-admin.html)
70	// in the AWS CloudFormation User Guide.
71	CallAs types.CallAs
72
73	// [Service-managed permissions] The AWS Organizations accounts from which to
74	// delete stack instances. You can specify Accounts or DeploymentTargets, but not
75	// both.
76	DeploymentTargets *types.DeploymentTargets
77
78	// The unique identifier for this stack set operation. If you don't specify an
79	// operation ID, the SDK generates one automatically. The operation ID also
80	// functions as an idempotency token, to ensure that AWS CloudFormation performs
81	// the stack set operation only once, even if you retry the request multiple times.
82	// You can retry stack set operation requests to ensure that AWS CloudFormation
83	// successfully received them. Repeating this stack set operation with a new
84	// operation ID retries all stack instances whose status is OUTDATED.
85	OperationId *string
86
87	// Preferences for how AWS CloudFormation performs this stack set operation.
88	OperationPreferences *types.StackSetOperationPreferences
89}
90
91type DeleteStackInstancesOutput struct {
92
93	// The unique identifier for this stack set operation.
94	OperationId *string
95
96	// Metadata pertaining to the operation's result.
97	ResultMetadata middleware.Metadata
98}
99
100func addOperationDeleteStackInstancesMiddlewares(stack *middleware.Stack, options Options) (err error) {
101	err = stack.Serialize.Add(&awsAwsquery_serializeOpDeleteStackInstances{}, middleware.After)
102	if err != nil {
103		return err
104	}
105	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDeleteStackInstances{}, middleware.After)
106	if err != nil {
107		return err
108	}
109	if err = addSetLoggerMiddleware(stack, options); err != nil {
110		return err
111	}
112	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
113		return err
114	}
115	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
116		return err
117	}
118	if err = addResolveEndpointMiddleware(stack, options); err != nil {
119		return err
120	}
121	if err = v4.AddComputePayloadSHA256Middleware(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 = addIdempotencyToken_opDeleteStackInstancesMiddleware(stack, options); err != nil {
146		return err
147	}
148	if err = addOpDeleteStackInstancesValidationMiddleware(stack); err != nil {
149		return err
150	}
151	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDeleteStackInstances(options.Region), middleware.Before); err != nil {
152		return err
153	}
154	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
155		return err
156	}
157	if err = addResponseErrorMiddleware(stack); err != nil {
158		return err
159	}
160	if err = addRequestResponseLogging(stack, options); err != nil {
161		return err
162	}
163	return nil
164}
165
166type idempotencyToken_initializeOpDeleteStackInstances struct {
167	tokenProvider IdempotencyTokenProvider
168}
169
170func (*idempotencyToken_initializeOpDeleteStackInstances) ID() string {
171	return "OperationIdempotencyTokenAutoFill"
172}
173
174func (m *idempotencyToken_initializeOpDeleteStackInstances) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
175	out middleware.InitializeOutput, metadata middleware.Metadata, err error,
176) {
177	if m.tokenProvider == nil {
178		return next.HandleInitialize(ctx, in)
179	}
180
181	input, ok := in.Parameters.(*DeleteStackInstancesInput)
182	if !ok {
183		return out, metadata, fmt.Errorf("expected middleware input to be of type *DeleteStackInstancesInput ")
184	}
185
186	if input.OperationId == nil {
187		t, err := m.tokenProvider.GetIdempotencyToken()
188		if err != nil {
189			return out, metadata, err
190		}
191		input.OperationId = &t
192	}
193	return next.HandleInitialize(ctx, in)
194}
195func addIdempotencyToken_opDeleteStackInstancesMiddleware(stack *middleware.Stack, cfg Options) error {
196	return stack.Initialize.Add(&idempotencyToken_initializeOpDeleteStackInstances{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before)
197}
198
199func newServiceMetadataMiddleware_opDeleteStackInstances(region string) *awsmiddleware.RegisterServiceMetadata {
200	return &awsmiddleware.RegisterServiceMetadata{
201		Region:        region,
202		ServiceID:     ServiceID,
203		SigningName:   "cloudformation",
204		OperationName: "DeleteStackInstances",
205	}
206}
207