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. Associates a LoggingConfiguration with a specified web ACL. You can
21// access information about all traffic that AWS WAF inspects using the following
22// steps:
23//
24// * Create an Amazon Kinesis Data Firehose. Create the data firehose with
25// a PUT source and in the region that you are operating. However, if you are
26// capturing logs for Amazon CloudFront, always create the firehose in US East (N.
27// Virginia). Do not create the data firehose using a Kinesis stream as your
28// source.
29//
30// * Associate that firehose to your web ACL using a
31// PutLoggingConfiguration request.
32//
33// When you successfully enable logging using a
34// PutLoggingConfiguration request, AWS WAF will create a service linked role with
35// the necessary permissions to write logs to the Amazon Kinesis Data Firehose. For
36// more information, see Logging Web ACL Traffic Information
37// (https://docs.aws.amazon.com/waf/latest/developerguide/logging.html) in the AWS
38// WAF Developer Guide.
39func (c *Client) PutLoggingConfiguration(ctx context.Context, params *PutLoggingConfigurationInput, optFns ...func(*Options)) (*PutLoggingConfigurationOutput, error) {
40	if params == nil {
41		params = &PutLoggingConfigurationInput{}
42	}
43
44	result, metadata, err := c.invokeOperation(ctx, "PutLoggingConfiguration", params, optFns, c.addOperationPutLoggingConfigurationMiddlewares)
45	if err != nil {
46		return nil, err
47	}
48
49	out := result.(*PutLoggingConfigurationOutput)
50	out.ResultMetadata = metadata
51	return out, nil
52}
53
54type PutLoggingConfigurationInput struct {
55
56	// The Amazon Kinesis Data Firehose that contains the inspected traffic
57	// information, the redacted fields details, and the Amazon Resource Name (ARN) of
58	// the web ACL to monitor. When specifying Type in RedactedFields, you must use one
59	// of the following values: URI, QUERY_STRING, HEADER, or METHOD.
60	//
61	// This member is required.
62	LoggingConfiguration *types.LoggingConfiguration
63
64	noSmithyDocumentSerde
65}
66
67type PutLoggingConfigurationOutput struct {
68
69	// The LoggingConfiguration that you submitted in the request.
70	LoggingConfiguration *types.LoggingConfiguration
71
72	// Metadata pertaining to the operation's result.
73	ResultMetadata middleware.Metadata
74
75	noSmithyDocumentSerde
76}
77
78func (c *Client) addOperationPutLoggingConfigurationMiddlewares(stack *middleware.Stack, options Options) (err error) {
79	err = stack.Serialize.Add(&awsAwsjson11_serializeOpPutLoggingConfiguration{}, middleware.After)
80	if err != nil {
81		return err
82	}
83	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpPutLoggingConfiguration{}, middleware.After)
84	if err != nil {
85		return err
86	}
87	if err = addSetLoggerMiddleware(stack, options); err != nil {
88		return err
89	}
90	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
91		return err
92	}
93	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
94		return err
95	}
96	if err = addResolveEndpointMiddleware(stack, options); err != nil {
97		return err
98	}
99	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
100		return err
101	}
102	if err = addRetryMiddlewares(stack, options); err != nil {
103		return err
104	}
105	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
106		return err
107	}
108	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
109		return err
110	}
111	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
112		return err
113	}
114	if err = addClientUserAgent(stack); err != nil {
115		return err
116	}
117	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
118		return err
119	}
120	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
121		return err
122	}
123	if err = addOpPutLoggingConfigurationValidationMiddleware(stack); err != nil {
124		return err
125	}
126	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPutLoggingConfiguration(options.Region), middleware.Before); err != nil {
127		return err
128	}
129	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
130		return err
131	}
132	if err = addResponseErrorMiddleware(stack); err != nil {
133		return err
134	}
135	if err = addRequestResponseLogging(stack, options); err != nil {
136		return err
137	}
138	return nil
139}
140
141func newServiceMetadataMiddleware_opPutLoggingConfiguration(region string) *awsmiddleware.RegisterServiceMetadata {
142	return &awsmiddleware.RegisterServiceMetadata{
143		Region:        region,
144		ServiceID:     ServiceID,
145		SigningName:   "waf-regional",
146		OperationName: "PutLoggingConfiguration",
147	}
148}
149