1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package ecr 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/ecr/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Describes image repositories in a registry. 16func (c *Client) DescribeRepositories(ctx context.Context, params *DescribeRepositoriesInput, optFns ...func(*Options)) (*DescribeRepositoriesOutput, error) { 17 if params == nil { 18 params = &DescribeRepositoriesInput{} 19 } 20 21 result, metadata, err := c.invokeOperation(ctx, "DescribeRepositories", params, optFns, addOperationDescribeRepositoriesMiddlewares) 22 if err != nil { 23 return nil, err 24 } 25 26 out := result.(*DescribeRepositoriesOutput) 27 out.ResultMetadata = metadata 28 return out, nil 29} 30 31type DescribeRepositoriesInput struct { 32 33 // The maximum number of repository results returned by DescribeRepositories in 34 // paginated output. When this parameter is used, DescribeRepositories only returns 35 // maxResults results in a single page along with a nextToken response element. The 36 // remaining results of the initial request can be seen by sending another 37 // DescribeRepositories request with the returned nextToken value. This value can 38 // be between 1 and 1000. If this parameter is not used, then DescribeRepositories 39 // returns up to 100 results and a nextToken value, if applicable. This option 40 // cannot be used when you specify repositories with repositoryNames. 41 MaxResults *int32 42 43 // The nextToken value returned from a previous paginated DescribeRepositories 44 // request where maxResults was used and the results exceeded the value of that 45 // parameter. Pagination continues from the end of the previous results that 46 // returned the nextToken value. This value is null when there are no more results 47 // to return. This option cannot be used when you specify repositories with 48 // repositoryNames. This token should be treated as an opaque identifier that is 49 // only used to retrieve the next items in a list and not for other programmatic 50 // purposes. 51 NextToken *string 52 53 // The AWS account ID associated with the registry that contains the repositories 54 // to be described. If you do not specify a registry, the default registry is 55 // assumed. 56 RegistryId *string 57 58 // A list of repositories to describe. If this parameter is omitted, then all 59 // repositories in a registry are described. 60 RepositoryNames []string 61} 62 63type DescribeRepositoriesOutput struct { 64 65 // The nextToken value to include in a future DescribeRepositories request. When 66 // the results of a DescribeRepositories request exceed maxResults, this value can 67 // be used to retrieve the next page of results. This value is null when there are 68 // no more results to return. 69 NextToken *string 70 71 // A list of repository objects corresponding to valid repositories. 72 Repositories []types.Repository 73 74 // Metadata pertaining to the operation's result. 75 ResultMetadata middleware.Metadata 76} 77 78func addOperationDescribeRepositoriesMiddlewares(stack *middleware.Stack, options Options) (err error) { 79 err = stack.Serialize.Add(&awsAwsjson11_serializeOpDescribeRepositories{}, middleware.After) 80 if err != nil { 81 return err 82 } 83 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpDescribeRepositories{}, middleware.After) 84 if err != nil { 85 return err 86 } 87 if err = addSetLoggerMiddleware(stack, options); err != nil { 88 return err 89 } 90 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 91 return err 92 } 93 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 94 return err 95 } 96 if err = addResolveEndpointMiddleware(stack, options); err != nil { 97 return err 98 } 99 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 100 return err 101 } 102 if err = addRetryMiddlewares(stack, options); err != nil { 103 return err 104 } 105 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 106 return err 107 } 108 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 109 return err 110 } 111 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 112 return err 113 } 114 if err = addClientUserAgent(stack); err != nil { 115 return err 116 } 117 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 118 return err 119 } 120 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 121 return err 122 } 123 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeRepositories(options.Region), middleware.Before); err != nil { 124 return err 125 } 126 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 127 return err 128 } 129 if err = addResponseErrorMiddleware(stack); err != nil { 130 return err 131 } 132 if err = addRequestResponseLogging(stack, options); err != nil { 133 return err 134 } 135 return nil 136} 137 138// DescribeRepositoriesAPIClient is a client that implements the 139// DescribeRepositories operation. 140type DescribeRepositoriesAPIClient interface { 141 DescribeRepositories(context.Context, *DescribeRepositoriesInput, ...func(*Options)) (*DescribeRepositoriesOutput, error) 142} 143 144var _ DescribeRepositoriesAPIClient = (*Client)(nil) 145 146// DescribeRepositoriesPaginatorOptions is the paginator options for 147// DescribeRepositories 148type DescribeRepositoriesPaginatorOptions struct { 149 // The maximum number of repository results returned by DescribeRepositories in 150 // paginated output. When this parameter is used, DescribeRepositories only returns 151 // maxResults results in a single page along with a nextToken response element. The 152 // remaining results of the initial request can be seen by sending another 153 // DescribeRepositories request with the returned nextToken value. This value can 154 // be between 1 and 1000. If this parameter is not used, then DescribeRepositories 155 // returns up to 100 results and a nextToken value, if applicable. This option 156 // cannot be used when you specify repositories with repositoryNames. 157 Limit int32 158 159 // Set to true if pagination should stop if the service returns a pagination token 160 // that matches the most recent token provided to the service. 161 StopOnDuplicateToken bool 162} 163 164// DescribeRepositoriesPaginator is a paginator for DescribeRepositories 165type DescribeRepositoriesPaginator struct { 166 options DescribeRepositoriesPaginatorOptions 167 client DescribeRepositoriesAPIClient 168 params *DescribeRepositoriesInput 169 nextToken *string 170 firstPage bool 171} 172 173// NewDescribeRepositoriesPaginator returns a new DescribeRepositoriesPaginator 174func NewDescribeRepositoriesPaginator(client DescribeRepositoriesAPIClient, params *DescribeRepositoriesInput, optFns ...func(*DescribeRepositoriesPaginatorOptions)) *DescribeRepositoriesPaginator { 175 if params == nil { 176 params = &DescribeRepositoriesInput{} 177 } 178 179 options := DescribeRepositoriesPaginatorOptions{} 180 if params.MaxResults != nil { 181 options.Limit = *params.MaxResults 182 } 183 184 for _, fn := range optFns { 185 fn(&options) 186 } 187 188 return &DescribeRepositoriesPaginator{ 189 options: options, 190 client: client, 191 params: params, 192 firstPage: true, 193 } 194} 195 196// HasMorePages returns a boolean indicating whether more pages are available 197func (p *DescribeRepositoriesPaginator) HasMorePages() bool { 198 return p.firstPage || p.nextToken != nil 199} 200 201// NextPage retrieves the next DescribeRepositories page. 202func (p *DescribeRepositoriesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeRepositoriesOutput, error) { 203 if !p.HasMorePages() { 204 return nil, fmt.Errorf("no more pages available") 205 } 206 207 params := *p.params 208 params.NextToken = p.nextToken 209 210 var limit *int32 211 if p.options.Limit > 0 { 212 limit = &p.options.Limit 213 } 214 params.MaxResults = limit 215 216 result, err := p.client.DescribeRepositories(ctx, ¶ms, optFns...) 217 if err != nil { 218 return nil, err 219 } 220 p.firstPage = false 221 222 prevToken := p.nextToken 223 p.nextToken = result.NextToken 224 225 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 226 p.nextToken = nil 227 } 228 229 return result, nil 230} 231 232func newServiceMetadataMiddleware_opDescribeRepositories(region string) *awsmiddleware.RegisterServiceMetadata { 233 return &awsmiddleware.RegisterServiceMetadata{ 234 Region: region, 235 ServiceID: ServiceID, 236 SigningName: "ecr", 237 OperationName: "DescribeRepositories", 238 } 239} 240