1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package wafregional
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/wafregional/types"
10	"github.com/aws/smithy-go/middleware"
11	smithyhttp "github.com/aws/smithy-go/transport/http"
12)
13
14// This is AWS WAF Classic documentation. For more information, see AWS WAF Classic
15// (https://docs.aws.amazon.com/waf/latest/developerguide/classic-waf-chapter.html)
16// in the developer guide. For the latest version of AWS WAF, use the AWS WAFV2 API
17// and see the AWS WAF Developer Guide
18// (https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html). With
19// the latest version, AWS WAF has a single set of endpoints for regional and
20// global use. Inserts or deletes ByteMatchTuple objects (filters) in a
21// ByteMatchSet. For each ByteMatchTuple object, you specify the following
22// values:
23//
24// * Whether to insert or delete the object from the array. If you want to
25// change a ByteMatchSetUpdate object, you delete the existing object and add a new
26// one.
27//
28// * The part of a web request that you want AWS WAF to inspect, such as a
29// query string or the value of the User-Agent header.
30//
31// * The bytes (typically a
32// string that corresponds with ASCII characters) that you want AWS WAF to look
33// for. For more information, including how you specify the values for the AWS WAF
34// API and the AWS CLI or SDKs, see TargetString in the ByteMatchTuple data
35// type.
36//
37// * Where to look, such as at the beginning or the end of a query
38// string.
39//
40// * Whether to perform any conversions on the request, such as converting
41// it to lowercase, before inspecting it for the specified string.
42//
43// For example,
44// you can add a ByteMatchSetUpdate object that matches web requests in which
45// User-Agent headers contain the string BadBot. You can then configure AWS WAF to
46// block those requests. To create and configure a ByteMatchSet, perform the
47// following steps:
48//
49// * Create a ByteMatchSet. For more information, see
50// CreateByteMatchSet.
51//
52// * Use GetChangeToken to get the change token that you
53// provide in the ChangeToken parameter of an UpdateByteMatchSet request.
54//
55// * Submit
56// an UpdateByteMatchSet request to specify the part of the request that you want
57// AWS WAF to inspect (for example, the header or the URI) and the value that you
58// want AWS WAF to watch for.
59//
60// For more information about how to use the AWS WAF
61// API to allow or block HTTP requests, see the AWS WAF Developer Guide
62// (https://docs.aws.amazon.com/waf/latest/developerguide/).
63func (c *Client) UpdateByteMatchSet(ctx context.Context, params *UpdateByteMatchSetInput, optFns ...func(*Options)) (*UpdateByteMatchSetOutput, error) {
64	if params == nil {
65		params = &UpdateByteMatchSetInput{}
66	}
67
68	result, metadata, err := c.invokeOperation(ctx, "UpdateByteMatchSet", params, optFns, addOperationUpdateByteMatchSetMiddlewares)
69	if err != nil {
70		return nil, err
71	}
72
73	out := result.(*UpdateByteMatchSetOutput)
74	out.ResultMetadata = metadata
75	return out, nil
76}
77
78type UpdateByteMatchSetInput struct {
79
80	// The ByteMatchSetId of the ByteMatchSet that you want to update. ByteMatchSetId
81	// is returned by CreateByteMatchSet and by ListByteMatchSets.
82	//
83	// This member is required.
84	ByteMatchSetId *string
85
86	// The value returned by the most recent call to GetChangeToken.
87	//
88	// This member is required.
89	ChangeToken *string
90
91	// An array of ByteMatchSetUpdate objects that you want to insert into or delete
92	// from a ByteMatchSet. For more information, see the applicable data types:
93	//
94	// *
95	// ByteMatchSetUpdate: Contains Action and ByteMatchTuple
96	//
97	// * ByteMatchTuple:
98	// Contains FieldToMatch, PositionalConstraint, TargetString, and
99	// TextTransformation
100	//
101	// * FieldToMatch: Contains Data and Type
102	//
103	// This member is required.
104	Updates []types.ByteMatchSetUpdate
105}
106
107type UpdateByteMatchSetOutput struct {
108
109	// The ChangeToken that you used to submit the UpdateByteMatchSet request. You can
110	// also use this value to query the status of the request. For more information,
111	// see GetChangeTokenStatus.
112	ChangeToken *string
113
114	// Metadata pertaining to the operation's result.
115	ResultMetadata middleware.Metadata
116}
117
118func addOperationUpdateByteMatchSetMiddlewares(stack *middleware.Stack, options Options) (err error) {
119	err = stack.Serialize.Add(&awsAwsjson11_serializeOpUpdateByteMatchSet{}, middleware.After)
120	if err != nil {
121		return err
122	}
123	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpUpdateByteMatchSet{}, middleware.After)
124	if err != nil {
125		return err
126	}
127	if err = addSetLoggerMiddleware(stack, options); err != nil {
128		return err
129	}
130	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
131		return err
132	}
133	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
134		return err
135	}
136	if err = addResolveEndpointMiddleware(stack, options); err != nil {
137		return err
138	}
139	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
140		return err
141	}
142	if err = addRetryMiddlewares(stack, options); err != nil {
143		return err
144	}
145	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
146		return err
147	}
148	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
149		return err
150	}
151	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
152		return err
153	}
154	if err = addClientUserAgent(stack); err != nil {
155		return err
156	}
157	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
158		return err
159	}
160	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
161		return err
162	}
163	if err = addOpUpdateByteMatchSetValidationMiddleware(stack); err != nil {
164		return err
165	}
166	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opUpdateByteMatchSet(options.Region), middleware.Before); err != nil {
167		return err
168	}
169	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
170		return err
171	}
172	if err = addResponseErrorMiddleware(stack); err != nil {
173		return err
174	}
175	if err = addRequestResponseLogging(stack, options); err != nil {
176		return err
177	}
178	return nil
179}
180
181func newServiceMetadataMiddleware_opUpdateByteMatchSet(region string) *awsmiddleware.RegisterServiceMetadata {
182	return &awsmiddleware.RegisterServiceMetadata{
183		Region:        region,
184		ServiceID:     ServiceID,
185		SigningName:   "waf-regional",
186		OperationName: "UpdateByteMatchSet",
187	}
188}
189