1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package databasemigrationservice 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/databasemigrationservice/types" 11 "github.com/aws/smithy-go/middleware" 12 smithyhttp "github.com/aws/smithy-go/transport/http" 13) 14 15// Lists all the event subscriptions for a customer account. The description of a 16// subscription includes SubscriptionName, SNSTopicARN, CustomerID, SourceType, 17// SourceID, CreationTime, and Status. If you specify SubscriptionName, this action 18// lists the description for that subscription. 19func (c *Client) DescribeEventSubscriptions(ctx context.Context, params *DescribeEventSubscriptionsInput, optFns ...func(*Options)) (*DescribeEventSubscriptionsOutput, error) { 20 if params == nil { 21 params = &DescribeEventSubscriptionsInput{} 22 } 23 24 result, metadata, err := c.invokeOperation(ctx, "DescribeEventSubscriptions", params, optFns, addOperationDescribeEventSubscriptionsMiddlewares) 25 if err != nil { 26 return nil, err 27 } 28 29 out := result.(*DescribeEventSubscriptionsOutput) 30 out.ResultMetadata = metadata 31 return out, nil 32} 33 34// 35type DescribeEventSubscriptionsInput struct { 36 37 // Filters applied to event subscriptions. 38 Filters []types.Filter 39 40 // An optional pagination token provided by a previous request. If this parameter 41 // is specified, the response includes only records beyond the marker, up to the 42 // value specified by MaxRecords. 43 Marker *string 44 45 // The maximum number of records to include in the response. If more records exist 46 // than the specified MaxRecords value, a pagination token called a marker is 47 // included in the response so that the remaining results can be retrieved. 48 // Default: 100 Constraints: Minimum 20, maximum 100. 49 MaxRecords *int32 50 51 // The name of the AWS DMS event subscription to be described. 52 SubscriptionName *string 53} 54 55// 56type DescribeEventSubscriptionsOutput struct { 57 58 // A list of event subscriptions. 59 EventSubscriptionsList []types.EventSubscription 60 61 // An optional pagination token provided by a previous request. If this parameter 62 // is specified, the response includes only records beyond the marker, up to the 63 // value specified by MaxRecords. 64 Marker *string 65 66 // Metadata pertaining to the operation's result. 67 ResultMetadata middleware.Metadata 68} 69 70func addOperationDescribeEventSubscriptionsMiddlewares(stack *middleware.Stack, options Options) (err error) { 71 err = stack.Serialize.Add(&awsAwsjson11_serializeOpDescribeEventSubscriptions{}, middleware.After) 72 if err != nil { 73 return err 74 } 75 err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpDescribeEventSubscriptions{}, middleware.After) 76 if err != nil { 77 return err 78 } 79 if err = addSetLoggerMiddleware(stack, options); err != nil { 80 return err 81 } 82 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 83 return err 84 } 85 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 86 return err 87 } 88 if err = addResolveEndpointMiddleware(stack, options); err != nil { 89 return err 90 } 91 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 92 return err 93 } 94 if err = addRetryMiddlewares(stack, options); err != nil { 95 return err 96 } 97 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 98 return err 99 } 100 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 101 return err 102 } 103 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 104 return err 105 } 106 if err = addClientUserAgent(stack); err != nil { 107 return err 108 } 109 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 110 return err 111 } 112 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 113 return err 114 } 115 if err = addOpDescribeEventSubscriptionsValidationMiddleware(stack); err != nil { 116 return err 117 } 118 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeEventSubscriptions(options.Region), middleware.Before); err != nil { 119 return err 120 } 121 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 122 return err 123 } 124 if err = addResponseErrorMiddleware(stack); err != nil { 125 return err 126 } 127 if err = addRequestResponseLogging(stack, options); err != nil { 128 return err 129 } 130 return nil 131} 132 133// DescribeEventSubscriptionsAPIClient is a client that implements the 134// DescribeEventSubscriptions operation. 135type DescribeEventSubscriptionsAPIClient interface { 136 DescribeEventSubscriptions(context.Context, *DescribeEventSubscriptionsInput, ...func(*Options)) (*DescribeEventSubscriptionsOutput, error) 137} 138 139var _ DescribeEventSubscriptionsAPIClient = (*Client)(nil) 140 141// DescribeEventSubscriptionsPaginatorOptions is the paginator options for 142// DescribeEventSubscriptions 143type DescribeEventSubscriptionsPaginatorOptions struct { 144 // The maximum number of records to include in the response. If more records exist 145 // than the specified MaxRecords value, a pagination token called a marker is 146 // included in the response so that the remaining results can be retrieved. 147 // Default: 100 Constraints: Minimum 20, maximum 100. 148 Limit int32 149 150 // Set to true if pagination should stop if the service returns a pagination token 151 // that matches the most recent token provided to the service. 152 StopOnDuplicateToken bool 153} 154 155// DescribeEventSubscriptionsPaginator is a paginator for 156// DescribeEventSubscriptions 157type DescribeEventSubscriptionsPaginator struct { 158 options DescribeEventSubscriptionsPaginatorOptions 159 client DescribeEventSubscriptionsAPIClient 160 params *DescribeEventSubscriptionsInput 161 nextToken *string 162 firstPage bool 163} 164 165// NewDescribeEventSubscriptionsPaginator returns a new 166// DescribeEventSubscriptionsPaginator 167func NewDescribeEventSubscriptionsPaginator(client DescribeEventSubscriptionsAPIClient, params *DescribeEventSubscriptionsInput, optFns ...func(*DescribeEventSubscriptionsPaginatorOptions)) *DescribeEventSubscriptionsPaginator { 168 if params == nil { 169 params = &DescribeEventSubscriptionsInput{} 170 } 171 172 options := DescribeEventSubscriptionsPaginatorOptions{} 173 if params.MaxRecords != nil { 174 options.Limit = *params.MaxRecords 175 } 176 177 for _, fn := range optFns { 178 fn(&options) 179 } 180 181 return &DescribeEventSubscriptionsPaginator{ 182 options: options, 183 client: client, 184 params: params, 185 firstPage: true, 186 } 187} 188 189// HasMorePages returns a boolean indicating whether more pages are available 190func (p *DescribeEventSubscriptionsPaginator) HasMorePages() bool { 191 return p.firstPage || p.nextToken != nil 192} 193 194// NextPage retrieves the next DescribeEventSubscriptions page. 195func (p *DescribeEventSubscriptionsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeEventSubscriptionsOutput, error) { 196 if !p.HasMorePages() { 197 return nil, fmt.Errorf("no more pages available") 198 } 199 200 params := *p.params 201 params.Marker = p.nextToken 202 203 var limit *int32 204 if p.options.Limit > 0 { 205 limit = &p.options.Limit 206 } 207 params.MaxRecords = limit 208 209 result, err := p.client.DescribeEventSubscriptions(ctx, ¶ms, optFns...) 210 if err != nil { 211 return nil, err 212 } 213 p.firstPage = false 214 215 prevToken := p.nextToken 216 p.nextToken = result.Marker 217 218 if p.options.StopOnDuplicateToken && prevToken != nil && p.nextToken != nil && *prevToken == *p.nextToken { 219 p.nextToken = nil 220 } 221 222 return result, nil 223} 224 225func newServiceMetadataMiddleware_opDescribeEventSubscriptions(region string) *awsmiddleware.RegisterServiceMetadata { 226 return &awsmiddleware.RegisterServiceMetadata{ 227 Region: region, 228 ServiceID: ServiceID, 229 SigningName: "dms", 230 OperationName: "DescribeEventSubscriptions", 231 } 232} 233