code.dwrz.net

Go monorepo.
Log | Files | Refs

api_op_ListCidrCollections.go (6468B)


      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 // Returns a paginated list of CIDR collections in the Amazon Web Services account
     16 // (metadata only).
     17 func (c *Client) ListCidrCollections(ctx context.Context, params *ListCidrCollectionsInput, optFns ...func(*Options)) (*ListCidrCollectionsOutput, error) {
     18 	if params == nil {
     19 		params = &ListCidrCollectionsInput{}
     20 	}
     21 
     22 	result, metadata, err := c.invokeOperation(ctx, "ListCidrCollections", params, optFns, c.addOperationListCidrCollectionsMiddlewares)
     23 	if err != nil {
     24 		return nil, err
     25 	}
     26 
     27 	out := result.(*ListCidrCollectionsOutput)
     28 	out.ResultMetadata = metadata
     29 	return out, nil
     30 }
     31 
     32 type ListCidrCollectionsInput struct {
     33 
     34 	// The maximum number of CIDR collections to return in the response.
     35 	MaxResults *int32
     36 
     37 	// An opaque pagination token to indicate where the service is to begin enumerating
     38 	// results. If no value is provided, the listing of results starts from the
     39 	// beginning.
     40 	NextToken *string
     41 
     42 	noSmithyDocumentSerde
     43 }
     44 
     45 type ListCidrCollectionsOutput struct {
     46 
     47 	// A complex type with information about the CIDR collection.
     48 	CidrCollections []types.CollectionSummary
     49 
     50 	// An opaque pagination token to indicate where the service is to begin enumerating
     51 	// results. If no value is provided, the listing of results starts from the
     52 	// beginning.
     53 	NextToken *string
     54 
     55 	// Metadata pertaining to the operation's result.
     56 	ResultMetadata middleware.Metadata
     57 
     58 	noSmithyDocumentSerde
     59 }
     60 
     61 func (c *Client) addOperationListCidrCollectionsMiddlewares(stack *middleware.Stack, options Options) (err error) {
     62 	err = stack.Serialize.Add(&awsRestxml_serializeOpListCidrCollections{}, middleware.After)
     63 	if err != nil {
     64 		return err
     65 	}
     66 	err = stack.Deserialize.Add(&awsRestxml_deserializeOpListCidrCollections{}, middleware.After)
     67 	if err != nil {
     68 		return err
     69 	}
     70 	if err = addSetLoggerMiddleware(stack, options); err != nil {
     71 		return err
     72 	}
     73 	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
     74 		return err
     75 	}
     76 	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
     77 		return err
     78 	}
     79 	if err = addResolveEndpointMiddleware(stack, options); err != nil {
     80 		return err
     81 	}
     82 	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
     83 		return err
     84 	}
     85 	if err = addRetryMiddlewares(stack, options); err != nil {
     86 		return err
     87 	}
     88 	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
     89 		return err
     90 	}
     91 	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
     92 		return err
     93 	}
     94 	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
     95 		return err
     96 	}
     97 	if err = addClientUserAgent(stack); err != nil {
     98 		return err
     99 	}
    100 	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
    101 		return err
    102 	}
    103 	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
    104 		return err
    105 	}
    106 	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListCidrCollections(options.Region), middleware.Before); err != nil {
    107 		return err
    108 	}
    109 	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
    110 		return err
    111 	}
    112 	if err = addResponseErrorMiddleware(stack); err != nil {
    113 		return err
    114 	}
    115 	if err = addRequestResponseLogging(stack, options); err != nil {
    116 		return err
    117 	}
    118 	return nil
    119 }
    120 
    121 // ListCidrCollectionsAPIClient is a client that implements the ListCidrCollections
    122 // operation.
    123 type ListCidrCollectionsAPIClient interface {
    124 	ListCidrCollections(context.Context, *ListCidrCollectionsInput, ...func(*Options)) (*ListCidrCollectionsOutput, error)
    125 }
    126 
    127 var _ ListCidrCollectionsAPIClient = (*Client)(nil)
    128 
    129 // ListCidrCollectionsPaginatorOptions is the paginator options for
    130 // ListCidrCollections
    131 type ListCidrCollectionsPaginatorOptions struct {
    132 	// The maximum number of CIDR collections to return in the response.
    133 	Limit int32
    134 
    135 	// Set to true if pagination should stop if the service returns a pagination token
    136 	// that matches the most recent token provided to the service.
    137 	StopOnDuplicateToken bool
    138 }
    139 
    140 // ListCidrCollectionsPaginator is a paginator for ListCidrCollections
    141 type ListCidrCollectionsPaginator struct {
    142 	options   ListCidrCollectionsPaginatorOptions
    143 	client    ListCidrCollectionsAPIClient
    144 	params    *ListCidrCollectionsInput
    145 	nextToken *string
    146 	firstPage bool
    147 }
    148 
    149 // NewListCidrCollectionsPaginator returns a new ListCidrCollectionsPaginator
    150 func NewListCidrCollectionsPaginator(client ListCidrCollectionsAPIClient, params *ListCidrCollectionsInput, optFns ...func(*ListCidrCollectionsPaginatorOptions)) *ListCidrCollectionsPaginator {
    151 	if params == nil {
    152 		params = &ListCidrCollectionsInput{}
    153 	}
    154 
    155 	options := ListCidrCollectionsPaginatorOptions{}
    156 	if params.MaxResults != nil {
    157 		options.Limit = *params.MaxResults
    158 	}
    159 
    160 	for _, fn := range optFns {
    161 		fn(&options)
    162 	}
    163 
    164 	return &ListCidrCollectionsPaginator{
    165 		options:   options,
    166 		client:    client,
    167 		params:    params,
    168 		firstPage: true,
    169 		nextToken: params.NextToken,
    170 	}
    171 }
    172 
    173 // HasMorePages returns a boolean indicating whether more pages are available
    174 func (p *ListCidrCollectionsPaginator) HasMorePages() bool {
    175 	return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
    176 }
    177 
    178 // NextPage retrieves the next ListCidrCollections page.
    179 func (p *ListCidrCollectionsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListCidrCollectionsOutput, error) {
    180 	if !p.HasMorePages() {
    181 		return nil, fmt.Errorf("no more pages available")
    182 	}
    183 
    184 	params := *p.params
    185 	params.NextToken = p.nextToken
    186 
    187 	var limit *int32
    188 	if p.options.Limit > 0 {
    189 		limit = &p.options.Limit
    190 	}
    191 	params.MaxResults = limit
    192 
    193 	result, err := p.client.ListCidrCollections(ctx, &params, optFns...)
    194 	if err != nil {
    195 		return nil, err
    196 	}
    197 	p.firstPage = false
    198 
    199 	prevToken := p.nextToken
    200 	p.nextToken = result.NextToken
    201 
    202 	if p.options.StopOnDuplicateToken &&
    203 		prevToken != nil &&
    204 		p.nextToken != nil &&
    205 		*prevToken == *p.nextToken {
    206 		p.nextToken = nil
    207 	}
    208 
    209 	return result, nil
    210 }
    211 
    212 func newServiceMetadataMiddleware_opListCidrCollections(region string) *awsmiddleware.RegisterServiceMetadata {
    213 	return &awsmiddleware.RegisterServiceMetadata{
    214 		Region:        region,
    215 		ServiceID:     ServiceID,
    216 		SigningName:   "route53",
    217 		OperationName: "ListCidrCollections",
    218 	}
    219 }