{-# 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.CloudWatch.ListTagsForResource -- Copyright : (c) 2013-2023 Brendan Hay -- License : Mozilla Public License, v. 2.0. -- Maintainer : Brendan Hay -- Stability : auto-generated -- Portability : non-portable (GHC extensions) -- -- Displays the tags associated with a CloudWatch resource. Currently, -- alarms and Contributor Insights rules support tagging. module Amazonka.CloudWatch.ListTagsForResource ( -- * Creating a Request ListTagsForResource (..), newListTagsForResource, -- * Request Lenses listTagsForResource_resourceARN, -- * Destructuring the Response ListTagsForResourceResponse (..), newListTagsForResourceResponse, -- * Response Lenses listTagsForResourceResponse_tags, listTagsForResourceResponse_httpStatus, ) where import Amazonka.CloudWatch.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 -- | /See:/ 'newListTagsForResource' smart constructor. data ListTagsForResource = ListTagsForResource' { -- | The ARN of the CloudWatch resource that you want to view tags for. -- -- The ARN format of an alarm is -- @arn:aws:cloudwatch:@/@Region@/@:@/@account-id@/@:alarm:@/@alarm-name@/@ @ -- -- The ARN format of a Contributor Insights rule is -- @arn:aws:cloudwatch:@/@Region@/@:@/@account-id@/@:insight-rule:@/@insight-rule-name@/@ @ -- -- For more information about ARN format, see -- -- in the /Amazon Web Services General Reference/. resourceARN :: Prelude.Text } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListTagsForResource' 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: -- -- 'resourceARN', 'listTagsForResource_resourceARN' - The ARN of the CloudWatch resource that you want to view tags for. -- -- The ARN format of an alarm is -- @arn:aws:cloudwatch:@/@Region@/@:@/@account-id@/@:alarm:@/@alarm-name@/@ @ -- -- The ARN format of a Contributor Insights rule is -- @arn:aws:cloudwatch:@/@Region@/@:@/@account-id@/@:insight-rule:@/@insight-rule-name@/@ @ -- -- For more information about ARN format, see -- -- in the /Amazon Web Services General Reference/. newListTagsForResource :: -- | 'resourceARN' Prelude.Text -> ListTagsForResource newListTagsForResource pResourceARN_ = ListTagsForResource' {resourceARN = pResourceARN_} -- | The ARN of the CloudWatch resource that you want to view tags for. -- -- The ARN format of an alarm is -- @arn:aws:cloudwatch:@/@Region@/@:@/@account-id@/@:alarm:@/@alarm-name@/@ @ -- -- The ARN format of a Contributor Insights rule is -- @arn:aws:cloudwatch:@/@Region@/@:@/@account-id@/@:insight-rule:@/@insight-rule-name@/@ @ -- -- For more information about ARN format, see -- -- in the /Amazon Web Services General Reference/. listTagsForResource_resourceARN :: Lens.Lens' ListTagsForResource Prelude.Text listTagsForResource_resourceARN = Lens.lens (\ListTagsForResource' {resourceARN} -> resourceARN) (\s@ListTagsForResource' {} a -> s {resourceARN = a} :: ListTagsForResource) instance Core.AWSRequest ListTagsForResource where type AWSResponse ListTagsForResource = ListTagsForResourceResponse request overrides = Request.postQuery (overrides defaultService) response = Response.receiveXMLWrapper "ListTagsForResourceResult" ( \s h x -> ListTagsForResourceResponse' Prelude.<$> ( x Data..@? "Tags" Core..!@ Prelude.mempty Prelude.>>= Core.may (Data.parseXMLList "member") ) Prelude.<*> (Prelude.pure (Prelude.fromEnum s)) ) instance Prelude.Hashable ListTagsForResource where hashWithSalt _salt ListTagsForResource' {..} = _salt `Prelude.hashWithSalt` resourceARN instance Prelude.NFData ListTagsForResource where rnf ListTagsForResource' {..} = Prelude.rnf resourceARN instance Data.ToHeaders ListTagsForResource where toHeaders = Prelude.const Prelude.mempty instance Data.ToPath ListTagsForResource where toPath = Prelude.const "/" instance Data.ToQuery ListTagsForResource where toQuery ListTagsForResource' {..} = Prelude.mconcat [ "Action" Data.=: ("ListTagsForResource" :: Prelude.ByteString), "Version" Data.=: ("2010-08-01" :: Prelude.ByteString), "ResourceARN" Data.=: resourceARN ] -- | /See:/ 'newListTagsForResourceResponse' smart constructor. data ListTagsForResourceResponse = ListTagsForResourceResponse' { -- | The list of tag keys and values associated with the resource you -- specified. tags :: Prelude.Maybe [Tag], -- | The response's http status code. httpStatus :: Prelude.Int } deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic) -- | -- Create a value of 'ListTagsForResourceResponse' 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: -- -- 'tags', 'listTagsForResourceResponse_tags' - The list of tag keys and values associated with the resource you -- specified. -- -- 'httpStatus', 'listTagsForResourceResponse_httpStatus' - The response's http status code. newListTagsForResourceResponse :: -- | 'httpStatus' Prelude.Int -> ListTagsForResourceResponse newListTagsForResourceResponse pHttpStatus_ = ListTagsForResourceResponse' { tags = Prelude.Nothing, httpStatus = pHttpStatus_ } -- | The list of tag keys and values associated with the resource you -- specified. listTagsForResourceResponse_tags :: Lens.Lens' ListTagsForResourceResponse (Prelude.Maybe [Tag]) listTagsForResourceResponse_tags = Lens.lens (\ListTagsForResourceResponse' {tags} -> tags) (\s@ListTagsForResourceResponse' {} a -> s {tags = a} :: ListTagsForResourceResponse) Prelude.. Lens.mapping Lens.coerced -- | The response's http status code. listTagsForResourceResponse_httpStatus :: Lens.Lens' ListTagsForResourceResponse Prelude.Int listTagsForResourceResponse_httpStatus = Lens.lens (\ListTagsForResourceResponse' {httpStatus} -> httpStatus) (\s@ListTagsForResourceResponse' {} a -> s {httpStatus = a} :: ListTagsForResourceResponse) instance Prelude.NFData ListTagsForResourceResponse where rnf ListTagsForResourceResponse' {..} = Prelude.rnf tags `Prelude.seq` Prelude.rnf httpStatus