{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Transcribe.Types.ChannelDefinition
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Transcribe.Types.ChannelDefinition 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 Amazonka.Transcribe.Types.ParticipantRole

-- | Makes it possible to specify which speaker is on which channel. For
-- example, if your agent is the first participant to speak, you would set
-- @ChannelId@ to @0@ (to indicate the first channel) and @ParticipantRole@
-- to @AGENT@ (to indicate that it\'s the agent speaking).
--
-- /See:/ 'newChannelDefinition' smart constructor.
data ChannelDefinition = ChannelDefinition'
  { -- | Specify the audio channel you want to define.
    ChannelDefinition -> Maybe Natural
channelId :: Prelude.Maybe Prelude.Natural,
    -- | Specify the speaker you want to define. Omitting this parameter is
    -- equivalent to specifying both participants.
    ChannelDefinition -> Maybe ParticipantRole
participantRole :: Prelude.Maybe ParticipantRole
  }
  deriving (ChannelDefinition -> ChannelDefinition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChannelDefinition -> ChannelDefinition -> Bool
$c/= :: ChannelDefinition -> ChannelDefinition -> Bool
== :: ChannelDefinition -> ChannelDefinition -> Bool
$c== :: ChannelDefinition -> ChannelDefinition -> Bool
Prelude.Eq, ReadPrec [ChannelDefinition]
ReadPrec ChannelDefinition
Int -> ReadS ChannelDefinition
ReadS [ChannelDefinition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ChannelDefinition]
$creadListPrec :: ReadPrec [ChannelDefinition]
readPrec :: ReadPrec ChannelDefinition
$creadPrec :: ReadPrec ChannelDefinition
readList :: ReadS [ChannelDefinition]
$creadList :: ReadS [ChannelDefinition]
readsPrec :: Int -> ReadS ChannelDefinition
$creadsPrec :: Int -> ReadS ChannelDefinition
Prelude.Read, Int -> ChannelDefinition -> ShowS
[ChannelDefinition] -> ShowS
ChannelDefinition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChannelDefinition] -> ShowS
$cshowList :: [ChannelDefinition] -> ShowS
show :: ChannelDefinition -> String
$cshow :: ChannelDefinition -> String
showsPrec :: Int -> ChannelDefinition -> ShowS
$cshowsPrec :: Int -> ChannelDefinition -> ShowS
Prelude.Show, forall x. Rep ChannelDefinition x -> ChannelDefinition
forall x. ChannelDefinition -> Rep ChannelDefinition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ChannelDefinition x -> ChannelDefinition
$cfrom :: forall x. ChannelDefinition -> Rep ChannelDefinition x
Prelude.Generic)

-- |
-- Create a value of 'ChannelDefinition' 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:
--
-- 'channelId', 'channelDefinition_channelId' - Specify the audio channel you want to define.
--
-- 'participantRole', 'channelDefinition_participantRole' - Specify the speaker you want to define. Omitting this parameter is
-- equivalent to specifying both participants.
newChannelDefinition ::
  ChannelDefinition
newChannelDefinition :: ChannelDefinition
newChannelDefinition =
  ChannelDefinition'
    { $sel:channelId:ChannelDefinition' :: Maybe Natural
channelId = forall a. Maybe a
Prelude.Nothing,
      $sel:participantRole:ChannelDefinition' :: Maybe ParticipantRole
participantRole = forall a. Maybe a
Prelude.Nothing
    }

-- | Specify the audio channel you want to define.
channelDefinition_channelId :: Lens.Lens' ChannelDefinition (Prelude.Maybe Prelude.Natural)
channelDefinition_channelId :: Lens' ChannelDefinition (Maybe Natural)
channelDefinition_channelId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelDefinition' {Maybe Natural
channelId :: Maybe Natural
$sel:channelId:ChannelDefinition' :: ChannelDefinition -> Maybe Natural
channelId} -> Maybe Natural
channelId) (\s :: ChannelDefinition
s@ChannelDefinition' {} Maybe Natural
a -> ChannelDefinition
s {$sel:channelId:ChannelDefinition' :: Maybe Natural
channelId = Maybe Natural
a} :: ChannelDefinition)

-- | Specify the speaker you want to define. Omitting this parameter is
-- equivalent to specifying both participants.
channelDefinition_participantRole :: Lens.Lens' ChannelDefinition (Prelude.Maybe ParticipantRole)
channelDefinition_participantRole :: Lens' ChannelDefinition (Maybe ParticipantRole)
channelDefinition_participantRole = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ChannelDefinition' {Maybe ParticipantRole
participantRole :: Maybe ParticipantRole
$sel:participantRole:ChannelDefinition' :: ChannelDefinition -> Maybe ParticipantRole
participantRole} -> Maybe ParticipantRole
participantRole) (\s :: ChannelDefinition
s@ChannelDefinition' {} Maybe ParticipantRole
a -> ChannelDefinition
s {$sel:participantRole:ChannelDefinition' :: Maybe ParticipantRole
participantRole = Maybe ParticipantRole
a} :: ChannelDefinition)

instance Data.FromJSON ChannelDefinition where
  parseJSON :: Value -> Parser ChannelDefinition
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ChannelDefinition"
      ( \Object
x ->
          Maybe Natural -> Maybe ParticipantRole -> ChannelDefinition
ChannelDefinition'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ChannelId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ParticipantRole")
      )

instance Prelude.Hashable ChannelDefinition where
  hashWithSalt :: Int -> ChannelDefinition -> Int
hashWithSalt Int
_salt ChannelDefinition' {Maybe Natural
Maybe ParticipantRole
participantRole :: Maybe ParticipantRole
channelId :: Maybe Natural
$sel:participantRole:ChannelDefinition' :: ChannelDefinition -> Maybe ParticipantRole
$sel:channelId:ChannelDefinition' :: ChannelDefinition -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
channelId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ParticipantRole
participantRole

instance Prelude.NFData ChannelDefinition where
  rnf :: ChannelDefinition -> ()
rnf ChannelDefinition' {Maybe Natural
Maybe ParticipantRole
participantRole :: Maybe ParticipantRole
channelId :: Maybe Natural
$sel:participantRole:ChannelDefinition' :: ChannelDefinition -> Maybe ParticipantRole
$sel:channelId:ChannelDefinition' :: ChannelDefinition -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
channelId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ParticipantRole
participantRole

instance Data.ToJSON ChannelDefinition where
  toJSON :: ChannelDefinition -> Value
toJSON ChannelDefinition' {Maybe Natural
Maybe ParticipantRole
participantRole :: Maybe ParticipantRole
channelId :: Maybe Natural
$sel:participantRole:ChannelDefinition' :: ChannelDefinition -> Maybe ParticipantRole
$sel:channelId:ChannelDefinition' :: ChannelDefinition -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ChannelId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
channelId,
            (Key
"ParticipantRole" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ParticipantRole
participantRole
          ]
      )