api_op_ListHostedZones.go (7830B)
1 // Code generated by smithy-go-codegen DO NOT EDIT. 2 3 package route53 4 5 import ( 6 "context" 7 "fmt" 8 9 "github.com/aws/aws-sdk-go-v2/service/route53/types" 10 "github.com/aws/smithy-go/middleware" 11 ) 12 13 // Retrieves a list of the public and private hosted zones that are associated 14 // with the current Amazon Web Services account. The response includes a 15 // HostedZones child element for each hosted zone. 16 // 17 // Amazon Route 53 returns a maximum of 100 items in each response. If you have a 18 // lot of hosted zones, you can use the maxitems parameter to list them in groups 19 // of up to 100. 20 func (c *Client) ListHostedZones(ctx context.Context, params *ListHostedZonesInput, optFns ...func(*Options)) (*ListHostedZonesOutput, error) { 21 if params == nil { 22 params = &ListHostedZonesInput{} 23 } 24 25 result, metadata, err := c.invokeOperation(ctx, "ListHostedZones", params, optFns, c.addOperationListHostedZonesMiddlewares) 26 if err != nil { 27 return nil, err 28 } 29 30 out := result.(*ListHostedZonesOutput) 31 out.ResultMetadata = metadata 32 return out, nil 33 } 34 35 // A request to retrieve a list of the public and private hosted zones that are 36 // associated with the current Amazon Web Services account. 37 type ListHostedZonesInput struct { 38 39 // If you're using reusable delegation sets and you want to list all of the hosted 40 // zones that are associated with a reusable delegation set, specify the ID of that 41 // reusable delegation set. 42 DelegationSetId *string 43 44 // (Optional) Specifies if the hosted zone is private. 45 HostedZoneType types.HostedZoneType 46 47 // If the value of IsTruncated in the previous response was true , you have more 48 // hosted zones. To get more hosted zones, submit another ListHostedZones request. 49 // 50 // For the value of marker , specify the value of NextMarker from the previous 51 // response, which is the ID of the first hosted zone that Amazon Route 53 will 52 // return if you submit another request. 53 // 54 // If the value of IsTruncated in the previous response was false , there are no 55 // more hosted zones to get. 56 Marker *string 57 58 // (Optional) The maximum number of hosted zones that you want Amazon Route 53 to 59 // return. If you have more than maxitems hosted zones, the value of IsTruncated 60 // in the response is true , and the value of NextMarker is the hosted zone ID of 61 // the first hosted zone that Route 53 will return if you submit another request. 62 MaxItems *int32 63 64 noSmithyDocumentSerde 65 } 66 67 type ListHostedZonesOutput struct { 68 69 // A complex type that contains general information about the hosted zone. 70 // 71 // This member is required. 72 HostedZones []types.HostedZone 73 74 // A flag indicating whether there are more hosted zones to be listed. If the 75 // response was truncated, you can get more hosted zones by submitting another 76 // ListHostedZones request and specifying the value of NextMarker in the marker 77 // parameter. 78 // 79 // This member is required. 80 IsTruncated bool 81 82 // For the second and subsequent calls to ListHostedZones , Marker is the value 83 // that you specified for the marker parameter in the request that produced the 84 // current response. 85 // 86 // This member is required. 87 Marker *string 88 89 // The value that you specified for the maxitems parameter in the call to 90 // ListHostedZones that produced the current response. 91 // 92 // This member is required. 93 MaxItems *int32 94 95 // If IsTruncated is true , the value of NextMarker identifies the first hosted 96 // zone in the next group of hosted zones. Submit another ListHostedZones request, 97 // and specify the value of NextMarker from the response in the marker parameter. 98 // 99 // This element is present only if IsTruncated is true . 100 NextMarker *string 101 102 // Metadata pertaining to the operation's result. 103 ResultMetadata middleware.Metadata 104 105 noSmithyDocumentSerde 106 } 107 108 func (c *Client) addOperationListHostedZonesMiddlewares(stack *middleware.Stack, options Options) (err error) { 109 err = stack.Serialize.Add(&awsRestxml_serializeOpListHostedZones{}, middleware.After) 110 if err != nil { 111 return err 112 } 113 err = stack.Deserialize.Add(&awsRestxml_deserializeOpListHostedZones{}, middleware.After) 114 if err != nil { 115 return err 116 } 117 118 if err = addComputeContentLength(stack); err != nil { 119 return err 120 } 121 if err = addResolveEndpointMiddleware(stack, options); err != nil { 122 return err 123 } 124 if err = addComputePayloadSHA256(stack); err != nil { 125 return err 126 } 127 if err = addRecordResponseTiming(stack, options); err != nil { 128 return err 129 } 130 if err = addCredentialSource(stack, options); err != nil { 131 return err 132 } 133 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 134 return err 135 } 136 if err = addResponseErrorMiddleware(stack); err != nil { 137 return err 138 } 139 if err = addSanitizeURLMiddleware(stack); err != nil { 140 return err 141 } 142 if err = addRequestResponseLogging(stack, options); err != nil { 143 return err 144 } 145 if err = addDisableHTTPSMiddleware(stack, options); err != nil { 146 return err 147 } 148 if err = addInterceptors(stack, options); err != nil { 149 return err 150 } 151 return nil 152 } 153 154 // ListHostedZonesPaginatorOptions is the paginator options for ListHostedZones 155 type ListHostedZonesPaginatorOptions struct { 156 // (Optional) The maximum number of hosted zones that you want Amazon Route 53 to 157 // return. If you have more than maxitems hosted zones, the value of IsTruncated 158 // in the response is true , and the value of NextMarker is the hosted zone ID of 159 // the first hosted zone that Route 53 will return if you submit another request. 160 Limit int32 161 162 // Set to true if pagination should stop if the service returns a pagination token 163 // that matches the most recent token provided to the service. 164 StopOnDuplicateToken bool 165 } 166 167 // ListHostedZonesPaginator is a paginator for ListHostedZones 168 type ListHostedZonesPaginator struct { 169 options ListHostedZonesPaginatorOptions 170 client ListHostedZonesAPIClient 171 params *ListHostedZonesInput 172 nextToken *string 173 firstPage bool 174 } 175 176 // NewListHostedZonesPaginator returns a new ListHostedZonesPaginator 177 func NewListHostedZonesPaginator(client ListHostedZonesAPIClient, params *ListHostedZonesInput, optFns ...func(*ListHostedZonesPaginatorOptions)) *ListHostedZonesPaginator { 178 if params == nil { 179 params = &ListHostedZonesInput{} 180 } 181 182 options := ListHostedZonesPaginatorOptions{} 183 if params.MaxItems != nil { 184 options.Limit = *params.MaxItems 185 } 186 187 for _, fn := range optFns { 188 fn(&options) 189 } 190 191 return &ListHostedZonesPaginator{ 192 options: options, 193 client: client, 194 params: params, 195 firstPage: true, 196 nextToken: params.Marker, 197 } 198 } 199 200 // HasMorePages returns a boolean indicating whether more pages are available 201 func (p *ListHostedZonesPaginator) HasMorePages() bool { 202 return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0) 203 } 204 205 // NextPage retrieves the next ListHostedZones page. 206 func (p *ListHostedZonesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListHostedZonesOutput, error) { 207 if !p.HasMorePages() { 208 return nil, fmt.Errorf("no more pages available") 209 } 210 211 params := *p.params 212 params.Marker = p.nextToken 213 214 var limit *int32 215 if p.options.Limit > 0 { 216 limit = &p.options.Limit 217 } 218 params.MaxItems = limit 219 220 optFns = append([]func(*Options){ 221 addIsPaginatorUserAgent, 222 }, optFns...) 223 result, err := p.client.ListHostedZones(ctx, ¶ms, optFns...) 224 if err != nil { 225 return nil, err 226 } 227 p.firstPage = false 228 229 prevToken := p.nextToken 230 p.nextToken = result.NextMarker 231 232 if p.options.StopOnDuplicateToken && 233 prevToken != nil && 234 p.nextToken != nil && 235 *prevToken == *p.nextToken { 236 p.nextToken = nil 237 } 238 239 return result, nil 240 } 241 242 // ListHostedZonesAPIClient is a client that implements the ListHostedZones 243 // operation. 244 type ListHostedZonesAPIClient interface { 245 ListHostedZones(context.Context, *ListHostedZonesInput, ...func(*Options)) (*ListHostedZonesOutput, error) 246 } 247 248 var _ ListHostedZonesAPIClient = (*Client)(nil)