{-# 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.Redshift.DescribeTags
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns a list of tags. You can return tags from a specific resource by
-- specifying an ARN, or you can return all tags for a given type of
-- resource, such as clusters, snapshots, and so on.
--
-- The following are limitations for @DescribeTags@:
--
-- -   You cannot specify an ARN and a resource-type value together in the
--     same request.
--
-- -   You cannot use the @MaxRecords@ and @Marker@ parameters together
--     with the ARN parameter.
--
-- -   The @MaxRecords@ parameter can be a range from 10 to 50 results to
--     return in a request.
--
-- If you specify both tag keys and tag values in the same request, Amazon
-- Redshift returns all resources that match any combination of the
-- specified keys and values. For example, if you have @owner@ and
-- @environment@ for tag keys, and @admin@ and @test@ for tag values, all
-- resources that have any combination of those values are returned.
--
-- If both tag keys and values are omitted from the request, resources are
-- returned regardless of whether they have tag keys or values associated
-- with them.
--
-- This operation returns paginated results.
module Amazonka.Redshift.DescribeTags
  ( -- * Creating a Request
    DescribeTags (..),
    newDescribeTags,

    -- * Request Lenses
    describeTags_tagValues,
    describeTags_resourceType,
    describeTags_resourceName,
    describeTags_tagKeys,
    describeTags_marker,
    describeTags_maxRecords,

    -- * Destructuring the Response
    DescribeTagsResponse (..),
    newDescribeTagsResponse,

    -- * Response Lenses
    describeTagsResponse_marker,
    describeTagsResponse_taggedResources,
    describeTagsResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Redshift.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- |
--
-- /See:/ 'newDescribeTags' smart constructor.
data DescribeTags = DescribeTags'
  { -- | A tag value or values for which you want to return all matching
    -- resources that are associated with the specified value or values. For
    -- example, suppose that you have resources tagged with values called
    -- @admin@ and @test@. If you specify both of these tag values in the
    -- request, Amazon Redshift returns a response with all resources that have
    -- either or both of these tag values associated with them.
    DescribeTags -> Maybe [Text]
tagValues :: Prelude.Maybe [Prelude.Text],
    -- | The type of resource with which you want to view tags. Valid resource
    -- types are:
    --
    -- -   Cluster
    --
    -- -   CIDR\/IP
    --
    -- -   EC2 security group
    --
    -- -   Snapshot
    --
    -- -   Cluster security group
    --
    -- -   Subnet group
    --
    -- -   HSM connection
    --
    -- -   HSM certificate
    --
    -- -   Parameter group
    --
    -- -   Snapshot copy grant
    --
    -- For more information about Amazon Redshift resource types and
    -- constructing ARNs, go to
    -- <https://docs.aws.amazon.com/redshift/latest/mgmt/redshift-iam-access-control-overview.html#redshift-iam-access-control-specify-actions Specifying Policy Elements: Actions, Effects, Resources, and Principals>
    -- in the Amazon Redshift Cluster Management Guide.
    DescribeTags -> Maybe Text
resourceType :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) for which you want to describe the tag or
    -- tags. For example, @arn:aws:redshift:us-east-2:123456789:cluster:t1@.
    DescribeTags -> Maybe Text
resourceName :: Prelude.Maybe Prelude.Text,
    -- | A tag key or keys for which you want to return all matching resources
    -- that are associated with the specified key or keys. For example, suppose
    -- that you have resources tagged with keys called @owner@ and
    -- @environment@. If you specify both of these tag keys in the request,
    -- Amazon Redshift returns a response with all resources that have either
    -- or both of these tag keys associated with them.
    DescribeTags -> Maybe [Text]
tagKeys :: Prelude.Maybe [Prelude.Text],
    -- | A value that indicates the starting point for the next set of response
    -- records in a subsequent request. If a value is returned in a response,
    -- you can retrieve the next set of records by providing this returned
    -- marker value in the @marker@ parameter and retrying the command. If the
    -- @marker@ field is empty, all response records have been retrieved for
    -- the request.
    DescribeTags -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | The maximum number or response records to return in each call. If the
    -- number of remaining response records exceeds the specified @MaxRecords@
    -- value, a value is returned in a @marker@ field of the response. You can
    -- retrieve the next set of records by retrying the command with the
    -- returned @marker@ value.
    DescribeTags -> Maybe Int
maxRecords :: Prelude.Maybe Prelude.Int
  }
  deriving (DescribeTags -> DescribeTags -> Bool
(DescribeTags -> DescribeTags -> Bool)
-> (DescribeTags -> DescribeTags -> Bool) -> Eq DescribeTags
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeTags -> DescribeTags -> Bool
$c/= :: DescribeTags -> DescribeTags -> Bool
== :: DescribeTags -> DescribeTags -> Bool
$c== :: DescribeTags -> DescribeTags -> Bool
Prelude.Eq, ReadPrec [DescribeTags]
ReadPrec DescribeTags
Int -> ReadS DescribeTags
ReadS [DescribeTags]
(Int -> ReadS DescribeTags)
-> ReadS [DescribeTags]
-> ReadPrec DescribeTags
-> ReadPrec [DescribeTags]
-> Read DescribeTags
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeTags]
$creadListPrec :: ReadPrec [DescribeTags]
readPrec :: ReadPrec DescribeTags
$creadPrec :: ReadPrec DescribeTags
readList :: ReadS [DescribeTags]
$creadList :: ReadS [DescribeTags]
readsPrec :: Int -> ReadS DescribeTags
$creadsPrec :: Int -> ReadS DescribeTags
Prelude.Read, Int -> DescribeTags -> ShowS
[DescribeTags] -> ShowS
DescribeTags -> String
(Int -> DescribeTags -> ShowS)
-> (DescribeTags -> String)
-> ([DescribeTags] -> ShowS)
-> Show DescribeTags
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeTags] -> ShowS
$cshowList :: [DescribeTags] -> ShowS
show :: DescribeTags -> String
$cshow :: DescribeTags -> String
showsPrec :: Int -> DescribeTags -> ShowS
$cshowsPrec :: Int -> DescribeTags -> ShowS
Prelude.Show, (forall x. DescribeTags -> Rep DescribeTags x)
-> (forall x. Rep DescribeTags x -> DescribeTags)
-> Generic DescribeTags
forall x. Rep DescribeTags x -> DescribeTags
forall x. DescribeTags -> Rep DescribeTags x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeTags x -> DescribeTags
$cfrom :: forall x. DescribeTags -> Rep DescribeTags x
Prelude.Generic)

