{-# 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.OptOutSpeaker
-- 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)
--
-- Opts out a speaker from Voice ID system. A speaker can be opted out
-- regardless of whether or not they already exist in the system. If they
-- don\'t yet exist, a new speaker is created in an opted out state. If
-- they already exist, their existing status is overridden and they are
-- opted out. Enrollment and evaluation authentication requests are
-- rejected for opted out speakers, and opted out speakers have no voice
-- embeddings stored in the system.
module Amazonka.VoiceId.OptOutSpeaker
  ( -- * Creating a Request
    OptOutSpeaker (..),
    newOptOutSpeaker,

    -- * Request Lenses
    optOutSpeaker_domainId,
    optOutSpeaker_speakerId,

    -- * Destructuring the Response
    OptOutSpeakerResponse (..),
    newOptOutSpeakerResponse,

    -- * Response Lenses
    optOutSpeakerResponse_speaker,
    optOutSpeakerResponse_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:/ 'newOptOutSpeaker' smart constructor.
data OptOutSpeaker = OptOutSpeaker'
  { -- | The identifier of the domain containing the speaker.
    OptOutSpeaker -> Text
domainId :: Prelude.Text,
    -- | The identifier of the speaker you want opted-out.
    OptOutSpeaker -> Sensitive Text
speakerId :: Core.Sensitive Prelude.Text
  }
  deriving (OptOutSpeaker -> OptOutSpeaker -> Bool
(OptOutSpeaker -> OptOutSpeaker -> Bool)
-> (OptOutSpeaker -> OptOutSpeaker -> Bool) -> Eq OptOutSpeaker
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OptOutSpeaker -> OptOutSpeaker -> Bool
$c/= :: OptOutSpeaker -> OptOutSpeaker -> Bool
== :: OptOutSpeaker -> OptOutSpeaker -> Bool
$c== :: OptOutSpeaker -> OptOutSpeaker -> Bool
Prelude.Eq, Int -> OptOutSpeaker -> ShowS
[OptOutSpeaker] -> ShowS
OptOutSpeaker -> String
(Int -> OptOutSpeaker -> ShowS)
-> (OptOutSpeaker -> String)
-> ([OptOutSpeaker] -> ShowS)
-> Show OptOutSpeaker
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OptOutSpeaker] -> ShowS
$cshowList :: [OptOutSpeaker] -> ShowS
show :: OptOutSpeaker -> String
$cshow :: OptOutSpeaker -> String
showsPrec :: Int -> OptOutSpeaker -> ShowS
$cshowsPrec :: Int -> OptOutSpeaker -> ShowS
Prelude.Show, (forall x. OptOutSpeaker -> Rep OptOutSpeaker x)
-> (forall x. Rep OptOutSpeaker x -> OptOutSpeaker)
-> Generic OptOutSpeaker
forall x. Rep OptOutSpeaker x -> OptOutSpeaker
forall x. OptOutSpeaker -> Rep OptOutSpeaker x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OptOutSpeaker x -> OptOutSpeaker
$cfrom :: forall x. OptOutSpeaker -> Rep OptOutSpeaker x
Prelude.Generic)

-- |
-- Create a value of 'OptOutSpeaker' 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', 'optOutSpeaker_domainId' - The identifier of the domain containing the speaker.
--
-- 'speakerId', 'optOutSpeaker_speakerId' - The identifier of the speaker you want opted-out.
newOptOutSpeaker ::
  -- | 'domainId'
  Prelude.Text ->
  -- | 'speakerId'
  Prelude.Text ->
  OptOutSpeaker
newOptOutSpeaker :: Text -> Text -> OptOutSpeaker
newOptOutSpeaker Text
pDomainId_ Text
pSpeakerId_ =
  OptOutSpeaker' :: Text -> Sensitive Text -> OptOutSpeaker
OptOutSpeaker'
    { $sel:domainId:OptOutSpeaker' :: Text
domainId = Text
pDomainId_,
      $sel:speakerId:OptOutSpeaker' :: 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 containing the speaker.
optOutSpeaker_domainId :: Lens.Lens' OptOutSpeaker Prelude.Text
optOutSpeaker_domainId :: (Text -> f Text) -> OptOutSpeaker -> f OptOutSpeaker
optOutSpeaker_domainId = (OptOutSpeaker -> Text)
-> (OptOutSpeaker -> Text -> OptOutSpeaker)
-> Lens OptOutSpeaker OptOutSpeaker Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OptOutSpeaker' {Text
domainId :: Text
$sel:domainId:OptOutSpeaker' :: OptOutSpeaker -> Text
domainId} -> Text
domainId) (\s :: OptOutSpeaker
s@OptOutSpeaker' {} Text
a -> OptOutSpeaker
s {$sel:domainId:OptOutSpeaker' :: Text
domainId = Text
a} :: OptOutSpeaker)

