{-# 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.Polly.Types.Lexicon
-- 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)
module Amazonka.Polly.Types.Lexicon where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Provides lexicon name and lexicon content in string format. For more
-- information, see
-- <https://www.w3.org/TR/pronunciation-lexicon/ Pronunciation Lexicon Specification (PLS) Version 1.0>.
--
-- /See:/ 'newLexicon' smart constructor.
data Lexicon = Lexicon'
  { -- | Lexicon content in string format. The content of a lexicon must be in
    -- PLS format.
    Lexicon -> Maybe (Sensitive Text)
content :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | Name of the lexicon.
    Lexicon -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (Lexicon -> Lexicon -> Bool
(Lexicon -> Lexicon -> Bool)
-> (Lexicon -> Lexicon -> Bool) -> Eq Lexicon
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Lexicon -> Lexicon -> Bool
$c/= :: Lexicon -> Lexicon -> Bool
== :: Lexicon -> Lexicon -> Bool
$c== :: Lexicon -> Lexicon -> Bool
Prelude.Eq, Int -> Lexicon -> ShowS
[Lexicon] -> ShowS
Lexicon -> String
(Int -> Lexicon -> ShowS)
-> (Lexicon -> String) -> ([Lexicon] -> ShowS) -> Show Lexicon
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Lexicon] -> ShowS
$cshowList :: [Lexicon] -> ShowS
show :: Lexicon -> String
$cshow :: Lexicon -> String
showsPrec :: Int -> Lexicon -> ShowS
$cshowsPrec :: Int -> Lexicon -> ShowS
Prelude.Show, (forall x. Lexicon -> Rep Lexicon x)
-> (forall x. Rep Lexicon x -> Lexicon) -> Generic Lexicon
forall x. Rep Lexicon x -> Lexicon
forall x. Lexicon -> Rep Lexicon x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Lexicon x -> Lexicon
$cfrom :: forall x. Lexicon -> Rep Lexicon x
Prelude.Generic)

-- |
-- Create a value of 'Lexicon' 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:
--
-- 'content', 'lexicon_content' - Lexicon content in string format. The content of a lexicon must be in
-- PLS format.
--
-- 'name', 'lexicon_name' - Name of the lexicon.
newLexicon ::
  Lexicon
newLexicon :: Lexicon
newLexicon =
  Lexicon' :: Maybe (Sensitive Text) -> Maybe Text -> Lexicon
Lexicon'
    { $sel:content:Lexicon' :: Maybe (Sensitive Text)
content = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Lexicon' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Lexicon content in string format. The content of a lexicon must be in
-- PLS format.
lexicon_content :: Lens.Lens' Lexicon (Prelude.Maybe Prelude.Text)
lexicon_content :: (Maybe Text -> f (Maybe Text)) -> Lexicon -> f Lexicon
lexicon_content = (Lexicon -> Maybe (Sensitive Text))
-> (Lexicon -> Maybe (Sensitive Text) -> Lexicon)
-> Lens
     Lexicon Lexicon (Maybe (Sensitive Text)) (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Lexicon' {Maybe (Sensitive Text)
content :: Maybe (Sensitive Text)
$sel:content:Lexicon' :: Lexicon -> Maybe (Sensitive Text)
content} -> Maybe (Sensitive Text)
content) (\s :: Lexicon
s@Lexicon' {} Maybe (Sensitive Text)
a -> Lexicon
s {$sel:content:Lexicon' :: Maybe (Sensitive Text)
content = Maybe (Sensitive Text)
a} :: Lexicon) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> Lexicon -> f Lexicon)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> Lexicon
-> f Lexicon
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 AnIso (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | Name of the lexicon.
lexicon_name :: Lens.Lens' Lexicon (Prelude.Maybe Prelude.Text)
lexicon_name :: (Maybe Text -> f (Maybe Text)) -> Lexicon -> f Lexicon
lexicon_name = (Lexicon -> Maybe Text)
-> (Lexicon -> Maybe Text -> Lexicon)
-> Lens Lexicon Lexicon (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Lexicon' {Maybe Text
name :: Maybe Text
$sel:name:Lexicon' :: Lexicon -> Maybe Text
name} -> Maybe Text
name) (\s :: Lexicon
s@Lexicon' {} Maybe Text
a -> Lexicon
s {$sel:name:Lexicon' :: Maybe Text
name = Maybe Text
a} :: Lexicon)

instance Core.FromJSON Lexicon where
  parseJSON :: Value -> Parser Lexicon
parseJSON =
    String -> (Object -> Parser Lexicon) -> Value -> Parser Lexicon
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Lexicon"
      ( \Object
x ->
          Maybe (Sensitive Text) -> Maybe Text -> Lexicon
Lexicon'
            (Maybe (Sensitive Text) -> Maybe Text -> Lexicon)
-> Parser (Maybe (Sensitive Text))
-> Parser (Maybe Text -> Lexicon)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Sensitive Text))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Content")
            Parser (Maybe Text -> Lexicon)
-> Parser (Maybe Text) -> Parser Lexicon
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
      )

instance Prelude.Hashable Lexicon

instance Prelude.NFData Lexicon