api_op_UpdateDistribution.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  // Updates an existing Amazon Lightsail content delivery network (CDN)
  15  // distribution.
  16  //
  17  // Use this action to update the configuration of your existing distribution.
  18  func (c *Client) UpdateDistribution(ctx context.Context, params *UpdateDistributionInput, optFns ...func(*Options)) (*UpdateDistributionOutput, error) {
  19  	if params == nil {
  20  		params = &UpdateDistributionInput{}
  21  	}
  22  
  23  	result, metadata, err := c.invokeOperation(ctx, "UpdateDistribution", params, optFns, c.addOperationUpdateDistributionMiddlewares)
  24  	if err != nil {
  25  		return nil, err
  26  	}
  27  
  28  	out := result.(*UpdateDistributionOutput)
  29  	out.ResultMetadata = metadata
  30  	return out, nil
  31  }
  32  
  33  type UpdateDistributionInput struct {
  34  
  35  	// The name of the distribution to update.
  36  	//
  37  	// Use the GetDistributions action to get a list of distribution names that you
  38  	// can specify.
  39  	//
  40  	// This member is required.
  41  	DistributionName *string
  42  
  43  	// An object that describes the cache behavior settings for the distribution.
  44  	//
  45  	// The cacheBehaviorSettings specified in your UpdateDistributionRequest will
  46  	// replace your distribution's existing settings.
  47  	CacheBehaviorSettings *types.CacheSettings
  48  
  49  	// An array of objects that describe the per-path cache behavior for the
  50  	// distribution.
  51  	CacheBehaviors []types.CacheBehaviorPerPath
  52  
  53  	// The name of the SSL/TLS certificate that you want to attach to the distribution.
  54  	//
  55  	// Only certificates with a status of ISSUED can be attached to a distribution.
  56  	//
  57  	// Use the [GetCertificates] action to get a list of certificate names that you can specify.
  58  	//
  59  	// [GetCertificates]: https://docs.aws.amazon.com/lightsail/2016-11-28/api-reference/API_GetCertificates.html
  60  	CertificateName *string
  61  
  62  	// An object that describes the default cache behavior for the distribution.
  63  	DefaultCacheBehavior *types.CacheBehavior
  64  
  65  	// Indicates whether to enable the distribution.
  66  	IsEnabled *bool
  67  
  68  	// An object that describes the origin resource for the distribution, such as a
  69  	// Lightsail instance, bucket, or load balancer.
  70  	//
  71  	// The distribution pulls, caches, and serves content from the origin.
  72  	Origin *types.InputOrigin
  73  
  74  	// Indicates whether the default SSL/TLS certificate is attached to the
  75  	// distribution. The default value is true . When true , the distribution uses the
  76  	// default domain name such as d111111abcdef8.cloudfront.net .
  77  	//
  78  	// Set this value to false to attach a new certificate to the distribution.
  79  	UseDefaultCertificate *bool
  80  
  81  	// Use this parameter to update the minimum TLS protocol version for the SSL/TLS
  82  	// certificate that's attached to the distribution.
  83  	ViewerMinimumTlsProtocolVersion types.ViewerMinimumTlsProtocolVersionEnum
  84  
  85  	noSmithyDocumentSerde
  86  }
  87  
  88  type UpdateDistributionOutput struct {
  89  
  90  	// An array of objects that describe the result of the action, such as the status
  91  	// of the request, the timestamp of the request, and the resources affected by the
  92  	// request.
  93  	Operation *types.Operation
  94  
  95  	// Metadata pertaining to the operation's result.
  96  	ResultMetadata middleware.Metadata
  97  
  98  	noSmithyDocumentSerde
  99  }
 100  
 101  func (c *Client) addOperationUpdateDistributionMiddlewares(stack *middleware.Stack, options Options) (err error) {
 102  	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
 103  		return err
 104  	}
 105  	err = stack.Serialize.Add(&awsAwsjson11_serializeOpUpdateDistribution{}, middleware.After)
 106  	if err != nil {
 107  		return err
 108  	}
 109  	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpUpdateDistribution{}, middleware.After)
 110  	if err != nil {
 111  		return err
 112  	}
 113  	if err := addProtocolFinalizerMiddlewares(stack, options, "UpdateDistribution"); err != nil {
 114  		return fmt.Errorf("add protocol finalizers: %v", err)
 115  	}
 116  
 117  	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
 118  		return err
 119  	}
 120  	if err = addSetLoggerMiddleware(stack, options); err != nil {
 121  		return err
 122  	}
 123  	if err = addClientRequestID(stack); err != nil {
 124  		return err
 125  	}
 126  	if err = addComputeContentLength(stack); err != nil {
 127  		return err
 128  	}
 129  	if err = addResolveEndpointMiddleware(stack, options); err != nil {
 130  		return err
 131  	}
 132  	if err = addComputePayloadSHA256(stack); err != nil {
 133  		return err
 134  	}
 135  	if err = addRetry(stack, options); err != nil {
 136  		return err
 137  	}
 138  	if err = addRawResponseToMetadata(stack); err != nil {
 139  		return err
 140  	}
 141  	if err = addRecordResponseTiming(stack); err != nil {
 142  		return err
 143  	}
 144  	if err = addSpanRetryLoop(stack, options); err != nil {
 145  		return err
 146  	}
 147  	if err = addClientUserAgent(stack, options); err != nil {
 148  		return err
 149  	}
 150  	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
 151  		return err
 152  	}
 153  	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
 154  		return err
 155  	}
 156  	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
 157  		return err
 158  	}
 159  	if err = addTimeOffsetBuild(stack, c); err != nil {
 160  		return err
 161  	}
 162  	if err = addUserAgentRetryMode(stack, options); err != nil {
 163  		return err
 164  	}
 165  	if err = addCredentialSource(stack, options); err != nil {
 166  		return err
 167  	}
 168  	if err = addOpUpdateDistributionValidationMiddleware(stack); err != nil {
 169  		return err
 170  	}
 171  	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opUpdateDistribution(options.Region), middleware.Before); err != nil {
 172  		return err
 173  	}
 174  	if err = addRecursionDetection(stack); err != nil {
 175  		return err
 176  	}
 177  	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
 178  		return err
 179  	}
 180  	if err = addResponseErrorMiddleware(stack); err != nil {
 181  		return err
 182  	}
 183  	if err = addRequestResponseLogging(stack, options); err != nil {
 184  		return err
 185  	}
 186  	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
 187  		return err
 188  	}
 189  	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
 190  		return err
 191  	}
 192  	if err = addInterceptAttempt(stack, options); err != nil {
 193  		return err
 194  	}
 195  	if err = addInterceptors(stack, options); err != nil {
 196  		return err
 197  	}
 198  	return nil
 199  }
 200  
 201  func newServiceMetadataMiddleware_opUpdateDistribution(region string) *awsmiddleware.RegisterServiceMetadata {
 202  	return &awsmiddleware.RegisterServiceMetadata{
 203  		Region:        region,
 204  		ServiceID:     ServiceID,
 205  		OperationName: "UpdateDistribution",
 206  	}
 207  }
 208