1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package machinelearning
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/machinelearning/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Returns a list of DataSource that match the search criteria in the request.
16func (c *Client) DescribeDataSources(ctx context.Context, params *DescribeDataSourcesInput, optFns ...func(*Options)) (*DescribeDataSourcesOutput, error) {
17	if params == nil {
18		params = &DescribeDataSourcesInput{}
19	}
20
21	result, metadata, err := c.invokeOperation(ctx, "DescribeDataSources", params, optFns, addOperationDescribeDataSourcesMiddlewares)
22	if err != nil {
23		return nil, err
24	}
25
26	out := result.(*DescribeDataSourcesOutput)
27	out.ResultMetadata = metadata
28	return out, nil
29}
30
31type DescribeDataSourcesInput struct {
32
33	// The equal to operator. The DataSource results will have FilterVariable values
34	// that exactly match the value specified with EQ.
35	EQ *string
36
37	// Use one of the following variables to filter a list of DataSource:
38	//
39	// * CreatedAt
40	// - Sets the search criteria to DataSource creation dates.
41	//
42	// * Status - Sets the
43	// search criteria to DataSource statuses.
44	//
45	// * Name - Sets the search criteria to
46	// the contents of DataSourceName.
47	//
48	// * DataUri - Sets the search criteria to the URI
49	// of data files used to create the DataSource. The URI can identify either a file
50	// or an Amazon Simple Storage Service (Amazon S3) bucket or directory.
51	//
52	// * IAMUser
53	// - Sets the search criteria to the user account that invoked the DataSource
54	// creation.
55	FilterVariable types.DataSourceFilterVariable
56
57	// The greater than or equal to operator. The DataSource results will have
58	// FilterVariable values that are greater than or equal to the value specified with
59	// GE.
60	GE *string
61
62	// The greater than operator. The DataSource results will have FilterVariable
63	// values that are greater than the value specified with GT.
64	GT *string
65
66	// The less than or equal to operator. The DataSource results will have
67	// FilterVariable values that are less than or equal to the value specified with
68	// LE.
69	LE *string
70
71	// The less than operator. The DataSource results will have FilterVariable values
72	// that are less than the value specified with LT.
73	LT *string
74
75	// The maximum number of DataSource to include in the result.
76	Limit *int32
77
78	// The not equal to operator. The DataSource results will have FilterVariable
79	// values not equal to the value specified with NE.
80	NE *string
81
82	// The ID of the page in the paginated results.
83	NextToken *string
84
85	// A string that is found at the beginning of a variable, such as Name or Id. For
86	// example, a DataSource could have the Name2014-09-09-HolidayGiftMailer. To search
87	// for this DataSource, select Name for the FilterVariable and any of the following
88	// strings for the Prefix:
89	//
90	// * 2014-09
91	//
92	// * 2014-09-09
93	//
94	// * 2014-09-09-Holiday
95	Prefix *string
96
97	// A two-value parameter that determines the sequence of the resulting list of
98	// DataSource.
99	//
100	// * asc - Arranges the list in ascending order (A-Z, 0-9).
101	//
102	// * dsc -
103	// Arranges the list in descending order (Z-A, 9-0).
104	//
105	// Results are sorted by
106	// FilterVariable.
107	SortOrder types.SortOrder
108}
109
110// Represents the query results from a DescribeDataSources operation. The content
111// is essentially a list of DataSource.
112type DescribeDataSourcesOutput struct {
113
114	// An ID of the next page in the paginated results that indicates at least one more
115	// page follows.
116	NextToken *string
117
118	// A list of DataSource that meet the search criteria.
119	Results []types.DataSource
120
121	// Metadata pertaining to the operation's result.
122	ResultMetadata middleware.Metadata
123}
124
125func addOperationDescribeDataSourcesMiddlewares(stack *middleware.Stack, options Options) (err error) {
126	err = stack.Serialize.Add(&awsAwsjson11_serializeOpDescribeDataSources{}, middleware.After)
127	if err != nil {
128		return err
129	}
130	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpDescribeDataSources{}, middleware.After)
131	if err != nil {
132		return err
133	}
134	if err = addSetLoggerMiddleware(stack, options); err != nil {
135		return err
136	}
137	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
138		return err
139	}
140	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
141		return err
142	}
143	if err = addResolveEndpointMiddleware(stack, options); err != nil {
144		return err
145	}
146	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
147		return err
148	}
149	if err = addRetryMiddlewares(stack, options); err != nil {
150		return err
151	}
152	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
153		return err
154	}
155	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
156		return err
157	}
158	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
159		return err
160	}
161	if err = addClientUserAgent(stack); err != nil {
162		return err
163	}
164	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
165		return err
166	}
167	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
168		return err
169	}
170	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeDataSources(options.Region), middleware.Before); err != nil {
171		return err
172	}
173	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
174		return err
175	}
176	if err = addResponseErrorMiddleware(stack); err != nil {
177		return err
178	}
179	if err = addRequestResponseLogging(stack, options); err != nil {
180		return err
181	}
182	return nil
183}
184
185// DescribeDataSourcesAPIClient is a client that implements the DescribeDataSources
186// operation.
187type DescribeDataSourcesAPIClient interface {
188	DescribeDataSources(context.Context, *DescribeDataSourcesInput, ...func(*Options)) (*DescribeDataSourcesOutput, error)
189}
190
191var _ DescribeDataSourcesAPIClient = (*Client)(nil)
192
193// DescribeDataSourcesPaginatorOptions is the paginator options for
194// DescribeDataSources
195type DescribeDataSourcesPaginatorOptions struct {
196	// The maximum number of DataSource to include in the result.
197	Limit int32
198
199	// Set to true if pagination should stop if the service returns a pagination token
200	// that matches the most recent token provided to the service.
201	StopOnDuplicateToken bool
202}
203
204// DescribeDataSourcesPaginator is a paginator for DescribeDataSources
205type DescribeDataSourcesPaginator struct {
206	options   DescribeDataSourcesPaginatorOptions
207	client    DescribeDataSourcesAPIClient
208	params    *DescribeDataSourcesInput
209	nextToken *string
210	firstPage bool
211}
212
213// NewDescribeDataSourcesPaginator returns a new DescribeDataSourcesPaginator
214func NewDescribeDataSourcesPaginator(client DescribeDataSourcesAPIClient, params *DescribeDataSourcesInput, optFns ...func(*DescribeDataSourcesPaginatorOptions)) *DescribeDataSourcesPaginator {
215	options := DescribeDataSourcesPaginatorOptions{}
216	if params.Limit != nil {
217		options.Limit = *params.Limit
218	}
219
220	for _, fn := range optFns {
221		fn(&options)
222	}
223
224	if params == nil {
225		params = &DescribeDataSourcesInput{}
226	}
227
228	return &DescribeDataSourcesPaginator{
229		options:   options,
230		client:    client,
231		params:    params,
232		firstPage: true,
233	}
234}
235
236// HasMorePages returns a boolean indicating whether more pages are available
237func (p *DescribeDataSourcesPaginator) HasMorePages() bool {
238	return p.firstPage || p.nextToken != nil
239}
240
241// NextPage retrieves the next DescribeDataSources page.
242func (p *DescribeDataSourcesPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeDataSourcesOutput, error) {
243	if !p.HasMorePages() {
244		return nil, fmt.Errorf("no more pages available")
245	}
246
247	params := *p.params
248	params.NextToken = p.nextToken
249
250	var limit *int32
251	if p.options.Limit > 0 {
252		limit = &p.options.Limit
253	}
254	params.Limit = limit
255
256	result, err := p.client.DescribeDataSources(ctx, &params, optFns...)
257	if err != nil {
258		return nil, err
259	}
260	p.firstPage = false
261
262	prevToken := p.nextToken
263	p.nextToken = result.NextToken
264
265	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
266		p.nextToken = nil
267	}
268
269	return result, nil
270}
271
272func newServiceMetadataMiddleware_opDescribeDataSources(region string) *awsmiddleware.RegisterServiceMetadata {
273	return &awsmiddleware.RegisterServiceMetadata{
274		Region:        region,
275		ServiceID:     ServiceID,
276		SigningName:   "machinelearning",
277		OperationName: "DescribeDataSources",
278	}
279}
280