1 // Code generated by smithy-go-codegen DO NOT EDIT.
2 3 package route53
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/route53/types"
10 "github.com/aws/smithy-go/middleware"
11 smithyhttp "github.com/aws/smithy-go/transport/http"
12 )
13 14 // Disassociates an Amazon Virtual Private Cloud (Amazon VPC) from an Amazon Route
15 // 53 private hosted zone. Note the following:
16 //
17 // - You can't disassociate the last Amazon VPC from a private hosted zone.
18 //
19 // - You can't convert a private hosted zone into a public hosted zone.
20 //
21 // - You can submit a DisassociateVPCFromHostedZone request using either the
22 // account that created the hosted zone or the account that created the Amazon VPC.
23 //
24 // - Some services, such as Cloud Map and Amazon Elastic File System (Amazon
25 // EFS) automatically create hosted zones and associate VPCs with the hosted zones.
26 // A service can create a hosted zone using your account or using its own account.
27 // You can disassociate a VPC from a hosted zone only if the service created the
28 // hosted zone using your account.
29 //
30 // When you run [DisassociateVPCFromHostedZone], if the hosted zone has a value for OwningAccount , you can use
31 //
32 // DisassociateVPCFromHostedZone . If the hosted zone has a value for
33 // OwningService , you can't use DisassociateVPCFromHostedZone .
34 //
35 // When revoking access, the hosted zone and the Amazon VPC must belong to the
36 // same partition. A partition is a group of Amazon Web Services Regions. Each
37 // Amazon Web Services account is scoped to one partition.
38 //
39 // The following are the supported partitions:
40 //
41 // - aws - Amazon Web Services Regions
42 //
43 // - aws-cn - China Regions
44 //
45 // - aws-us-gov - Amazon Web Services GovCloud (US) Region
46 //
47 // For more information, see [Access Management] in the Amazon Web Services General Reference.
48 //
49 // [Access Management]: https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html
50 // [DisassociateVPCFromHostedZone]: https://docs.aws.amazon.com/Route53/latest/APIReference/API_ListHostedZonesByVPC.html
51 func (c *Client) DisassociateVPCFromHostedZone(ctx context.Context, params *DisassociateVPCFromHostedZoneInput, optFns ...func(*Options)) (*DisassociateVPCFromHostedZoneOutput, error) {
52 if params == nil {
53 params = &DisassociateVPCFromHostedZoneInput{}
54 }
55 56 result, metadata, err := c.invokeOperation(ctx, "DisassociateVPCFromHostedZone", params, optFns, c.addOperationDisassociateVPCFromHostedZoneMiddlewares)
57 if err != nil {
58 return nil, err
59 }
60 61 out := result.(*DisassociateVPCFromHostedZoneOutput)
62 out.ResultMetadata = metadata
63 return out, nil
64 }
65 66 // A complex type that contains information about the VPC that you want to
67 // disassociate from a specified private hosted zone.
68 type DisassociateVPCFromHostedZoneInput struct {
69 70 // The ID of the private hosted zone that you want to disassociate a VPC from.
71 //
72 // This member is required.
73 HostedZoneId *string
74 75 // A complex type that contains information about the VPC that you're
76 // disassociating from the specified hosted zone.
77 //
78 // This member is required.
79 VPC *types.VPC
80 81 // Optional: A comment about the disassociation request.
82 Comment *string
83 84 noSmithyDocumentSerde
85 }
86 87 // A complex type that contains the response information for the disassociate
88 // request.
89 type DisassociateVPCFromHostedZoneOutput struct {
90 91 // A complex type that describes the changes made to the specified private hosted
92 // zone.
93 //
94 // This member is required.
95 ChangeInfo *types.ChangeInfo
96 97 // Metadata pertaining to the operation's result.
98 ResultMetadata middleware.Metadata
99 100 noSmithyDocumentSerde
101 }
102 103 func (c *Client) addOperationDisassociateVPCFromHostedZoneMiddlewares(stack *middleware.Stack, options Options) (err error) {
104 if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
105 return err
106 }
107 err = stack.Serialize.Add(&awsRestxml_serializeOpDisassociateVPCFromHostedZone{}, middleware.After)
108 if err != nil {
109 return err
110 }
111 err = stack.Deserialize.Add(&awsRestxml_deserializeOpDisassociateVPCFromHostedZone{}, middleware.After)
112 if err != nil {
113 return err
114 }
115 if err := addProtocolFinalizerMiddlewares(stack, options, "DisassociateVPCFromHostedZone"); err != nil {
116 return fmt.Errorf("add protocol finalizers: %v", err)
117 }
118 119 if err = addlegacyEndpointContextSetter(stack, options); err != nil {
120 return err
121 }
122 if err = addSetLoggerMiddleware(stack, options); err != nil {
123 return err
124 }
125 if err = addClientRequestID(stack); err != nil {
126 return err
127 }
128 if err = addComputeContentLength(stack); err != nil {
129 return err
130 }
131 if err = addResolveEndpointMiddleware(stack, options); err != nil {
132 return err
133 }
134 if err = addComputePayloadSHA256(stack); err != nil {
135 return err
136 }
137 if err = addRetry(stack, options); err != nil {
138 return err
139 }
140 if err = addRawResponseToMetadata(stack); err != nil {
141 return err
142 }
143 if err = addRecordResponseTiming(stack); err != nil {
144 return err
145 }
146 if err = addSpanRetryLoop(stack, options); err != nil {
147 return err
148 }
149 if err = addClientUserAgent(stack, options); err != nil {
150 return err
151 }
152 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
153 return err
154 }
155 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
156 return err
157 }
158 if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
159 return err
160 }
161 if err = addTimeOffsetBuild(stack, c); err != nil {
162 return err
163 }
164 if err = addUserAgentRetryMode(stack, options); err != nil {
165 return err
166 }
167 if err = addCredentialSource(stack, options); err != nil {
168 return err
169 }
170 if err = addOpDisassociateVPCFromHostedZoneValidationMiddleware(stack); err != nil {
171 return err
172 }
173 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDisassociateVPCFromHostedZone(options.Region), middleware.Before); err != nil {
174 return err
175 }
176 if err = addRecursionDetection(stack); err != nil {
177 return err
178 }
179 if err = addRequestIDRetrieverMiddleware(stack); err != nil {
180 return err
181 }
182 if err = addResponseErrorMiddleware(stack); err != nil {
183 return err
184 }
185 if err = addSanitizeURLMiddleware(stack); err != nil {
186 return err
187 }
188 if err = addRequestResponseLogging(stack, options); err != nil {
189 return err
190 }
191 if err = addDisableHTTPSMiddleware(stack, options); err != nil {
192 return err
193 }
194 if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
195 return err
196 }
197 if err = addInterceptAttempt(stack, options); err != nil {
198 return err
199 }
200 if err = addInterceptors(stack, options); err != nil {
201 return err
202 }
203 return nil
204 }
205 206 func newServiceMetadataMiddleware_opDisassociateVPCFromHostedZone(region string) *awsmiddleware.RegisterServiceMetadata {
207 return &awsmiddleware.RegisterServiceMetadata{
208 Region: region,
209 ServiceID: ServiceID,
210 OperationName: "DisassociateVPCFromHostedZone",
211 }
212 }
213