{-# 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.VoiceId.DescribeSpeaker
-- 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)
--
-- Describes the specified speaker.
module Amazonka.VoiceId.DescribeSpeaker
  ( -- * Creating a Request
    DescribeSpeaker (..),
    newDescribeSpeaker,

    -- * Request Lenses
    describeSpeaker_domainId,
    describeSpeaker_speakerId,

    -- * Destructuring the Response
    DescribeSpeakerResponse (..),
    newDescribeSpeakerResponse,

    -- * Response Lenses
    describeSpeakerResponse_speaker,
    describeSpeakerResponse_httpStatus,
  )
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.VoiceId.Types

-- | /See:/ 'newDescribeSpeaker' smart constructor.
data DescribeSpeaker = DescribeSpeaker'
  { -- | The identifier of the domain that contains the speaker.
    DescribeSpeaker -> Text
domainId :: Prelude.Text,
    -- | The identifier of the speaker you are describing.
    DescribeSpeaker -> Sensitive Text
speakerId :: Core.Sensitive Prelude.Text
  }
  deriving (DescribeSpeaker -> DescribeSpeaker -> Bool
(DescribeSpeaker -> DescribeSpeaker -> Bool)
-> (DescribeSpeaker -> DescribeSpeaker -> Bool)
-> Eq DescribeSpeaker
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeSpeaker -> DescribeSpeaker -> Bool
$c/= :: DescribeSpeaker -> DescribeSpeaker -> Bool
== :: DescribeSpeaker -> DescribeSpeaker -> Bool
$c== :: DescribeSpeaker -> DescribeSpeaker -> Bool
Prelude.Eq, Int -> DescribeSpeaker -> ShowS
[DescribeSpeaker] -> ShowS
DescribeSpeaker -> String
(Int -> DescribeSpeaker -> ShowS)
-> (DescribeSpeaker -> String)
-> ([DescribeSpeaker] -> ShowS)
-> Show DescribeSpeaker
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeSpeaker] -> ShowS
$cshowList :: [DescribeSpeaker] -> ShowS
show :: DescribeSpeaker -> String
$cshow :: DescribeSpeaker -> String
showsPrec :: Int -> DescribeSpeaker -> ShowS
$cshowsPrec :: Int -> DescribeSpeaker -> ShowS
Prelude.Show, (forall x. DescribeSpeaker -> Rep DescribeSpeaker x)
-> (forall x. Rep DescribeSpeaker x -> DescribeSpeaker)
-> Generic DescribeSpeaker
forall x. Rep DescribeSpeaker x -> DescribeSpeaker
forall x. DescribeSpeaker -> Rep DescribeSpeaker x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeSpeaker x -> DescribeSpeaker
$cfrom :: forall x. DescribeSpeaker -> Rep DescribeSpeaker x
Prelude.Generic)

-- |
-- Create a value of 'DescribeSpeaker' 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:
--
-- 'domainId', 'describeSpeaker_domainId' - The identifier of the domain that contains the speaker.
--
-- 'speakerId', 'describeSpeaker_speakerId' - The identifier of the speaker you are describing.
newDescribeSpeaker ::
  -- | 'domainId'
  Prelude.Text ->
  -- | 'speakerId'
  Prelude.Text ->
  DescribeSpeaker
newDescribeSpeaker :: Text -> Text -> DescribeSpeaker
newDescribeSpeaker Text
pDomainId_ Text
pSpeakerId_ =
  DescribeSpeaker' :: Text -> Sensitive Text -> DescribeSpeaker
DescribeSpeaker'
    { $sel:domainId:DescribeSpeaker' :: Text
domainId = Text
pDomainId_,
      $sel:speakerId:DescribeSpeaker' :: Sensitive Text
speakerId = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pSpeakerId_
    }