-- |
-- Create a value of 'DescribeTags' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'tagValues', 'describeTags_tagValues' - A tag value or values for which you want to return all matching
-- resources that are associated with the specified value or values. For
-- example, suppose that you have resources tagged with values called
-- @admin@ and @test@. If you specify both of these tag values in the
-- request, Amazon Redshift returns a response with all resources that have
-- either or both of these tag values associated with them.
--
-- 'resourceType', 'describeTags_resourceType' - The type of resource with which you want to view tags. Valid resource
-- types are:
--
-- -   Cluster
--
-- -   CIDR\/IP
--
-- -   EC2 security group
--
-- -   Snapshot
--
-- -   Cluster security group
--
-- -   Subnet group
--
-- -   HSM connection
--
-- -   HSM certificate
--
-- -   Parameter group
--
-- -   Snapshot copy grant
--
-- For more information about Amazon Redshift resource types and
-- constructing ARNs, go to
-- <https://docs.aws.amazon.com/redshift/latest/mgmt/redshift-iam-access-control-overview.html#redshift-iam-access-control-specify-actions Specifying Policy Elements: Actions, Effects, Resources, and Principals>
-- in the Amazon Redshift Cluster Management Guide.
--
-- 'resourceName', 'describeTags_resourceName' - The Amazon Resource Name (ARN) for which you want to describe the tag or
-- tags. For example, @arn:aws:redshift:us-east-2:123456789:cluster:t1@.
--
-- 'tagKeys', 'describeTags_tagKeys' - A tag key or keys for which you want to return all matching resources
-- that are associated with the specified key or keys. For example, suppose
-- that you have resources tagged with keys called @owner@ and
-- @environment@. If you specify both of these tag keys in the request,
-- Amazon Redshift returns a response with all resources that have either
-- or both of these tag keys associated with them.
--
-- 'marker', 'describeTags_marker' - A value that indicates the starting point for the next set of response
-- records in a subsequent request. If a value is returned in a response,
-- you can retrieve the next set of records by providing this returned
-- marker value in the @marker@ parameter and retrying the command. If the
-- @marker@ field is empty, all response records have been retrieved for
-- the request.
--
-- 'maxRecords', 'describeTags_maxRecords' - The maximum number or response records to return in each call. If the
-- number of remaining response records exceeds the specified @MaxRecords@
-- value, a value is returned in a @marker@ field of the response. You can
-- retrieve the next set of records by retrying the command with the
-- returned @marker@ value.
newDescribeTags ::
  DescribeTags
