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// Returns events related to clusters, security groups, snapshots, and parameter 17// groups for the past 14 days. Events specific to a particular cluster, security 18// group, snapshot or parameter group can be obtained by providing the name as a 19// parameter. By default, the past hour of events are returned. 20func (c *Client) DescribeEvents(ctx context.Context, params *DescribeEventsInput, optFns ...func(*Options)) (*DescribeEventsOutput, error) { 21 if params == nil { 22 params = &DescribeEventsInput{} 23 } 24 25 result, metadata, err := c.invokeOperation(ctx, "DescribeEvents", params, optFns, addOperationDescribeEventsMiddlewares) 26 if err != nil { 27 return nil, err 28 } 29 30 out := result.(*DescribeEventsOutput) 31 out.ResultMetadata = metadata 32 return out, nil 33} 34 35// 36type DescribeEventsInput struct { 37 38 // The number of minutes prior to the time of the request for which to retrieve 39 // events. For example, if the request is sent at 18:00 and you specify a duration 40 // of 60, then only events which have occurred after 17:00 will be returned. 41 // Default: 60 42 Duration *int32 43 44 // The end of the time interval for which to retrieve events, specified in ISO 8601 45 // format. For more information about ISO 8601, go to the ISO8601 Wikipedia page. 46 // (http://en.wikipedia.org/wiki/ISO_8601) Example: 2009-07-08T18:00Z 47 EndTime *time.Time 48 49 // An optional parameter that specifies the starting point to return a set of 50 // response records. When the results of a DescribeEvents request exceed the value 51 // specified in MaxRecords, AWS returns a value in the Marker field of the 52 // response. You can retrieve the next set of response records by providing the 53 // returned marker value in the Marker parameter and retrying the request. 54 Marker *string 55 56 // The maximum number of response records to return in each call. If the number of 57 // remaining response records exceeds the specified MaxRecords value, a value is 58 // returned in a marker field of the response. You can retrieve the next set of 59 // records by retrying the command with the returned marker value. Default: 100 60 // Constraints: minimum 20, maximum 100. 61 MaxRecords *int32 62 63 // The identifier of the event source for which events will be returned. If this 64 // parameter is not specified, then all sources are included in the response. 65 // Constraints: If SourceIdentifier is supplied, SourceType must also be 66 // provided. 67 // 68 // * Specify a cluster identifier when SourceType is cluster. 69 // 70 // * Specify 71 // a cluster security group name when SourceType is cluster-security-group. 72 // 73 // * 74 // Specify a cluster parameter group name when SourceType is 75 // cluster-parameter-group. 76 // 77 // * Specify a cluster snapshot identifier when 78 // SourceType is cluster-snapshot. 79 SourceIdentifier *string 80 81 // The event source to retrieve events for. If no value is specified, all events 82 // are returned. Constraints: If SourceType is supplied, SourceIdentifier must also 83 // be provided. 84 // 85 // * Specify cluster when SourceIdentifier is a cluster 86 // identifier. 87 // 88 // * Specify cluster-security-group when SourceIdentifier is a cluster 89 // security group name. 90 // 91 // * Specify cluster-parameter-group when SourceIdentifier is 92 // a cluster parameter group name. 93 // 94 // * Specify cluster-snapshot when 95 // SourceIdentifier is a cluster snapshot identifier. 96 SourceType types.SourceType 97 98 // The beginning of the time interval to retrieve events for, specified in ISO 8601 99 // format. For more information about ISO 8601, go to the ISO8601 Wikipedia page. 100 // (http://en.wikipedia.org/wiki/ISO_8601) Example: 2009-07-08T18:00Z 101 StartTime *time.Time 102} 103 104// 105type DescribeEventsOutput struct { 106 107 // A list of Event instances. 108 Events []types.Event 109 110 // A value that indicates the starting point for the next set of response records 111 // in a subsequent request. If a value is returned in a response, you can retrieve 112 // the next set of records by providing this returned marker value in the Marker 113 // parameter and retrying the command. If the Marker field is empty, all response 114 // records have been retrieved for the request. 115 Marker *string 116 117 // Metadata pertaining to the operation's result. 118 ResultMetadata middleware.Metadata 119} 120 121func addOperationDescribeEventsMiddlewares(stack *middleware.Stack, options Options) (err error) { 122 err = stack.Serialize.Add(&awsAwsquery_serializeOpDescribeEvents{}, middleware.After) 123 if err != nil { 124 return err 125 } 126 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDescribeEvents{}, middleware.After) 127 if err != nil { 128 return err 129 } 130 if err = addSetLoggerMiddleware(stack, options); err != nil { 131 return err 132 } 133 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 134 return err 135 } 136 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 137 return err 138 } 139 if err = addResolveEndpointMiddleware(stack, options); err != nil { 140 return err 141 } 142 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 143 return err 144 } 145 if err = addRetryMiddlewares(stack, options); err != nil { 146 return err 147 } 148 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 149 return err 150 } 151 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 152 return err 153 } 154 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 155 return err 156 } 157 if err = addClientUserAgent(stack); err != nil { 158 return err 159 } 160 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 161 return err 162 } 163 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 164 return err 165 } 166 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeEvents(options.Region), middleware.Before); err != nil { 167 return err 168 } 169 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 170 return err 171 } 172 if err = addResponseErrorMiddleware(stack); err != nil { 173 return err 174 } 175 if err = addRequestResponseLogging(stack, options); err != nil { 176 return err 177 } 178 return nil 179} 180 181// DescribeEventsAPIClient is a client that implements the DescribeEvents 182// operation. 183type DescribeEventsAPIClient interface { 184 DescribeEvents(context.Context, *DescribeEventsInput, ...func(*Options)) (*DescribeEventsOutput, error) 185} 186 187var _ DescribeEventsAPIClient = (*Client)(nil) 188 189// DescribeEventsPaginatorOptions is the paginator options for DescribeEvents 190type DescribeEventsPaginatorOptions struct { 191 // The maximum number of response records to return in each call. If the number of 192 // remaining response records exceeds the specified MaxRecords value, a value is 193 // returned in a marker field of the response. You can retrieve the next set of 194 // records by retrying the command with the returned marker value. Default: 100 195 // Constraints: minimum 20, maximum 100. 196 Limit int32 197 198 // Set to true if pagination should stop if the service returns a pagination token 199 // that matches the most recent token provided to the service. 200 StopOnDuplicateToken bool 201} 202 203// DescribeEventsPaginator is a paginator for DescribeEvents 204type DescribeEventsPaginator struct { 205 options DescribeEventsPaginatorOptions 206 client DescribeEventsAPIClient 207 params *DescribeEventsInput 208 nextToken *string 209 firstPage bool 210} 211 212// NewDescribeEventsPaginator returns a new DescribeEventsPaginator 213func NewDescribeEventsPaginator(client DescribeEventsAPIClient, params *DescribeEventsInput, optFns ...func(*DescribeEventsPaginatorOptions)) *DescribeEventsPaginator { 214 if params == nil { 215 params = &DescribeEventsInput{} 216 } 217 218 options := DescribeEventsPaginatorOptions{} 219 if params.MaxRecords != nil { 220 options.Limit = *params.MaxRecords 221 } 222 223 for _, fn := range optFns { 224 fn(&options) 225 } 226 227 return &DescribeEventsPaginator{ 228 options: options, 229 client: client, 230 params: params, 231 firstPage: true, 232 } 233} 234 235// HasMorePages returns a boolean indicating whether more pages are available 236func (p *DescribeEventsPaginator) HasMorePages() bool { 237 return p.firstPage || p.nextToken != nil 238} 239 240// NextPage retrieves the next DescribeEvents page. 241func (p *DescribeEventsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeEventsOutput, error) { 242 if !p.HasMorePages() { 243 return nil, fmt.Errorf("no more pages available") 244 } 245 246 params := *p.params 247 params.Marker = p.nextToken 248 249 var limit *int32 250 if p.options.Limit > 0 { 251 limit = &p.options.Limit 252 } 253 params.MaxRecords = limit 254 255 result, err := p.client.DescribeEvents(ctx, ¶ms, optFns...) 256 if err != nil { 257 return nil, err 258 } 259 p.firstPage = false 260 261 prevToken := p.nextToken 262 p.nextToken = result.Marker 263 264 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 265 p.nextToken = nil 266 } 267 268 return result, nil 269} 270 271func newServiceMetadataMiddleware_opDescribeEvents(region string) *awsmiddleware.RegisterServiceMetadata { 272 return &awsmiddleware.RegisterServiceMetadata{ 273 Region: region, 274 ServiceID: ServiceID, 275 SigningName: "redshift", 276 OperationName: "DescribeEvents", 277 } 278} 279