src

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

api_op_ListCidrLocations.go (5621B)


      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 // Returns a paginated list of CIDR locations for the given collection (metadata
     14 // only, does not include CIDR blocks).
     15 func (c *Client) ListCidrLocations(ctx context.Context, params *ListCidrLocationsInput, optFns ...func(*Options)) (*ListCidrLocationsOutput, error) {
     16 	if params == nil {
     17 		params = &ListCidrLocationsInput{}
     18 	}
     19 
     20 	result, metadata, err := c.invokeOperation(ctx, "ListCidrLocations", params, optFns, c.addOperationListCidrLocationsMiddlewares)
     21 	if err != nil {
     22 		return nil, err
     23 	}
     24 
     25 	out := result.(*ListCidrLocationsOutput)
     26 	out.ResultMetadata = metadata
     27 	return out, nil
     28 }
     29 
     30 type ListCidrLocationsInput struct {
     31 
     32 	// The CIDR collection ID.
     33 	//
     34 	// This member is required.
     35 	CollectionId *string
     36 
     37 	// The maximum number of CIDR collection locations to return in the response.
     38 	MaxResults *int32
     39 
     40 	// An opaque pagination token to indicate where the service is to begin
     41 	// enumerating results.
     42 	//
     43 	// If no value is provided, the listing of results starts from the beginning.
     44 	NextToken *string
     45 
     46 	noSmithyDocumentSerde
     47 }
     48 
     49 type ListCidrLocationsOutput struct {
     50 
     51 	// A complex type that contains information about the list of CIDR locations.
     52 	CidrLocations []types.LocationSummary
     53 
     54 	// An opaque pagination token to indicate where the service is to begin
     55 	// enumerating results.
     56 	//
     57 	// If no value is provided, the listing of results starts from the beginning.
     58 	NextToken *string
     59 
     60 	// Metadata pertaining to the operation's result.
     61 	ResultMetadata middleware.Metadata
     62 
     63 	noSmithyDocumentSerde
     64 }
     65 
     66 func (c *Client) addOperationListCidrLocationsMiddlewares(stack *middleware.Stack, options Options) (err error) {
     67 	err = stack.Serialize.Add(&awsRestxml_serializeOpListCidrLocations{}, middleware.After)
     68 	if err != nil {
     69 		return err
     70 	}
     71 	err = stack.Deserialize.Add(&awsRestxml_deserializeOpListCidrLocations{}, middleware.After)
     72 	if err != nil {
     73 		return err
     74 	}
     75 
     76 	if err = addComputeContentLength(stack); err != nil {
     77 		return err
     78 	}
     79 	if err = addResolveEndpointMiddleware(stack, options); err != nil {
     80 		return err
     81 	}
     82 	if err = addComputePayloadSHA256(stack); err != nil {
     83 		return err
     84 	}
     85 	if err = addRecordResponseTiming(stack, options); err != nil {
     86 		return err
     87 	}
     88 	if err = addCredentialSource(stack, options); err != nil {
     89 		return err
     90 	}
     91 	if err = addOpListCidrLocationsValidationMiddleware(stack); err != nil {
     92 		return err
     93 	}
     94 	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
     95 		return err
     96 	}
     97 	if err = addResponseErrorMiddleware(stack); err != nil {
     98 		return err
     99 	}
    100 	if err = addRequestResponseLogging(stack, options); err != nil {
    101 		return err
    102 	}
    103 	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
    104 		return err
    105 	}
    106 	if err = addInterceptors(stack, options); err != nil {
    107 		return err
    108 	}
    109 	return nil
    110 }
    111 
    112 // ListCidrLocationsPaginatorOptions is the paginator options for ListCidrLocations
    113 type ListCidrLocationsPaginatorOptions struct {
    114 	// The maximum number of CIDR collection locations to return in the response.
    115 	Limit int32
    116 
    117 	// Set to true if pagination should stop if the service returns a pagination token
    118 	// that matches the most recent token provided to the service.
    119 	StopOnDuplicateToken bool
    120 }
    121 
    122 // ListCidrLocationsPaginator is a paginator for ListCidrLocations
    123 type ListCidrLocationsPaginator struct {
    124 	options   ListCidrLocationsPaginatorOptions
    125 	client    ListCidrLocationsAPIClient
    126 	params    *ListCidrLocationsInput
    127 	nextToken *string
    128 	firstPage bool
    129 }
    130 
    131 // NewListCidrLocationsPaginator returns a new ListCidrLocationsPaginator
    132 func NewListCidrLocationsPaginator(client ListCidrLocationsAPIClient, params *ListCidrLocationsInput, optFns ...func(*ListCidrLocationsPaginatorOptions)) *ListCidrLocationsPaginator {
    133 	if params == nil {
    134 		params = &ListCidrLocationsInput{}
    135 	}
    136 
    137 	options := ListCidrLocationsPaginatorOptions{}
    138 	if params.MaxResults != nil {
    139 		options.Limit = *params.MaxResults
    140 	}
    141 
    142 	for _, fn := range optFns {
    143 		fn(&options)
    144 	}
    145 
    146 	return &ListCidrLocationsPaginator{
    147 		options:   options,
    148 		client:    client,
    149 		params:    params,
    150 		firstPage: true,
    151 		nextToken: params.NextToken,
    152 	}
    153 }
    154 
    155 // HasMorePages returns a boolean indicating whether more pages are available
    156 func (p *ListCidrLocationsPaginator) HasMorePages() bool {
    157 	return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
    158 }
    159 
    160 // NextPage retrieves the next ListCidrLocations page.
    161 func (p *ListCidrLocationsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListCidrLocationsOutput, error) {
    162 	if !p.HasMorePages() {
    163 		return nil, fmt.Errorf("no more pages available")
    164 	}
    165 
    166 	params := *p.params
    167 	params.NextToken = p.nextToken
    168 
    169 	var limit *int32
    170 	if p.options.Limit > 0 {
    171 		limit = &p.options.Limit
    172 	}
    173 	params.MaxResults = limit
    174 
    175 	optFns = append([]func(*Options){
    176 		addIsPaginatorUserAgent,
    177 	}, optFns...)
    178 	result, err := p.client.ListCidrLocations(ctx, &params, optFns...)
    179 	if err != nil {
    180 		return nil, err
    181 	}
    182 	p.firstPage = false
    183 
    184 	prevToken := p.nextToken
    185 	p.nextToken = result.NextToken
    186 
    187 	if p.options.StopOnDuplicateToken &&
    188 		prevToken != nil &&
    189 		p.nextToken != nil &&
    190 		*prevToken == *p.nextToken {
    191 		p.nextToken = nil
    192 	}
    193 
    194 	return result, nil
    195 }
    196 
    197 // ListCidrLocationsAPIClient is a client that implements the ListCidrLocations
    198 // operation.
    199 type ListCidrLocationsAPIClient interface {
    200 	ListCidrLocations(context.Context, *ListCidrLocationsInput, ...func(*Options)) (*ListCidrLocationsOutput, error)
    201 }
    202 
    203 var _ ListCidrLocationsAPIClient = (*Client)(nil)