{-# 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.Route53Domains.ListTagsForDomain
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- This operation returns all of the tags that are associated with the
-- specified domain.
--
-- All tag operations are eventually consistent; subsequent operations
-- might not immediately represent all issued operations.
module Amazonka.Route53Domains.ListTagsForDomain
  ( -- * Creating a Request
    ListTagsForDomain (..),
    newListTagsForDomain,

    -- * Request Lenses
    listTagsForDomain_domainName,

    -- * Destructuring the Response
    ListTagsForDomainResponse (..),
    newListTagsForDomainResponse,

    -- * Response Lenses
    listTagsForDomainResponse_tagList,
    listTagsForDomainResponse_httpStatus,
  )
where

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
import Amazonka.Route53Domains.Types

-- | The ListTagsForDomainRequest includes the following elements.
--
-- /See:/ 'newListTagsForDomain' smart constructor.
data ListTagsForDomain = ListTagsForDomain'
  { -- | The domain for which you want to get a list of tags.
    ListTagsForDomain -> Text
domainName :: Prelude.Text
  }
  deriving (ListTagsForDomain -> ListTagsForDomain -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTagsForDomain -> ListTagsForDomain -> Bool
$c/= :: ListTagsForDomain -> ListTagsForDomain -> Bool
== :: ListTagsForDomain -> ListTagsForDomain -> Bool
$c== :: ListTagsForDomain -> ListTagsForDomain -> Bool
Prelude.Eq, ReadPrec [ListTagsForDomain]
ReadPrec ListTagsForDomain
Int -> ReadS ListTagsForDomain
ReadS [ListTagsForDomain]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTagsForDomain]
$creadListPrec :: ReadPrec [ListTagsForDomain]
readPrec :: ReadPrec ListTagsForDomain
$creadPrec :: ReadPrec ListTagsForDomain
readList :: ReadS [ListTagsForDomain]
$creadList :: ReadS [ListTagsForDomain]
readsPrec :: Int -> ReadS ListTagsForDomain
$creadsPrec :: Int -> ReadS ListTagsForDomain
Prelude.Read, Int -> ListTagsForDomain -> ShowS
[ListTagsForDomain] -> ShowS
ListTagsForDomain -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTagsForDomain] -> ShowS
$cshowList :: [ListTagsForDomain] -> ShowS
show :: ListTagsForDomain -> String
$cshow :: ListTagsForDomain -> String
showsPrec :: Int -> ListTagsForDomain -> ShowS
$cshowsPrec :: Int -> ListTagsForDomain -> ShowS
Prelude.Show, forall x. Rep ListTagsForDomain x -> ListTagsForDomain
forall x. ListTagsForDomain -> Rep ListTagsForDomain x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListTagsForDomain x -> ListTagsForDomain
$cfrom :: forall x. ListTagsForDomain -> Rep ListTagsForDomain x
Prelude.Generic)

-- |
-- Create a value of 'ListTagsForDomain' 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:
--
-- 'domainName', 'listTagsForDomain_domainName' - The domain for which you want to get a list of tags.
newListTagsForDomain ::
  -- | 'domainName'
  Prelude.Text ->
  ListTagsForDomain
newListTagsForDomain :: Text -> ListTagsForDomain
newListTagsForDomain Text
pDomainName_ =
  ListTagsForDomain' {$sel:domainName:ListTagsForDomain' :: Text
domainName = Text
pDomainName_}

-- | The domain for which you want to get a list of tags.
listTagsForDomain_domainName :: Lens.Lens' ListTagsForDomain Prelude.Text
listTagsForDomain_domainName :: Lens' ListTagsForDomain Text
listTagsForDomain_domainName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForDomain' {Text
domainName :: Text
$sel:domainName:ListTagsForDomain' :: ListTagsForDomain -> Text
domainName} -> Text
domainName) (\s :: ListTagsForDomain
s@ListTagsForDomain' {} Text
a -> ListTagsForDomain
s {$sel:domainName:ListTagsForDomain' :: Text
domainName = Text
a} :: ListTagsForDomain)

instance Core.AWSRequest ListTagsForDomain where
  type
    AWSResponse ListTagsForDomain =
      ListTagsForDomainResponse
  request :: (Service -> Service)
-> ListTagsForDomain -> Request ListTagsForDomain
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListTagsForDomain
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListTagsForDomain)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Tag] -> Int -> ListTagsForDomainResponse
ListTagsForDomainResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"TagList" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListTagsForDomain where
  hashWithSalt :: Int -> ListTagsForDomain -> Int
hashWithSalt Int
_salt ListTagsForDomain' {Text
domainName :: Text
$sel:domainName:ListTagsForDomain' :: ListTagsForDomain -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
domainName

instance Prelude.NFData ListTagsForDomain where
  rnf :: ListTagsForDomain -> ()
rnf ListTagsForDomain' {Text
domainName :: Text
$sel:domainName:ListTagsForDomain' :: ListTagsForDomain -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
domainName

