src

Go monorepo.
git clone git://code.dwrz.net/src
Log | Files | Refs

api_op_ListHostedZones.go (10639B)


      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 // Retrieves a list of the public and private hosted zones that are associated
     15 // with the current Amazon Web Services account. The response includes a
     16 // HostedZones child element for each hosted zone.
     17 //
     18 // Amazon Route 53 returns a maximum of 100 items in each response. If you have a
     19 // lot of hosted zones, you can use the maxitems parameter to list them in groups
     20 // of up to 100.
     21 func (c *Client) ListHostedZones(ctx context.Context, params *ListHostedZonesInput, optFns ...func(*Options)) (*ListHostedZonesOutput, error) {
     22 	if params == nil {
     23 		params = &ListHostedZonesInput{}
     24 	}
     25 
     26 	result, metadata, err := c.invokeOperation(ctx, "ListHostedZones", params, optFns, c.addOperationListHostedZonesMiddlewares)
     27 	if err != nil {
     28 		return nil, err
     29 	}
     30 
     31 	out := result.(*ListHostedZonesOutput)
     32 	out.ResultMetadata = metadata
     33 	return out, nil
     34 }
     35 
     36 // A request to retrieve a list of the public and private hosted zones that are
     37 // associated with the current Amazon Web Services account.
     38 type ListHostedZonesInput struct {
     39 
     40 	// If you're using reusable delegation sets and you want to list all of the hosted
     41 	// zones that are associated with a reusable delegation set, specify the ID of that
     42 	// reusable delegation set.
     43 	DelegationSetId *string
     44 
     45 	//  (Optional) Specifies if the hosted zone is private.
     46 	HostedZoneType types.HostedZoneType
     47 
     48 	// If the value of IsTruncated in the previous response was true , you have more
     49 	// hosted zones. To get more hosted zones, submit another ListHostedZones request.
     50 	//
     51 	// For the value of marker , specify the value of NextMarker from the previous
     52 	// response, which is the ID of the first hosted zone that Amazon Route 53 will
     53 	// return if you submit another request.
     54 	//
     55 	// If the value of IsTruncated in the previous response was false , there are no
     56 	// more hosted zones to get.
     57 	Marker *string
     58 
     59 	// (Optional) The maximum number of hosted zones that you want Amazon Route 53 to
     60 	// return. If you have more than maxitems hosted zones, the value of IsTruncated
     61 	// in the response is true , and the value of NextMarker is the hosted zone ID of
     62 	// the first hosted zone that Route 53 will return if you submit another request.
     63 	MaxItems *int32
     64 
     65 	noSmithyDocumentSerde
     66 }
     67 
     68 type ListHostedZonesOutput struct {
     69 
     70 	// A complex type that contains general information about the hosted zone.
     71 	//
     72 	// This member is required.
     73 	HostedZones []types.HostedZone
     74 
     75 	// A flag indicating whether there are more hosted zones to be listed. If the
     76 	// response was truncated, you can get more hosted zones by submitting another
     77 	// ListHostedZones request and specifying the value of NextMarker in the marker
     78 	// parameter.
     79 	//
     80 	// This member is required.
     81 	IsTruncated bool
     82 
     83 	// For the second and subsequent calls to ListHostedZones , Marker is the value
     84 	// that you specified for the marker parameter in the request that produced the
     85 	// current response.
     86 	//
     87 	// This member is required.
     88 	Marker *string
     89 
     90 	// The value that you specified for the maxitems parameter in the call to
     91 	// ListHostedZones that produced the current response.
     92 	//
     93 	// This member is required.
     94 	MaxItems *int32
     95 
     96 	// If IsTruncated is true , the value of NextMarker identifies the first hosted
     97 	// zone in the next group of hosted zones. Submit another ListHostedZones request,
     98 	// and specify the value of NextMarker from the response in the marker parameter.
     99 	//
    100 	// This element is present only if IsTruncated is true .
    101 	NextMarker *string
    102 
    103 	// Metadata pertaining to the operation's result.
    104 	ResultMetadata middleware.Metadata
    105 
    106 	noSmithyDocumentSerde
    107 }
    108 
    109 func (c *Client) addOperationListHostedZonesMiddlewares(stack *middleware.Stack, options Options) (err error) {
    110 	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
    111 		return err
    112 	}
    113 	err = stack.Serialize.Add(&awsRestxml_serializeOpListHostedZones{}, middleware.After)
    114 	if err != nil {
    115 		return err
    116 	}
    117 	err = stack.Deserialize.Add(&awsRestxml_deserializeOpListHostedZones{}, middleware.After)
    118 	if err != nil {
    119 		return err
    120 	}
    121 	if err := addProtocolFinalizerMiddlewares(stack, options, "ListHostedZones"); err != nil {
    122 		return fmt.Errorf("add protocol finalizers: %v", err)
    123 	}
    124 
    125 	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
    126 		return err
    127 	}
    128 	if err = addSetLoggerMiddleware(stack, options); err != nil {
    129 		return err
    130 	}
    131 	if err = addClientRequestID(stack); err != nil {
    132 		return err
    133 	}
    134 	if err = addComputeContentLength(stack); err != nil {
    135 		return err
    136 	}
    137 	if err = addResolveEndpointMiddleware(stack, options); err != nil {
    138 		return err
    139 	}
    140 	if err = addComputePayloadSHA256(stack); err != nil {
    141 		return err
    142 	}
    143 	if err = addRetry(stack, options); err != nil {
    144 		return err
    145 	}
    146 	if err = addRawResponseToMetadata(stack); err != nil {
    147 		return err
    148 	}
    149 	if err = addRecordResponseTiming(stack); err != nil {
    150 		return err
    151 	}
    152 	if err = addSpanRetryLoop(stack, options); err != nil {
    153 		return err
    154 	}
    155 	if err = addClientUserAgent(stack, options); err != nil {
    156 		return err
    157 	}
    158 	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
    159 		return err
    160 	}
    161 	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
    162 		return err
    163 	}
    164 	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
    165 		return err
    166 	}
    167 	if err = addTimeOffsetBuild(stack, c); err != nil {
    168 		return err
    169 	}
    170 	if err = addUserAgentRetryMode(stack, options); err != nil {
    171 		return err
    172 	}
    173 	if err = addCredentialSource(stack, options); err != nil {
    174 		return err
    175 	}
    176 	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListHostedZones(options.Region), middleware.Before); err != nil {
    177 		return err
    178 	}
    179 	if err = addRecursionDetection(stack); err != nil {
    180 		return err
    181 	}
    182 	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
    183 		return err
    184 	}
    185 	if err = addResponseErrorMiddleware(stack); err != nil {
    186 		return err
    187 	}
    188 	if err = addSanitizeURLMiddleware(stack); err != nil {
    189 		return err
    190 	}
    191 	if err = addRequestResponseLogging(stack, options); err != nil {
    192 		return err
    193 	}
    194 	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
    195 		return err
    196 	}
    197 	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
    198 		return err
    199 	}
    200 	if err = addInterceptAttempt(stack, options); err != nil {
    201 		return err
    202 	}
    203 	if err = addInterceptExecution(stack, options); err != nil {
    204 		return err
    205 	}
    206 	if err = addInterceptBeforeSerialization(stack, options); err != nil {
    207 		return err
    208 	}
    209 	if err = addInterceptAfterSerialization(stack, options); err != nil {
    210 		return err
    211 	}
    212 	if err = addInterceptBeforeSigning(stack, options); err != nil {
    213 		return err
    214 	}
    215 	if err = addInterceptAfterSigning(stack, options); err != nil {
    216 		return err
    217 	}
    218 	if err = addInterceptTransmit(stack, options); err != nil {
    219 		return err
    220 	}
    221 	if err = addInterceptBeforeDeserialization(stack, options); err != nil {
    222 		return err
    223 	}
    224 	if err = addInterceptAfterDeserialization(stack, options); err != nil {
    225 		return err
    226 	}
    227 	if err = addSpanInitializeStart(stack); err != nil {
    228 		return err
    229 	}
    230 	if err = addSpanInitializeEnd(stack); err != nil {
    231 		return err
    232 	}
    233 	if err = addSpanBuildRequestStart(stack); err != nil {
    234 		return err
    235 	}
    236 	if err = addSpanBuildRequestEnd(stack); err != nil {
    237 		return err
    238 	}
    239 	return nil
    240 }
    241 
    242 // ListHostedZonesPaginatorOptions is the paginator options for ListHostedZones
    243 type ListHostedZonesPaginatorOptions struct {
    244 	// (Optional) The maximum number of hosted zones that you want Amazon Route 53 to
    245 	// return. If you have more than maxitems hosted zones, the value of IsTruncated
    246 	// in the response is true , and the value of NextMarker is the hosted zone ID of
    247 	// the first hosted zone that Route 53 will return if you submit another request.
    248 	Limit int32
    249 
    250 	// Set to true if pagination should stop if the service returns a pagination token
    251 	// that matches the most recent token provided to the service.
    252 	StopOnDuplicateToken bool
    253 }
    254 
    255 // ListHostedZonesPaginator is a paginator for ListHostedZones
    256 type ListHostedZonesPaginator struct {
    257 	options   ListHostedZonesPaginatorOptions
    258 	client    ListHostedZonesAPIClient
    259 	params    *ListHostedZonesInput
    260 	nextToken *string
    261 	firstPage bool
    262 }
    263 
    264 // NewListHostedZonesPaginator returns a new ListHostedZonesPaginator
    265 func NewListHostedZonesPaginator(client ListHostedZonesAPIClient, params *ListHostedZonesInput, optFns ...func(*ListHostedZonesPaginatorOptions)) *ListHostedZonesPaginator {
    266 	if params == nil {
    267 		params = &ListHostedZonesInput{}
    268 	}
    269 
    270 	options := ListHostedZonesPaginatorOptions{}
    271 	if params.MaxItems != nil {
    272 		options.Limit = *params.MaxItems
    273 	}
    274 
    275 	for _, fn := range optFns {
    276 		fn(&options)
    277 	}
    278 
    279 	return &ListHostedZonesPaginator{
    280 		options:   options,
    281 		client:    client,
    282 		params:    params,
    283 		firstPage: true,
    284 		nextToken: params.Marker,
    285 	}
    286 }
    287 
    288 // HasMorePages returns a boolean indicating whether more pages are available
    289 func (p *ListHostedZonesPaginator) HasMorePages() bool {
    290 	return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
    291 }
    292 
    293 // NextPage retrieves the next ListHostedZones page.
    294 func (p *ListHostedZonesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListHostedZonesOutput, error) {
    295 	if !p.HasMorePages() {
    296 		return nil, fmt.Errorf("no more pages available")
    297 	}
    298 
    299 	params := *p.params
    300 	params.Marker = p.nextToken
    301 
    302 	var limit *int32
    303 	if p.options.Limit > 0 {
    304 		limit = &p.options.Limit
    305 	}
    306 	params.MaxItems = limit
    307 
    308 	optFns = append([]func(*Options){
    309 		addIsPaginatorUserAgent,
    310 	}, optFns...)
    311 	result, err := p.client.ListHostedZones(ctx, &params, optFns...)
    312 	if err != nil {
    313 		return nil, err
    314 	}
    315 	p.firstPage = false
    316 
    317 	prevToken := p.nextToken
    318 	p.nextToken = result.NextMarker
    319 
    320 	if p.options.StopOnDuplicateToken &&
    321 		prevToken != nil &&
    322 		p.nextToken != nil &&
    323 		*prevToken == *p.nextToken {
    324 		p.nextToken = nil
    325 	}
    326 
    327 	return result, nil
    328 }
    329 
    330 // ListHostedZonesAPIClient is a client that implements the ListHostedZones
    331 // operation.
    332 type ListHostedZonesAPIClient interface {
    333 	ListHostedZones(context.Context, *ListHostedZonesInput, ...func(*Options)) (*ListHostedZonesOutput, error)
    334 }
    335 
    336 var _ ListHostedZonesAPIClient = (*Client)(nil)
    337 
    338 func newServiceMetadataMiddleware_opListHostedZones(region string) *awsmiddleware.RegisterServiceMetadata {
    339 	return &awsmiddleware.RegisterServiceMetadata{
    340 		Region:        region,
    341 		ServiceID:     ServiceID,
    342 		OperationName: "ListHostedZones",
    343 	}
    344 }