1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package sagemaker 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/sagemaker/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13 "time" 14) 15 16// Lists the artifacts in your account and their properties. 17func (c *Client) ListArtifacts(ctx context.Context, params *ListArtifactsInput, optFns ...func(*Options)) (*ListArtifactsOutput, error) { 18 if params == nil { 19 params = &ListArtifactsInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "ListArtifacts", params, optFns, addOperationListArtifactsMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*ListArtifactsOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32type ListArtifactsInput struct { 33 34 // A filter that returns only artifacts of the specified type. 35 ArtifactType *string 36 37 // A filter that returns only artifacts created on or after the specified time. 38 CreatedAfter *time.Time 39 40 // A filter that returns only artifacts created on or before the specified time. 41 CreatedBefore *time.Time 42 43 // The maximum number of artifacts to return in the response. The default value is 44 // 10. 45 MaxResults *int32 46 47 // If the previous call to ListArtifacts didn't return the full set of artifacts, 48 // the call returns a token for getting the next set of artifacts. 49 NextToken *string 50 51 // The property used to sort results. The default value is CreationTime. 52 SortBy types.SortArtifactsBy 53 54 // The sort order. The default value is Descending. 55 SortOrder types.SortOrder 56 57 // A filter that returns only artifacts with the specified source URI. 58 SourceUri *string 59} 60 61type ListArtifactsOutput struct { 62 63 // A list of artifacts and their properties. 64 ArtifactSummaries []types.ArtifactSummary 65 66 // A token for getting the next set of artifacts, if there are any. 67 NextToken *string 68 69 // Metadata pertaining to the operation's result. 70 ResultMetadata middleware.Metadata 71} 72 73func addOperationListArtifactsMiddlewares(stack *middleware.Stack, options Options) (err error) { 74 err = stack.Serialize.Add(&awsAwsjson11_serializeOpListArtifacts{}, middleware.After) 75 if err != nil { 76 return err 77 } 78 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListArtifacts{}, middleware.After) 79 if err != nil { 80 return err 81 } 82 if err = addSetLoggerMiddleware(stack, options); err != nil { 83 return err 84 } 85 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 86 return err 87 } 88 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 89 return err 90 } 91 if err = addResolveEndpointMiddleware(stack, options); err != nil { 92 return err 93 } 94 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 95 return err 96 } 97 if err = addRetryMiddlewares(stack, options); err != nil { 98 return err 99 } 100 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 101 return err 102 } 103 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 104 return err 105 } 106 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 107 return err 108 } 109 if err = addClientUserAgent(stack); err != nil { 110 return err 111 } 112 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 113 return err 114 } 115 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 116 return err 117 } 118 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListArtifacts(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// ListArtifactsAPIClient is a client that implements the ListArtifacts operation. 134type ListArtifactsAPIClient interface { 135 ListArtifacts(context.Context, *ListArtifactsInput, ...func(*Options)) (*ListArtifactsOutput, error) 136} 137 138var _ ListArtifactsAPIClient = (*Client)(nil) 139 140// ListArtifactsPaginatorOptions is the paginator options for ListArtifacts 141type ListArtifactsPaginatorOptions struct { 142 // The maximum number of artifacts to return in the response. The default value is 143 // 10. 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// ListArtifactsPaginator is a paginator for ListArtifacts 152type ListArtifactsPaginator struct { 153 options ListArtifactsPaginatorOptions 154 client ListArtifactsAPIClient 155 params *ListArtifactsInput 156 nextToken *string 157 firstPage bool 158} 159 160// NewListArtifactsPaginator returns a new ListArtifactsPaginator 161func NewListArtifactsPaginator(client ListArtifactsAPIClient, params *ListArtifactsInput, optFns ...func(*ListArtifactsPaginatorOptions)) *ListArtifactsPaginator { 162 options := ListArtifactsPaginatorOptions{} 163 if params.MaxResults != nil { 164 options.Limit = *params.MaxResults 165 } 166 167 for _, fn := range optFns { 168 fn(&options) 169 } 170 171 if params == nil { 172 params = &ListArtifactsInput{} 173 } 174 175 return &ListArtifactsPaginator{ 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 *ListArtifactsPaginator) HasMorePages() bool { 185 return p.firstPage || p.nextToken != nil 186} 187 188// NextPage retrieves the next ListArtifacts page. 189func (p *ListArtifactsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListArtifactsOutput, error) { 190 if !p.HasMorePages() { 191 return nil, fmt.Errorf("no more pages available") 192 } 193 194 params := *p.params 195 params.NextToken = p.nextToken 196 197 var limit *int32 198 if p.options.Limit > 0 { 199 limit = &p.options.Limit 200 } 201 params.MaxResults = limit 202 203 result, err := p.client.ListArtifacts(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.NextToken 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_opListArtifacts(region string) *awsmiddleware.RegisterServiceMetadata { 220 return &awsmiddleware.RegisterServiceMetadata{ 221 Region: region, 222 ServiceID: ServiceID, 223 SigningName: "sagemaker", 224 OperationName: "ListArtifacts", 225 } 226} 227