src

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

api_op_ListCidrBlocks.go (5361B)


      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 location objects and their CIDR blocks.
     14 func (c *Client) ListCidrBlocks(ctx context.Context, params *ListCidrBlocksInput, optFns ...func(*Options)) (*ListCidrBlocksOutput, error) {
     15 	if params == nil {
     16 		params = &ListCidrBlocksInput{}
     17 	}
     18 
     19 	result, metadata, err := c.invokeOperation(ctx, "ListCidrBlocks", params, optFns, c.addOperationListCidrBlocksMiddlewares)
     20 	if err != nil {
     21 		return nil, err
     22 	}
     23 
     24 	out := result.(*ListCidrBlocksOutput)
     25 	out.ResultMetadata = metadata
     26 	return out, nil
     27 }
     28 
     29 type ListCidrBlocksInput struct {
     30 
     31 	// The UUID of the CIDR collection.
     32 	//
     33 	// This member is required.
     34 	CollectionId *string
     35 
     36 	// The name of the CIDR collection location.
     37 	LocationName *string
     38 
     39 	// Maximum number of results you want returned.
     40 	MaxResults *int32
     41 
     42 	// An opaque pagination token to indicate where the service is to begin
     43 	// enumerating results.
     44 	NextToken *string
     45 
     46 	noSmithyDocumentSerde
     47 }
     48 
     49 type ListCidrBlocksOutput struct {
     50 
     51 	// A complex type that contains information about the CIDR blocks.
     52 	CidrBlocks []types.CidrBlockSummary
     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) addOperationListCidrBlocksMiddlewares(stack *middleware.Stack, options Options) (err error) {
     67 	err = stack.Serialize.Add(&awsRestxml_serializeOpListCidrBlocks{}, middleware.After)
     68 	if err != nil {
     69 		return err
     70 	}
     71 	err = stack.Deserialize.Add(&awsRestxml_deserializeOpListCidrBlocks{}, 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 = addOpListCidrBlocksValidationMiddleware(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 // ListCidrBlocksPaginatorOptions is the paginator options for ListCidrBlocks
    113 type ListCidrBlocksPaginatorOptions struct {
    114 	// Maximum number of results you want returned.
    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 // ListCidrBlocksPaginator is a paginator for ListCidrBlocks
    123 type ListCidrBlocksPaginator struct {
    124 	options   ListCidrBlocksPaginatorOptions
    125 	client    ListCidrBlocksAPIClient
    126 	params    *ListCidrBlocksInput
    127 	nextToken *string
    128 	firstPage bool
    129 }
    130 
    131 // NewListCidrBlocksPaginator returns a new ListCidrBlocksPaginator
    132 func NewListCidrBlocksPaginator(client ListCidrBlocksAPIClient, params *ListCidrBlocksInput, optFns ...func(*ListCidrBlocksPaginatorOptions)) *ListCidrBlocksPaginator {
    133 	if params == nil {
    134 		params = &ListCidrBlocksInput{}
    135 	}
    136 
    137 	options := ListCidrBlocksPaginatorOptions{}
    138 	if params.MaxResults != nil {
    139 		options.Limit = *params.MaxResults
    140 	}
    141 
    142 	for _, fn := range optFns {
    143 		fn(&options)
    144 	}
    145 
    146 	return &ListCidrBlocksPaginator{
    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 *ListCidrBlocksPaginator) HasMorePages() bool {
    157 	return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
    158 }
    159 
    160 // NextPage retrieves the next ListCidrBlocks page.
    161 func (p *ListCidrBlocksPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListCidrBlocksOutput, 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.ListCidrBlocks(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 // ListCidrBlocksAPIClient is a client that implements the ListCidrBlocks
    198 // operation.
    199 type ListCidrBlocksAPIClient interface {
    200 	ListCidrBlocks(context.Context, *ListCidrBlocksInput, ...func(*Options)) (*ListCidrBlocksOutput, error)
    201 }
    202 
    203 var _ ListCidrBlocksAPIClient = (*Client)(nil)