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 WebACL, which contains the Rules that identify the 21// CloudFront web requests that you want to allow, block, or count. AWS WAF 22// evaluates Rules in order based on the value of Priority for each Rule. You also 23// specify a default action, either ALLOW or BLOCK. If a web request doesn't match 24// any of the Rules in a WebACL, AWS WAF responds to the request with the default 25// action. To create and configure a WebACL, perform the following steps: 26// 27// * Create 28// and update the ByteMatchSet objects and other predicates that you want to 29// include in Rules. For more information, see CreateByteMatchSet, 30// UpdateByteMatchSet, CreateIPSet, UpdateIPSet, CreateSqlInjectionMatchSet, and 31// UpdateSqlInjectionMatchSet. 32// 33// * Create and update the Rules that you want to 34// include in the WebACL. For more information, see CreateRule and UpdateRule. 35// 36// * 37// Use GetChangeToken to get the change token that you provide in the ChangeToken 38// parameter of a CreateWebACL request. 39// 40// * Submit a CreateWebACL request. 41// 42// * Use 43// GetChangeToken to get the change token that you provide in the ChangeToken 44// parameter of an UpdateWebACL request. 45// 46// * Submit an UpdateWebACL request to 47// specify the Rules that you want to include in the WebACL, to specify the default 48// action, and to associate the WebACL with a CloudFront distribution. 49// 50// For more 51// information about how to use the AWS WAF API, see the AWS WAF Developer Guide 52// (https://docs.aws.amazon.com/waf/latest/developerguide/). 53func (c *Client) CreateWebACL(ctx context.Context, params *CreateWebACLInput, optFns ...func(*Options)) (*CreateWebACLOutput, error) { 54 if params == nil { 55 params = &CreateWebACLInput{} 56 } 57 58 result, metadata, err := c.invokeOperation(ctx, "CreateWebACL", params, optFns, c.addOperationCreateWebACLMiddlewares) 59 if err != nil { 60 return nil, err 61 } 62 63 out := result.(*CreateWebACLOutput) 64 out.ResultMetadata = metadata 65 return out, nil 66} 67 68type CreateWebACLInput struct { 69 70 // The value returned by the most recent call to GetChangeToken. 71 // 72 // This member is required. 73 ChangeToken *string 74 75 // The action that you want AWS WAF to take when a request doesn't match the 76 // criteria specified in any of the Rule objects that are associated with the 77 // WebACL. 78 // 79 // This member is required. 80 DefaultAction *types.WafAction 81 82 // A friendly name or description for the metrics for this WebACL.The name can 83 // contain only alphanumeric characters (A-Z, a-z, 0-9), with maximum length 128 84 // and minimum length one. It can't contain whitespace or metric names reserved for 85 // AWS WAF, including "All" and "Default_Action." You can't change MetricName after 86 // you create the WebACL. 87 // 88 // This member is required. 89 MetricName *string 90 91 // A friendly name or description of the WebACL. You can't change Name after you 92 // create the WebACL. 93 // 94 // This member is required. 95 Name *string 96 97 // 98 Tags []types.Tag 99 100 noSmithyDocumentSerde 101} 102 103type CreateWebACLOutput struct { 104 105 // The ChangeToken that you used to submit the CreateWebACL request. You can also 106 // use this value to query the status of the request. For more information, see 107 // GetChangeTokenStatus. 108 ChangeToken *string 109 110 // The WebACL returned in the CreateWebACL response. 111 WebACL *types.WebACL 112 113 // Metadata pertaining to the operation's result. 114 ResultMetadata middleware.Metadata 115 116 noSmithyDocumentSerde 117} 118 119func (c *Client) addOperationCreateWebACLMiddlewares(stack *middleware.Stack, options Options) (err error) { 120 err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateWebACL{}, middleware.After) 121 if err != nil { 122 return err 123 } 124 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateWebACL{}, middleware.After) 125 if err != nil { 126 return err 127 } 128 if err = addSetLoggerMiddleware(stack, options); err != nil { 129 return err 130 } 131 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 132 return err 133 } 134 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 135 return err 136 } 137 if err = addResolveEndpointMiddleware(stack, options); err != nil { 138 return err 139 } 140 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 141 return err 142 } 143 if err = addRetryMiddlewares(stack, options); err != nil { 144 return err 145 } 146 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 147 return err 148 } 149 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 150 return err 151 } 152 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 153 return err 154 } 155 if err = addClientUserAgent(stack); err != nil { 156 return err 157 } 158 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 159 return err 160 } 161 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 162 return err 163 } 164 if err = addOpCreateWebACLValidationMiddleware(stack); err != nil { 165 return err 166 } 167 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateWebACL(options.Region), middleware.Before); err != nil { 168 return err 169 } 170 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 171 return err 172 } 173 if err = addResponseErrorMiddleware(stack); err != nil { 174 return err 175 } 176 if err = addRequestResponseLogging(stack, options); err != nil { 177 return err 178 } 179 return nil 180} 181 182func newServiceMetadataMiddleware_opCreateWebACL(region string) *awsmiddleware.RegisterServiceMetadata { 183 return &awsmiddleware.RegisterServiceMetadata{ 184 Region: region, 185 ServiceID: ServiceID, 186 SigningName: "waf-regional", 187 OperationName: "CreateWebACL", 188 } 189} 190