// Code generated by smithy-go-codegen DO NOT EDIT.

package lightsail

import (
	"context"
	"fmt"
	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
	"github.com/aws/aws-sdk-go-v2/service/lightsail/types"
	"github.com/aws/smithy-go/middleware"
	smithyhttp "github.com/aws/smithy-go/transport/http"
)

// Returns information about one or more Amazon Lightsail buckets. The information
// returned includes the synchronization status of the Amazon Simple Storage
// Service (Amazon S3) account-level block public access feature for your Lightsail
// buckets.
//
// For more information about buckets, see [Buckets in Amazon Lightsail] in the Amazon Lightsail Developer
// Guide.
//
// [Buckets in Amazon Lightsail]: https://docs.aws.amazon.com/lightsail/latest/userguide/buckets-in-amazon-lightsail
func (c *Client) GetBuckets(ctx context.Context, params *GetBucketsInput, optFns ...func(*Options)) (*GetBucketsOutput, error) {
	if params == nil {
		params = &GetBucketsInput{}
	}

	result, metadata, err := c.invokeOperation(ctx, "GetBuckets", params, optFns, c.addOperationGetBucketsMiddlewares)
	if err != nil {
		return nil, err
	}

	out := result.(*GetBucketsOutput)
	out.ResultMetadata = metadata
	return out, nil
}

type GetBucketsInput struct {

	// The name of the bucket for which to return information.
	//
	// When omitted, the response includes all of your buckets in the Amazon Web
	// Services Region where the request is made.
	BucketName *string

	// A Boolean value that indicates whether to include Lightsail instances that were
	// given access to the bucket using the [SetResourceAccessForBucket]action.
	//
	// [SetResourceAccessForBucket]: https://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_SetResourceAccessForBucket.html
	IncludeConnectedResources *bool

	// A Boolean value that indicates whether to include Lightsail bucket CORS
	// configuration in the response. For more information, see [Configuring cross-origin resource sharing (CORS)].
	//
	// This parameter is only supported when getting a single bucket with bucketName
	// specified. The default value for this parameter is False .
	//
	// [Configuring cross-origin resource sharing (CORS)]: https://docs.aws.amazon.com/lightsail/latest/userguide/configure-cors.html
	IncludeCors *bool

	// The token to advance to the next page of results from your request.
	//
	// To get a page token, perform an initial GetBuckets request. If your results are
	// paginated, the response will return a next page token that you can specify as
	// the page token in a subsequent request.
	PageToken *string

	noSmithyDocumentSerde
}

type GetBucketsOutput struct {

	// An object that describes the synchronization status of the Amazon S3
	// account-level block public access feature for your Lightsail buckets.
	//
	// For more information about this feature and how it affects Lightsail buckets,
	// see [Block public access for buckets in Amazon Lightsail].
	//
	// [Block public access for buckets in Amazon Lightsail]: https://docs.aws.amazon.com/lightsail/latest/userguide/amazon-lightsail-block-public-access-for-buckets
	AccountLevelBpaSync *types.AccountLevelBpaSync

	// An array of objects that describe buckets.
	Buckets []types.Bucket

	// The token to advance to the next page of results from your request.
	//
	// A next page token is not returned if there are no more results to display.
	//
	// To get the next page of results, perform another GetBuckets request and specify
	// the next page token using the pageToken parameter.
	NextPageToken *string

	// Metadata pertaining to the operation's result.
	ResultMetadata middleware.Metadata

	noSmithyDocumentSerde
}

func (c *Client) addOperationGetBucketsMiddlewares(stack *middleware.Stack, options Options) (err error) {
	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
		return err
	}
	err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetBuckets{}, middleware.After)
	if err != nil {
		return err
	}
	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetBuckets{}, middleware.After)
	if err != nil {
		return err
	}
	if err := addProtocolFinalizerMiddlewares(stack, options, "GetBuckets"); err != nil {
		return fmt.Errorf("add protocol finalizers: %v", err)
	}

	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
		return err
	}
	if err = addSetLoggerMiddleware(stack, options); err != nil {
		return err
	}
	if err = addClientRequestID(stack); err != nil {
		return err
	}
	if err = addComputeContentLength(stack); err != nil {
		return err
	}
	if err = addResolveEndpointMiddleware(stack, options); err != nil {
		return err
	}
	if err = addComputePayloadSHA256(stack); err != nil {
		return err
	}
	if err = addRetry(stack, options, c); err != nil {
		return err
	}
	if err = addRawResponseToMetadata(stack); err != nil {
		return err
	}
	if err = addRecordResponseTiming(stack); err != nil {
		return err
	}
	if err = addSpanRetryLoop(stack, options); err != nil {
		return err
	}
	if err = addClientUserAgent(stack, options); err != nil {
		return err
	}
	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
		return err
	}
	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
		return err
	}
	if err = addUserAgentRetryMode(stack, options); err != nil {
		return err
	}
	if err = addCredentialSource(stack, options); err != nil {
		return err
	}
	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetBuckets(options.Region), middleware.Before); err != nil {
		return err
	}
	if err = addRecursionDetection(stack); err != nil {
		return err
	}
	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
		return err
	}
	if err = addResponseErrorMiddleware(stack); err != nil {
		return err
	}
	if err = addRequestResponseLogging(stack, options); err != nil {
		return err
	}
	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
		return err
	}
	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
		return err
	}
	if err = addInterceptAttempt(stack, options); err != nil {
		return err
	}
	if err = addInterceptors(stack, options); err != nil {
		return err
	}
	return nil
}

func newServiceMetadataMiddleware_opGetBuckets(region string) *awsmiddleware.RegisterServiceMetadata {
	return &awsmiddleware.RegisterServiceMetadata{
		Region:        region,
		ServiceID:     ServiceID,
		OperationName: "GetBuckets",
	}
}
