src

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

api_op_ListCidrLocations.go (6945B)


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