1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package cloudfront
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/smithy-go/middleware"
10	smithyhttp "github.com/aws/smithy-go/transport/http"
11)
12
13// Delete a distribution.
14func (c *Client) DeleteDistribution(ctx context.Context, params *DeleteDistributionInput, optFns ...func(*Options)) (*DeleteDistributionOutput, error) {
15	if params == nil {
16		params = &DeleteDistributionInput{}
17	}
18
19	result, metadata, err := c.invokeOperation(ctx, "DeleteDistribution", params, optFns, addOperationDeleteDistributionMiddlewares)
20	if err != nil {
21		return nil, err
22	}
23
24	out := result.(*DeleteDistributionOutput)
25	out.ResultMetadata = metadata
26	return out, nil
27}
28
29// This action deletes a web distribution. To delete a web distribution using the
30// CloudFront API, perform the following steps. To delete a web distribution using
31// the CloudFront API:
32//
33// * Disable the web distribution
34//
35// * Submit a GET Distribution
36// Config request to get the current configuration and the Etag header for the
37// distribution.
38//
39// * Update the XML document that was returned in the response to
40// your GET Distribution Config request to change the value of Enabled to false.
41//
42// *
43// Submit a PUT Distribution Config request to update the configuration for your
44// distribution. In the request body, include the XML document that you updated in
45// Step 3. Set the value of the HTTP If-Match header to the value of the ETag
46// header that CloudFront returned when you submitted the GET Distribution Config
47// request in Step 2.
48//
49// * Review the response to the PUT Distribution Config request
50// to confirm that the distribution was successfully disabled.
51//
52// * Submit a GET
53// Distribution request to confirm that your changes have propagated. When
54// propagation is complete, the value of Status is Deployed.
55//
56// * Submit a DELETE
57// Distribution request. Set the value of the HTTP If-Match header to the value of
58// the ETag header that CloudFront returned when you submitted the GET Distribution
59// Config request in Step 6.
60//
61// * Review the response to your DELETE Distribution
62// request to confirm that the distribution was successfully deleted.
63//
64// For
65// information about deleting a distribution using the CloudFront console, see
66// Deleting a Distribution
67// (https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/HowToDeleteDistribution.html)
68// in the Amazon CloudFront Developer Guide.
69type DeleteDistributionInput struct {
70
71	// The distribution ID.
72	//
73	// This member is required.
74	Id *string
75
76	// The value of the ETag header that you received when you disabled the
77	// distribution. For example: E2QWRUHAPOMQZL.
78	IfMatch *string
79}
80
81type DeleteDistributionOutput struct {
82	// Metadata pertaining to the operation's result.
83	ResultMetadata middleware.Metadata
84}
85
86func addOperationDeleteDistributionMiddlewares(stack *middleware.Stack, options Options) (err error) {
87	err = stack.Serialize.Add(&awsRestxml_serializeOpDeleteDistribution{}, middleware.After)
88	if err != nil {
89		return err
90	}
91	err = stack.Deserialize.Add(&awsRestxml_deserializeOpDeleteDistribution{}, middleware.After)
92	if err != nil {
93		return err
94	}
95	if err = addSetLoggerMiddleware(stack, options); err != nil {
96		return err
97	}
98	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
99		return err
100	}
101	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
102		return err
103	}
104	if err = addResolveEndpointMiddleware(stack, options); err != nil {
105		return err
106	}
107	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
108		return err
109	}
110	if err = addRetryMiddlewares(stack, options); err != nil {
111		return err
112	}
113	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
114		return err
115	}
116	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
117		return err
118	}
119	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
120		return err
121	}
122	if err = addClientUserAgent(stack); err != nil {
123		return err
124	}
125	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
126		return err
127	}
128	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
129		return err
130	}
131	if err = addOpDeleteDistributionValidationMiddleware(stack); err != nil {
132		return err
133	}
134	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDeleteDistribution(options.Region), middleware.Before); err != nil {
135		return err
136	}
137	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
138		return err
139	}
140	if err = addResponseErrorMiddleware(stack); err != nil {
141		return err
142	}
143	if err = addRequestResponseLogging(stack, options); err != nil {
144		return err
145	}
146	return nil
147}
148
149func newServiceMetadataMiddleware_opDeleteDistribution(region string) *awsmiddleware.RegisterServiceMetadata {
150	return &awsmiddleware.RegisterServiceMetadata{
151		Region:        region,
152		ServiceID:     ServiceID,
153		SigningName:   "cloudfront",
154		OperationName: "DeleteDistribution",
155	}
156}
157