newDescribeTags :: DescribeTags
newDescribeTags =
  DescribeTags' :: Maybe [Text]
-> Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe Text
-> Maybe Int
-> DescribeTags
DescribeTags'
    { $sel:tagValues:DescribeTags' :: Maybe [Text]
tagValues = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceType:DescribeTags' :: Maybe Text
resourceType = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceName:DescribeTags' :: Maybe Text
resourceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tagKeys:DescribeTags' :: Maybe [Text]
tagKeys = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:marker:DescribeTags' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxRecords:DescribeTags' :: Maybe Int
maxRecords = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | A tag value or values for which you want to return all matching
-- resources that are associated with the specified value or values. For
-- example, suppose that you have resources tagged with values called
-- @admin@ and @test@. If you specify both of these tag values in the
-- request, Amazon Redshift returns a response with all resources that have
-- either or both of these tag values associated with them.
describeTags_tagValues :: Lens.Lens' DescribeTags (Prelude.Maybe [Prelude.Text])
describeTags_tagValues :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeTags -> f DescribeTags
describeTags_tagValues = (DescribeTags -> Maybe [Text])
-> (DescribeTags -> Maybe [Text] -> DescribeTags)
-> Lens DescribeTags DescribeTags (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTags' {Maybe [Text]
tagValues :: Maybe [Text]
$sel:tagValues:DescribeTags' :: DescribeTags -> Maybe [Text]
tagValues} -> Maybe [Text]
tagValues) (\s :: DescribeTags
s@DescribeTags' {} Maybe [Text]
a -> DescribeTags
s {$sel:tagValues:DescribeTags' :: Maybe [Text]
tagValues = Maybe [Text]
a} :: DescribeTags) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeTags -> f DescribeTags)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeTags
-> f DescribeTags
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The type of resource with which you want to view tags. Valid resource
-- types are:
--
-- -   Cluster
--
-- -   CIDR\/IP
--
-- -   EC2 security group
--
-- -   Snapshot
--
-- -   Cluster security group
--
-- -   Subnet group
--
-- -   HSM connection
--
-- -   HSM certificate
--
-- -   Parameter group
--
-- -   Snapshot copy grant
--
-- For more information about Amazon Redshift resource types and
-- constructing ARNs, go to
-- <https://docs.aws.amazon.com/redshift/latest/mgmt/redshift-iam-access-control-overview.html#redshift-iam-access-control-specify-actions Specifying Policy Elements: Actions, Effects, Resources, and Principals>
-- in the Amazon Redshift Cluster Management Guide.
describeTags_resourceType :: Lens.Lens' DescribeTags (Prelude.Maybe Prelude.Text)
describeTags_resourceType :: (Maybe Text -> f (Maybe Text)) -> DescribeTags -> f DescribeTags
describeTags_resourceType = (DescribeTags -> Maybe Text)
-> (DescribeTags -> Maybe Text -> DescribeTags)
-> Lens DescribeTags DescribeTags (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTags' {Maybe Text
resourceType :: Maybe Text
$sel:resourceType:DescribeTags' :: DescribeTags -> Maybe Text
resourceType} -> Maybe Text
resourceType) (\s :: DescribeTags
s@DescribeTags' {} Maybe Text
a -> DescribeTags
s {$sel:resourceType:DescribeTags' :: Maybe Text
resourceType = Maybe Text
a} :: DescribeTags)

