api_op_CreateLogGroup.go 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 a log group with the specified name. You can create up to 20,000 log
  11. // groups per account. You must use the following guidelines when naming a log
  12. // group:
  13. //
  14. // * Log group names must be unique within a region for an Amazon Web
  15. // Services account.
  16. //
  17. // * Log group names can be between 1 and 512 characters
  18. // long.
  19. //
  20. // * Log group names consist of the following characters: a-z, A-Z, 0-9, '_'
  21. // (underscore), '-' (hyphen), '/' (forward slash), '.' (period), and '#' (number
  22. // sign)
  23. //
  24. // When you create a log group, by default the log events in the log group
  25. // never expire. To set a retention policy so that events expire and are deleted
  26. // after a specified time, use PutRetentionPolicy
  27. // (https://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutRetentionPolicy.html).
  28. // If you associate a Key Management Service customer master key (CMK) with the log
  29. // group, ingested data is encrypted using the CMK. This association is stored as
  30. // long as the data encrypted with the CMK is still within CloudWatch Logs. This
  31. // enables CloudWatch Logs to decrypt this data whenever it is requested. If you
  32. // attempt to associate a CMK with the log group but the CMK does not exist or the
  33. // CMK is disabled, you receive an InvalidParameterException error. CloudWatch Logs
  34. // supports only symmetric CMKs. Do not associate an asymmetric CMK with your log
  35. // group. For more information, see Using Symmetric and Asymmetric Keys
  36. // (https://docs.aws.amazon.com/kms/latest/developerguide/symmetric-asymmetric.html).
  37. func (c *Client) CreateLogGroup(ctx context.Context, params *CreateLogGroupInput, optFns ...func(*Options)) (*CreateLogGroupOutput, error) {
  38. if params == nil {
  39. params = &CreateLogGroupInput{}
  40. }
  41. result, metadata, err := c.invokeOperation(ctx, "CreateLogGroup", params, optFns, c.addOperationCreateLogGroupMiddlewares)
  42. if err != nil {
  43. return nil, err
  44. }
  45. out := result.(*CreateLogGroupOutput)
  46. out.ResultMetadata = metadata
  47. return out, nil
  48. }
  49. type CreateLogGroupInput struct {
  50. // The name of the log group.
  51. //
  52. // This member is required.
  53. LogGroupName *string
  54. // The Amazon Resource Name (ARN) of the CMK to use when encrypting log data. For
  55. // more information, see Amazon Resource Names - Key Management Service
  56. // (https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-kms).
  57. KmsKeyId *string
  58. // The key-value pairs to use for the tags. CloudWatch Logs doesn’t support IAM
  59. // policies that prevent users from assigning specified tags to log groups using
  60. // the aws:Resource/key-name or aws:TagKeys condition keys. For more information
  61. // about using tags to control access, see Controlling access to Amazon Web
  62. // Services resources using tags
  63. // (https://docs.aws.amazon.com/IAM/latest/UserGuide/access_tags.html).
  64. Tags map[string]string
  65. noSmithyDocumentSerde
  66. }
  67. type CreateLogGroupOutput struct {
  68. // Metadata pertaining to the operation's result.
  69. ResultMetadata middleware.Metadata
  70. noSmithyDocumentSerde
  71. }
  72. func (c *Client) addOperationCreateLogGroupMiddlewares(stack *middleware.Stack, options Options) (err error) {
  73. err = stack.Serialize.Add(&awsAwsjson11_serializeOpCreateLogGroup{}, middleware.After)
  74. if err != nil {
  75. return err
  76. }
  77. err = stack.Deserialize.Add(&awsAwsjson11_deserializeOpCreateLogGroup{}, middleware.After)
  78. if err != nil {
  79. return err
  80. }
  81. if err = addSetLoggerMiddleware(stack, options); err != nil {
  82. return err
  83. }
  84. if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil {
  85. return err
  86. }
  87. if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil {
  88. return err
  89. }
  90. if err = addResolveEndpointMiddleware(stack, options); err != nil {
  91. return err
  92. }
  93. if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil {
  94. return err
  95. }
  96. if err = addRetryMiddlewares(stack, options); err != nil {
  97. return err
  98. }
  99. if err = addHTTPSignerV4Middleware(stack, options); err != nil {
  100. return err
  101. }
  102. if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil {
  103. return err
  104. }
  105. if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil {
  106. return err
  107. }
  108. if err = addClientUserAgent(stack); err != nil {
  109. return err
  110. }
  111. if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil {
  112. return err
  113. }
  114. if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil {
  115. return err
  116. }
  117. if err = addOpCreateLogGroupValidationMiddleware(stack); err != nil {
  118. return err
  119. }
  120. if err = stack.Initialize.Add(newServiceMetadataMiddleware_opCreateLogGroup(options.Region), middleware.Before); err != nil {
  121. return err
  122. }
  123. if err = addRequestIDRetrieverMiddleware(stack); err != nil {
  124. return err
  125. }
  126. if err = addResponseErrorMiddleware(stack); err != nil {
  127. return err
  128. }
  129. if err = addRequestResponseLogging(stack, options); err != nil {
  130. return err
  131. }
  132. return nil
  133. }
  134. func newServiceMetadataMiddleware_opCreateLogGroup(region string) *awsmiddleware.RegisterServiceMetadata {
  135. return &awsmiddleware.RegisterServiceMetadata{
  136. Region: region,
  137. ServiceID: ServiceID,
  138. SigningName: "logs",
  139. OperationName: "CreateLogGroup",
  140. }
  141. }