1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package apigateway 4 5import ( 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/apigateway/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Represents a collection of BasePathMapping resources. 16func (c *Client) GetBasePathMappings(ctx context.Context, params *GetBasePathMappingsInput, optFns ...func(*Options)) (*GetBasePathMappingsOutput, error) { 17 if params == nil { 18 params = &GetBasePathMappingsInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "GetBasePathMappings", params, optFns, c.addOperationGetBasePathMappingsMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*GetBasePathMappingsOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31// A request to get information about a collection of BasePathMapping resources. 32type GetBasePathMappingsInput struct { 33 34 // [Required] The domain name of a BasePathMapping resource. 35 // 36 // This member is required. 37 DomainName *string 38 39 // The maximum number of returned results per page. The default value is 25 and the 40 // maximum value is 500. 41 Limit *int32 42 43 // The current pagination position in the paged result set. 44 Position *string 45 46 noSmithyDocumentSerde 47} 48 49// Represents a collection of BasePathMapping resources. Use Custom Domain Names 50// (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html) 51type GetBasePathMappingsOutput struct { 52 53 // The current page of elements from this collection. 54 Items []types.BasePathMapping 55 56 // The current pagination position in the paged result set. 57 Position *string 58 59 // Metadata pertaining to the operation's result. 60 ResultMetadata middleware.Metadata 61 62 noSmithyDocumentSerde 63} 64 65func (c *Client) addOperationGetBasePathMappingsMiddlewares(stack *middleware.Stack, options Options) (err error) { 66 err = stack.Serialize.Add(&awsRestjson1_serializeOpGetBasePathMappings{}, middleware.After) 67 if err != nil { 68 return err 69 } 70 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpGetBasePathMappings{}, middleware.After) 71 if err != nil { 72 return err 73 } 74 if err = addSetLoggerMiddleware(stack, options); err != nil { 75 return err 76 } 77 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 78 return err 79 } 80 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 81 return err 82 } 83 if err = addResolveEndpointMiddleware(stack, options); err != nil { 84 return err 85 } 86 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 87 return err 88 } 89 if err = addRetryMiddlewares(stack, options); err != nil { 90 return err 91 } 92 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 93 return err 94 } 95 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 96 return err 97 } 98 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 99 return err 100 } 101 if err = addClientUserAgent(stack); err != nil { 102 return err 103 } 104 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 105 return err 106 } 107 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 108 return err 109 } 110 if err = addOpGetBasePathMappingsValidationMiddleware(stack); err != nil { 111 return err 112 } 113 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetBasePathMappings(options.Region), middleware.Before); err != nil { 114 return err 115 } 116 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 117 return err 118 } 119 if err = addResponseErrorMiddleware(stack); err != nil { 120 return err 121 } 122 if err = addAcceptHeader(stack); err != nil { 123 return err 124 } 125 if err = addRequestResponseLogging(stack, options); err != nil { 126 return err 127 } 128 return nil 129} 130 131// GetBasePathMappingsAPIClient is a client that implements the GetBasePathMappings 132// operation. 133type GetBasePathMappingsAPIClient interface { 134 GetBasePathMappings(context.Context, *GetBasePathMappingsInput, ...func(*Options)) (*GetBasePathMappingsOutput, error) 135} 136 137var _ GetBasePathMappingsAPIClient = (*Client)(nil) 138 139// GetBasePathMappingsPaginatorOptions is the paginator options for 140// GetBasePathMappings 141type GetBasePathMappingsPaginatorOptions struct { 142 // The maximum number of returned results per page. The default value is 25 and the 143 // maximum value is 500. 144 Limit int32 145 146 // Set to true if pagination should stop if the service returns a pagination token 147 // that matches the most recent token provided to the service. 148 StopOnDuplicateToken bool 149} 150 151// GetBasePathMappingsPaginator is a paginator for GetBasePathMappings 152type GetBasePathMappingsPaginator struct { 153 options GetBasePathMappingsPaginatorOptions 154 client GetBasePathMappingsAPIClient 155 params *GetBasePathMappingsInput 156 nextToken *string 157 firstPage bool 158} 159 160// NewGetBasePathMappingsPaginator returns a new GetBasePathMappingsPaginator 161func NewGetBasePathMappingsPaginator(client GetBasePathMappingsAPIClient, params *GetBasePathMappingsInput, optFns ...func(*GetBasePathMappingsPaginatorOptions)) *GetBasePathMappingsPaginator { 162 if params == nil { 163 params = &GetBasePathMappingsInput{} 164 } 165 166 options := GetBasePathMappingsPaginatorOptions{} 167 if params.Limit != nil { 168 options.Limit = *params.Limit 169 } 170 171 for _, fn := range optFns { 172 fn(&options) 173 } 174 175 return &GetBasePathMappingsPaginator{ 176 options: options, 177 client: client, 178 params: params, 179 firstPage: true, 180 } 181} 182 183// HasMorePages returns a boolean indicating whether more pages are available 184func (p *GetBasePathMappingsPaginator) HasMorePages() bool { 185 return p.firstPage || p.nextToken != nil 186} 187 188// NextPage retrieves the next GetBasePathMappings page. 189func (p *GetBasePathMappingsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetBasePathMappingsOutput, error) { 190 if !p.HasMorePages() { 191 return nil, fmt.Errorf("no more pages available") 192 } 193 194 params := *p.params 195 params.Position = p.nextToken 196 197 var limit *int32 198 if p.options.Limit > 0 { 199 limit = &p.options.Limit 200 } 201 params.Limit = limit 202 203 result, err := p.client.GetBasePathMappings(ctx, ¶ms, optFns...) 204 if err != nil { 205 return nil, err 206 } 207 p.firstPage = false 208 209 prevToken := p.nextToken 210 p.nextToken = result.Position 211 212 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 213 p.nextToken = nil 214 } 215 216 return result, nil 217} 218 219func newServiceMetadataMiddleware_opGetBasePathMappings(region string) *awsmiddleware.RegisterServiceMetadata { 220 return &awsmiddleware.RegisterServiceMetadata{ 221 Region: region, 222 ServiceID: ServiceID, 223 SigningName: "apigateway", 224 OperationName: "GetBasePathMappings", 225 } 226} 227