{-# 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.LexV2Models.Types.ConversationLogSettings
-- 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.LexV2Models.Types.ConversationLogSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LexV2Models.Types.AudioLogSetting
import Amazonka.LexV2Models.Types.TextLogSetting
import qualified Amazonka.Prelude as Prelude

-- | Configures conversation logging that saves audio, text, and metadata for
-- the conversations with your users.
--
-- /See:/ 'newConversationLogSettings' smart constructor.
data ConversationLogSettings = ConversationLogSettings'
  { -- | The Amazon S3 settings for logging audio to an S3 bucket.
    ConversationLogSettings -> Maybe (NonEmpty AudioLogSetting)
audioLogSettings :: Prelude.Maybe (Prelude.NonEmpty AudioLogSetting),
    -- | The Amazon CloudWatch Logs settings for logging text and metadata.
    ConversationLogSettings -> Maybe (NonEmpty TextLogSetting)
textLogSettings :: Prelude.Maybe (Prelude.NonEmpty TextLogSetting)
  }
  deriving (ConversationLogSettings -> ConversationLogSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConversationLogSettings -> ConversationLogSettings -> Bool
$c/= :: ConversationLogSettings -> ConversationLogSettings -> Bool
== :: ConversationLogSettings -> ConversationLogSettings -> Bool
$c== :: ConversationLogSettings -> ConversationLogSettings -> Bool
Prelude.Eq, ReadPrec [ConversationLogSettings]
ReadPrec ConversationLogSettings
Int -> ReadS ConversationLogSettings
ReadS [ConversationLogSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConversationLogSettings]
$creadListPrec :: ReadPrec [ConversationLogSettings]
readPrec :: ReadPrec ConversationLogSettings
$creadPrec :: ReadPrec ConversationLogSettings
readList :: ReadS [ConversationLogSettings]
$creadList :: ReadS [ConversationLogSettings]
readsPrec :: Int -> ReadS ConversationLogSettings
$creadsPrec :: Int -> ReadS ConversationLogSettings
Prelude.Read, Int -> ConversationLogSettings -> ShowS
[ConversationLogSettings] -> ShowS
ConversationLogSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConversationLogSettings] -> ShowS
$cshowList :: [ConversationLogSettings] -> ShowS
show :: ConversationLogSettings -> String
$cshow :: ConversationLogSettings -> String
showsPrec :: Int -> ConversationLogSettings -> ShowS
$cshowsPrec :: Int -> ConversationLogSettings -> ShowS
Prelude.Show, forall x. Rep ConversationLogSettings x -> ConversationLogSettings
forall x. ConversationLogSettings -> Rep ConversationLogSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConversationLogSettings x -> ConversationLogSettings
$cfrom :: forall x. ConversationLogSettings -> Rep ConversationLogSettings x
Prelude.Generic)

-- |
-- Create a value of 'ConversationLogSettings' 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:
--
-- 'audioLogSettings', 'conversationLogSettings_audioLogSettings' - The Amazon S3 settings for logging audio to an S3 bucket.
--
-- 'textLogSettings', 'conversationLogSettings_textLogSettings' - The Amazon CloudWatch Logs settings for logging text and metadata.
newConversationLogSettings ::
  ConversationLogSettings