-- | The Amazon Resource Name (ARN) for which you want to describe the tag or
-- tags. For example, @arn:aws:redshift:us-east-2:123456789:cluster:t1@.
describeTags_resourceName :: Lens.Lens' DescribeTags (Prelude.Maybe Prelude.Text)
describeTags_resourceName :: (Maybe Text -> f (Maybe Text)) -> DescribeTags -> f DescribeTags
describeTags_resourceName = (DescribeTags -> Maybe Text)
-> (DescribeTags -> Maybe Text -> DescribeTags)
-> Lens DescribeTags DescribeTags (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTags' {Maybe Text
resourceName :: Maybe Text
$sel:resourceName:DescribeTags' :: DescribeTags -> Maybe Text
resourceName} -> Maybe Text
resourceName) (\s :: DescribeTags
s@DescribeTags' {} Maybe Text
a -> DescribeTags
s {$sel:resourceName:DescribeTags' :: Maybe Text
resourceName = Maybe Text
a} :: DescribeTags)

-- | A tag key or keys for which you want to return all matching resources
-- that are associated with the specified key or keys. For example, suppose
-- that you have resources tagged with keys called @owner@ and
-- @environment@. If you specify both of these tag keys in the request,
-- Amazon Redshift returns a response with all resources that have either
-- or both of these tag keys associated with them.
describeTags_tagKeys :: Lens.Lens' DescribeTags (Prelude.Maybe [Prelude.Text])
describeTags_tagKeys :: (Maybe [Text] -> f (Maybe [Text]))
-> DescribeTags -> f DescribeTags
describeTags_tagKeys = (DescribeTags -> Maybe [Text])
-> (DescribeTags -> Maybe [Text] -> DescribeTags)
-> Lens DescribeTags DescribeTags (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTags' {Maybe [Text]
tagKeys :: Maybe [Text]
$sel:tagKeys:DescribeTags' :: DescribeTags -> Maybe [Text]
tagKeys} -> Maybe [Text]
tagKeys) (\s :: DescribeTags
s@DescribeTags' {} Maybe [Text]
a -> DescribeTags
s {$sel:tagKeys:DescribeTags' :: Maybe [Text]
tagKeys = Maybe [Text]
a} :: DescribeTags) ((Maybe [Text] -> f (Maybe [Text]))
 -> DescribeTags -> f DescribeTags)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> DescribeTags
-> f DescribeTags
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A value that indicates the starting point for the next set of response
-- records in a subsequent request. If a value is returned in a response,
-- you can retrieve the next set of records by providing this returned
-- marker value in the @marker@ parameter and retrying the command. If the
-- @marker@ field is empty, all response records have been retrieved for
-- the request.
describeTags_marker :: Lens.Lens' DescribeTags (Prelude.Maybe Prelude.Text)
describeTags_marker :: (Maybe Text -> f (Maybe Text)) -> DescribeTags -> f DescribeTags
describeTags_marker = (DescribeTags -> Maybe Text)
-> (DescribeTags -> Maybe Text -> DescribeTags)
-> Lens DescribeTags DescribeTags (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTags' {Maybe Text
marker :: Maybe Text
$sel:marker:DescribeTags' :: DescribeTags -> Maybe Text
marker} -> Maybe Text
marker) (\s :: DescribeTags
s@DescribeTags' {} Maybe Text
a -> DescribeTags
s {$sel:marker:DescribeTags' :: Maybe Text
marker = Maybe Text
a} :: DescribeTags)

