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) 14 15// Lists descriptions of all the Amazon Redshift event notification subscriptions 16// for a customer account. If you specify a subscription name, lists the 17// description for that subscription. If you specify both tag keys and tag values 18// in the same request, Amazon Redshift returns all event notification 19// subscriptions that match any combination of the specified keys and values. For 20// example, if you have owner and environment for tag keys, and admin and test for 21// tag values, all subscriptions that have any combination of those values are 22// returned. If both tag keys and values are omitted from the request, 23// subscriptions are returned regardless of whether they have tag keys or values 24// associated with them. 25func (c *Client) DescribeEventSubscriptions(ctx context.Context, params *DescribeEventSubscriptionsInput, optFns ...func(*Options)) (*DescribeEventSubscriptionsOutput, error) { 26 if params == nil { 27 params = &DescribeEventSubscriptionsInput{} 28 } 29 30 result, metadata, err := c.invokeOperation(ctx, "DescribeEventSubscriptions", params, optFns, addOperationDescribeEventSubscriptionsMiddlewares) 31 if err != nil { 32 return nil, err 33 } 34 35 out := result.(*DescribeEventSubscriptionsOutput) 36 out.ResultMetadata = metadata 37 return out, nil 38} 39 40// 41type DescribeEventSubscriptionsInput struct { 42 43 // An optional parameter that specifies the starting point to return a set of 44 // response records. When the results of a DescribeEventSubscriptions request 45 // exceed the value specified in MaxRecords, AWS returns a value in the Marker 46 // field of the response. You can retrieve the next set of response records by 47 // providing the returned marker value in the Marker parameter and retrying the 48 // request. 49 Marker *string 50 51 // The maximum number of response records to return in each call. If the number of 52 // remaining response records exceeds the specified MaxRecords value, a value is 53 // returned in a marker field of the response. You can retrieve the next set of 54 // records by retrying the command with the returned marker value. Default: 100 55 // Constraints: minimum 20, maximum 100. 56 MaxRecords *int32 57 58 // The name of the Amazon Redshift event notification subscription to be described. 59 SubscriptionName *string 60 61 // A tag key or keys for which you want to return all matching event notification 62 // subscriptions that are associated with the specified key or keys. For example, 63 // suppose that you have subscriptions that are tagged with keys called owner and 64 // environment. If you specify both of these tag keys in the request, Amazon 65 // Redshift returns a response with the subscriptions that have either or both of 66 // these tag keys associated with them. 67 TagKeys []string 68 69 // A tag value or values for which you want to return all matching event 70 // notification subscriptions that are associated with the specified tag value or 71 // values. For example, suppose that you have subscriptions that are tagged with 72 // values called admin and test. If you specify both of these tag values in the 73 // request, Amazon Redshift returns a response with the subscriptions that have 74 // either or both of these tag values associated with them. 75 TagValues []string 76} 77 78// 79type DescribeEventSubscriptionsOutput struct { 80 81 // A list of event subscriptions. 82 EventSubscriptionsList []types.EventSubscription 83 84 // A value that indicates the starting point for the next set of response records 85 // in a subsequent request. If a value is returned in a response, you can retrieve 86 // the next set of records by providing this returned marker value in the Marker 87 // parameter and retrying the command. If the Marker field is empty, all response 88 // records have been retrieved for the request. 89 Marker *string 90 91 // Metadata pertaining to the operation's result. 92 ResultMetadata middleware.Metadata 93} 94 95func addOperationDescribeEventSubscriptionsMiddlewares(stack *middleware.Stack, options Options) (err error) { 96 err = stack.Serialize.Add(&awsAwsquery_serializeOpDescribeEventSubscriptions{}, middleware.After) 97 if err != nil { 98 return err 99 } 100 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpDescribeEventSubscriptions{}, middleware.After) 101 if err != nil { 102 return err 103 } 104 if err = addSetLoggerMiddleware(stack, options); err != nil { 105 return err 106 } 107 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 108 return err 109 } 110 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 111 return err 112 } 113 if err = addResolveEndpointMiddleware(stack, options); err != nil { 114 return err 115 } 116 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 117 return err 118 } 119 if err = addRetryMiddlewares(stack, options); err != nil { 120 return err 121 } 122 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 123 return err 124 } 125 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 126 return err 127 } 128 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 129 return err 130 } 131 if err = addClientUserAgent(stack); err != nil { 132 return err 133 } 134 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 135 return err 136 } 137 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 138 return err 139 } 140 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeEventSubscriptions(options.Region), middleware.Before); err != nil { 141 return err 142 } 143 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 144 return err 145 } 146 if err = addResponseErrorMiddleware(stack); err != nil { 147 return err 148 } 149 if err = addRequestResponseLogging(stack, options); err != nil { 150 return err 151 } 152 return nil 153} 154 155// DescribeEventSubscriptionsAPIClient is a client that implements the 156// DescribeEventSubscriptions operation. 157type DescribeEventSubscriptionsAPIClient interface { 158 DescribeEventSubscriptions(context.Context, *DescribeEventSubscriptionsInput, ...func(*Options)) (*DescribeEventSubscriptionsOutput, error) 159} 160 161var _ DescribeEventSubscriptionsAPIClient = (*Client)(nil) 162 163// DescribeEventSubscriptionsPaginatorOptions is the paginator options for 164// DescribeEventSubscriptions 165type DescribeEventSubscriptionsPaginatorOptions struct { 166 // The maximum number of response records to return in each call. If the number of 167 // remaining response records exceeds the specified MaxRecords value, a value is 168 // returned in a marker field of the response. You can retrieve the next set of 169 // records by retrying the command with the returned marker value. Default: 100 170 // Constraints: minimum 20, maximum 100. 171 Limit int32 172 173 // Set to true if pagination should stop if the service returns a pagination token 174 // that matches the most recent token provided to the service. 175 StopOnDuplicateToken bool 176} 177 178// DescribeEventSubscriptionsPaginator is a paginator for 179// DescribeEventSubscriptions 180type DescribeEventSubscriptionsPaginator struct { 181 options DescribeEventSubscriptionsPaginatorOptions 182 client DescribeEventSubscriptionsAPIClient 183 params *DescribeEventSubscriptionsInput 184 nextToken *string 185 firstPage bool 186} 187 188// NewDescribeEventSubscriptionsPaginator returns a new 189// DescribeEventSubscriptionsPaginator 190func NewDescribeEventSubscriptionsPaginator(client DescribeEventSubscriptionsAPIClient, params *DescribeEventSubscriptionsInput, optFns ...func(*DescribeEventSubscriptionsPaginatorOptions)) *DescribeEventSubscriptionsPaginator { 191 if params == nil { 192 params = &DescribeEventSubscriptionsInput{} 193 } 194 195 options := DescribeEventSubscriptionsPaginatorOptions{} 196 if params.MaxRecords != nil { 197 options.Limit = *params.MaxRecords 198 } 199 200 for _, fn := range optFns { 201 fn(&options) 202 } 203 204 return &DescribeEventSubscriptionsPaginator{ 205 options: options, 206 client: client, 207 params: params, 208 firstPage: true, 209 } 210} 211 212// HasMorePages returns a boolean indicating whether more pages are available 213func (p *DescribeEventSubscriptionsPaginator) HasMorePages() bool { 214 return p.firstPage || p.nextToken != nil 215} 216 217// NextPage retrieves the next DescribeEventSubscriptions page. 218func (p *DescribeEventSubscriptionsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeEventSubscriptionsOutput, error) { 219 if !p.HasMorePages() { 220 return nil, fmt.Errorf("no more pages available") 221 } 222 223 params := *p.params 224 params.Marker = p.nextToken 225 226 var limit *int32 227 if p.options.Limit > 0 { 228 limit = &p.options.Limit 229 } 230 params.MaxRecords = limit 231 232 result, err := p.client.DescribeEventSubscriptions(ctx, ¶ms, optFns...) 233 if err != nil { 234 return nil, err 235 } 236 p.firstPage = false 237 238 prevToken := p.nextToken 239 p.nextToken = result.Marker 240 241 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 242 p.nextToken = nil 243 } 244 245 return result, nil 246} 247 248func newServiceMetadataMiddleware_opDescribeEventSubscriptions(region string) *awsmiddleware.RegisterServiceMetadata { 249 return &awsmiddleware.RegisterServiceMetadata{ 250 Region: region, 251 ServiceID: ServiceID, 252 SigningName: "redshift", 253 OperationName: "DescribeEventSubscriptions", 254 } 255} 256