{-# 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-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)
--
-- 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_httpStatus,
    listTagsForDomainResponse_tagList,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ListTagsForDomain -> ListTagsForDomain -> Bool)
-> (ListTagsForDomain -> ListTagsForDomain -> Bool)
-> Eq ListTagsForDomain
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]
(Int -> ReadS ListTagsForDomain)
-> ReadS [ListTagsForDomain]
-> ReadPrec ListTagsForDomain
-> ReadPrec [ListTagsForDomain]
-> Read 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
(Int -> ListTagsForDomain -> ShowS)
-> (ListTagsForDomain -> String)
-> ([ListTagsForDomain] -> ShowS)
-> Show ListTagsForDomain
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. ListTagsForDomain -> Rep ListTagsForDomain x)
-> (forall x. Rep ListTagsForDomain x -> ListTagsForDomain)
-> Generic ListTagsForDomain
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' :: Text -> ListTagsForDomain
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 :: (Text -> f Text) -> ListTagsForDomain -> f ListTagsForDomain
listTagsForDomain_domainName = (ListTagsForDomain -> Text)
-> (ListTagsForDomain -> Text -> ListTagsForDomain)
-> Lens ListTagsForDomain ListTagsForDomain Text Text
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 :: ListTagsForDomain -> Request ListTagsForDomain
request = Service -> ListTagsForDomain -> Request ListTagsForDomain
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListTagsForDomain
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListTagsForDomain)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListTagsForDomain))
-> Logger
-> Service
-> Proxy ListTagsForDomain
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListTagsForDomain)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> [Tag] -> ListTagsForDomainResponse
ListTagsForDomainResponse'
            (Int -> [Tag] -> ListTagsForDomainResponse)
-> Either String Int
-> Either String ([Tag] -> ListTagsForDomainResponse)
forall (f :: * -> *) a b. Functor 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))
            Either String ([Tag] -> ListTagsForDomainResponse)
-> Either String [Tag] -> Either String ListTagsForDomainResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe [Tag])
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"TagList" Either String (Maybe [Tag]) -> [Tag] -> Either String [Tag]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Tag]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable ListTagsForDomain

instance Prelude.NFData ListTagsForDomain

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

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

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

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

-- | The ListTagsForDomain response includes the following elements.
--
-- /See:/ 'newListTagsForDomainResponse' smart constructor.
data ListTagsForDomainResponse = ListTagsForDomainResponse'
  { -- | The response's http status code.
    ListTagsForDomainResponse -> Int
httpStatus :: Prelude.Int,
    -- | A list of the tags that are associated with the specified domain.
    ListTagsForDomainResponse -> [Tag]
tagList :: [Tag]
  }
  deriving (ListTagsForDomainResponse -> ListTagsForDomainResponse -> Bool
(ListTagsForDomainResponse -> ListTagsForDomainResponse -> Bool)
-> (ListTagsForDomainResponse -> ListTagsForDomainResponse -> Bool)
-> Eq ListTagsForDomainResponse
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]
(Int -> ReadS ListTagsForDomainResponse)
-> ReadS [ListTagsForDomainResponse]
-> ReadPrec ListTagsForDomainResponse
-> ReadPrec [ListTagsForDomainResponse]
-> Read 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
(Int -> ListTagsForDomainResponse -> ShowS)
-> (ListTagsForDomainResponse -> String)
-> ([ListTagsForDomainResponse] -> ShowS)
-> Show ListTagsForDomainResponse
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.
 ListTagsForDomainResponse -> Rep ListTagsForDomainResponse x)
-> (forall x.
    Rep ListTagsForDomainResponse x -> ListTagsForDomainResponse)
-> Generic ListTagsForDomainResponse
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:
--
-- 'httpStatus', 'listTagsForDomainResponse_httpStatus' - The response's http status code.
--
-- 'tagList', 'listTagsForDomainResponse_tagList' - A list of the tags that are associated with the specified domain.
newListTagsForDomainResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListTagsForDomainResponse
newListTagsForDomainResponse :: Int -> ListTagsForDomainResponse
newListTagsForDomainResponse Int
pHttpStatus_ =
  ListTagsForDomainResponse' :: Int -> [Tag] -> ListTagsForDomainResponse
ListTagsForDomainResponse'
    { $sel:httpStatus:ListTagsForDomainResponse' :: Int
httpStatus =
        Int
pHttpStatus_,
      $sel:tagList:ListTagsForDomainResponse' :: [Tag]
tagList = [Tag]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The response's http status code.
listTagsForDomainResponse_httpStatus :: Lens.Lens' ListTagsForDomainResponse Prelude.Int
listTagsForDomainResponse_httpStatus :: (Int -> f Int)
-> ListTagsForDomainResponse -> f ListTagsForDomainResponse
listTagsForDomainResponse_httpStatus = (ListTagsForDomainResponse -> Int)
-> (ListTagsForDomainResponse -> Int -> ListTagsForDomainResponse)
-> Lens ListTagsForDomainResponse ListTagsForDomainResponse Int Int
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)

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

instance Prelude.NFData ListTagsForDomainResponse