-- | The maximum number or response records to return in each call. If the
-- number of remaining response records exceeds the specified @MaxRecords@
-- value, a value is returned in a @marker@ field of the response. You can
-- retrieve the next set of records by retrying the command with the
-- returned @marker@ value.
describeTags_maxRecords :: Lens.Lens' DescribeTags (Prelude.Maybe Prelude.Int)
describeTags_maxRecords :: (Maybe Int -> f (Maybe Int)) -> DescribeTags -> f DescribeTags
describeTags_maxRecords = (DescribeTags -> Maybe Int)
-> (DescribeTags -> Maybe Int -> DescribeTags)
-> Lens DescribeTags DescribeTags (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTags' {Maybe Int
maxRecords :: Maybe Int
$sel:maxRecords:DescribeTags' :: DescribeTags -> Maybe Int
maxRecords} -> Maybe Int
maxRecords) (\s :: DescribeTags
s@DescribeTags' {} Maybe Int
a -> DescribeTags
s {$sel:maxRecords:DescribeTags' :: Maybe Int
maxRecords = Maybe Int
a} :: DescribeTags)

instance Core.AWSPager DescribeTags where
  page :: DescribeTags -> AWSResponse DescribeTags -> Maybe DescribeTags
page DescribeTags
rq AWSResponse DescribeTags
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeTags
DescribeTagsResponse
rs
            DescribeTagsResponse
-> Getting (First Text) DescribeTagsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeTagsResponse -> Const (First Text) DescribeTagsResponse
Lens' DescribeTagsResponse (Maybe Text)
describeTagsResponse_marker ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeTagsResponse -> Const (First Text) DescribeTagsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeTagsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeTags
forall a. Maybe a
Prelude.Nothing
    | Maybe [TaggedResource] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeTags
DescribeTagsResponse
rs
            DescribeTagsResponse
-> Getting
     (First [TaggedResource]) DescribeTagsResponse [TaggedResource]
-> Maybe [TaggedResource]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [TaggedResource]
 -> Const (First [TaggedResource]) (Maybe [TaggedResource]))
-> DescribeTagsResponse
-> Const (First [TaggedResource]) DescribeTagsResponse
Lens' DescribeTagsResponse (Maybe [TaggedResource])
describeTagsResponse_taggedResources
              ((Maybe [TaggedResource]
  -> Const (First [TaggedResource]) (Maybe [TaggedResource]))
 -> DescribeTagsResponse
 -> Const (First [TaggedResource]) DescribeTagsResponse)
-> (([TaggedResource]
     -> Const (First [TaggedResource]) [TaggedResource])
    -> Maybe [TaggedResource]
    -> Const (First [TaggedResource]) (Maybe [TaggedResource]))
-> Getting
     (First [TaggedResource]) DescribeTagsResponse [TaggedResource]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([TaggedResource]
 -> Const (First [TaggedResource]) [TaggedResource])
-> Maybe [TaggedResource]
-> Const (First [TaggedResource]) (Maybe [TaggedResource])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeTags
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeTags -> Maybe DescribeTags
forall a. a -> Maybe a
Prelude.Just (DescribeTags -> Maybe DescribeTags)
-> DescribeTags -> Maybe DescribeTags
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeTags
rq
          DescribeTags -> (DescribeTags -> DescribeTags) -> DescribeTags
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeTags -> Identity DescribeTags
Lens DescribeTags DescribeTags (Maybe Text) (Maybe Text)
describeTags_marker
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeTags -> Identity DescribeTags)
-> Maybe Text -> DescribeTags -> DescribeTags
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeTags
DescribeTagsResponse
rs
          DescribeTagsResponse
