api_op_CreateDelivery.go 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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. // Creates a delivery. A delivery is a connection between a logical delivery
  13. // source and a logical delivery destination that you have already created. Only
  14. // some Amazon Web Services services support being configured as a delivery source
  15. // using this operation. These services are listed as Supported [V2 Permissions] in
  16. // the table at Enabling logging from Amazon Web Services services. (https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/AWS-logs-and-resource-policy.html)
  17. // A delivery destination can represent a log group in CloudWatch Logs, an Amazon
  18. // S3 bucket, or a delivery stream in Kinesis Data Firehose. To configure logs
  19. // delivery between a supported Amazon Web Services service and a destination, you
  20. // must do the following:
  21. // - Create a delivery source, which is a logical object that represents the
  22. // resource that is actually sending the logs. For more information, see
  23. // PutDeliverySource (https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutDeliverySource.html)
  24. // .
  25. // - Create a delivery destination, which is a logical object that represents
  26. // the actual delivery destination. For more information, see
  27. // PutDeliveryDestination (https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutDeliveryDestination.html)
  28. // .
  29. // - If you are delivering logs cross-account, you must use
  30. // PutDeliveryDestinationPolicy (https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutDeliveryDestinationPolicy.html)
  31. // in the destination account to assign an IAM policy to the destination. This
  32. // policy allows delivery to that destination.
  33. // - Use CreateDelivery to create a delivery by pairing exactly one delivery
  34. // source and one delivery destination.
  35. //
  36. // You can configure a single delivery source to send logs to multiple
  37. // destinations by creating multiple deliveries. You can also create multiple
  38. // deliveries to configure multiple delivery sources to send logs to the same
  39. // delivery destination. You can't update an existing delivery. You can only create
  40. // and delete deliveries.
  41. func (c *Client) CreateDelivery(ctx context.Context, params *CreateDeliveryInput, optFns ...func(*Options)) (*CreateDeliveryOutput, error) {
  42. if params == nil {
  43. params = &CreateDeliveryInput{}
  44. }
  45. result, metadata, err := c.invokeOperation(ctx, "CreateDelivery", params, optFns, c.addOperationCreateDeliveryMiddlewares)
  46. if err != nil {
  47. return nil, err
  48. }
  49. out := result.(*CreateDeliveryOutput)
  50. out.ResultMetadata = metadata
  51. return out, nil
  52. }
  53. type CreateDeliveryInput struct {
  54. // The ARN of the delivery destination to use for this delivery.
  55. //
  56. // This member is required.
  57. DeliveryDestinationArn *string
  58. // The name of the delivery source to use for this delivery.
  59. //
  60. // This member is required.
  61. DeliverySourceName *string
  62. // An optional list of key-value pairs to associate with the resource. For more
  63. // information about tagging, see Tagging Amazon Web Services resources (https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html)
  64. Tags map[string]string
  65. noSmithyDocumentSerde
  66. }
  67. type CreateDeliveryOutput struct {
  68. // A structure that contains information about the delivery that you just created.
  69. Delivery *types.Delivery
  70. // Metadata pertaining to the operation's result.
  71. ResultMetadata middleware.Metadata
  72. noSmithyDocumentSerde
  73. }
  74. func (c *Client) addOperationCreateDeliveryMiddlewares(stack *middleware.Stack, options Options) (err error) {
  75. if err := stack.Serialize.Add(&setOperationInputMiddleware{}, middleware.After); err != nil {
  76. return err
  77. }
  78. err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateDelivery{}, middleware.After)
  79. if err != nil {
  80. return err
  81. }
  82. err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateDelivery{}, middleware.After)
  83. if err != nil {
  84. return err
  85. }
  86. if err := addProtocolFinalizerMiddlewares(stack, options, "CreateDelivery"); err != nil {
  87. return fmt.Errorf("add protocol finalizers: %v", err)
  88. }
  89. if err = addlegacyEndpointContextSetter(stack, options); err != nil {
  90. return err
  91. }
  92. if err = addSetLoggerMiddleware(stack, options); err != nil {
  93. return err
  94. }
  95. if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
  96. return err
  97. }
  98. if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
  99. return err
  100. }
  101. if err = addResolveEndpointMiddleware(stack, options); err != nil {
  102. return err
  103. }
  104. if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
  105. return err
  106. }
  107. if err = addRetryMiddlewares(stack, options); err != nil {
  108. return err
  109. }
  110. if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
  111. return err
  112. }
  113. if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
  114. return err
  115. }
  116. if err = addClientUserAgent(stack, options); err != nil {
  117. return err
  118. }
  119. if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
  120. return err
  121. }
  122. if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
  123. return err
  124. }
  125. if err = addSetLegacyContextSigningOptionsMiddleware(stack); err != nil {
  126. return err
  127. }
  128. if err = addOpCreateDeliveryValidationMiddleware(stack); err != nil {
  129. return err
  130. }
  131. if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateDelivery(options.Region), middleware.Before); err != nil {
  132. return err
  133. }
  134. if err = awsmiddleware.AddRecursionDetection(stack); err != nil {
  135. return err
  136. }
  137. if err = addRequestIDRetrieverMiddleware(stack); err != nil {
  138. return err
  139. }
  140. if err = addResponseErrorMiddleware(stack); err != nil {
  141. return err
  142. }
  143. if err = addRequestResponseLogging(stack, options); err != nil {
  144. return err
  145. }
  146. if err = addDisableHTTPSMiddleware(stack, options); err != nil {
  147. return err
  148. }
  149. return nil
  150. }
  151. func newServiceMetadataMiddleware_opCreateDelivery(region string) *awsmiddleware.RegisterServiceMetadata {
  152. return &awsmiddleware.RegisterServiceMetadata{
  153. Region: region,
  154. ServiceID: ServiceID,
  155. OperationName: "CreateDelivery",
  156. }
  157. }