src

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

api_op_ListCidrBlocks.go (6677B)


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