-> Getting (First Text) DescribeTagsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeTagsResponse -> Const (First Text) DescribeTagsResponse
Lens' DescribeTagsResponse (Maybe Text)
describeTagsResponse_marker ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeTagsResponse -> Const (First Text) DescribeTagsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeTagsResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest DescribeTags where
  type AWSResponse DescribeTags = DescribeTagsResponse
  request :: DescribeTags -> Request DescribeTags
request = Service -> DescribeTags -> Request DescribeTags
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeTags
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeTags)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse DescribeTags))
-> Logger
-> Service
-> Proxy DescribeTags
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeTags)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"DescribeTagsResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Text -> Maybe [TaggedResource] -> Int -> DescribeTagsResponse
DescribeTagsResponse'
            (Maybe Text
 -> Maybe [TaggedResource] -> Int -> DescribeTagsResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [TaggedResource] -> Int -> DescribeTagsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Marker")
            Either
  String (Maybe [TaggedResource] -> Int -> DescribeTagsResponse)
-> Either String (Maybe [TaggedResource])
-> Either String (Int -> DescribeTagsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"TaggedResources" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String (Maybe [TaggedResource]))
-> Either String (Maybe [TaggedResource])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [TaggedResource])
-> [Node] -> Either String (Maybe [TaggedResource])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [TaggedResource]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"TaggedResource")
                        )
            Either String (Int -> DescribeTagsResponse)
-> Either String Int -> Either String DescribeTagsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribeTags

instance Prelude.NFData DescribeTags

instance Core.ToHeaders DescribeTags where
  toHeaders :: DescribeTags -> ResponseHeaders
toHeaders = ResponseHeaders -> DescribeTags -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath DescribeTags where
  toPath :: DescribeTags -> ByteString
toPath = ByteString -> DescribeTags -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery DescribeTags where
  toQuery :: DescribeTags -> QueryString
toQuery DescribeTags' {Maybe Int
Maybe [Text]
Maybe Text
maxRecords :: Maybe Int
marker :: Maybe Text
tagKeys :: Maybe [Text]
resourceName :: Maybe Text
resourceType :: Maybe Text
tagValues :: Maybe [Text]
$sel:maxRecords:DescribeTags' :: DescribeTags -> Maybe Int
$sel:marker:DescribeTags' :: DescribeTags -> Maybe Text
$sel:tagKeys:DescribeTags' :: DescribeTags -> Maybe [Text]
$sel:resourceName:DescribeTags' :: DescribeTags -> Maybe Text
$sel:resourceType:DescribeTags' :: DescribeTags -> Maybe Text
$sel:tagValues:DescribeTags' :: DescribeTags -> Maybe [Text]
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"DescribeTags" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"TagValues"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"TagValue" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
tagValues),
        ByteString
"ResourceType" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
resourceType,
        ByteString
"ResourceName" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
resourceName,
        ByteString
"TagKeys"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"TagKey" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
tagKeys),
        ByteString
"Marker" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
marker,
        ByteString
"MaxRecords" ByteString -> Maybe Int -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Int
maxRecords
      ]

