1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package schemas 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/schemas/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Search the schemas 16func (c *Client) SearchSchemas(ctx context.Context, params *SearchSchemasInput, optFns ...func(*Options)) (*SearchSchemasOutput, error) { 17 if params == nil { 18 params = &SearchSchemasInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "SearchSchemas", params, optFns, c.addOperationSearchSchemasMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*SearchSchemasOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31type SearchSchemasInput struct { 32 33 // Specifying this limits the results to only schemas that include the provided 34 // keywords. 35 // 36 // This member is required. 37 Keywords *string 38 39 // The name of the registry. 40 // 41 // This member is required. 42 RegistryName *string 43 44 Limit int32 45 46 // The token that specifies the next page of results to return. To request the 47 // first page, leave NextToken empty. The token will expire in 24 hours, and cannot 48 // be shared with other accounts. 49 NextToken *string 50 51 noSmithyDocumentSerde 52} 53 54type SearchSchemasOutput struct { 55 56 // The token that specifies the next page of results to return. To request the 57 // first page, leave NextToken empty. The token will expire in 24 hours, and cannot 58 // be shared with other accounts. 59 NextToken *string 60 61 // An array of SearchSchemaSummary information. 62 Schemas []types.SearchSchemaSummary 63 64 // Metadata pertaining to the operation's result. 65 ResultMetadata middleware.Metadata 66 67 noSmithyDocumentSerde 68} 69 70func (c *Client) addOperationSearchSchemasMiddlewares(stack *middleware.Stack, options Options) (err error) { 71 err = stack.Serialize.Add(&awsRestjson1_serializeOpSearchSchemas{}, middleware.After) 72 if err != nil { 73 return err 74 } 75 err = stack.Deserialize.Add(&awsRestjson1_deserializeOpSearchSchemas{}, middleware.After) 76 if err != nil { 77 return err 78 } 79 if err = addSetLoggerMiddleware(stack, options); err != nil { 80 return err 81 } 82 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 83 return err 84 } 85 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 86 return err 87 } 88 if err = addResolveEndpointMiddleware(stack, options); err != nil { 89 return err 90 } 91 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 92 return err 93 } 94 if err = addRetryMiddlewares(stack, options); err != nil { 95 return err 96 } 97 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 98 return err 99 } 100 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 101 return err 102 } 103 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 104 return err 105 } 106 if err = addClientUserAgent(stack); err != nil { 107 return err 108 } 109 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 110 return err 111 } 112 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 113 return err 114 } 115 if err = addOpSearchSchemasValidationMiddleware(stack); err != nil { 116 return err 117 } 118 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opSearchSchemas(options.Region), middleware.Before); err != nil { 119 return err 120 } 121 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 122 return err 123 } 124 if err = addResponseErrorMiddleware(stack); err != nil { 125 return err 126 } 127 if err = addRequestResponseLogging(stack, options); err != nil { 128 return err 129 } 130 return nil 131} 132 133// SearchSchemasAPIClient is a client that implements the SearchSchemas operation. 134type SearchSchemasAPIClient interface { 135 SearchSchemas(context.Context, *SearchSchemasInput, ...func(*Options)) (*SearchSchemasOutput, error) 136} 137 138var _ SearchSchemasAPIClient = (*Client)(nil) 139 140// SearchSchemasPaginatorOptions is the paginator options for SearchSchemas 141type SearchSchemasPaginatorOptions struct { 142 Limit int32 143 144 // Set to true if pagination should stop if the service returns a pagination token 145 // that matches the most recent token provided to the service. 146 StopOnDuplicateToken bool 147} 148 149// SearchSchemasPaginator is a paginator for SearchSchemas 150type SearchSchemasPaginator struct { 151 options SearchSchemasPaginatorOptions 152 client SearchSchemasAPIClient 153 params *SearchSchemasInput 154 nextToken *string 155 firstPage bool 156} 157 158// NewSearchSchemasPaginator returns a new SearchSchemasPaginator 159func NewSearchSchemasPaginator(client SearchSchemasAPIClient, params *SearchSchemasInput, optFns ...func(*SearchSchemasPaginatorOptions)) *SearchSchemasPaginator { 160 if params == nil { 161 params = &SearchSchemasInput{} 162 } 163 164 options := SearchSchemasPaginatorOptions{} 165 if params.Limit != 0 { 166 options.Limit = params.Limit 167 } 168 169 for _, fn := range optFns { 170 fn(&options) 171 } 172 173 return &SearchSchemasPaginator{ 174 options: options, 175 client: client, 176 params: params, 177 firstPage: true, 178 } 179} 180 181// HasMorePages returns a boolean indicating whether more pages are available 182func (p *SearchSchemasPaginator) HasMorePages() bool { 183 return p.firstPage || p.nextToken != nil 184} 185 186// NextPage retrieves the next SearchSchemas page. 187func (p *SearchSchemasPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*SearchSchemasOutput, error) { 188 if !p.HasMorePages() { 189 return nil, fmt.Errorf("no more pages available") 190 } 191 192 params := *p.params 193 params.NextToken = p.nextToken 194 195 params.Limit = p.options.Limit 196 197 result, err := p.client.SearchSchemas(ctx, ¶ms, optFns...) 198 if err != nil { 199 return nil, err 200 } 201 p.firstPage = false 202 203 prevToken := p.nextToken 204 p.nextToken = result.NextToken 205 206 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 207 p.nextToken = nil 208 } 209 210 return result, nil 211} 212 213func newServiceMetadataMiddleware_opSearchSchemas(region string) *awsmiddleware.RegisterServiceMetadata { 214 return &awsmiddleware.RegisterServiceMetadata{ 215 Region: region, 216 ServiceID: ServiceID, 217 SigningName: "schemas", 218 OperationName: "SearchSchemas", 219 } 220} 221