api_op_PutDestination.go 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. // Code generated by smithy-go-codegen DO NOT EDIT.
  2. package cloudwatchlogs
  3. import (
  4. "context"
  5. awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware"
  6. "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
  7. "github.com/aws/aws-sdk-go-v2/service/cloudwatchlogs/types"
  8. "github.com/aws/smithy-go/middleware"
  9. smithyhttp "github.com/aws/smithy-go/transport/http"
  10. )
  11. // Creates or updates a destination. This operation is used only to create
  12. // destinations for cross-account subscriptions. A destination encapsulates a
  13. // physical resource (such as an Amazon Kinesis stream) and enables you to
  14. // subscribe to a real-time stream of log events for a different account, ingested
  15. // using PutLogEvents
  16. // (https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html).
  17. // Through an access policy, a destination controls what is written to it. By
  18. // default, PutDestination does not set any access policy with the destination,
  19. // which means a cross-account user cannot call PutSubscriptionFilter
  20. // (https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutSubscriptionFilter.html)
  21. // against this destination. To enable this, the destination owner must call
  22. // PutDestinationPolicy
  23. // (https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutDestinationPolicy.html)
  24. // after PutDestination. To perform a PutDestination operation, you must also have
  25. // the iam:PassRole permission.
  26. func (c *Client) PutDestination(ctx context.Context, params *PutDestinationInput, optFns ...func(*Options)) (*PutDestinationOutput, error) {
  27. if params == nil {
  28. params = &PutDestinationInput{}
  29. }
  30. result, metadata, err := c.invokeOperation(ctx, "PutDestination", params, optFns, c.addOperationPutDestinationMiddlewares)
  31. if err != nil {
  32. return nil, err
  33. }
  34. out := result.(*PutDestinationOutput)
  35. out.ResultMetadata = metadata
  36. return out, nil
  37. }
  38. type PutDestinationInput struct {
  39. // A name for the destination.
  40. //
  41. // This member is required.
  42. DestinationName *string
  43. // The ARN of an IAM role that grants CloudWatch Logs permissions to call the
  44. // Amazon Kinesis PutRecord operation on the destination stream.
  45. //
  46. // This member is required.
  47. RoleArn *string
  48. // The ARN of an Amazon Kinesis stream to which to deliver matching log events.
  49. //
  50. // This member is required.
  51. TargetArn *string
  52. noSmithyDocumentSerde
  53. }
  54. type PutDestinationOutput struct {
  55. // The destination.
  56. Destination *types.Destination
  57. // Metadata pertaining to the operation's result.
  58. ResultMetadata middleware.Metadata
  59. noSmithyDocumentSerde
  60. }
  61. func (c *Client) addOperationPutDestinationMiddlewares(stack *middleware.Stack, options Options) (err error) {
  62. err = stack.Serialize.Add(&awsAwsjson11_serializeOpPutDestination{}, middleware.After)
  63. if err != nil {
  64. return err
  65. }
  66. err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpPutDestination{}, middleware.After)
  67. if err != nil {
  68. return err
  69. }
  70. if err = addSetLoggerMiddleware(stack, options); err != nil {
  71. return err
  72. }
  73. if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
  74. return err
  75. }
  76. if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
  77. return err
  78. }
  79. if err = addResolveEndpointMiddleware(stack, options); err != nil {
  80. return err
  81. }
  82. if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
  83. return err
  84. }
  85. if err = addRetryMiddlewares(stack, options); err != nil {
  86. return err
  87. }
  88. if err = addHTTPSignerV4Middleware(stack, options); err != nil {
  89. return err
  90. }
  91. if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
  92. return err
  93. }
  94. if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
  95. return err
  96. }
  97. if err = addClientUserAgent(stack); err != nil {
  98. return err
  99. }
  100. if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
  101. return err
  102. }
  103. if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
  104. return err
  105. }
  106. if err = addOpPutDestinationValidationMiddleware(stack); err != nil {
  107. return err
  108. }
  109. if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPutDestination(options.Region), middleware.Before); err != nil {
  110. return err
  111. }
  112. if err = addRequestIDRetrieverMiddleware(stack); err != nil {
  113. return err
  114. }
  115. if err = addResponseErrorMiddleware(stack); err != nil {
  116. return err
  117. }
  118. if err = addRequestResponseLogging(stack, options); err != nil {
  119. return err
  120. }
  121. return nil
  122. }
  123. func newServiceMetadataMiddleware_opPutDestination(region string) *awsmiddleware.RegisterServiceMetadata {
  124. return &awsmiddleware.RegisterServiceMetadata{
  125. Region: region,
  126. ServiceID: ServiceID,
  127. SigningName: "logs",
  128. OperationName: "PutDestination",
  129. }
  130. }