src

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

api_op_ListHostedZones.go (9131B)


      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. Amazon Route 53 returns a
     17 // maximum of 100 items in each response. If you have a lot of hosted zones, you
     18 // can use the maxitems parameter to list them in groups of up to 100.
     19 func (c *Client) ListHostedZones(ctx context.Context, params *ListHostedZonesInput, optFns ...func(*Options)) (*ListHostedZonesOutput, error) {
     20 	if params == nil {
     21 		params = &ListHostedZonesInput{}
     22 	}
     23 
     24 	result, metadata, err := c.invokeOperation(ctx, "ListHostedZones", params, optFns, c.addOperationListHostedZonesMiddlewares)
     25 	if err != nil {
     26 		return nil, err
     27 	}
     28 
     29 	out := result.(*ListHostedZonesOutput)
     30 	out.ResultMetadata = metadata
     31 	return out, nil
     32 }
     33 
     34 // A request to retrieve a list of the public and private hosted zones that are
     35 // associated with the current Amazon Web Services account.
     36 type ListHostedZonesInput struct {
     37 
     38 	// If you're using reusable delegation sets and you want to list all of the hosted
     39 	// zones that are associated with a reusable delegation set, specify the ID of that
     40 	// reusable delegation set.
     41 	DelegationSetId *string
     42 
     43 	// (Optional) Specifies if the hosted zone is private.
     44 	HostedZoneType types.HostedZoneType
     45 
     46 	// If the value of IsTruncated in the previous response was true , you have more
     47 	// hosted zones. To get more hosted zones, submit another ListHostedZones request.
     48 	// For the value of marker , specify the value of NextMarker from the previous
     49 	// response, which is the ID of the first hosted zone that Amazon Route 53 will
     50 	// return if you submit another request. If the value of IsTruncated in the
     51 	// previous response was false , there are no more hosted zones to get.
     52 	Marker *string
     53 
     54 	// (Optional) The maximum number of hosted zones that you want Amazon Route 53 to
     55 	// return. If you have more than maxitems hosted zones, the value of IsTruncated
     56 	// in the response is true , and the value of NextMarker is the hosted zone ID of
     57 	// the first hosted zone that Route 53 will return if you submit another request.
     58 	MaxItems *int32
     59 
     60 	noSmithyDocumentSerde
     61 }
     62 
     63 type ListHostedZonesOutput struct {
     64 
     65 	// A complex type that contains general information about the hosted zone.
     66 	//
     67 	// This member is required.
     68 	HostedZones []types.HostedZone
     69 
     70 	// A flag indicating whether there are more hosted zones to be listed. If the
     71 	// response was truncated, you can get more hosted zones by submitting another
     72 	// ListHostedZones request and specifying the value of NextMarker in the marker
     73 	// parameter.
     74 	//
     75 	// This member is required.
     76 	IsTruncated bool
     77 
     78 	// For the second and subsequent calls to ListHostedZones , Marker is the value
     79 	// that you specified for the marker parameter in the request that produced the
     80 	// current response.
     81 	//
     82 	// This member is required.
     83 	Marker *string
     84 
     85 	// The value that you specified for the maxitems parameter in the call to
     86 	// ListHostedZones that produced the current response.
     87 	//
     88 	// This member is required.
     89 	MaxItems *int32
     90 
     91 	// If IsTruncated is true , the value of NextMarker identifies the first hosted
     92 	// zone in the next group of hosted zones. Submit another ListHostedZones request,
     93 	// and specify the value of NextMarker from the response in the marker parameter.
     94 	// This element is present only if IsTruncated is true .
     95 	NextMarker *string
     96 
     97 	// Metadata pertaining to the operation's result.
     98 	ResultMetadata middleware.Metadata
     99 
    100 	noSmithyDocumentSerde
    101 }
    102 
    103 func (c *Client) addOperationListHostedZonesMiddlewares(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_serializeOpListHostedZones{}, middleware.After)
    108 	if err != nil {
    109 		return err
    110 	}
    111 	err = stack.Deserialize.Add(&awsRestxml_deserializeOpListHostedZones{}, middleware.After)
    112 	if err != nil {
    113 		return err
    114 	}
    115 	if err := addProtocolFinalizerMiddlewares(stack, options, "ListHostedZones"); 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 = addClientUserAgent(stack, options); err != nil {
    147 		return err
    148 	}
    149 	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
    150 		return err
    151 	}
    152 	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
    153 		return err
    154 	}
    155 	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
    156 		return err
    157 	}
    158 	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListHostedZones(options.Region), middleware.Before); err != nil {
    159 		return err
    160 	}
    161 	if err = addRecursionDetection(stack); err != nil {
    162 		return err
    163 	}
    164 	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
    165 		return err
    166 	}
    167 	if err = addResponseErrorMiddleware(stack); err != nil {
    168 		return err
    169 	}
    170 	if err = addSanitizeURLMiddleware(stack); err != nil {
    171 		return err
    172 	}
    173 	if err = addRequestResponseLogging(stack, options); err != nil {
    174 		return err
    175 	}
    176 	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
    177 		return err
    178 	}
    179 	return nil
    180 }
    181 
    182 // ListHostedZonesAPIClient is a client that implements the ListHostedZones
    183 // operation.
    184 type ListHostedZonesAPIClient interface {
    185 	ListHostedZones(context.Context, *ListHostedZonesInput, ...func(*Options)) (*ListHostedZonesOutput, error)
    186 }
    187 
    188 var _ ListHostedZonesAPIClient = (*Client)(nil)
    189 
    190 // ListHostedZonesPaginatorOptions is the paginator options for ListHostedZones
    191 type ListHostedZonesPaginatorOptions struct {
    192 	// (Optional) The maximum number of hosted zones that you want Amazon Route 53 to
    193 	// return. If you have more than maxitems hosted zones, the value of IsTruncated
    194 	// in the response is true , and the value of NextMarker is the hosted zone ID of
    195 	// the first hosted zone that Route 53 will return if you submit another request.
    196 	Limit int32
    197 
    198 	// Set to true if pagination should stop if the service returns a pagination token
    199 	// that matches the most recent token provided to the service.
    200 	StopOnDuplicateToken bool
    201 }
    202 
    203 // ListHostedZonesPaginator is a paginator for ListHostedZones
    204 type ListHostedZonesPaginator struct {
    205 	options   ListHostedZonesPaginatorOptions
    206 	client    ListHostedZonesAPIClient
    207 	params    *ListHostedZonesInput
    208 	nextToken *string
    209 	firstPage bool
    210 }
    211 
    212 // NewListHostedZonesPaginator returns a new ListHostedZonesPaginator
    213 func NewListHostedZonesPaginator(client ListHostedZonesAPIClient, params *ListHostedZonesInput, optFns ...func(*ListHostedZonesPaginatorOptions)) *ListHostedZonesPaginator {
    214 	if params == nil {
    215 		params = &ListHostedZonesInput{}
    216 	}
    217 
    218 	options := ListHostedZonesPaginatorOptions{}
    219 	if params.MaxItems != nil {
    220 		options.Limit = *params.MaxItems
    221 	}
    222 
    223 	for _, fn := range optFns {
    224 		fn(&options)
    225 	}
    226 
    227 	return &ListHostedZonesPaginator{
    228 		options:   options,
    229 		client:    client,
    230 		params:    params,
    231 		firstPage: true,
    232 		nextToken: params.Marker,
    233 	}
    234 }
    235 
    236 // HasMorePages returns a boolean indicating whether more pages are available
    237 func (p *ListHostedZonesPaginator) HasMorePages() bool {
    238 	return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
    239 }
    240 
    241 // NextPage retrieves the next ListHostedZones page.
    242 func (p *ListHostedZonesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListHostedZonesOutput, error) {
    243 	if !p.HasMorePages() {
    244 		return nil, fmt.Errorf("no more pages available")
    245 	}
    246 
    247 	params := *p.params
    248 	params.Marker = p.nextToken
    249 
    250 	var limit *int32
    251 	if p.options.Limit > 0 {
    252 		limit = &p.options.Limit
    253 	}
    254 	params.MaxItems = limit
    255 
    256 	result, err := p.client.ListHostedZones(ctx, &params, optFns...)
    257 	if err != nil {
    258 		return nil, err
    259 	}
    260 	p.firstPage = false
    261 
    262 	prevToken := p.nextToken
    263 	p.nextToken = result.NextMarker
    264 
    265 	if p.options.StopOnDuplicateToken &&
    266 		prevToken != nil &&
    267 		p.nextToken != nil &&
    268 		*prevToken == *p.nextToken {
    269 		p.nextToken = nil
    270 	}
    271 
    272 	return result, nil
    273 }
    274 
    275 func newServiceMetadataMiddleware_opListHostedZones(region string) *awsmiddleware.RegisterServiceMetadata {
    276 	return &awsmiddleware.RegisterServiceMetadata{
    277 		Region:        region,
    278 		ServiceID:     ServiceID,
    279 		OperationName: "ListHostedZones",
    280 	}
    281 }