-- | The identifier of the speaker you want opted-out.
optOutSpeaker_speakerId :: Lens.Lens' OptOutSpeaker Prelude.Text
optOutSpeaker_speakerId :: (Text -> f Text) -> OptOutSpeaker -> f OptOutSpeaker
optOutSpeaker_speakerId = (OptOutSpeaker -> Sensitive Text)
-> (OptOutSpeaker -> Sensitive Text -> OptOutSpeaker)
-> Lens
     OptOutSpeaker OptOutSpeaker (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OptOutSpeaker' {Sensitive Text
speakerId :: Sensitive Text
$sel:speakerId:OptOutSpeaker' :: OptOutSpeaker -> Sensitive Text
speakerId} -> Sensitive Text
speakerId) (\s :: OptOutSpeaker
s@OptOutSpeaker' {} Sensitive Text
a -> OptOutSpeaker
s {$sel:speakerId:OptOutSpeaker' :: Sensitive Text
speakerId = Sensitive Text
a} :: OptOutSpeaker) ((Sensitive Text -> f (Sensitive Text))
 -> OptOutSpeaker -> f OptOutSpeaker)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> OptOutSpeaker
-> f OptOutSpeaker
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 OptOutSpeaker where
  type
    AWSResponse OptOutSpeaker =
      OptOutSpeakerResponse
  request :: OptOutSpeaker -> Request OptOutSpeaker
request = Service -> OptOutSpeaker -> Request OptOutSpeaker
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy OptOutSpeaker
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse OptOutSpeaker)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse OptOutSpeaker))
-> Logger
-> Service
-> Proxy OptOutSpeaker
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse OptOutSpeaker)))
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 -> OptOutSpeakerResponse
OptOutSpeakerResponse'
            (Maybe Speaker -> Int -> OptOutSpeakerResponse)
-> Either String (Maybe Speaker)
-> Either String (Int -> OptOutSpeakerResponse)
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 -> OptOutSpeakerResponse)
-> Either String Int -> Either String OptOutSpeakerResponse
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 OptOutSpeaker

instance Prelude.NFData OptOutSpeaker

instance Core.ToHeaders OptOutSpeaker where
  toHeaders :: OptOutSpeaker -> ResponseHeaders
toHeaders =
    ResponseHeaders -> OptOutSpeaker -> 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.OptOutSpeaker" :: 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 OptOutSpeaker where
  toJSON :: OptOutSpeaker -> Value
toJSON OptOutSpeaker' {Text
Sensitive Text
speakerId :: Sensitive Text
domainId :: Text
$sel:speakerId:OptOutSpeaker' :: OptOutSpeaker -> Sensitive Text
$sel:domainId:OptOutSpeaker' :: OptOutSpeaker -> 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 OptOutSpeaker where
  toPath :: OptOutSpeaker -> ByteString
toPath = ByteString -> OptOutSpeaker -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'OptOutSpeakerResponse' 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', 'optOutSpeakerResponse_speaker' - Details about the opted-out speaker.
--
-- 'httpStatus', 'optOutSpeakerResponse_httpStatus' - The response's http status code.
newOptOutSpeakerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  OptOutSpeakerResponse
newOptOutSpeakerResponse :: Int -> OptOutSpeakerResponse
newOptOutSpeakerResponse Int
pHttpStatus_ =
  OptOutSpeakerResponse' :: Maybe Speaker -> Int -> OptOutSpeakerResponse
OptOutSpeakerResponse'
    { $sel:speaker:OptOutSpeakerResponse' :: Maybe Speaker
speaker = Maybe Speaker
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:OptOutSpeakerResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Details about the opted-out speaker.
optOutSpeakerResponse_speaker :: Lens.Lens' OptOutSpeakerResponse (Prelude.Maybe Speaker)
optOutSpeakerResponse_speaker :: (Maybe Speaker -> f (Maybe Speaker))
-> OptOutSpeakerResponse -> f OptOutSpeakerResponse
optOutSpeakerResponse_speaker = (OptOutSpeakerResponse -> Maybe Speaker)
-> (OptOutSpeakerResponse
    -> Maybe Speaker -> OptOutSpeakerResponse)
-> Lens
     OptOutSpeakerResponse
     OptOutSpeakerResponse
     (Maybe Speaker)
     (Maybe Speaker)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OptOutSpeakerResponse' {Maybe Speaker
speaker :: Maybe Speaker
$sel:speaker:OptOutSpeakerResponse' :: OptOutSpeakerResponse -> Maybe Speaker
speaker} -> Maybe Speaker
speaker) (\s :: OptOutSpeakerResponse
s@OptOutSpeakerResponse' {} Maybe Speaker
a -> OptOutSpeakerResponse
s {$sel:speaker:OptOutSpeakerResponse' :: Maybe Speaker
speaker = Maybe Speaker
a} :: OptOutSpeakerResponse)

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

instance Prelude.NFData OptOutSpeakerResponse