api_op_DescribeDestinations.go 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. // Code generated by smithy-go-codegen DO NOT EDIT.
  2. package cloudwatchlogs
  3. import (
  4. "context"
  5. "fmt"
  6. awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
  7. "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
  8. "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/types"
  9. "github.com/aws/smithy-go/middleware"
  10. smithyhttp "github.com/aws/smithy-go/transport/http"
  11. )
  12. // Lists all your destinations. The results are ASCII-sorted by destination name.
  13. func (c *Client) DescribeDestinations(ctx context.Context, params *DescribeDestinationsInput, optFns ...func(*Options)) (*DescribeDestinationsOutput, error) {
  14. if params == nil {
  15. params = &DescribeDestinationsInput{}
  16. }
  17. result, metadata, err := c.invokeOperation(ctx, "DescribeDestinations", params, optFns, c.addOperationDescribeDestinationsMiddlewares)
  18. if err != nil {
  19. return nil, err
  20. }
  21. out := result.(*DescribeDestinationsOutput)
  22. out.ResultMetadata = metadata
  23. return out, nil
  24. }
  25. type DescribeDestinationsInput struct {
  26. // The prefix to match. If you don't specify a value, no prefix filter is applied.
  27. DestinationNamePrefix *string
  28. // The maximum number of items returned. If you don't specify a value, the default
  29. // is up to 50 items.
  30. Limit *int32
  31. // The token for the next set of items to return. (You received this token from a
  32. // previous call.)
  33. NextToken *string
  34. noSmithyDocumentSerde
  35. }
  36. type DescribeDestinationsOutput struct {
  37. // The destinations.
  38. Destinations []types.Destination
  39. // The token for the next set of items to return. The token expires after 24 hours.
  40. NextToken *string
  41. // Metadata pertaining to the operation's result.
  42. ResultMetadata middleware.Metadata
  43. noSmithyDocumentSerde
  44. }
  45. func (c *Client) addOperationDescribeDestinationsMiddlewares(stack *middleware.Stack, options Options) (err error) {
  46. err = stack.Serialize.Add(&awsAwsjson11_serializeOpDescribeDestinations{}, middleware.After)
  47. if err != nil {
  48. return err
  49. }
  50. err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpDescribeDestinations{}, middleware.After)
  51. if err != nil {
  52. return err
  53. }
  54. if err = addSetLoggerMiddleware(stack, options); err != nil {
  55. return err
  56. }
  57. if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
  58. return err
  59. }
  60. if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
  61. return err
  62. }
  63. if err = addResolveEndpointMiddleware(stack, options); err != nil {
  64. return err
  65. }
  66. if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
  67. return err
  68. }
  69. if err = addRetryMiddlewares(stack, options); err != nil {
  70. return err
  71. }
  72. if err = addHTTPSignerV4Middleware(stack, options); err != nil {
  73. return err
  74. }
  75. if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
  76. return err
  77. }
  78. if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
  79. return err
  80. }
  81. if err = addClientUserAgent(stack); err != nil {
  82. return err
  83. }
  84. if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
  85. return err
  86. }
  87. if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
  88. return err
  89. }
  90. if err = stack.Initialize.Add(newServiceMetadataMiddleware_opDescribeDestinations(options.Region), middleware.Before); err != nil {
  91. return err
  92. }
  93. if err = addRequestIDRetrieverMiddleware(stack); err != nil {
  94. return err
  95. }
  96. if err = addResponseErrorMiddleware(stack); err != nil {
  97. return err
  98. }
  99. if err = addRequestResponseLogging(stack, options); err != nil {
  100. return err
  101. }
  102. return nil
  103. }
  104. // DescribeDestinationsAPIClient is a client that implements the
  105. // DescribeDestinations operation.
  106. type DescribeDestinationsAPIClient interface {
  107. DescribeDestinations(context.Context, *DescribeDestinationsInput, ...func(*Options)) (*DescribeDestinationsOutput, error)
  108. }
  109. var _ DescribeDestinationsAPIClient = (*Client)(nil)
  110. // DescribeDestinationsPaginatorOptions is the paginator options for
  111. // DescribeDestinations
  112. type DescribeDestinationsPaginatorOptions struct {
  113. // The maximum number of items returned. If you don't specify a value, the default
  114. // is up to 50 items.
  115. Limit int32
  116. // Set to true if pagination should stop if the service returns a pagination token
  117. // that matches the most recent token provided to the service.
  118. StopOnDuplicateToken bool
  119. }
  120. // DescribeDestinationsPaginator is a paginator for DescribeDestinations
  121. type DescribeDestinationsPaginator struct {
  122. options DescribeDestinationsPaginatorOptions
  123. client DescribeDestinationsAPIClient
  124. params *DescribeDestinationsInput
  125. nextToken *string
  126. firstPage bool
  127. }
  128. // NewDescribeDestinationsPaginator returns a new DescribeDestinationsPaginator
  129. func NewDescribeDestinationsPaginator(client DescribeDestinationsAPIClient, params *DescribeDestinationsInput, optFns ...func(*DescribeDestinationsPaginatorOptions)) *DescribeDestinationsPaginator {
  130. if params == nil {
  131. params = &DescribeDestinationsInput{}
  132. }
  133. options := DescribeDestinationsPaginatorOptions{}
  134. if params.Limit != nil {
  135. options.Limit = *params.Limit
  136. }
  137. for _, fn := range optFns {
  138. fn(&options)
  139. }
  140. return &DescribeDestinationsPaginator{
  141. options: options,
  142. client: client,
  143. params: params,
  144. firstPage: true,
  145. nextToken: params.NextToken,
  146. }
  147. }
  148. // HasMorePages returns a boolean indicating whether more pages are available
  149. func (p *DescribeDestinationsPaginator) HasMorePages() bool {
  150. return p.firstPage || (p.nextToken != nil && len(*p.nextToken) != 0)
  151. }
  152. // NextPage retrieves the next DescribeDestinations page.
  153. func (p *DescribeDestinationsPaginator) NextPage(ctx context.Context, optFns ...func(*Options)) (*DescribeDestinationsOutput, error) {
  154. if !p.HasMorePages() {
  155. return nil, fmt.Errorf("no more pages available")
  156. }
  157. params := *p.params
  158. params.NextToken = p.nextToken
  159. var limit *int32
  160. if p.options.Limit > 0 {
  161. limit = &p.options.Limit
  162. }
  163. params.Limit = limit
  164. result, err := p.client.DescribeDestinations(ctx, &params, optFns...)
  165. if err != nil {
  166. return nil, err
  167. }
  168. p.firstPage = false
  169. prevToken := p.nextToken
  170. p.nextToken = result.NextToken
  171. if p.options.StopOnDuplicateToken &&
  172. prevToken != nil &&
  173. p.nextToken != nil &&
  174. *prevToken == *p.nextToken {
  175. p.nextToken = nil
  176. }
  177. return result, nil
  178. }
  179. func newServiceMetadataMiddleware_opDescribeDestinations(region string) *awsmiddleware.RegisterServiceMetadata {
  180. return &awsmiddleware.RegisterServiceMetadata{
  181. Region: region,
  182. ServiceID: ServiceID,
  183. SigningName: "logs",
  184. OperationName: "DescribeDestinations",
  185. }
  186. }