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