api_op_GetDistributions.go raw

   1  // Code generated by smithy-go-codegen DO NOT EDIT.
   2  
   3  package lightsail
   4  
   5  import (
   6  	"context"
   7  	"fmt"
   8  	awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
   9  	"github.com/aws/aws-sdk-go-v2/service/lightsail/types"
  10  	"github.com/aws/smithy-go/middleware"
  11  	smithyhttp "github.com/aws/smithy-go/transport/http"
  12  )
  13  
  14  // Returns information about one or more of your Amazon Lightsail content delivery
  15  // network (CDN) distributions.
  16  func (c *Client) GetDistributions(ctx context.Context, params *GetDistributionsInput, optFns ...func(*Options)) (*GetDistributionsOutput, error) {
  17  	if params == nil {
  18  		params = &GetDistributionsInput{}
  19  	}
  20  
  21  	result, metadata, err := c.invokeOperation(ctx, "GetDistributions", params, optFns, c.addOperationGetDistributionsMiddlewares)
  22  	if err != nil {
  23  		return nil, err
  24  	}
  25  
  26  	out := result.(*GetDistributionsOutput)
  27  	out.ResultMetadata = metadata
  28  	return out, nil
  29  }
  30  
  31  type GetDistributionsInput struct {
  32  
  33  	// The name of the distribution for which to return information.
  34  	//
  35  	// When omitted, the response includes all of your distributions in the Amazon Web
  36  	// Services Region where the request is made.
  37  	DistributionName *string
  38  
  39  	// The token to advance to the next page of results from your request.
  40  	//
  41  	// To get a page token, perform an initial GetDistributions request. If your
  42  	// results are paginated, the response will return a next page token that you can
  43  	// specify as the page token in a subsequent request.
  44  	PageToken *string
  45  
  46  	noSmithyDocumentSerde
  47  }
  48  
  49  type GetDistributionsOutput struct {
  50  
  51  	// An array of objects that describe your distributions.
  52  	Distributions []types.LightsailDistribution
  53  
  54  	// The token to advance to the next page of results from your request.
  55  	//
  56  	// A next page token is not returned if there are no more results to display.
  57  	//
  58  	// To get the next page of results, perform another GetDistributions request and
  59  	// specify the next page token using the pageToken parameter.
  60  	NextPageToken *string
  61  
  62  	// Metadata pertaining to the operation's result.
  63  	ResultMetadata middleware.Metadata
  64  
  65  	noSmithyDocumentSerde
  66  }
  67  
  68  func (c *Client) addOperationGetDistributionsMiddlewares(stack *middleware.Stack, options Options) (err error) {
  69  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
  70  		return err
  71  	}
  72  	err = stack.Serialize.Add(&awsAwsjson11_serializeOpGetDistributions{}, middleware.After)
  73  	if err != nil {
  74  		return err
  75  	}
  76  	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpGetDistributions{}, middleware.After)
  77  	if err != nil {
  78  		return err
  79  	}
  80  	if err := addProtocolFinalizerMiddlewares(stack, options, "GetDistributions"); err != nil {
  81  		return fmt.Errorf("add protocol finalizers: %v", err)
  82  	}
  83  
  84  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
  85  		return err
  86  	}
  87  	if err = addSetLoggerMiddleware(stack, options); err != nil {
  88  		return err
  89  	}
  90  	if err = addClientRequestID(stack); err != nil {
  91  		return err
  92  	}
  93  	if err = addComputeContentLength(stack); err != nil {
  94  		return err
  95  	}
  96  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
  97  		return err
  98  	}
  99  	if err = addComputePayloadSHA256(stack); err != nil {
 100  		return err
 101  	}
 102  	if err = addRetry(stack, options); err != nil {
 103  		return err
 104  	}
 105  	if err = addRawResponseToMetadata(stack); err != nil {
 106  		return err
 107  	}
 108  	if err = addRecordResponseTiming(stack); err != nil {
 109  		return err
 110  	}
 111  	if err = addSpanRetryLoop(stack, options); err != nil {
 112  		return err
 113  	}
 114  	if err = addClientUserAgent(stack, options); 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 = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 124  		return err
 125  	}
 126  	if err = addTimeOffsetBuild(stack, c); err != nil {
 127  		return err
 128  	}
 129  	if err = addUserAgentRetryMode(stack, options); err != nil {
 130  		return err
 131  	}
 132  	if err = addCredentialSource(stack, options); err != nil {
 133  		return err
 134  	}
 135  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetDistributions(options.Region), middleware.Before); err != nil {
 136  		return err
 137  	}
 138  	if err = addRecursionDetection(stack); err != nil {
 139  		return err
 140  	}
 141  	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
 142  		return err
 143  	}
 144  	if err = addResponseErrorMiddleware(stack); err != nil {
 145  		return err
 146  	}
 147  	if err = addRequestResponseLogging(stack, options); err != nil {
 148  		return err
 149  	}
 150  	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
 151  		return err
 152  	}
 153  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 154  		return err
 155  	}
 156  	if err = addInterceptAttempt(stack, options); err != nil {
 157  		return err
 158  	}
 159  	if err = addInterceptors(stack, options); err != nil {
 160  		return err
 161  	}
 162  	return nil
 163  }
 164  
 165  func newServiceMetadataMiddleware_opGetDistributions(region string) *awsmiddleware.RegisterServiceMetadata {
 166  	return &awsmiddleware.RegisterServiceMetadata{
 167  		Region:        region,
 168  		ServiceID:     ServiceID,
 169  		OperationName: "GetDistributions",
 170  	}
 171  }
 172