api_op_PutDestinationPolicy.go 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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/smithy-go/middleware"
  8. smithyhttp "github.com/aws/smithy-go/transport/http"
  9. )
  10. // Creates or updates an access policy associated with an existing destination. An
  11. // access policy is an IAM policy document
  12. // (https://docs.aws.amazon.com/IAM/latest/UserGuide/policies_overview.html) that
  13. // is used to authorize claims to register a subscription filter against a given
  14. // destination. If multiple Amazon Web Services accounts are sending logs to this
  15. // destination, each sender account must be listed separately in the policy. The
  16. // policy does not support specifying * as the Principal or the use of the
  17. // aws:PrincipalOrgId global key.
  18. func (c *Client) PutDestinationPolicy(ctx context.Context, params *PutDestinationPolicyInput, optFns ...func(*Options)) (*PutDestinationPolicyOutput, error) {
  19. if params == nil {
  20. params = &PutDestinationPolicyInput{}
  21. }
  22. result, metadata, err := c.invokeOperation(ctx, "PutDestinationPolicy", params, optFns, c.addOperationPutDestinationPolicyMiddlewares)
  23. if err != nil {
  24. return nil, err
  25. }
  26. out := result.(*PutDestinationPolicyOutput)
  27. out.ResultMetadata = metadata
  28. return out, nil
  29. }
  30. type PutDestinationPolicyInput struct {
  31. // An IAM policy document that authorizes cross-account users to deliver their log
  32. // events to the associated destination. This can be up to 5120 bytes.
  33. //
  34. // This member is required.
  35. AccessPolicy *string
  36. // A name for an existing destination.
  37. //
  38. // This member is required.
  39. DestinationName *string
  40. // Specify true if you are updating an existing destination policy to grant
  41. // permission to an organization ID instead of granting permission to individual
  42. // AWS accounts. Before you update a destination policy this way, you must first
  43. // update the subscription filters in the accounts that send logs to this
  44. // destination. If you do not, the subscription filters might stop working. By
  45. // specifying true for forceUpdate, you are affirming that you have already updated
  46. // the subscription filters. For more information, see Updating an existing
  47. // cross-account subscription
  48. // (https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Cross-Account-Log_Subscription-Update.html)
  49. // If you omit this parameter, the default of false is used.
  50. ForceUpdate *bool
  51. noSmithyDocumentSerde
  52. }
  53. type PutDestinationPolicyOutput struct {
  54. // Metadata pertaining to the operation's result.
  55. ResultMetadata middleware.Metadata
  56. noSmithyDocumentSerde
  57. }
  58. func (c *Client) addOperationPutDestinationPolicyMiddlewares(stack *middleware.Stack, options Options) (err error) {
  59. err = stack.Serialize.Add(&awsAwsjson11_serializeOpPutDestinationPolicy{}, middleware.After)
  60. if err != nil {
  61. return err
  62. }
  63. err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpPutDestinationPolicy{}, middleware.After)
  64. if err != nil {
  65. return err
  66. }
  67. if err = addSetLoggerMiddleware(stack, options); err != nil {
  68. return err
  69. }
  70. if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
  71. return err
  72. }
  73. if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
  74. return err
  75. }
  76. if err = addResolveEndpointMiddleware(stack, options); err != nil {
  77. return err
  78. }
  79. if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
  80. return err
  81. }
  82. if err = addRetryMiddlewares(stack, options); err != nil {
  83. return err
  84. }
  85. if err = addHTTPSignerV4Middleware(stack, options); err != nil {
  86. return err
  87. }
  88. if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
  89. return err
  90. }
  91. if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
  92. return err
  93. }
  94. if err = addClientUserAgent(stack); err != nil {
  95. return err
  96. }
  97. if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
  98. return err
  99. }
  100. if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
  101. return err
  102. }
  103. if err = addOpPutDestinationPolicyValidationMiddleware(stack); err != nil {
  104. return err
  105. }
  106. if err = stack.Initialize.Add(newServiceMetadataMiddleware_opPutDestinationPolicy(options.Region), middleware.Before); err != nil {
  107. return err
  108. }
  109. if err = addRequestIDRetrieverMiddleware(stack); err != nil {
  110. return err
  111. }
  112. if err = addResponseErrorMiddleware(stack); err != nil {
  113. return err
  114. }
  115. if err = addRequestResponseLogging(stack, options); err != nil {
  116. return err
  117. }
  118. return nil
  119. }
  120. func newServiceMetadataMiddleware_opPutDestinationPolicy(region string) *awsmiddleware.RegisterServiceMetadata {
  121. return &awsmiddleware.RegisterServiceMetadata{
  122. Region: region,
  123. ServiceID: ServiceID,
  124. SigningName: "logs",
  125. OperationName: "PutDestinationPolicy",
  126. }
  127. }