src

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

api_op_ListCidrLocations.go (8438B)


      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.
     43 	//
     44 	// If no value is provided, the listing of results starts from the 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
     56 	// enumerating results.
     57 	//
     58 	// If no value is provided, the listing of results starts from the beginning.
     59 	NextToken *string
     60 
     61 	// Metadata pertaining to the operation's result.
     62 	ResultMetadata middleware.Metadata
     63 
     64 	noSmithyDocumentSerde
     65 }
     66 
     67 func (c *Client) addOperationListCidrLocationsMiddlewares(stack *middleware.Stack, options Options) (err error) {
     68 	if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
     69 		return err
     70 	}
     71 	err = stack.Serialize.Add(&awsRestxml_serializeOpListCidrLocations{}, middleware.After)
     72 	if err != nil {
     73 		return err
     74 	}
     75 	err = stack.Deserialize.Add(&awsRestxml_deserializeOpListCidrLocations{}, middleware.After)
     76 	if err != nil {
     77 		return err
     78 	}
     79 	if err := addProtocolFinalizerMiddlewares(stack, options, "ListCidrLocations"); err != nil {
     80 		return fmt.Errorf("add protocol finalizers: %v", err)
     81 	}
     82 
     83 	if err = addlegacyEndpointContextSetter(stack, options); err != nil {
     84 		return err
     85 	}
     86 	if err = addSetLoggerMiddleware(stack, options); err != nil {
     87 		return err
     88 	}
     89 	if err = addClientRequestID(stack); err != nil {
     90 		return err
     91 	}
     92 	if err = addComputeContentLength(stack); err != nil {
     93 		return err
     94 	}
     95 	if err = addResolveEndpointMiddleware(stack, options); err != nil {
     96 		return err
     97 	}
     98 	if err = addComputePayloadSHA256(stack); err != nil {
     99 		return err
    100 	}
    101 	if err = addRetry(stack, options); err != nil {
    102 		return err
    103 	}
    104 	if err = addRawResponseToMetadata(stack); err != nil {
    105 		return err
    106 	}
    107 	if err = addRecordResponseTiming(stack); err != nil {
    108 		return err
    109 	}
    110 	if err = addSpanRetryLoop(stack, options); err != nil {
    111 		return err
    112 	}
    113 	if err = addClientUserAgent(stack, options); err != nil {
    114 		return err
    115 	}
    116 	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
    117 		return err
    118 	}
    119 	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
    120 		return err
    121 	}
    122 	if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
    123 		return err
    124 	}
    125 	if err = addTimeOffsetBuild(stack, c); err != nil {
    126 		return err
    127 	}
    128 	if err = addUserAgentRetryMode(stack, options); err != nil {
    129 		return err
    130 	}
    131 	if err = addCredentialSource(stack, options); err != nil {
    132 		return err
    133 	}
    134 	if err = addOpListCidrLocationsValidationMiddleware(stack); err != nil {
    135 		return err
    136 	}
    137 	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListCidrLocations(options.Region), middleware.Before); err != nil {
    138 		return err
    139 	}
    140 	if err = addRecursionDetection(stack); err != nil {
    141 		return err
    142 	}
    143 	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
    144 		return err
    145 	}
    146 	if err = addResponseErrorMiddleware(stack); err != nil {
    147 		return err
    148 	}
    149 	if err = addRequestResponseLogging(stack, options); err != nil {
    150 		return err
    151 	}
    152 	if err = addDisableHTTPSMiddleware(stack, options); err != nil {
    153 		return err
    154 	}
    155 	if err = addInterceptBeforeRetryLoop(stack, options); err != nil {
    156 		return err
    157 	}
    158 	if err = addInterceptAttempt(stack, options); err != nil {
    159 		return err
    160 	}
    161 	if err = addInterceptExecution(stack, options); err != nil {
    162 		return err
    163 	}
    164 	if err = addInterceptBeforeSerialization(stack, options); err != nil {
    165 		return err
    166 	}
    167 	if err = addInterceptAfterSerialization(stack, options); err != nil {
    168 		return err
    169 	}
    170 	if err = addInterceptBeforeSigning(stack, options); err != nil {
    171 		return err
    172 	}
    173 	if err = addInterceptAfterSigning(stack, options); err != nil {
    174 		return err
    175 	}
    176 	if err = addInterceptTransmit(stack, options); err != nil {
    177 		return err
    178 	}
    179 	if err = addInterceptBeforeDeserialization(stack, options); err != nil {
    180 		return err
    181 	}
    182 	if err = addInterceptAfterDeserialization(stack, options); err != nil {
    183 		return err
    184 	}
    185 	if err = addSpanInitializeStart(stack); err != nil {
    186 		return err
    187 	}
    188 	if err = addSpanInitializeEnd(stack); err != nil {
    189 		return err
    190 	}
    191 	if err = addSpanBuildRequestStart(stack); err != nil {
    192 		return err
    193 	}
    194 	if err = addSpanBuildRequestEnd(stack); err != nil {
    195 		return err
    196 	}
    197 	return nil
    198 }
    199 
    200 // ListCidrLocationsPaginatorOptions is the paginator options for ListCidrLocations
    201 type ListCidrLocationsPaginatorOptions struct {
    202 	// The maximum number of CIDR collection locations to return in the response.
    203 	Limit int32
    204 
    205 	// Set to true if pagination should stop if the service returns a pagination token
    206 	// that matches the most recent token provided to the service.
    207 	StopOnDuplicateToken bool
    208 }
    209 
    210 // ListCidrLocationsPaginator is a paginator for ListCidrLocations
    211 type ListCidrLocationsPaginator struct {
    212 	options   ListCidrLocationsPaginatorOptions
    213 	client    ListCidrLocationsAPIClient
    214 	params    *ListCidrLocationsInput
    215 	nextToken *string
    216 	firstPage bool
    217 }
    218 
    219 // NewListCidrLocationsPaginator returns a new ListCidrLocationsPaginator
    220 func NewListCidrLocationsPaginator(client ListCidrLocationsAPIClient, params *ListCidrLocationsInput, optFns ...func(*ListCidrLocationsPaginatorOptions)) *ListCidrLocationsPaginator {
    221 	if params == nil {
    222 		params = &ListCidrLocationsInput{}
    223 	}
    224 
    225 	options := ListCidrLocationsPaginatorOptions{}
    226 	if params.MaxResults != nil {
    227 		options.Limit = *params.MaxResults
    228 	}
    229 
    230 	for _, fn := range optFns {
    231 		fn(&options)
    232 	}
    233 
    234 	return &ListCidrLocationsPaginator{
    235 		options:   options,
    236 		client:    client,
    237 		params:    params,
    238 		firstPage: true,
    239 		nextToken: params.NextToken,
    240 	}
    241 }
    242 
    243 // HasMorePages returns a boolean indicating whether more pages are available
    244 func (p *ListCidrLocationsPaginator) HasMorePages() bool {
    245 	return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
    246 }
    247 
    248 // NextPage retrieves the next ListCidrLocations page.
    249 func (p *ListCidrLocationsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListCidrLocationsOutput, error) {
    250 	if !p.HasMorePages() {
    251 		return nil, fmt.Errorf("no more pages available")
    252 	}
    253 
    254 	params := *p.params
    255 	params.NextToken = p.nextToken
    256 
    257 	var limit *int32
    258 	if p.options.Limit > 0 {
    259 		limit = &p.options.Limit
    260 	}
    261 	params.MaxResults = limit
    262 
    263 	optFns = append([]func(*Options){
    264 		addIsPaginatorUserAgent,
    265 	}, optFns...)
    266 	result, err := p.client.ListCidrLocations(ctx, &params, optFns...)
    267 	if err != nil {
    268 		return nil, err
    269 	}
    270 	p.firstPage = false
    271 
    272 	prevToken := p.nextToken
    273 	p.nextToken = result.NextToken
    274 
    275 	if p.options.StopOnDuplicateToken &&
    276 		prevToken != nil &&
    277 		p.nextToken != nil &&
    278 		*prevToken == *p.nextToken {
    279 		p.nextToken = nil
    280 	}
    281 
    282 	return result, nil
    283 }
    284 
    285 // ListCidrLocationsAPIClient is a client that implements the ListCidrLocations
    286 // operation.
    287 type ListCidrLocationsAPIClient interface {
    288 	ListCidrLocations(context.Context, *ListCidrLocationsInput, ...func(*Options)) (*ListCidrLocationsOutput, error)
    289 }
    290 
    291 var _ ListCidrLocationsAPIClient = (*Client)(nil)
    292 
    293 func newServiceMetadataMiddleware_opListCidrLocations(region string) *awsmiddleware.RegisterServiceMetadata {
    294 	return &awsmiddleware.RegisterServiceMetadata{
    295 		Region:        region,
    296 		ServiceID:     ServiceID,
    297 		OperationName: "ListCidrLocations",
    298 	}
    299 }