-- | The identifier of the domain that contains the speaker.
describeSpeaker_domainId :: Lens.Lens' DescribeSpeaker Prelude.Text
describeSpeaker_domainId :: (Text -> f Text) -> DescribeSpeaker -> f DescribeSpeaker
describeSpeaker_domainId = (DescribeSpeaker -> Text)
-> (DescribeSpeaker -> Text -> DescribeSpeaker)
-> Lens DescribeSpeaker DescribeSpeaker Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSpeaker' {Text
domainId :: Text
$sel:domainId:DescribeSpeaker' :: DescribeSpeaker -> Text
domainId} -> Text
domainId) (\s :: DescribeSpeaker
s@DescribeSpeaker' {} Text
a -> DescribeSpeaker
s {$sel:domainId:DescribeSpeaker' :: Text
domainId = Text
a} :: DescribeSpeaker)

-- | The identifier of the speaker you are describing.
describeSpeaker_speakerId :: Lens.Lens' DescribeSpeaker Prelude.Text
describeSpeaker_speakerId :: (Text -> f Text) -> DescribeSpeaker -> f DescribeSpeaker
describeSpeaker_speakerId = (DescribeSpeaker -> Sensitive Text)
-> (DescribeSpeaker -> Sensitive Text -> DescribeSpeaker)
-> Lens
     DescribeSpeaker DescribeSpeaker (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSpeaker' {Sensitive Text
speakerId :: Sensitive Text
$sel:speakerId:DescribeSpeaker' :: DescribeSpeaker -> Sensitive Text
speakerId} -> Sensitive Text
speakerId) (\s :: DescribeSpeaker
s@DescribeSpeaker' {} Sensitive Text
a -> DescribeSpeaker
s {$sel:speakerId:DescribeSpeaker' :: Sensitive Text
speakerId = Sensitive Text
a} :: DescribeSpeaker) ((Sensitive Text -> f (Sensitive Text))
 -> DescribeSpeaker -> f DescribeSpeaker)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> DescribeSpeaker
-> f DescribeSpeaker
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

instance Core.AWSRequest DescribeSpeaker where
  type
    AWSResponse DescribeSpeaker =
      DescribeSpeakerResponse
  request :: DescribeSpeaker -> Request DescribeSpeaker
request = Service -> DescribeSpeaker -> Request DescribeSpeaker
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeSpeaker
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeSpeaker)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeSpeaker))
-> Logger
-> Service
-> Proxy DescribeSpeaker
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeSpeaker)))
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 ->
          Maybe Speaker -> Int -> DescribeSpeakerResponse
DescribeSpeakerResponse'
            (Maybe Speaker -> Int -> DescribeSpeakerResponse)
-> Either String (Maybe Speaker)
-> Either String (Int -> DescribeSpeakerResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Speaker)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Speaker")
            Either String (Int -> DescribeSpeakerResponse)
-> Either String Int -> Either String DescribeSpeakerResponse
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 DescribeSpeaker

instance Prelude.NFData DescribeSpeaker

instance Core.ToHeaders DescribeSpeaker where
  toHeaders :: DescribeSpeaker -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeSpeaker -> 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
"VoiceID.DescribeSpeaker" :: Prelude.ByteString),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DescribeSpeaker where
  toJSON :: DescribeSpeaker -> Value
toJSON DescribeSpeaker' {Text
Sensitive Text
speakerId :: Sensitive Text
domainId :: Text
$sel:speakerId:DescribeSpeaker' :: DescribeSpeaker -> Sensitive Text
$sel:domainId:DescribeSpeaker' :: DescribeSpeaker -> 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
"DomainId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
domainId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"SpeakerId" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
speakerId)
          ]
      )

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

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

