1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package wafv2 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/wafv2/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// This is the latest version of AWS WAF, named AWS WAFV2, released in November, 15// 2019. For information, including how to migrate your AWS WAF resources from the 16// prior release, see the AWS WAF Developer Guide 17// (https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html). 18// Creates a RuleGroup per the specifications provided. A rule group defines a 19// collection of rules to inspect and control web requests that you can use in a 20// WebACL. When you create a rule group, you define an immutable capacity limit. If 21// you update a rule group, you must stay within the capacity. This allows others 22// to reuse the rule group with confidence in its capacity requirements. 23func (c *Client) CreateRuleGroup(ctx context.Context, params *CreateRuleGroupInput, optFns ...func(*Options)) (*CreateRuleGroupOutput, error) { 24 if params == nil { 25 params = &CreateRuleGroupInput{} 26 } 27 28 result, metadata, err := c.invokeOperation(ctx, "CreateRuleGroup", params, optFns, addOperationCreateRuleGroupMiddlewares) 29 if err != nil { 30 return nil, err 31 } 32 33 out := result.(*CreateRuleGroupOutput) 34 out.ResultMetadata = metadata 35 return out, nil 36} 37 38type CreateRuleGroupInput struct { 39 40 // The web ACL capacity units (WCUs) required for this rule group. When you create 41 // your own rule group, you define this, and you cannot change it after creation. 42 // When you add or modify the rules in a rule group, AWS WAF enforces this limit. 43 // You can check the capacity for a set of rules using CheckCapacity. AWS WAF uses 44 // WCUs to calculate and control the operating resources that are used to run your 45 // rules, rule groups, and web ACLs. AWS WAF calculates capacity differently for 46 // each rule type, to reflect the relative cost of each rule. Simple rules that 47 // cost little to run use fewer WCUs than more complex rules that use more 48 // processing power. Rule group capacity is fixed at creation, which helps users 49 // plan their web ACL WCU usage when they use a rule group. The WCU limit for web 50 // ACLs is 1,500. 51 // 52 // This member is required. 53 Capacity int64 54 55 // The name of the rule group. You cannot change the name of a rule group after you 56 // create it. 57 // 58 // This member is required. 59 Name *string 60 61 // Specifies whether this is for an AWS CloudFront distribution or for a regional 62 // application. A regional application can be an Application Load Balancer (ALB), 63 // an API Gateway REST API, or an AppSync GraphQL API. To work with CloudFront, you 64 // must also specify the Region US East (N. Virginia) as follows: 65 // 66 // * CLI - Specify 67 // the Region when you use the CloudFront scope: --scope=CLOUDFRONT 68 // --region=us-east-1. 69 // 70 // * API and SDKs - For all calls, use the Region endpoint 71 // us-east-1. 72 // 73 // This member is required. 74 Scope types.Scope 75 76 // Defines and enables Amazon CloudWatch metrics and web request sample collection. 77 // 78 // This member is required. 79 VisibilityConfig *types.VisibilityConfig 80 81 // A description of the rule group that helps with identification. You cannot 82 // change the description of a rule group after you create it. 83 Description *string 84 85 // The Rule statements used to identify the web requests that you want to allow, 86 // block, or count. Each rule includes one top-level statement that AWS WAF uses to 87 // identify matching web requests, and parameters that govern how AWS WAF handles 88 // them. 89 Rules []types.Rule 90 91 // An array of key:value pairs to associate with the resource. 92 Tags []types.Tag 93} 94 95type CreateRuleGroupOutput struct { 96 97 // High-level information about a RuleGroup, returned by operations like create and 98 // list. This provides information like the ID, that you can use to retrieve and 99 // manage a RuleGroup, and the ARN, that you provide to the 100 // RuleGroupReferenceStatement to use the rule group in a Rule. 101 Summary *types.RuleGroupSummary 102 103 // Metadata pertaining to the operation's result. 104 ResultMetadata middleware.Metadata 105} 106 107func addOperationCreateRuleGroupMiddlewares(stack *middleware.Stack, options Options) (err error) { 108 err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateRuleGroup{}, middleware.After) 109 if err != nil { 110 return err 111 } 112 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateRuleGroup{}, middleware.After) 113 if err != nil { 114 return err 115 } 116 if err = addSetLoggerMiddleware(stack, options); err != nil { 117 return err 118 } 119 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 120 return err 121 } 122 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 123 return err 124 } 125 if err = addResolveEndpointMiddleware(stack, options); err != nil { 126 return err 127 } 128 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 129 return err 130 } 131 if err = addRetryMiddlewares(stack, options); err != nil { 132 return err 133 } 134 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 135 return err 136 } 137 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 138 return err 139 } 140 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 141 return err 142 } 143 if err = addClientUserAgent(stack); err != nil { 144 return err 145 } 146 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 147 return err 148 } 149 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 150 return err 151 } 152 if err = addOpCreateRuleGroupValidationMiddleware(stack); err != nil { 153 return err 154 } 155 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateRuleGroup(options.Region), middleware.Before); err != nil { 156 return err 157 } 158 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 159 return err 160 } 161 if err = addResponseErrorMiddleware(stack); err != nil { 162 return err 163 } 164 if err = addRequestResponseLogging(stack, options); err != nil { 165 return err 166 } 167 return nil 168} 169 170func newServiceMetadataMiddleware_opCreateRuleGroup(region string) *awsmiddleware.RegisterServiceMetadata { 171 return &awsmiddleware.RegisterServiceMetadata{ 172 Region: region, 173 ServiceID: ServiceID, 174 SigningName: "wafv2", 175 OperationName: "CreateRuleGroup", 176 } 177} 178