code.dwrz.net

Go monorepo.
Log | Files | Refs

api_op_ListHostedZones.go (8681B)


      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/aws/signer/v4"
     10 	"github.com/aws/aws-sdk-go-v2/service/route53/types"
     11 	"github.com/aws/smithy-go/middleware"
     12 	smithyhttp "github.com/aws/smithy-go/transport/http"
     13 )
     14 
     15 // Retrieves a list of the public and private hosted zones that are associated with
     16 // the current Amazon Web Services account. The response includes a HostedZones
     17 // child element for each hosted zone. Amazon Route 53 returns a maximum of 100
     18 // items in each response. If you have a lot of hosted zones, you can use the
     19 // maxitems parameter to list them in groups 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 	// If the value of IsTruncated in the previous response was true, you have more
     45 	// hosted zones. To get more hosted zones, submit another ListHostedZones request.
     46 	// For the value of marker, specify the value of NextMarker from the previous
     47 	// response, which is the ID of the first hosted zone that Amazon Route 53 will
     48 	// return if you submit another request. If the value of IsTruncated in the
     49 	// previous response was false, there are no more hosted zones to get.
     50 	Marker *string
     51 
     52 	// (Optional) The maximum number of hosted zones that you want Amazon Route 53 to
     53 	// return. If you have more than maxitems hosted zones, the value of IsTruncated in
     54 	// the response is true, and the value of NextMarker is the hosted zone ID of the
     55 	// first hosted zone that Route 53 will return if you submit another request.
     56 	MaxItems *int32
     57 
     58 	noSmithyDocumentSerde
     59 }
     60 
     61 type ListHostedZonesOutput struct {
     62 
     63 	// A complex type that contains general information about the hosted zone.
     64 	//
     65 	// This member is required.
     66 	HostedZones []types.HostedZone
     67 
     68 	// A flag indicating whether there are more hosted zones to be listed. If the
     69 	// response was truncated, you can get more hosted zones by submitting another
     70 	// ListHostedZones request and specifying the value of NextMarker in the marker
     71 	// parameter.
     72 	//
     73 	// This member is required.
     74 	IsTruncated bool
     75 
     76 	// For the second and subsequent calls to ListHostedZones, Marker is the value that
     77 	// you specified for the marker parameter in the request that produced the current
     78 	// response.
     79 	//
     80 	// This member is required.
     81 	Marker *string
     82 
     83 	// The value that you specified for the maxitems parameter in the call to
     84 	// ListHostedZones that produced the current response.
     85 	//
     86 	// This member is required.
     87 	MaxItems *int32
     88 
     89 	// If IsTruncated is true, the value of NextMarker identifies the first hosted zone
     90 	// in the next group of hosted zones. Submit another ListHostedZones request, and
     91 	// specify the value of NextMarker from the response in the marker parameter. This
     92 	// element is present only if IsTruncated is true.
     93 	NextMarker *string
     94 
     95 	// Metadata pertaining to the operation's result.
     96 	ResultMetadata middleware.Metadata
     97 
     98 	noSmithyDocumentSerde
     99 }
    100 
    101 func (c *Client) addOperationListHostedZonesMiddlewares(stack *middleware.Stack, options Options) (err error) {
    102 	err = stack.Serialize.Add(&awsRestxml_serializeOpListHostedZones{}, middleware.After)
    103 	if err != nil {
    104 		return err
    105 	}
    106 	err = stack.Deserialize.Add(&awsRestxml_deserializeOpListHostedZones{}, middleware.After)
    107 	if err != nil {
    108 		return err
    109 	}
    110 	if err = addSetLoggerMiddleware(stack, options); err != nil {
    111 		return err
    112 	}
    113 	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
    114 		return err
    115 	}
    116 	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
    117 		return err
    118 	}
    119 	if err = addResolveEndpointMiddleware(stack, options); err != nil {
    120 		return err
    121 	}
    122 	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
    123 		return err
    124 	}
    125 	if err = addRetryMiddlewares(stack, options); err != nil {
    126 		return err
    127 	}
    128 	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
    129 		return err
    130 	}
    131 	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
    132 		return err
    133 	}
    134 	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
    135 		return err
    136 	}
    137 	if err = addClientUserAgent(stack); err != nil {
    138 		return err
    139 	}
    140 	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
    141 		return err
    142 	}
    143 	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
    144 		return err
    145 	}
    146 	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListHostedZones(options.Region), middleware.Before); err != nil {
    147 		return err
    148 	}
    149 	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
    150 		return err
    151 	}
    152 	if err = addResponseErrorMiddleware(stack); err != nil {
    153 		return err
    154 	}
    155 	if err = addSanitizeURLMiddleware(stack); err != nil {
    156 		return err
    157 	}
    158 	if err = addRequestResponseLogging(stack, options); err != nil {
    159 		return err
    160 	}
    161 	return nil
    162 }
    163 
    164 // ListHostedZonesAPIClient is a client that implements the ListHostedZones
    165 // operation.
    166 type ListHostedZonesAPIClient interface {
    167 	ListHostedZones(context.Context, *ListHostedZonesInput, ...func(*Options)) (*ListHostedZonesOutput, error)
    168 }
    169 
    170 var _ ListHostedZonesAPIClient = (*Client)(nil)
    171 
    172 // ListHostedZonesPaginatorOptions is the paginator options for ListHostedZones
    173 type ListHostedZonesPaginatorOptions struct {
    174 	// (Optional) The maximum number of hosted zones that you want Amazon Route 53 to
    175 	// return. If you have more than maxitems hosted zones, the value of IsTruncated in
    176 	// the response is true, and the value of NextMarker is the hosted zone ID of the
    177 	// first hosted zone that Route 53 will return if you submit another request.
    178 	Limit int32
    179 
    180 	// Set to true if pagination should stop if the service returns a pagination token
    181 	// that matches the most recent token provided to the service.
    182 	StopOnDuplicateToken bool
    183 }
    184 
    185 // ListHostedZonesPaginator is a paginator for ListHostedZones
    186 type ListHostedZonesPaginator struct {
    187 	options   ListHostedZonesPaginatorOptions
    188 	client    ListHostedZonesAPIClient
    189 	params    *ListHostedZonesInput
    190 	nextToken *string
    191 	firstPage bool
    192 }
    193 
    194 // NewListHostedZonesPaginator returns a new ListHostedZonesPaginator
    195 func NewListHostedZonesPaginator(client ListHostedZonesAPIClient, params *ListHostedZonesInput, optFns ...func(*ListHostedZonesPaginatorOptions)) *ListHostedZonesPaginator {
    196 	if params == nil {
    197 		params = &ListHostedZonesInput{}
    198 	}
    199 
    200 	options := ListHostedZonesPaginatorOptions{}
    201 	if params.MaxItems != nil {
    202 		options.Limit = *params.MaxItems
    203 	}
    204 
    205 	for _, fn := range optFns {
    206 		fn(&options)
    207 	}
    208 
    209 	return &ListHostedZonesPaginator{
    210 		options:   options,
    211 		client:    client,
    212 		params:    params,
    213 		firstPage: true,
    214 		nextToken: params.Marker,
    215 	}
    216 }
    217 
    218 // HasMorePages returns a boolean indicating whether more pages are available
    219 func (p *ListHostedZonesPaginator) HasMorePages() bool {
    220 	return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
    221 }
    222 
    223 // NextPage retrieves the next ListHostedZones page.
    224 func (p *ListHostedZonesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListHostedZonesOutput, error) {
    225 	if !p.HasMorePages() {
    226 		return nil, fmt.Errorf("no more pages available")
    227 	}
    228 
    229 	params := *p.params
    230 	params.Marker = p.nextToken
    231 
    232 	var limit *int32
    233 	if p.options.Limit > 0 {
    234 		limit = &p.options.Limit
    235 	}
    236 	params.MaxItems = limit
    237 
    238 	result, err := p.client.ListHostedZones(ctx, &params, optFns...)
    239 	if err != nil {
    240 		return nil, err
    241 	}
    242 	p.firstPage = false
    243 
    244 	prevToken := p.nextToken
    245 	p.nextToken = result.NextMarker
    246 
    247 	if p.options.StopOnDuplicateToken &&
    248 		prevToken != nil &&
    249 		p.nextToken != nil &&
    250 		*prevToken == *p.nextToken {
    251 		p.nextToken = nil
    252 	}
    253 
    254 	return result, nil
    255 }
    256 
    257 func newServiceMetadataMiddleware_opListHostedZones(region string) *awsmiddleware.RegisterServiceMetadata {
    258 	return &awsmiddleware.RegisterServiceMetadata{
    259 		Region:        region,
    260 		ServiceID:     ServiceID,
    261 		SigningName:   "route53",
    262 		OperationName: "ListHostedZones",
    263 	}
    264 }