instance Data.ToHeaders ListTagsForDomain where
  toHeaders :: ListTagsForDomain -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"Route53Domains_v20140515.ListTagsForDomain" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON ListTagsForDomain where
  toJSON :: ListTagsForDomain -> Value
toJSON ListTagsForDomain' {Text
domainName :: Text
$sel:domainName:ListTagsForDomain' :: ListTagsForDomain -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"DomainName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
domainName)]
      )

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

instance Data.ToQuery ListTagsForDomain where
  toQuery :: ListTagsForDomain -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | The ListTagsForDomain response includes the following elements.
--
-- /See:/ 'newListTagsForDomainResponse' smart constructor.
data ListTagsForDomainResponse = ListTagsForDomainResponse'
  { -- | A list of the tags that are associated with the specified domain.
    ListTagsForDomainResponse -> Maybe [Tag]
tagList :: Prelude.Maybe [Tag],
    -- | The response's http status code.
    ListTagsForDomainResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListTagsForDomainResponse -> ListTagsForDomainResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListTagsForDomainResponse -> ListTagsForDomainResponse -> Bool
$c/= :: ListTagsForDomainResponse -> ListTagsForDomainResponse -> Bool
== :: ListTagsForDomainResponse -> ListTagsForDomainResponse -> Bool
$c== :: ListTagsForDomainResponse -> ListTagsForDomainResponse -> Bool
Prelude.Eq, ReadPrec [ListTagsForDomainResponse]
ReadPrec ListTagsForDomainResponse
Int -> ReadS ListTagsForDomainResponse
ReadS [ListTagsForDomainResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListTagsForDomainResponse]
$creadListPrec :: ReadPrec [ListTagsForDomainResponse]
readPrec :: ReadPrec ListTagsForDomainResponse
$creadPrec :: ReadPrec ListTagsForDomainResponse
readList :: ReadS [ListTagsForDomainResponse]
$creadList :: ReadS [ListTagsForDomainResponse]
readsPrec :: Int -> ReadS ListTagsForDomainResponse
$creadsPrec :: Int -> ReadS ListTagsForDomainResponse
Prelude.Read, Int -> ListTagsForDomainResponse -> ShowS
[ListTagsForDomainResponse] -> ShowS
ListTagsForDomainResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListTagsForDomainResponse] -> ShowS
$cshowList :: [ListTagsForDomainResponse] -> ShowS
show :: ListTagsForDomainResponse -> String
$cshow :: ListTagsForDomainResponse -> String
showsPrec :: Int -> ListTagsForDomainResponse -> ShowS
$cshowsPrec :: Int -> ListTagsForDomainResponse -> ShowS
Prelude.Show, forall x.
Rep ListTagsForDomainResponse x -> ListTagsForDomainResponse
forall x.
ListTagsForDomainResponse -> Rep ListTagsForDomainResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListTagsForDomainResponse x -> ListTagsForDomainResponse
$cfrom :: forall x.
ListTagsForDomainResponse -> Rep ListTagsForDomainResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListTagsForDomainResponse' 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:
--
-- 'tagList', 'listTagsForDomainResponse_tagList' - A list of the tags that are associated with the specified domain.
--
-- 'httpStatus', 'listTagsForDomainResponse_httpStatus' - The response's http status code.
newListTagsForDomainResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListTagsForDomainResponse
newListTagsForDomainResponse :: Int -> ListTagsForDomainResponse
newListTagsForDomainResponse Int
pHttpStatus_ =
  ListTagsForDomainResponse'
    { $sel:tagList:ListTagsForDomainResponse' :: Maybe [Tag]
tagList =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListTagsForDomainResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of the tags that are associated with the specified domain.
listTagsForDomainResponse_tagList :: Lens.Lens' ListTagsForDomainResponse (Prelude.Maybe [Tag])
listTagsForDomainResponse_tagList :: Lens' ListTagsForDomainResponse (Maybe [Tag])
listTagsForDomainResponse_tagList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListTagsForDomainResponse' {Maybe [Tag]
tagList :: Maybe [Tag]
$sel:tagList:ListTagsForDomainResponse' :: ListTagsForDomainResponse -> Maybe [Tag]
tagList} -> Maybe [Tag]
tagList) (\s :: ListTagsForDomainResponse
s@ListTagsForDomainResponse' {} Maybe [Tag]
a -> ListTagsForDomainResponse
s {$sel:tagList:ListTagsForDomainResponse' :: Maybe [Tag]
tagList = Maybe [Tag]
a} :: ListTagsForDomainResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListTagsForDomainResponse where
  rnf :: ListTagsForDomainResponse -> ()
rnf ListTagsForDomainResponse' {Int
Maybe [Tag]
httpStatus :: Int
tagList :: Maybe [Tag]
$sel:httpStatus:ListTagsForDomainResponse' :: ListTagsForDomainResponse -> Int
$sel:tagList:ListTagsForDomainResponse' :: ListTagsForDomainResponse -> Maybe [Tag]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tagList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus