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. Creates a RegexMatchSet. You then use UpdateRegexMatchSet to
21// identify the part of a web request that you want AWS WAF to inspect, such as the
22// values of the User-Agent header or the query string. For example, you can create
23// a RegexMatchSet that contains a RegexMatchTuple that looks for any requests with
24// User-Agent headers that match a RegexPatternSet with pattern B[a@]dB[o0]t. You
25// can then configure AWS WAF to reject those requests. To create and configure a
26// RegexMatchSet, perform the following steps:
27//
28// * Use GetChangeToken to get the
29// change token that you provide in the ChangeToken parameter of a
30// CreateRegexMatchSet request.
31//
32// * Submit a CreateRegexMatchSet request.
33//
34// * Use
35// GetChangeToken to get the change token that you provide in the ChangeToken
36// parameter of an UpdateRegexMatchSet request.
37//
38// * Submit an UpdateRegexMatchSet
39// request to specify the part of the request that you want AWS WAF to inspect (for
40// example, the header or the URI) and the value, using a RegexPatternSet, that you
41// want AWS WAF to watch for.
42//
43// For more information about how to use the AWS WAF
44// API to allow or block HTTP requests, see the AWS WAF Developer Guide
45// (https://docs.aws.amazon.com/waf/latest/developerguide/).
46func (c *Client) CreateRegexMatchSet(ctx context.Context, params *CreateRegexMatchSetInput, optFns ...func(*Options)) (*CreateRegexMatchSetOutput, error) {
47	if params == nil {
48		params = &CreateRegexMatchSetInput{}
49	}
50
51	result, metadata, err := c.invokeOperation(ctx, "CreateRegexMatchSet", params, optFns, addOperationCreateRegexMatchSetMiddlewares)
52	if err != nil {
53		return nil, err
54	}
55
56	out := result.(*CreateRegexMatchSetOutput)
57	out.ResultMetadata = metadata
58	return out, nil
59}
60
61type CreateRegexMatchSetInput struct {
62
63	// The value returned by the most recent call to GetChangeToken.
64	//
65	// This member is required.
66	ChangeToken *string
67
68	// A friendly name or description of the RegexMatchSet. You can't change Name after
69	// you create a RegexMatchSet.
70	//
71	// This member is required.
72	Name *string
73}
74
75type CreateRegexMatchSetOutput struct {
76
77	// The ChangeToken that you used to submit the CreateRegexMatchSet request. You can
78	// also use this value to query the status of the request. For more information,
79	// see GetChangeTokenStatus.
80	ChangeToken *string
81
82	// A RegexMatchSet that contains no RegexMatchTuple objects.
83	RegexMatchSet *types.RegexMatchSet
84
85	// Metadata pertaining to the operation's result.
86	ResultMetadata middleware.Metadata
87}
88
89func addOperationCreateRegexMatchSetMiddlewares(stack *middleware.Stack, options Options) (err error) {
90	err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateRegexMatchSet{}, middleware.After)
91	if err != nil {
92		return err
93	}
94	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateRegexMatchSet{}, middleware.After)
95	if err != nil {
96		return err
97	}
98	if err = addSetLoggerMiddleware(stack, options); err != nil {
99		return err
100	}
101	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
102		return err
103	}
104	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
105		return err
106	}
107	if err = addResolveEndpointMiddleware(stack, options); err != nil {
108		return err
109	}
110	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
111		return err
112	}
113	if err = addRetryMiddlewares(stack, options); err != nil {
114		return err
115	}
116	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
117		return err
118	}
119	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
120		return err
121	}
122	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
123		return err
124	}
125	if err = addClientUserAgent(stack); err != nil {
126		return err
127	}
128	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
129		return err
130	}
131	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
132		return err
133	}
134	if err = addOpCreateRegexMatchSetValidationMiddleware(stack); err != nil {
135		return err
136	}
137	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateRegexMatchSet(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
152func newServiceMetadataMiddleware_opCreateRegexMatchSet(region string) *awsmiddleware.RegisterServiceMetadata {
153	return &awsmiddleware.RegisterServiceMetadata{
154		Region:        region,
155		ServiceID:     ServiceID,
156		SigningName:   "waf-regional",
157		OperationName: "CreateRegexMatchSet",
158	}
159}
160