code.dwrz.net

Go monorepo.
Log | Files | Refs

api_op_ListCidrLocations.go (6595B)


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