1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package codeguruprofiler
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/codeguruprofiler/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13)
14
15// Returns a list of FindingsReportSummary
16// (https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_FindingsReportSummary.html)
17// objects that contain analysis results for all profiling groups in your AWS
18// account.
19func (c *Client) GetFindingsReportAccountSummary(ctx context.Context, params *GetFindingsReportAccountSummaryInput, optFns ...func(*Options)) (*GetFindingsReportAccountSummaryOutput, error) {
20	if params == nil {
21		params = &GetFindingsReportAccountSummaryInput{}
22	}
23
24	result, metadata, err := c.invokeOperation(ctx, "GetFindingsReportAccountSummary", params, optFns, c.addOperationGetFindingsReportAccountSummaryMiddlewares)
25	if err != nil {
26		return nil, err
27	}
28
29	out := result.(*GetFindingsReportAccountSummaryOutput)
30	out.ResultMetadata = metadata
31	return out, nil
32}
33
34// The structure representing the GetFindingsReportAccountSummaryRequest.
35type GetFindingsReportAccountSummaryInput struct {
36
37	// A Boolean value indicating whether to only return reports from daily profiles.
38	// If set to True, only analysis data from daily profiles is returned. If set to
39	// False, analysis data is returned from smaller time windows (for example, one
40	// hour).
41	DailyReportsOnly *bool
42
43	// The maximum number of results returned by  GetFindingsReportAccountSummary in
44	// paginated output. When this parameter is used, GetFindingsReportAccountSummary
45	// only returns maxResults results in a single page along with a nextToken response
46	// element. The remaining results of the initial request can be seen by sending
47	// another GetFindingsReportAccountSummary request with the returned nextToken
48	// value.
49	MaxResults *int32
50
51	// The nextToken value returned from a previous paginated
52	// GetFindingsReportAccountSummary request where maxResults was used and the
53	// results exceeded the value of that parameter. Pagination continues from the end
54	// of the previous results that returned the nextToken value. This token should be
55	// treated as an opaque identifier that is only used to retrieve the next items in
56	// a list and not for other programmatic purposes.
57	NextToken *string
58
59	noSmithyDocumentSerde
60}
61
62// The structure representing the GetFindingsReportAccountSummaryResponse.
63type GetFindingsReportAccountSummaryOutput struct {
64
65	// The return list of FindingsReportSummary
66	// (https://docs.aws.amazon.com/codeguru/latest/profiler-api/API_FindingsReportSummary.html)
67	// objects taht contain summaries of analysis results for all profiling groups in
68	// your AWS account.
69	//
70	// This member is required.
71	ReportSummaries []types.FindingsReportSummary
72
73	// The nextToken value to include in a future GetFindingsReportAccountSummary
74	// request. When the results of a GetFindingsReportAccountSummary request exceed
75	// maxResults, this value can be used to retrieve the next page of results. This
76	// value is null when there are no more results to return.
77	NextToken *string
78
79	// Metadata pertaining to the operation's result.
80	ResultMetadata middleware.Metadata
81
82	noSmithyDocumentSerde
83}
84
85func (c *Client) addOperationGetFindingsReportAccountSummaryMiddlewares(stack *middleware.Stack, options Options) (err error) {
86	err = stack.Serialize.Add(&awsRestjson1_serializeOpGetFindingsReportAccountSummary{}, middleware.After)
87	if err != nil {
88		return err
89	}
90	err = stack.Deserialize.Add(&awsRestjson1_deserializeOpGetFindingsReportAccountSummary{}, middleware.After)
91	if err != nil {
92		return err
93	}
94	if err = addSetLoggerMiddleware(stack, options); err != nil {
95		return err
96	}
97	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
98		return err
99	}
100	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
101		return err
102	}
103	if err = addResolveEndpointMiddleware(stack, options); err != nil {
104		return err
105	}
106	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
107		return err
108	}
109	if err = addRetryMiddlewares(stack, options); err != nil {
110		return err
111	}
112	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
113		return err
114	}
115	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
116		return err
117	}
118	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
119		return err
120	}
121	if err = addClientUserAgent(stack); err != nil {
122		return err
123	}
124	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
125		return err
126	}
127	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
128		return err
129	}
130	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opGetFindingsReportAccountSummary(options.Region), middleware.Before); err != nil {
131		return err
132	}
133	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
134		return err
135	}
136	if err = addResponseErrorMiddleware(stack); err != nil {
137		return err
138	}
139	if err = addRequestResponseLogging(stack, options); err != nil {
140		return err
141	}
142	return nil
143}
144
145// GetFindingsReportAccountSummaryAPIClient is a client that implements the
146// GetFindingsReportAccountSummary operation.
147type GetFindingsReportAccountSummaryAPIClient interface {
148	GetFindingsReportAccountSummary(context.Context, *GetFindingsReportAccountSummaryInput, ...func(*Options)) (*GetFindingsReportAccountSummaryOutput, error)
149}
150
151var _ GetFindingsReportAccountSummaryAPIClient = (*Client)(nil)
152
153// GetFindingsReportAccountSummaryPaginatorOptions is the paginator options for
154// GetFindingsReportAccountSummary
155type GetFindingsReportAccountSummaryPaginatorOptions struct {
156	// The maximum number of results returned by  GetFindingsReportAccountSummary in
157	// paginated output. When this parameter is used, GetFindingsReportAccountSummary
158	// only returns maxResults results in a single page along with a nextToken response
159	// element. The remaining results of the initial request can be seen by sending
160	// another GetFindingsReportAccountSummary request with the returned nextToken
161	// value.
162	Limit int32
163
164	// Set to true if pagination should stop if the service returns a pagination token
165	// that matches the most recent token provided to the service.
166	StopOnDuplicateToken bool
167}
168
169// GetFindingsReportAccountSummaryPaginator is a paginator for
170// GetFindingsReportAccountSummary
171type GetFindingsReportAccountSummaryPaginator struct {
172	options   GetFindingsReportAccountSummaryPaginatorOptions
173	client    GetFindingsReportAccountSummaryAPIClient
174	params    *GetFindingsReportAccountSummaryInput
175	nextToken *string
176	firstPage bool
177}
178
179// NewGetFindingsReportAccountSummaryPaginator returns a new
180// GetFindingsReportAccountSummaryPaginator
181func NewGetFindingsReportAccountSummaryPaginator(client GetFindingsReportAccountSummaryAPIClient, params *GetFindingsReportAccountSummaryInput, optFns ...func(*GetFindingsReportAccountSummaryPaginatorOptions)) *GetFindingsReportAccountSummaryPaginator {
182	if params == nil {
183		params = &GetFindingsReportAccountSummaryInput{}
184	}
185
186	options := GetFindingsReportAccountSummaryPaginatorOptions{}
187	if params.MaxResults != nil {
188		options.Limit = *params.MaxResults
189	}
190
191	for _, fn := range optFns {
192		fn(&options)
193	}
194
195	return &GetFindingsReportAccountSummaryPaginator{
196		options:   options,
197		client:    client,
198		params:    params,
199		firstPage: true,
200	}
201}
202
203// HasMorePages returns a boolean indicating whether more pages are available
204func (p *GetFindingsReportAccountSummaryPaginator) HasMorePages() bool {
205	return p.firstPage || p.nextToken != nil
206}
207
208// NextPage retrieves the next GetFindingsReportAccountSummary page.
209func (p *GetFindingsReportAccountSummaryPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*GetFindingsReportAccountSummaryOutput, error) {
210	if !p.HasMorePages() {
211		return nil, fmt.Errorf("no more pages available")
212	}
213
214	params := *p.params
215	params.NextToken = p.nextToken
216
217	var limit *int32
218	if p.options.Limit > 0 {
219		limit = &p.options.Limit
220	}
221	params.MaxResults = limit
222
223	result, err := p.client.GetFindingsReportAccountSummary(ctx, &params, optFns...)
224	if err != nil {
225		return nil, err
226	}
227	p.firstPage = false
228
229	prevToken := p.nextToken
230	p.nextToken = result.NextToken
231
232	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
233		p.nextToken = nil
234	}
235
236	return result, nil
237}
238
239func newServiceMetadataMiddleware_opGetFindingsReportAccountSummary(region string) *awsmiddleware.RegisterServiceMetadata {
240	return &awsmiddleware.RegisterServiceMetadata{
241		Region:        region,
242		ServiceID:     ServiceID,
243		SigningName:   "codeguru-profiler",
244		OperationName: "GetFindingsReportAccountSummary",
245	}
246}
247