-- | /See:/ 'newDescribeSpeakerResponse' smart constructor.
data DescribeSpeakerResponse = DescribeSpeakerResponse'
  { -- | Information about the specified speaker.
    DescribeSpeakerResponse -> Maybe Speaker
speaker :: Prelude.Maybe Speaker,
    -- | The response's http status code.
    DescribeSpeakerResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeSpeakerResponse -> DescribeSpeakerResponse -> Bool
(DescribeSpeakerResponse -> DescribeSpeakerResponse -> Bool)
-> (DescribeSpeakerResponse -> DescribeSpeakerResponse -> Bool)
-> Eq DescribeSpeakerResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeSpeakerResponse -> DescribeSpeakerResponse -> Bool
$c/= :: DescribeSpeakerResponse -> DescribeSpeakerResponse -> Bool
== :: DescribeSpeakerResponse -> DescribeSpeakerResponse -> Bool
$c== :: DescribeSpeakerResponse -> DescribeSpeakerResponse -> Bool
Prelude.Eq, Int -> DescribeSpeakerResponse -> ShowS
[DescribeSpeakerResponse] -> ShowS
DescribeSpeakerResponse -> String
(Int -> DescribeSpeakerResponse -> ShowS)
-> (DescribeSpeakerResponse -> String)
-> ([DescribeSpeakerResponse] -> ShowS)
-> Show DescribeSpeakerResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeSpeakerResponse] -> ShowS
$cshowList :: [DescribeSpeakerResponse] -> ShowS
show :: DescribeSpeakerResponse -> String
$cshow :: DescribeSpeakerResponse -> String
showsPrec :: Int -> DescribeSpeakerResponse -> ShowS
$cshowsPrec :: Int -> DescribeSpeakerResponse -> ShowS
Prelude.Show, (forall x.
 DescribeSpeakerResponse -> Rep DescribeSpeakerResponse x)
-> (forall x.
    Rep DescribeSpeakerResponse x -> DescribeSpeakerResponse)
-> Generic DescribeSpeakerResponse
forall x. Rep DescribeSpeakerResponse x -> DescribeSpeakerResponse
forall x. DescribeSpeakerResponse -> Rep DescribeSpeakerResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeSpeakerResponse x -> DescribeSpeakerResponse
$cfrom :: forall x. DescribeSpeakerResponse -> Rep DescribeSpeakerResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeSpeakerResponse' 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:
--
-- 'speaker', 'describeSpeakerResponse_speaker' - Information about the specified speaker.
--
-- 'httpStatus', 'describeSpeakerResponse_httpStatus' - The response's http status code.
newDescribeSpeakerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeSpeakerResponse
newDescribeSpeakerResponse :: Int -> DescribeSpeakerResponse
newDescribeSpeakerResponse Int
pHttpStatus_ =
  DescribeSpeakerResponse' :: Maybe Speaker -> Int -> DescribeSpeakerResponse
DescribeSpeakerResponse'
    { $sel:speaker:DescribeSpeakerResponse' :: Maybe Speaker
speaker = Maybe Speaker
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeSpeakerResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about the specified speaker.
describeSpeakerResponse_speaker :: Lens.Lens' DescribeSpeakerResponse (Prelude.Maybe Speaker)
describeSpeakerResponse_speaker :: (Maybe Speaker -> f (Maybe Speaker))
-> DescribeSpeakerResponse -> f DescribeSpeakerResponse
describeSpeakerResponse_speaker = (DescribeSpeakerResponse -> Maybe Speaker)
-> (DescribeSpeakerResponse
    -> Maybe Speaker -> DescribeSpeakerResponse)
-> Lens
     DescribeSpeakerResponse
     DescribeSpeakerResponse
     (Maybe Speaker)
     (Maybe Speaker)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeSpeakerResponse' {Maybe Speaker
speaker :: Maybe Speaker
$sel:speaker:DescribeSpeakerResponse' :: DescribeSpeakerResponse -> Maybe Speaker
speaker} -> Maybe Speaker
speaker) (\s :: DescribeSpeakerResponse
s@DescribeSpeakerResponse' {} Maybe Speaker
a -> DescribeSpeakerResponse
s {$sel:speaker:DescribeSpeakerResponse' :: Maybe Speaker
speaker = Maybe Speaker
a} :: DescribeSpeakerResponse)

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

instance Prelude.NFData DescribeSpeakerResponse