1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package route53resolver
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/route53resolver/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Associates a FirewallRuleGroup with a VPC, to provide DNS filtering for the VPC.
16func (c *Client) AssociateFirewallRuleGroup(ctx context.Context, params *AssociateFirewallRuleGroupInput, optFns ...func(*Options)) (*AssociateFirewallRuleGroupOutput, error) {
17	if params == nil {
18		params = &AssociateFirewallRuleGroupInput{}
19	}
20
21	result, metadata, err := c.invokeOperation(ctx, "AssociateFirewallRuleGroup", params, optFns, addOperationAssociateFirewallRuleGroupMiddlewares)
22	if err != nil {
23		return nil, err
24	}
25
26	out := result.(*AssociateFirewallRuleGroupOutput)
27	out.ResultMetadata = metadata
28	return out, nil
29}
30
31type AssociateFirewallRuleGroupInput struct {
32
33	// A unique string that identifies the request and that allows failed requests to
34	// be retried without the risk of executing the operation twice. CreatorRequestId
35	// can be any unique string, for example, a date/time stamp.
36	//
37	// This member is required.
38	CreatorRequestId *string
39
40	// The unique identifier of the firewall rule group.
41	//
42	// This member is required.
43	FirewallRuleGroupId *string
44
45	// A name that lets you identify the association, to manage and use it.
46	//
47	// This member is required.
48	Name *string
49
50	// The setting that determines the processing order of the rule group among the
51	// rule groups that you associate with the specified VPC. DNS Firewall filters VPC
52	// traffic starting from rule group with the lowest numeric priority setting. You
53	// must specify a unique priority for each rule group that you associate with a
54	// single VPC. To make it easier to insert rule groups later, leave space between
55	// the numbers, for example, use 100, 200, and so on. You can change the priority
56	// setting for a rule group association after you create it.
57	//
58	// This member is required.
59	Priority *int32
60
61	// The unique identifier of the VPC that you want to associate with the rule group.
62	//
63	// This member is required.
64	VpcId *string
65
66	// If enabled, this setting disallows modification or removal of the association,
67	// to help prevent against accidentally altering DNS firewall protections. When you
68	// create the association, the default setting is DISABLED.
69	MutationProtection types.MutationProtectionStatus
70
71	// A list of the tag keys and values that you want to associate with the rule group
72	// association.
73	Tags []types.Tag
74}
75
76type AssociateFirewallRuleGroupOutput struct {
77
78	// The association that you just created. The association has an Id that you can
79	// use to identify it in other requests, like update and delete.
80	FirewallRuleGroupAssociation *types.FirewallRuleGroupAssociation
81
82	// Metadata pertaining to the operation's result.
83	ResultMetadata middleware.Metadata
84}
85
86func addOperationAssociateFirewallRuleGroupMiddlewares(stack *middleware.Stack, options Options) (err error) {
87	err = stack.Serialize.Add(&awsAwsjson11_serializeOpAssociateFirewallRuleGroup{}, middleware.After)
88	if err != nil {
89		return err
90	}
91	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpAssociateFirewallRuleGroup{}, middleware.After)
92	if err != nil {
93		return err
94	}
95	if err = addSetLoggerMiddleware(stack, options); err != nil {
96		return err
97	}
98	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
99		return err
100	}
101	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
102		return err
103	}
104	if err = addResolveEndpointMiddleware(stack, options); err != nil {
105		return err
106	}
107	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
108		return err
109	}
110	if err = addRetryMiddlewares(stack, options); err != nil {
111		return err
112	}
113	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
114		return err
115	}
116	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
117		return err
118	}
119	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
120		return err
121	}
122	if err = addClientUserAgent(stack); err != nil {
123		return err
124	}
125	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
126		return err
127	}
128	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
129		return err
130	}
131	if err = addIdempotencyToken_opAssociateFirewallRuleGroupMiddleware(stack, options); err != nil {
132		return err
133	}
134	if err = addOpAssociateFirewallRuleGroupValidationMiddleware(stack); err != nil {
135		return err
136	}
137	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opAssociateFirewallRuleGroup(options.Region), middleware.Before); err != nil {
138		return err
139	}
140	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
141		return err
142	}
143	if err = addResponseErrorMiddleware(stack); err != nil {
144		return err
145	}
146	if err = addRequestResponseLogging(stack, options); err != nil {
147		return err
148	}
149	return nil
150}
151
152type idempotencyToken_initializeOpAssociateFirewallRuleGroup struct {
153	tokenProvider IdempotencyTokenProvider
154}
155
156func (*idempotencyToken_initializeOpAssociateFirewallRuleGroup) ID() string {
157	return "OperationIdempotencyTokenAutoFill"
158}
159
160func (m *idempotencyToken_initializeOpAssociateFirewallRuleGroup) HandleInitialize(ctx context.Context, in middleware.InitializeInput, next middleware.InitializeHandler) (
161	out middleware.InitializeOutput, metadata middleware.Metadata, err error,
162) {
163	if m.tokenProvider == nil {
164		return next.HandleInitialize(ctx, in)
165	}
166
167	input, ok := in.Parameters.(*AssociateFirewallRuleGroupInput)
168	if !ok {
169		return out, metadata, fmt.Errorf("expected middleware input to be of type *AssociateFirewallRuleGroupInput ")
170	}
171
172	if input.CreatorRequestId == nil {
173		t, err := m.tokenProvider.GetIdempotencyToken()
174		if err != nil {
175			return out, metadata, err
176		}
177		input.CreatorRequestId = &t
178	}
179	return next.HandleInitialize(ctx, in)
180}
181func addIdempotencyToken_opAssociateFirewallRuleGroupMiddleware(stack *middleware.Stack, cfg Options) error {
182	return stack.Initialize.Add(&idempotencyToken_initializeOpAssociateFirewallRuleGroup{tokenProvider: cfg.IdempotencyTokenProvider}, middleware.Before)
183}
184
185func newServiceMetadataMiddleware_opAssociateFirewallRuleGroup(region string) *awsmiddleware.RegisterServiceMetadata {
186	return &awsmiddleware.RegisterServiceMetadata{
187		Region:        region,
188		ServiceID:     ServiceID,
189		SigningName:   "route53resolver",
190		OperationName: "AssociateFirewallRuleGroup",
191	}
192}
193