1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package quicksight
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/quicksight/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Searches for dashboards that belong to a user.
16func (c *Client) SearchDashboards(ctx context.Context, params *SearchDashboardsInput, optFns ...func(*Options)) (*SearchDashboardsOutput, error) {
17	if params == nil {
18		params = &SearchDashboardsInput{}
19	}
20
21	result, metadata, err := c.invokeOperation(ctx, "SearchDashboards", params, optFns, addOperationSearchDashboardsMiddlewares)
22	if err != nil {
23		return nil, err
24	}
25
26	out := result.(*SearchDashboardsOutput)
27	out.ResultMetadata = metadata
28	return out, nil
29}
30
31type SearchDashboardsInput struct {
32
33	// The ID of the AWS account that contains the user whose dashboards you're
34	// searching for.
35	//
36	// This member is required.
37	AwsAccountId *string
38
39	// The filters to apply to the search. Currently, you can search only by user name,
40	// for example, "Filters": [ { "Name": "QUICKSIGHT_USER", "Operator":
41	// "StringEquals", "Value": "arn:aws:quicksight:us-east-1:1:user/default/UserName1"
42	// } ]
43	//
44	// This member is required.
45	Filters []types.DashboardSearchFilter
46
47	// The maximum number of results to be returned per request.
48	MaxResults int32
49
50	// The token for the next set of results, or null if there are no more results.
51	NextToken *string
52}
53
54type SearchDashboardsOutput struct {
55
56	// The list of dashboards owned by the user specified in Filters in your request.
57	DashboardSummaryList []types.DashboardSummary
58
59	// The token for the next set of results, or null if there are no more results.
60	NextToken *string
61
62	// The AWS request ID for this operation.
63	RequestId *string
64
65	// The HTTP status of the request.
66	Status int32
67
68	// Metadata pertaining to the operation's result.
69	ResultMetadata middleware.Metadata
70}
71
72func addOperationSearchDashboardsMiddlewares(stack *middleware.Stack, options Options) (err error) {
73	err = stack.Serialize.Add(&awsRestjson1_serializeOpSearchDashboards{}, middleware.After)
74	if err != nil {
75		return err
76	}
77	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpSearchDashboards{}, middleware.After)
78	if err != nil {
79		return err
80	}
81	if err = addSetLoggerMiddleware(stack, options); err != nil {
82		return err
83	}
84	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
85		return err
86	}
87	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
88		return err
89	}
90	if err = addResolveEndpointMiddleware(stack, options); err != nil {
91		return err
92	}
93	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
94		return err
95	}
96	if err = addRetryMiddlewares(stack, options); err != nil {
97		return err
98	}
99	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
100		return err
101	}
102	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
103		return err
104	}
105	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
106		return err
107	}
108	if err = addClientUserAgent(stack); err != nil {
109		return err
110	}
111	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
112		return err
113	}
114	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
115		return err
116	}
117	if err = addOpSearchDashboardsValidationMiddleware(stack); err != nil {
118		return err
119	}
120	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opSearchDashboards(options.Region), middleware.Before); err != nil {
121		return err
122	}
123	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
124		return err
125	}
126	if err = addResponseErrorMiddleware(stack); err != nil {
127		return err
128	}
129	if err = addRequestResponseLogging(stack, options); err != nil {
130		return err
131	}
132	return nil
133}
134
135// SearchDashboardsAPIClient is a client that implements the SearchDashboards
136// operation.
137type SearchDashboardsAPIClient interface {
138	SearchDashboards(context.Context, *SearchDashboardsInput, ...func(*Options)) (*SearchDashboardsOutput, error)
139}
140
141var _ SearchDashboardsAPIClient = (*Client)(nil)
142
143// SearchDashboardsPaginatorOptions is the paginator options for SearchDashboards
144type SearchDashboardsPaginatorOptions struct {
145	// The maximum number of results to be returned per request.
146	Limit int32
147
148	// Set to true if pagination should stop if the service returns a pagination token
149	// that matches the most recent token provided to the service.
150	StopOnDuplicateToken bool
151}
152
153// SearchDashboardsPaginator is a paginator for SearchDashboards
154type SearchDashboardsPaginator struct {
155	options   SearchDashboardsPaginatorOptions
156	client    SearchDashboardsAPIClient
157	params    *SearchDashboardsInput
158	nextToken *string
159	firstPage bool
160}
161
162// NewSearchDashboardsPaginator returns a new SearchDashboardsPaginator
163func NewSearchDashboardsPaginator(client SearchDashboardsAPIClient, params *SearchDashboardsInput, optFns ...func(*SearchDashboardsPaginatorOptions)) *SearchDashboardsPaginator {
164	if params == nil {
165		params = &SearchDashboardsInput{}
166	}
167
168	options := SearchDashboardsPaginatorOptions{}
169	if params.MaxResults != 0 {
170		options.Limit = params.MaxResults
171	}
172
173	for _, fn := range optFns {
174		fn(&options)
175	}
176
177	return &SearchDashboardsPaginator{
178		options:   options,
179		client:    client,
180		params:    params,
181		firstPage: true,
182	}
183}
184
185// HasMorePages returns a boolean indicating whether more pages are available
186func (p *SearchDashboardsPaginator) HasMorePages() bool {
187	return p.firstPage || p.nextToken != nil
188}
189
190// NextPage retrieves the next SearchDashboards page.
191func (p *SearchDashboardsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*SearchDashboardsOutput, error) {
192	if !p.HasMorePages() {
193		return nil, fmt.Errorf("no more pages available")
194	}
195
196	params := *p.params
197	params.NextToken = p.nextToken
198
199	params.MaxResults = p.options.Limit
200
201	result, err := p.client.SearchDashboards(ctx, &params, optFns...)
202	if err != nil {
203		return nil, err
204	}
205	p.firstPage = false
206
207	prevToken := p.nextToken
208	p.nextToken = result.NextToken
209
210	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
211		p.nextToken = nil
212	}
213
214	return result, nil
215}
216
217func newServiceMetadataMiddleware_opSearchDashboards(region string) *awsmiddleware.RegisterServiceMetadata {
218	return &awsmiddleware.RegisterServiceMetadata{
219		Region:        region,
220		ServiceID:     ServiceID,
221		SigningName:   "quicksight",
222		OperationName: "SearchDashboards",
223	}
224}
225