1// Code generated by smithy-go-codegen DO NOT EDIT.
2
3package redshift
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/redshift/types"
11	"github.com/aws/smithy-go/middleware"
12	smithyhttp "github.com/aws/smithy-go/transport/http"
13	"time"
14)
15
16// Describes properties of scheduled actions.
17func (c *Client) DescribeScheduledActions(ctx context.Context, params *DescribeScheduledActionsInput, optFns ...func(*Options)) (*DescribeScheduledActionsOutput, error) {
18	if params == nil {
19		params = &DescribeScheduledActionsInput{}
20	}
21
22	result, metadata, err := c.invokeOperation(ctx, "DescribeScheduledActions", params, optFns, addOperationDescribeScheduledActionsMiddlewares)
23	if err != nil {
24		return nil, err
25	}
26
27	out := result.(*DescribeScheduledActionsOutput)
28	out.ResultMetadata = metadata
29	return out, nil
30}
31
32type DescribeScheduledActionsInput struct {
33
34	// If true, retrieve only active scheduled actions. If false, retrieve only
35	// disabled scheduled actions.
36	Active *bool
37
38	// The end time in UTC of the scheduled action to retrieve. Only active scheduled
39	// actions that have invocations before this time are retrieved.
40	EndTime *time.Time
41
42	// List of scheduled action filters.
43	Filters []types.ScheduledActionFilter
44
45	// An optional parameter that specifies the starting point to return a set of
46	// response records. When the results of a DescribeScheduledActions request exceed
47	// the value specified in MaxRecords, AWS returns a value in the Marker field of
48	// the response. You can retrieve the next set of response records by providing the
49	// returned marker value in the Marker parameter and retrying the request.
50	Marker *string
51
52	// The maximum number of response records to return in each call. If the number of
53	// remaining response records exceeds the specified MaxRecords value, a value is
54	// returned in a marker field of the response. You can retrieve the next set of
55	// records by retrying the command with the returned marker value. Default: 100
56	// Constraints: minimum 20, maximum 100.
57	MaxRecords *int32
58
59	// The name of the scheduled action to retrieve.
60	ScheduledActionName *string
61
62	// The start time in UTC of the scheduled actions to retrieve. Only active
63	// scheduled actions that have invocations after this time are retrieved.
64	StartTime *time.Time
65
66	// The type of the scheduled actions to retrieve.
67	TargetActionType types.ScheduledActionTypeValues
68}
69
70type DescribeScheduledActionsOutput struct {
71
72	// An optional parameter that specifies the starting point to return a set of
73	// response records. When the results of a DescribeScheduledActions request exceed
74	// the value specified in MaxRecords, AWS returns a value in the Marker field of
75	// the response. You can retrieve the next set of response records by providing the
76	// returned marker value in the Marker parameter and retrying the request.
77	Marker *string
78
79	// List of retrieved scheduled actions.
80	ScheduledActions []types.ScheduledAction
81
82	// Metadata pertaining to the operation's result.
83	ResultMetadata middleware.Metadata
84}
85
86func addOperationDescribeScheduledActionsMiddlewares(stack *middleware.Stack, options Options) (err error) {
87	err = stack.Serialize.Add(&awsAwsquery_serializeOpDescribeScheduledActions{}, middleware.After)
88	if err != nil {
89		return err
90	}
91	err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDescribeScheduledActions{}, middleware.After)
92	if err != nil {
93		return err
94	}
95	if err = addSetLoggerMiddleware(stack, options); err != nil {
96		return err
97	}
98	if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
99		return err
100	}
101	if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
102		return err
103	}
104	if err = addResolveEndpointMiddleware(stack, options); err != nil {
105		return err
106	}
107	if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
108		return err
109	}
110	if err = addRetryMiddlewares(stack, options); err != nil {
111		return err
112	}
113	if err = addHTTPSignerV4Middleware(stack, options); err != nil {
114		return err
115	}
116	if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
117		return err
118	}
119	if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
120		return err
121	}
122	if err = addClientUserAgent(stack); err != nil {
123		return err
124	}
125	if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
126		return err
127	}
128	if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
129		return err
130	}
131	if err = addOpDescribeScheduledActionsValidationMiddleware(stack); err != nil {
132		return err
133	}
134	if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeScheduledActions(options.Region), middleware.Before); err != nil {
135		return err
136	}
137	if err = addRequestIDRetrieverMiddleware(stack); err != nil {
138		return err
139	}
140	if err = addResponseErrorMiddleware(stack); err != nil {
141		return err
142	}
143	if err = addRequestResponseLogging(stack, options); err != nil {
144		return err
145	}
146	return nil
147}
148
149// DescribeScheduledActionsAPIClient is a client that implements the
150// DescribeScheduledActions operation.
151type DescribeScheduledActionsAPIClient interface {
152	DescribeScheduledActions(context.Context, *DescribeScheduledActionsInput, ...func(*Options)) (*DescribeScheduledActionsOutput, error)
153}
154
155var _ DescribeScheduledActionsAPIClient = (*Client)(nil)
156
157// DescribeScheduledActionsPaginatorOptions is the paginator options for
158// DescribeScheduledActions
159type DescribeScheduledActionsPaginatorOptions struct {
160	// The maximum number of response records to return in each call. If the number of
161	// remaining response records exceeds the specified MaxRecords value, a value is
162	// returned in a marker field of the response. You can retrieve the next set of
163	// records by retrying the command with the returned marker value. Default: 100
164	// Constraints: minimum 20, maximum 100.
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// DescribeScheduledActionsPaginator is a paginator for DescribeScheduledActions
173type DescribeScheduledActionsPaginator struct {
174	options   DescribeScheduledActionsPaginatorOptions
175	client    DescribeScheduledActionsAPIClient
176	params    *DescribeScheduledActionsInput
177	nextToken *string
178	firstPage bool
179}
180
181// NewDescribeScheduledActionsPaginator returns a new
182// DescribeScheduledActionsPaginator
183func NewDescribeScheduledActionsPaginator(client DescribeScheduledActionsAPIClient, params *DescribeScheduledActionsInput, optFns ...func(*DescribeScheduledActionsPaginatorOptions)) *DescribeScheduledActionsPaginator {
184	if params == nil {
185		params = &DescribeScheduledActionsInput{}
186	}
187
188	options := DescribeScheduledActionsPaginatorOptions{}
189	if params.MaxRecords != nil {
190		options.Limit = *params.MaxRecords
191	}
192
193	for _, fn := range optFns {
194		fn(&options)
195	}
196
197	return &DescribeScheduledActionsPaginator{
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 *DescribeScheduledActionsPaginator) HasMorePages() bool {
207	return p.firstPage || p.nextToken != nil
208}
209
210// NextPage retrieves the next DescribeScheduledActions page.
211func (p *DescribeScheduledActionsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeScheduledActionsOutput, error) {
212	if !p.HasMorePages() {
213		return nil, fmt.Errorf("no more pages available")
214	}
215
216	params := *p.params
217	params.Marker = p.nextToken
218
219	var limit *int32
220	if p.options.Limit > 0 {
221		limit = &p.options.Limit
222	}
223	params.MaxRecords = limit
224
225	result, err := p.client.DescribeScheduledActions(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.Marker
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_opDescribeScheduledActions(region string) *awsmiddleware.RegisterServiceMetadata {
242	return &awsmiddleware.RegisterServiceMetadata{
243		Region:        region,
244		ServiceID:     ServiceID,
245		SigningName:   "redshift",
246		OperationName: "DescribeScheduledActions",
247	}
248}
249