newConversationLogSettings :: ConversationLogSettings
newConversationLogSettings =
  ConversationLogSettings'
    { $sel:audioLogSettings:ConversationLogSettings' :: Maybe (NonEmpty AudioLogSetting)
audioLogSettings =
        forall a. Maybe a
Prelude.Nothing,
      $sel:textLogSettings:ConversationLogSettings' :: Maybe (NonEmpty TextLogSetting)
textLogSettings = forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon S3 settings for logging audio to an S3 bucket.
conversationLogSettings_audioLogSettings :: Lens.Lens' ConversationLogSettings (Prelude.Maybe (Prelude.NonEmpty AudioLogSetting))
conversationLogSettings_audioLogSettings :: Lens' ConversationLogSettings (Maybe (NonEmpty AudioLogSetting))
conversationLogSettings_audioLogSettings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConversationLogSettings' {Maybe (NonEmpty AudioLogSetting)
audioLogSettings :: Maybe (NonEmpty AudioLogSetting)
$sel:audioLogSettings:ConversationLogSettings' :: ConversationLogSettings -> Maybe (NonEmpty AudioLogSetting)
audioLogSettings} -> Maybe (NonEmpty AudioLogSetting)
audioLogSettings) (\s :: ConversationLogSettings
s@ConversationLogSettings' {} Maybe (NonEmpty AudioLogSetting)
a -> ConversationLogSettings
s {$sel:audioLogSettings:ConversationLogSettings' :: Maybe (NonEmpty AudioLogSetting)
audioLogSettings = Maybe (NonEmpty AudioLogSetting)
a} :: ConversationLogSettings) 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 Amazon CloudWatch Logs settings for logging text and metadata.
conversationLogSettings_textLogSettings :: Lens.Lens' ConversationLogSettings (Prelude.Maybe (Prelude.NonEmpty TextLogSetting))
conversationLogSettings_textLogSettings :: Lens' ConversationLogSettings (Maybe (NonEmpty TextLogSetting))
conversationLogSettings_textLogSettings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConversationLogSettings' {Maybe (NonEmpty TextLogSetting)
textLogSettings :: Maybe (NonEmpty TextLogSetting)
$sel:textLogSettings:ConversationLogSettings' :: ConversationLogSettings -> Maybe (NonEmpty TextLogSetting)
textLogSettings} -> Maybe (NonEmpty TextLogSetting)
textLogSettings) (\s :: ConversationLogSettings
s@ConversationLogSettings' {} Maybe (NonEmpty TextLogSetting)
a -> ConversationLogSettings
s {$sel:textLogSettings:ConversationLogSettings' :: Maybe (NonEmpty TextLogSetting)
textLogSettings = Maybe (NonEmpty TextLogSetting)
a} :: ConversationLogSettings) 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

instance Data.FromJSON ConversationLogSettings where
  parseJSON :: Value -> Parser ConversationLogSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ConversationLogSettings"
      ( \Object
x ->
          Maybe (NonEmpty AudioLogSetting)
-> Maybe (NonEmpty TextLogSetting) -> ConversationLogSettings
ConversationLogSettings'
            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
"audioLogSettings")
            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
"textLogSettings")
      )

instance Prelude.Hashable ConversationLogSettings where
  hashWithSalt :: Int -> ConversationLogSettings -> Int
hashWithSalt Int
_salt ConversationLogSettings' {Maybe (NonEmpty AudioLogSetting)
Maybe (NonEmpty TextLogSetting)
textLogSettings :: Maybe (NonEmpty TextLogSetting)
audioLogSettings :: Maybe (NonEmpty AudioLogSetting)
$sel:textLogSettings:ConversationLogSettings' :: ConversationLogSettings -> Maybe (NonEmpty TextLogSetting)
$sel:audioLogSettings:ConversationLogSettings' :: ConversationLogSettings -> Maybe (NonEmpty AudioLogSetting)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty AudioLogSetting)
audioLogSettings
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty TextLogSetting)
textLogSettings

instance Prelude.NFData ConversationLogSettings where
  rnf :: ConversationLogSettings -> ()
rnf ConversationLogSettings' {Maybe (NonEmpty AudioLogSetting)
Maybe (NonEmpty TextLogSetting)
textLogSettings :: Maybe (NonEmpty TextLogSetting)
audioLogSettings :: Maybe (NonEmpty AudioLogSetting)
$sel:textLogSettings:ConversationLogSettings' :: ConversationLogSettings -> Maybe (NonEmpty TextLogSetting)
$sel:audioLogSettings:ConversationLogSettings' :: ConversationLogSettings -> Maybe (NonEmpty AudioLogSetting)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty AudioLogSetting)
audioLogSettings
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty TextLogSetting)
textLogSettings

instance Data.ToJSON ConversationLogSettings where
  toJSON :: ConversationLogSettings -> Value
toJSON ConversationLogSettings' {Maybe (NonEmpty AudioLogSetting)
Maybe (NonEmpty TextLogSetting)
textLogSettings :: Maybe (NonEmpty TextLogSetting)
audioLogSettings :: Maybe (NonEmpty AudioLogSetting)
$sel:textLogSettings:ConversationLogSettings' :: ConversationLogSettings -> Maybe (NonEmpty TextLogSetting)
$sel:audioLogSettings:ConversationLogSettings' :: ConversationLogSettings -> Maybe (NonEmpty AudioLogSetting)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"audioLogSettings" 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 (NonEmpty AudioLogSetting)
audioLogSettings,
            (Key
"textLogSettings" 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 (NonEmpty TextLogSetting)
textLogSettings
          ]
      )