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// Request a list of jobs. 17func (c *Client) ListAutoMLJobs(ctx context.Context, params *ListAutoMLJobsInput, optFns ...func(*Options)) (*ListAutoMLJobsOutput, error) { 18 if params == nil { 19 params = &ListAutoMLJobsInput{} 20 } 21 22 result, metadata, err := c.invokeOperation(ctx, "ListAutoMLJobs", params, optFns, addOperationListAutoMLJobsMiddlewares) 23 if err != nil { 24 return nil, err 25 } 26 27 out := result.(*ListAutoMLJobsOutput) 28 out.ResultMetadata = metadata 29 return out, nil 30} 31 32type ListAutoMLJobsInput struct { 33 34 // Request a list of jobs, using a filter for time. 35 CreationTimeAfter *time.Time 36 37 // Request a list of jobs, using a filter for time. 38 CreationTimeBefore *time.Time 39 40 // Request a list of jobs, using a filter for time. 41 LastModifiedTimeAfter *time.Time 42 43 // Request a list of jobs, using a filter for time. 44 LastModifiedTimeBefore *time.Time 45 46 // Request a list of jobs up to a specified limit. 47 MaxResults int32 48 49 // Request a list of jobs, using a search filter for name. 50 NameContains *string 51 52 // If the previous response was truncated, you receive this token. Use it in your 53 // next request to receive the next set of results. 54 NextToken *string 55 56 // The parameter by which to sort the results. The default is AutoMLJobName. 57 SortBy types.AutoMLSortBy 58 59 // The sort order for the results. The default is Descending. 60 SortOrder types.AutoMLSortOrder 61 62 // Request a list of jobs, using a filter for status. 63 StatusEquals types.AutoMLJobStatus 64} 65 66type ListAutoMLJobsOutput struct { 67 68 // Returns a summary list of jobs. 69 // 70 // This member is required. 71 AutoMLJobSummaries []types.AutoMLJobSummary 72 73 // If the previous response was truncated, you receive this token. Use it in your 74 // next request to receive the next set of results. 75 NextToken *string 76 77 // Metadata pertaining to the operation's result. 78 ResultMetadata middleware.Metadata 79} 80 81func addOperationListAutoMLJobsMiddlewares(stack *middleware.Stack, options Options) (err error) { 82 err = stack.Serialize.Add(&awsAwsjson11_serializeOpListAutoMLJobs{}, middleware.After) 83 if err != nil { 84 return err 85 } 86 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListAutoMLJobs{}, middleware.After) 87 if err != nil { 88 return err 89 } 90 if err = addSetLoggerMiddleware(stack, options); err != nil { 91 return err 92 } 93 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 94 return err 95 } 96 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 97 return err 98 } 99 if err = addResolveEndpointMiddleware(stack, options); err != nil { 100 return err 101 } 102 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 103 return err 104 } 105 if err = addRetryMiddlewares(stack, options); err != nil { 106 return err 107 } 108 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 109 return err 110 } 111 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 112 return err 113 } 114 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 115 return err 116 } 117 if err = addClientUserAgent(stack); err != nil { 118 return err 119 } 120 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 121 return err 122 } 123 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 124 return err 125 } 126 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListAutoMLJobs(options.Region), middleware.Before); err != nil { 127 return err 128 } 129 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 130 return err 131 } 132 if err = addResponseErrorMiddleware(stack); err != nil { 133 return err 134 } 135 if err = addRequestResponseLogging(stack, options); err != nil { 136 return err 137 } 138 return nil 139} 140 141// ListAutoMLJobsAPIClient is a client that implements the ListAutoMLJobs 142// operation. 143type ListAutoMLJobsAPIClient interface { 144 ListAutoMLJobs(context.Context, *ListAutoMLJobsInput, ...func(*Options)) (*ListAutoMLJobsOutput, error) 145} 146 147var _ ListAutoMLJobsAPIClient = (*Client)(nil) 148 149// ListAutoMLJobsPaginatorOptions is the paginator options for ListAutoMLJobs 150type ListAutoMLJobsPaginatorOptions struct { 151 // Request a list of jobs up to a specified limit. 152 Limit int32 153 154 // Set to true if pagination should stop if the service returns a pagination token 155 // that matches the most recent token provided to the service. 156 StopOnDuplicateToken bool 157} 158 159// ListAutoMLJobsPaginator is a paginator for ListAutoMLJobs 160type ListAutoMLJobsPaginator struct { 161 options ListAutoMLJobsPaginatorOptions 162 client ListAutoMLJobsAPIClient 163 params *ListAutoMLJobsInput 164 nextToken *string 165 firstPage bool 166} 167 168// NewListAutoMLJobsPaginator returns a new ListAutoMLJobsPaginator 169func NewListAutoMLJobsPaginator(client ListAutoMLJobsAPIClient, params *ListAutoMLJobsInput, optFns ...func(*ListAutoMLJobsPaginatorOptions)) *ListAutoMLJobsPaginator { 170 if params == nil { 171 params = &ListAutoMLJobsInput{} 172 } 173 174 options := ListAutoMLJobsPaginatorOptions{} 175 if params.MaxResults != 0 { 176 options.Limit = params.MaxResults 177 } 178 179 for _, fn := range optFns { 180 fn(&options) 181 } 182 183 return &ListAutoMLJobsPaginator{ 184 options: options, 185 client: client, 186 params: params, 187 firstPage: true, 188 } 189} 190 191// HasMorePages returns a boolean indicating whether more pages are available 192func (p *ListAutoMLJobsPaginator) HasMorePages() bool { 193 return p.firstPage || p.nextToken != nil 194} 195 196// NextPage retrieves the next ListAutoMLJobs page. 197func (p *ListAutoMLJobsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListAutoMLJobsOutput, error) { 198 if !p.HasMorePages() { 199 return nil, fmt.Errorf("no more pages available") 200 } 201 202 params := *p.params 203 params.NextToken = p.nextToken 204 205 params.MaxResults = p.options.Limit 206 207 result, err := p.client.ListAutoMLJobs(ctx, ¶ms, optFns...) 208 if err != nil { 209 return nil, err 210 } 211 p.firstPage = false 212 213 prevToken := p.nextToken 214 p.nextToken = result.NextToken 215 216 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 217 p.nextToken = nil 218 } 219 220 return result, nil 221} 222 223func newServiceMetadataMiddleware_opListAutoMLJobs(region string) *awsmiddleware.RegisterServiceMetadata { 224 return &awsmiddleware.RegisterServiceMetadata{ 225 Region: region, 226 ServiceID: ServiceID, 227 SigningName: "sagemaker", 228 OperationName: "ListAutoMLJobs", 229 } 230} 231