api_op_DeleteHostedZone.go (6832B)
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 // Deletes a hosted zone. If the hosted zone was created by another service, such 15 // as Cloud Map, see Deleting Public Hosted Zones That Were Created by Another 16 // Service (https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/DeleteHostedZone.html#delete-public-hosted-zone-created-by-another-service) 17 // in the Amazon Route 53 Developer Guide for information about how to delete it. 18 // (The process is the same for public and private hosted zones that were created 19 // by another service.) If you want to keep your domain registration but you want 20 // to stop routing internet traffic to your website or web application, we 21 // recommend that you delete resource record sets in the hosted zone instead of 22 // deleting the hosted zone. If you delete a hosted zone, you can't undelete it. 23 // You must create a new hosted zone and update the name servers for your domain 24 // registration, which can require up to 48 hours to take effect. (If you delegated 25 // responsibility for a subdomain to a hosted zone and you delete the child hosted 26 // zone, you must update the name servers in the parent hosted zone.) In addition, 27 // if you delete a hosted zone, someone could hijack the domain and route traffic 28 // to their own resources using your domain name. If you want to avoid the monthly 29 // charge for the hosted zone, you can transfer DNS service for the domain to a 30 // free DNS service. When you transfer DNS service, you have to update the name 31 // servers for the domain registration. If the domain is registered with Route 53, 32 // see UpdateDomainNameservers (https://docs.aws.amazon.com/Route53/latest/APIReference/API_domains_UpdateDomainNameservers.html) 33 // for information about how to replace Route 53 name servers with name servers for 34 // the new DNS service. If the domain is registered with another registrar, use the 35 // method provided by the registrar to update name servers for the domain 36 // registration. For more information, perform an internet search on "free DNS 37 // service." You can delete a hosted zone only if it contains only the default SOA 38 // record and NS resource record sets. If the hosted zone contains other resource 39 // record sets, you must delete them before you can delete the hosted zone. If you 40 // try to delete a hosted zone that contains other resource record sets, the 41 // request fails, and Route 53 returns a HostedZoneNotEmpty error. For information 42 // about deleting records from your hosted zone, see ChangeResourceRecordSets (https://docs.aws.amazon.com/Route53/latest/APIReference/API_ChangeResourceRecordSets.html) 43 // . To verify that the hosted zone has been deleted, do one of the following: 44 // - Use the GetHostedZone action to request information about the hosted zone. 45 // - Use the ListHostedZones action to get a list of the hosted zones associated 46 // with the current Amazon Web Services account. 47 func (c *Client) DeleteHostedZone(ctx context.Context, params *DeleteHostedZoneInput, optFns ...func(*Options)) (*DeleteHostedZoneOutput, error) { 48 if params == nil { 49 params = &DeleteHostedZoneInput{} 50 } 51 52 result, metadata, err := c.invokeOperation(ctx, "DeleteHostedZone", params, optFns, c.addOperationDeleteHostedZoneMiddlewares) 53 if err != nil { 54 return nil, err 55 } 56 57 out := result.(*DeleteHostedZoneOutput) 58 out.ResultMetadata = metadata 59 return out, nil 60 } 61 62 // A request to delete a hosted zone. 63 type DeleteHostedZoneInput struct { 64 65 // The ID of the hosted zone you want to delete. 66 // 67 // This member is required. 68 Id *string 69 70 noSmithyDocumentSerde 71 } 72 73 // A complex type that contains the response to a DeleteHostedZone request. 74 type DeleteHostedZoneOutput struct { 75 76 // A complex type that contains the ID, the status, and the date and time of a 77 // request to delete a hosted zone. 78 // 79 // This member is required. 80 ChangeInfo *types.ChangeInfo 81 82 // Metadata pertaining to the operation's result. 83 ResultMetadata middleware.Metadata 84 85 noSmithyDocumentSerde 86 } 87 88 func (c *Client) addOperationDeleteHostedZoneMiddlewares(stack *middleware.Stack, options Options) (err error) { 89 if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil { 90 return err 91 } 92 err = stack.Serialize.Add(&awsRestxml_serializeOpDeleteHostedZone{}, middleware.After) 93 if err != nil { 94 return err 95 } 96 err = stack.Deserialize.Add(&awsRestxml_deserializeOpDeleteHostedZone{}, middleware.After) 97 if err != nil { 98 return err 99 } 100 if err := addProtocolFinalizerMiddlewares(stack, options, "DeleteHostedZone"); err != nil { 101 return fmt.Errorf("add protocol finalizers: %v", err) 102 } 103 104 if err = addlegacyEndpointContextSetter(stack, options); err != nil { 105 return err 106 } 107 if err = addSetLoggerMiddleware(stack, options); err != nil { 108 return err 109 } 110 if err = addClientRequestID(stack); err != nil { 111 return err 112 } 113 if err = addComputeContentLength(stack); err != nil { 114 return err 115 } 116 if err = addResolveEndpointMiddleware(stack, options); err != nil { 117 return err 118 } 119 if err = addComputePayloadSHA256(stack); err != nil { 120 return err 121 } 122 if err = addRetry(stack, options); err != nil { 123 return err 124 } 125 if err = addRawResponseToMetadata(stack); err != nil { 126 return err 127 } 128 if err = addRecordResponseTiming(stack); err != nil { 129 return err 130 } 131 if err = addClientUserAgent(stack, options); err != nil { 132 return err 133 } 134 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 135 return err 136 } 137 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 138 return err 139 } 140 if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil { 141 return err 142 } 143 if err = addOpDeleteHostedZoneValidationMiddleware(stack); err != nil { 144 return err 145 } 146 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDeleteHostedZone(options.Region), middleware.Before); err != nil { 147 return err 148 } 149 if err = addRecursionDetection(stack); err != nil { 150 return err 151 } 152 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 153 return err 154 } 155 if err = addResponseErrorMiddleware(stack); err != nil { 156 return err 157 } 158 if err = addSanitizeURLMiddleware(stack); err != nil { 159 return err 160 } 161 if err = addRequestResponseLogging(stack, options); err != nil { 162 return err 163 } 164 if err = addDisableHTTPSMiddleware(stack, options); err != nil { 165 return err 166 } 167 return nil 168 } 169 170 func newServiceMetadataMiddleware_opDeleteHostedZone(region string) *awsmiddleware.RegisterServiceMetadata { 171 return &awsmiddleware.RegisterServiceMetadata{ 172 Region: region, 173 ServiceID: ServiceID, 174 OperationName: "DeleteHostedZone", 175 } 176 }