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