1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package applicationinsights
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/applicationinsights/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13	"time"
14)
15
16// Lists the INFO, WARN, and ERROR events for periodic configuration updates
17// performed by Application Insights. Examples of events represented are:
18//
19// * INFO:
20// creating a new alarm or updating an alarm threshold.
21//
22// * WARN: alarm not created
23// due to insufficient data points used to predict thresholds.
24//
25// * ERROR: alarm not
26// created due to permission errors or exceeding quotas.
27func (c *Client) ListConfigurationHistory(ctx context.Context, params *ListConfigurationHistoryInput, optFns ...func(*Options)) (*ListConfigurationHistoryOutput, error) {
28	if params == nil {
29		params = &ListConfigurationHistoryInput{}
30	}
31
32	result, metadata, err := c.invokeOperation(ctx, "ListConfigurationHistory", params, optFns, addOperationListConfigurationHistoryMiddlewares)
33	if err != nil {
34		return nil, err
35	}
36
37	out := result.(*ListConfigurationHistoryOutput)
38	out.ResultMetadata = metadata
39	return out, nil
40}
41
42type ListConfigurationHistoryInput struct {
43
44	// The end time of the event.
45	EndTime *time.Time
46
47	// The status of the configuration update event. Possible values include INFO,
48	// WARN, and ERROR.
49	EventStatus types.ConfigurationEventStatus
50
51	// The maximum number of results returned by ListConfigurationHistory in paginated
52	// output. When this parameter is used, ListConfigurationHistory returns only
53	// MaxResults in a single page along with a NextToken response element. The
54	// remaining results of the initial request can be seen by sending another
55	// ListConfigurationHistory request with the returned NextToken value. If this
56	// parameter is not used, then ListConfigurationHistory returns all results.
57	MaxResults *int32
58
59	// The NextToken value returned from a previous paginated ListConfigurationHistory
60	// request where MaxResults was used and the results exceeded the value of that
61	// parameter. Pagination continues from the end of the previous results that
62	// returned the NextToken value. This value is null when there are no more results
63	// to return.
64	NextToken *string
65
66	// Resource group to which the application belongs.
67	ResourceGroupName *string
68
69	// The start time of the event.
70	StartTime *time.Time
71}
72
73type ListConfigurationHistoryOutput struct {
74
75	// The list of configuration events and their corresponding details.
76	EventList []types.ConfigurationEvent
77
78	// The NextToken value to include in a future ListConfigurationHistory request.
79	// When the results of a ListConfigurationHistory request exceed MaxResults, this
80	// value can be used to retrieve the next page of results. This value is null when
81	// there are no more results to return.
82	NextToken *string
83
84	// Metadata pertaining to the operation's result.
85	ResultMetadata middleware.Metadata
86}
87
88func addOperationListConfigurationHistoryMiddlewares(stack *middleware.Stack, options Options) (err error) {
89	err = stack.Serialize.Add(&awsAwsjson11_serializeOpListConfigurationHistory{}, middleware.After)
90	if err != nil {
91		return err
92	}
93	err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpListConfigurationHistory{}, middleware.After)
94	if err != nil {
95		return err
96	}
97	if err = addSetLoggerMiddleware(stack, options); err != nil {
98		return err
99	}
100	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
101		return err
102	}
103	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
104		return err
105	}
106	if err = addResolveEndpointMiddleware(stack, options); err != nil {
107		return err
108	}
109	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
110		return err
111	}
112	if err = addRetryMiddlewares(stack, options); err != nil {
113		return err
114	}
115	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
116		return err
117	}
118	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
119		return err
120	}
121	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
122		return err
123	}
124	if err = addClientUserAgent(stack); err != nil {
125		return err
126	}
127	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
128		return err
129	}
130	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
131		return err
132	}
133	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opListConfigurationHistory(options.Region), middleware.Before); err != nil {
134		return err
135	}
136	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
137		return err
138	}
139	if err = addResponseErrorMiddleware(stack); err != nil {
140		return err
141	}
142	if err = addRequestResponseLogging(stack, options); err != nil {
143		return err
144	}
145	return nil
146}
147
148// ListConfigurationHistoryAPIClient is a client that implements the
149// ListConfigurationHistory operation.
150type ListConfigurationHistoryAPIClient interface {
151	ListConfigurationHistory(context.Context, *ListConfigurationHistoryInput, ...func(*Options)) (*ListConfigurationHistoryOutput, error)
152}
153
154var _ ListConfigurationHistoryAPIClient = (*Client)(nil)
155
156// ListConfigurationHistoryPaginatorOptions is the paginator options for
157// ListConfigurationHistory
158type ListConfigurationHistoryPaginatorOptions struct {
159	// The maximum number of results returned by ListConfigurationHistory in paginated
160	// output. When this parameter is used, ListConfigurationHistory returns only
161	// MaxResults in a single page along with a NextToken response element. The
162	// remaining results of the initial request can be seen by sending another
163	// ListConfigurationHistory request with the returned NextToken value. If this
164	// parameter is not used, then ListConfigurationHistory returns all results.
165	Limit int32
166
167	// Set to true if pagination should stop if the service returns a pagination token
168	// that matches the most recent token provided to the service.
169	StopOnDuplicateToken bool
170}
171
172// ListConfigurationHistoryPaginator is a paginator for ListConfigurationHistory
173type ListConfigurationHistoryPaginator struct {
174	options   ListConfigurationHistoryPaginatorOptions
175	client    ListConfigurationHistoryAPIClient
176	params    *ListConfigurationHistoryInput
177	nextToken *string
178	firstPage bool
179}
180
181// NewListConfigurationHistoryPaginator returns a new
182// ListConfigurationHistoryPaginator
183func NewListConfigurationHistoryPaginator(client ListConfigurationHistoryAPIClient, params *ListConfigurationHistoryInput, optFns ...func(*ListConfigurationHistoryPaginatorOptions)) *ListConfigurationHistoryPaginator {
184	options := ListConfigurationHistoryPaginatorOptions{}
185	if params.MaxResults != nil {
186		options.Limit = *params.MaxResults
187	}
188
189	for _, fn := range optFns {
190		fn(&options)
191	}
192
193	if params == nil {
194		params = &ListConfigurationHistoryInput{}
195	}
196
197	return &ListConfigurationHistoryPaginator{
198		options:   options,
199		client:    client,
200		params:    params,
201		firstPage: true,
202	}
203}
204
205// HasMorePages returns a boolean indicating whether more pages are available
206func (p *ListConfigurationHistoryPaginator) HasMorePages() bool {
207	return p.firstPage || p.nextToken != nil
208}
209
210// NextPage retrieves the next ListConfigurationHistory page.
211func (p *ListConfigurationHistoryPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*ListConfigurationHistoryOutput, error) {
212	if !p.HasMorePages() {
213		return nil, fmt.Errorf("no more pages available")
214	}
215
216	params := *p.params
217	params.NextToken = p.nextToken
218
219	var limit *int32
220	if p.options.Limit > 0 {
221		limit = &p.options.Limit
222	}
223	params.MaxResults = limit
224
225	result, err := p.client.ListConfigurationHistory(ctx, &params, optFns...)
226	if err != nil {
227		return nil, err
228	}
229	p.firstPage = false
230
231	prevToken := p.nextToken
232	p.nextToken = result.NextToken
233
234	if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken {
235		p.nextToken = nil
236	}
237
238	return result, nil
239}
240
241func newServiceMetadataMiddleware_opListConfigurationHistory(region string) *awsmiddleware.RegisterServiceMetadata {
242	return &awsmiddleware.RegisterServiceMetadata{
243		Region:        region,
244		ServiceID:     ServiceID,
245		SigningName:   "applicationinsights",
246		OperationName: "ListConfigurationHistory",
247	}
248}
249