-- |
--
-- /See:/ 'newDescribeTagsResponse' smart constructor.
data DescribeTagsResponse = DescribeTagsResponse'
  { -- | A value that indicates the starting point for the next set of response
    -- records in a subsequent request. If a value is returned in a response,
    -- you can retrieve the next set of records by providing this returned
    -- marker value in the @Marker@ parameter and retrying the command. If the
    -- @Marker@ field is empty, all response records have been retrieved for
    -- the request.
    DescribeTagsResponse -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | A list of tags with their associated resources.
    DescribeTagsResponse -> Maybe [TaggedResource]
taggedResources :: Prelude.Maybe [TaggedResource],
    -- | The response's http status code.
    DescribeTagsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeTagsResponse -> DescribeTagsResponse -> Bool
(DescribeTagsResponse -> DescribeTagsResponse -> Bool)
-> (DescribeTagsResponse -> DescribeTagsResponse -> Bool)
-> Eq DescribeTagsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeTagsResponse -> DescribeTagsResponse -> Bool
$c/= :: DescribeTagsResponse -> DescribeTagsResponse -> Bool
== :: DescribeTagsResponse -> DescribeTagsResponse -> Bool
$c== :: DescribeTagsResponse -> DescribeTagsResponse -> Bool
Prelude.Eq, ReadPrec [DescribeTagsResponse]
ReadPrec DescribeTagsResponse
Int -> ReadS DescribeTagsResponse
ReadS [DescribeTagsResponse]
(Int -> ReadS DescribeTagsResponse)
-> ReadS [DescribeTagsResponse]
-> ReadPrec DescribeTagsResponse
-> ReadPrec [DescribeTagsResponse]
-> Read DescribeTagsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeTagsResponse]
$creadListPrec :: ReadPrec [DescribeTagsResponse]
readPrec :: ReadPrec DescribeTagsResponse
$creadPrec :: ReadPrec DescribeTagsResponse
readList :: ReadS [DescribeTagsResponse]
$creadList :: ReadS [DescribeTagsResponse]
readsPrec :: Int -> ReadS DescribeTagsResponse
$creadsPrec :: Int -> ReadS DescribeTagsResponse
Prelude.Read, Int -> DescribeTagsResponse -> ShowS
[DescribeTagsResponse] -> ShowS
DescribeTagsResponse -> String
(Int -> DescribeTagsResponse -> ShowS)
-> (DescribeTagsResponse -> String)
-> ([DescribeTagsResponse] -> ShowS)
-> Show DescribeTagsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeTagsResponse] -> ShowS
$cshowList :: [DescribeTagsResponse] -> ShowS
show :: DescribeTagsResponse -> String
$cshow :: DescribeTagsResponse -> String
showsPrec :: Int -> DescribeTagsResponse -> ShowS
$cshowsPrec :: Int -> DescribeTagsResponse -> ShowS
Prelude.Show, (forall x. DescribeTagsResponse -> Rep DescribeTagsResponse x)
-> (forall x. Rep DescribeTagsResponse x -> DescribeTagsResponse)
-> Generic DescribeTagsResponse
forall x. Rep DescribeTagsResponse x -> DescribeTagsResponse
forall x. DescribeTagsResponse -> Rep DescribeTagsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeTagsResponse x -> DescribeTagsResponse
$cfrom :: forall x. DescribeTagsResponse -> Rep DescribeTagsResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeTagsResponse' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'marker', 'describeTagsResponse_marker' - A value that indicates the starting point for the next set of response
-- records in a subsequent request. If a value is returned in a response,
-- you can retrieve the next set of records by providing this returned
-- marker value in the @Marker@ parameter and retrying the command. If the
-- @Marker@ field is empty, all response records have been retrieved for
-- the request.
--
-- 'taggedResources', 'describeTagsResponse_taggedResources' - A list of tags with their associated resources.
--
-- 'httpStatus', 'describeTagsResponse_httpStatus' - The response's http status code.
newDescribeTagsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeTagsResponse
newDescribeTagsResponse :: Int -> DescribeTagsResponse
newDescribeTagsResponse Int
pHttpStatus_ =
  DescribeTagsResponse' :: Maybe Text -> Maybe [TaggedResource] -> Int -> DescribeTagsResponse
