1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package s3
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	s3cust "github.com/aws/aws-sdk-go-v2/service/s3/internal/customizations"
10	"github.com/aws/aws-sdk-go-v2/service/s3/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Returns the notification configuration of a bucket. If notifications are not
16// enabled on the bucket, the operation returns an empty NotificationConfiguration
17// element. By default, you must be the bucket owner to read the notification
18// configuration of a bucket. However, the bucket owner can use a bucket policy to
19// grant permission to other users to read this configuration with the
20// s3:GetBucketNotification permission. For more information about setting and
21// reading the notification configuration on a bucket, see Setting Up Notification
22// of Bucket Events
23// (https://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html). For
24// more information about bucket policies, see Using Bucket Policies
25// (https://docs.aws.amazon.com/AmazonS3/latest/dev/using-iam-policies.html). The
26// following operation is related to GetBucketNotification:
27//
28// *
29// PutBucketNotification
30// (https://docs.aws.amazon.com/AmazonS3/latest/API/API_PutBucketNotification.html)
31func (c *Client) GetBucketNotificationConfiguration(ctx context.Context, params *GetBucketNotificationConfigurationInput, optFns ...func(*Options)) (*GetBucketNotificationConfigurationOutput, error) {
32	if params == nil {
33		params = &GetBucketNotificationConfigurationInput{}
34	}
35
36	result, metadata, err := c.invokeOperation(ctx, "GetBucketNotificationConfiguration", params, optFns, addOperationGetBucketNotificationConfigurationMiddlewares)
37	if err != nil {
38		return nil, err
39	}
40
41	out := result.(*GetBucketNotificationConfigurationOutput)
42	out.ResultMetadata = metadata
43	return out, nil
44}
45
46type GetBucketNotificationConfigurationInput struct {
47
48	// The name of the bucket for which to get the notification configuration.
49	//
50	// This member is required.
51	Bucket *string
52
53	// The account id of the expected bucket owner. If the bucket is owned by a
54	// different account, the request will fail with an HTTP 403 (Access Denied) error.
55	ExpectedBucketOwner *string
56}
57
58// A container for specifying the notification configuration of the bucket. If this
59// element is empty, notifications are turned off for the bucket.
60type GetBucketNotificationConfigurationOutput struct {
61
62	// Describes the AWS Lambda functions to invoke and the events for which to invoke
63	// them.
64	LambdaFunctionConfigurations []types.LambdaFunctionConfiguration
65
66	// The Amazon Simple Queue Service queues to publish messages to and the events for
67	// which to publish messages.
68	QueueConfigurations []types.QueueConfiguration
69
70	// The topic to which notifications are sent and the events for which notifications
71	// are generated.
72	TopicConfigurations []types.TopicConfiguration
73
74	// Metadata pertaining to the operation's result.
75	ResultMetadata middleware.Metadata
76}
77
78func addOperationGetBucketNotificationConfigurationMiddlewares(stack *middleware.Stack, options Options) (err error) {
79	err = stack.Serialize.Add(&awsRestxml_serializeOpGetBucketNotificationConfiguration{}, middleware.After)
80	if err != nil {
81		return err
82	}
83	err = stack.Deserialize.Add(&awsRestxml_deserializeOpGetBucketNotificationConfiguration{}, 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 = addOpGetBucketNotificationConfigurationValidationMiddleware(stack); err != nil {
124		return err
125	}
126	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetBucketNotificationConfiguration(options.Region), middleware.Before); err != nil {
127		return err
128	}
129	if err = addMetadataRetrieverMiddleware(stack); err != nil {
130		return err
131	}
132	if err = addGetBucketNotificationConfigurationUpdateEndpoint(stack, options); err != nil {
133		return err
134	}
135	if err = addResponseErrorMiddleware(stack); err != nil {
136		return err
137	}
138	if err = v4.AddContentSHA256HeaderMiddleware(stack); err != nil {
139		return err
140	}
141	if err = disableAcceptEncodingGzip(stack); err != nil {
142		return err
143	}
144	if err = addRequestResponseLogging(stack, options); err != nil {
145		return err
146	}
147	return nil
148}
149
150func newServiceMetadataMiddleware_opGetBucketNotificationConfiguration(region string) *awsmiddleware.RegisterServiceMetadata {
151	return &awsmiddleware.RegisterServiceMetadata{
152		Region:        region,
153		ServiceID:     ServiceID,
154		SigningName:   "s3",
155		OperationName: "GetBucketNotificationConfiguration",
156	}
157}
158
159// getGetBucketNotificationConfigurationBucketMember returns a pointer to string
160// denoting a provided bucket member valueand a boolean indicating if the input has
161// a modeled bucket name,
162func getGetBucketNotificationConfigurationBucketMember(input interface{}) (*string, bool) {
163	in := input.(*GetBucketNotificationConfigurationInput)
164	if in.Bucket == nil {
165		return nil, false
166	}
167	return in.Bucket, true
168}
169func addGetBucketNotificationConfigurationUpdateEndpoint(stack *middleware.Stack, options Options) error {
170	return s3cust.UpdateEndpoint(stack, s3cust.UpdateEndpointOptions{
171		Accessor: s3cust.UpdateEndpointParameterAccessor{
172			GetBucketFromInput: getGetBucketNotificationConfigurationBucketMember,
173		},
174		UsePathStyle:            options.UsePathStyle,
175		UseAccelerate:           options.UseAccelerate,
176		SupportsAccelerate:      true,
177		EndpointResolver:        options.EndpointResolver,
178		EndpointResolverOptions: options.EndpointOptions,
179		UseDualstack:            options.UseDualstack,
180		UseARNRegion:            options.UseARNRegion,
181	})
182}
183