{-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE DuplicateRecordFields #-} {-# LANGUAGE NamedFieldPuns #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RecordWildCards #-} {-# LANGUAGE StrictData #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE NoImplicitPrelude #-} {-# OPTIONS_GHC -fno-warn-unused-binds #-} {-# OPTIONS_GHC -fno-warn-unused-imports #-} {-# OPTIONS_GHC -fno-warn-unused-matches #-} -- Derived from AWS service descriptions, licensed under Apache 2.0. -- | -- Module : Amazonka.CloudTrail.AddTags -- Copyright : (c) 2013-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- Adds one or more tags to a trail or event data store, up to a limit of -- 50. Overwrites an existing tag\'s value when a new value is specified -- for an existing tag key. Tag key names must be unique for a trail; you -- cannot have two keys with the same name but different values. If you -- specify a key without a value, the tag will be created with the -- specified key and a value of null. You can tag a trail or event data -- store that applies to all Amazon Web Services Regions only from the -- Region in which the trail or event data store was created (also known as -- its home region). module Amazonka.CloudTrail.AddTags ( -- * Creating a Request AddTags (..), newAddTags, -- * Request Lenses addTags_resourceId, addTags_tagsList, -- * Destructuring the Response AddTagsResponse (..), newAddTagsResponse, -- * Response Lenses addTagsResponse_httpStatus, ) where import Amazonka.CloudTrail.Types import qualified Amazonka.Core as Core import qualified Amazonka.Core.Lens.Internal as Lens import qualified Amazonka.Data as Data import qualified Amazonka.Prelude as Prelude import qualified Amazonka.Request as Request import qualified Amazonka.Response as Response -- | Specifies the tags to add to a trail or event data store. -- -- /See:/ 'newAddTags' smart constructor. data AddTags = AddTags' { -- | Specifies the ARN of the trail or event data store to which one or more -- tags will be added. The format of a trail ARN is: -- -- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@ resourceId :: Prelude.Text, -- | Contains a list of tags, up to a limit of 50 tagsList :: [Tag] } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'AddTags' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'resourceId', 'addTags_resourceId' - Specifies the ARN of the trail or event data store to which one or more -- tags will be added. The format of a trail ARN is: -- -- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@ -- -- 'tagsList', 'addTags_tagsList' - Contains a list of tags, up to a limit of 50 newAddTags :: -- | 'resourceId' Prelude.Text -> AddTags newAddTags pResourceId_ = AddTags' { resourceId = pResourceId_, tagsList = Prelude.mempty } -- | Specifies the ARN of the trail or event data store to which one or more -- tags will be added. The format of a trail ARN is: -- -- @arn:aws:cloudtrail:us-east-2:123456789012:trail\/MyTrail@ addTags_resourceId :: Lens.Lens' AddTags Prelude.Text addTags_resourceId = Lens.lens (\AddTags' {resourceId} -> resourceId) (\s@AddTags' {} a -> s {resourceId = a} :: AddTags) -- | Contains a list of tags, up to a limit of 50 addTags_tagsList :: Lens.Lens' AddTags [Tag] addTags_tagsList = Lens.lens (\AddTags' {tagsList} -> tagsList) (\s@AddTags' {} a -> s {tagsList = a} :: AddTags) Prelude.. Lens.coerced instance Core.AWSRequest AddTags where type AWSResponse AddTags = AddTagsResponse request overrides = Request.postJSON (overrides defaultService) response = Response.receiveEmpty ( \s h x -> AddTagsResponse' Prelude.<$> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable AddTags where hashWithSalt _salt AddTags' {..} = _salt `Prelude.hashWithSalt` resourceId `Prelude.hashWithSalt` tagsList instance Prelude.NFData AddTags where rnf AddTags' {..} = Prelude.rnf resourceId `Prelude.seq` Prelude.rnf tagsList instance Data.ToHeaders AddTags where toHeaders = Prelude.const ( Prelude.mconcat [ "X-Amz-Target" Data.=# ( "com.amazonaws.cloudtrail.v20131101.CloudTrail_20131101.AddTags" :: Prelude.ByteString ), "Content-Type" Data.=# ( "application/x-amz-json-1.1" :: Prelude.ByteString ) ] ) instance Data.ToJSON AddTags where toJSON AddTags' {..} = Data.object ( Prelude.catMaybes [ Prelude.Just ("ResourceId" Data..= resourceId), Prelude.Just ("TagsList" Data..= tagsList) ] ) instance Data.ToPath AddTags where toPath = Prelude.const "/" instance Data.ToQuery AddTags where toQuery = Prelude.const Prelude.mempty -- | Returns the objects or data if successful. Otherwise, returns an error. -- -- /See:/ 'newAddTagsResponse' smart constructor. data AddTagsResponse = AddTagsResponse' { -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'AddTagsResponse' with all optional fields omitted. -- -- Use or to modify other optional fields. -- -- The following record fields are available, with the corresponding lenses provided -- for backwards compatibility: -- -- 'httpStatus', 'addTagsResponse_httpStatus' - The response's http status code. newAddTagsResponse :: -- | 'httpStatus' Prelude.Int -> AddTagsResponse newAddTagsResponse pHttpStatus_ = AddTagsResponse' {httpStatus = pHttpStatus_} -- | The response's http status code. addTagsResponse_httpStatus :: Lens.Lens' AddTagsResponse Prelude.Int addTagsResponse_httpStatus = Lens.lens (\AddTagsResponse' {httpStatus} -> httpStatus) (\s@AddTagsResponse' {} a -> s {httpStatus = a} :: AddTagsResponse) instance Prelude.NFData AddTagsResponse where rnf AddTagsResponse' {..} = Prelude.rnf httpStatus