DescribeTagsResponse'
    { $sel:marker:DescribeTagsResponse' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:taggedResources:DescribeTagsResponse' :: Maybe [TaggedResource]
taggedResources = Maybe [TaggedResource]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeTagsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A value that indicates the starting point for the next set of response
-- records in a subsequent request. If a value is returned in a response,
-- you can retrieve the next set of records by providing this returned
-- marker value in the @Marker@ parameter and retrying the command. If the
-- @Marker@ field is empty, all response records have been retrieved for
-- the request.
describeTagsResponse_marker :: Lens.Lens' DescribeTagsResponse (Prelude.Maybe Prelude.Text)
describeTagsResponse_marker :: (Maybe Text -> f (Maybe Text))
-> DescribeTagsResponse -> f DescribeTagsResponse
describeTagsResponse_marker = (DescribeTagsResponse -> Maybe Text)
-> (DescribeTagsResponse -> Maybe Text -> DescribeTagsResponse)
-> Lens' DescribeTagsResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTagsResponse' {Maybe Text
marker :: Maybe Text
$sel:marker:DescribeTagsResponse' :: DescribeTagsResponse -> Maybe Text
marker} -> Maybe Text
marker) (\s :: DescribeTagsResponse
s@DescribeTagsResponse' {} Maybe Text
a -> DescribeTagsResponse
s {$sel:marker:DescribeTagsResponse' :: Maybe Text
marker = Maybe Text
a} :: DescribeTagsResponse)

-- | A list of tags with their associated resources.
describeTagsResponse_taggedResources :: Lens.Lens' DescribeTagsResponse (Prelude.Maybe [TaggedResource])
describeTagsResponse_taggedResources :: (Maybe [TaggedResource] -> f (Maybe [TaggedResource]))
-> DescribeTagsResponse -> f DescribeTagsResponse
describeTagsResponse_taggedResources = (DescribeTagsResponse -> Maybe [TaggedResource])
-> (DescribeTagsResponse
    -> Maybe [TaggedResource] -> DescribeTagsResponse)
-> Lens' DescribeTagsResponse (Maybe [TaggedResource])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTagsResponse' {Maybe [TaggedResource]
taggedResources :: Maybe [TaggedResource]
$sel:taggedResources:DescribeTagsResponse' :: DescribeTagsResponse -> Maybe [TaggedResource]
taggedResources} -> Maybe [TaggedResource]
taggedResources) (\s :: DescribeTagsResponse
s@DescribeTagsResponse' {} Maybe [TaggedResource]
a -> DescribeTagsResponse
s {$sel:taggedResources:DescribeTagsResponse' :: Maybe [TaggedResource]
taggedResources = Maybe [TaggedResource]
a} :: DescribeTagsResponse) ((Maybe [TaggedResource] -> f (Maybe [TaggedResource]))
 -> DescribeTagsResponse -> f DescribeTagsResponse)
-> ((Maybe [TaggedResource] -> f (Maybe [TaggedResource]))
    -> Maybe [TaggedResource] -> f (Maybe [TaggedResource]))
-> (Maybe [TaggedResource] -> f (Maybe [TaggedResource]))
-> DescribeTagsResponse
-> f DescribeTagsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [TaggedResource] [TaggedResource] [TaggedResource] [TaggedResource]
-> Iso
     (Maybe [TaggedResource])
     (Maybe [TaggedResource])
     (Maybe [TaggedResource])
     (Maybe [TaggedResource])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [TaggedResource] [TaggedResource] [TaggedResource] [TaggedResource]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
describeTagsResponse_httpStatus :: Lens.Lens' DescribeTagsResponse Prelude.Int
describeTagsResponse_httpStatus :: (Int -> f Int) -> DescribeTagsResponse -> f DescribeTagsResponse
describeTagsResponse_httpStatus = (DescribeTagsResponse -> Int)
-> (DescribeTagsResponse -> Int -> DescribeTagsResponse)
-> Lens DescribeTagsResponse DescribeTagsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeTagsResponse' {Int
httpStatus :: Int
$sel:httpStatus:DescribeTagsResponse' :: DescribeTagsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DescribeTagsResponse
s@DescribeTagsResponse' {} Int
a -> DescribeTagsResponse
s {$sel:httpStatus:DescribeTagsResponse' :: Int
httpStatus = Int
a} :: DescribeTagsResponse)

instance Prelude.NFData DescribeTagsResponse