src

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

api_op_ListCidrCollections.go (6820B)


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