{-# 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.Translate.Types.AppliedTerminology
-- 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.Translate.Types.AppliedTerminology where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Translate.Types.Term

-- | The custom terminology applied to the input text by Amazon Translate for
-- the translated text response. This is optional in the response and will
-- only be present if you specified terminology input in the request.
-- Currently, only one terminology can be applied per TranslateText
-- request.
--
-- /See:/ 'newAppliedTerminology' smart constructor.
data AppliedTerminology = AppliedTerminology'
  { -- | The specific terms of the custom terminology applied to the input text
    -- by Amazon Translate for the translated text response. A maximum of 250
    -- terms will be returned, and the specific terms applied will be the first
    -- 250 terms in the source text.
    AppliedTerminology -> Maybe [Term]
terms :: Prelude.Maybe [Term],
    -- | The name of the custom terminology applied to the input text by Amazon
    -- Translate for the translated text response.
    AppliedTerminology -> Maybe Text
name :: Prelude.Maybe Prelude.Text
  }
  deriving (AppliedTerminology -> AppliedTerminology -> Bool
(AppliedTerminology -> AppliedTerminology -> Bool)
-> (AppliedTerminology -> AppliedTerminology -> Bool)
-> Eq AppliedTerminology
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AppliedTerminology -> AppliedTerminology -> Bool
$c/= :: AppliedTerminology -> AppliedTerminology -> Bool
== :: AppliedTerminology -> AppliedTerminology -> Bool
$c== :: AppliedTerminology -> AppliedTerminology -> Bool
Prelude.Eq, ReadPrec [AppliedTerminology]
ReadPrec AppliedTerminology
Int -> ReadS AppliedTerminology
ReadS [AppliedTerminology]
(Int -> ReadS AppliedTerminology)
-> ReadS [AppliedTerminology]
-> ReadPrec AppliedTerminology
-> ReadPrec [AppliedTerminology]
-> Read AppliedTerminology
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AppliedTerminology]
$creadListPrec :: ReadPrec [AppliedTerminology]
readPrec :: ReadPrec AppliedTerminology
$creadPrec :: ReadPrec AppliedTerminology
readList :: ReadS [AppliedTerminology]
$creadList :: ReadS [AppliedTerminology]
readsPrec :: Int -> ReadS AppliedTerminology
$creadsPrec :: Int -> ReadS AppliedTerminology
Prelude.Read, Int -> AppliedTerminology -> ShowS
[AppliedTerminology] -> ShowS
AppliedTerminology -> String
(Int -> AppliedTerminology -> ShowS)
-> (AppliedTerminology -> String)
-> ([AppliedTerminology] -> ShowS)
-> Show AppliedTerminology
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AppliedTerminology] -> ShowS
$cshowList :: [AppliedTerminology] -> ShowS
show :: AppliedTerminology -> String
$cshow :: AppliedTerminology -> String
showsPrec :: Int -> AppliedTerminology -> ShowS
$cshowsPrec :: Int -> AppliedTerminology -> ShowS
Prelude.Show, (forall x. AppliedTerminology -> Rep AppliedTerminology x)
-> (forall x. Rep AppliedTerminology x -> AppliedTerminology)
-> Generic AppliedTerminology
forall x. Rep AppliedTerminology x -> AppliedTerminology
forall x. AppliedTerminology -> Rep AppliedTerminology x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AppliedTerminology x -> AppliedTerminology
$cfrom :: forall x. AppliedTerminology -> Rep AppliedTerminology x
Prelude.Generic)

-- |
-- Create a value of 'AppliedTerminology' 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:
--
-- 'terms', 'appliedTerminology_terms' - The specific terms of the custom terminology applied to the input text
-- by Amazon Translate for the translated text response. A maximum of 250
-- terms will be returned, and the specific terms applied will be the first
-- 250 terms in the source text.
--
-- 'name', 'appliedTerminology_name' - The name of the custom terminology applied to the input text by Amazon
-- Translate for the translated text response.
newAppliedTerminology ::
  AppliedTerminology
newAppliedTerminology :: AppliedTerminology
newAppliedTerminology =
  AppliedTerminology' :: Maybe [Term] -> Maybe Text -> AppliedTerminology
AppliedTerminology'
    { $sel:terms:AppliedTerminology' :: Maybe [Term]
terms = Maybe [Term]
forall a. Maybe a
Prelude.Nothing,
      $sel:name:AppliedTerminology' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The specific terms of the custom terminology applied to the input text
-- by Amazon Translate for the translated text response. A maximum of 250
-- terms will be returned, and the specific terms applied will be the first
-- 250 terms in the source text.
appliedTerminology_terms :: Lens.Lens' AppliedTerminology (Prelude.Maybe [Term])
appliedTerminology_terms :: (Maybe [Term] -> f (Maybe [Term]))
-> AppliedTerminology -> f AppliedTerminology
appliedTerminology_terms = (AppliedTerminology -> Maybe [Term])
-> (AppliedTerminology -> Maybe [Term] -> AppliedTerminology)
-> Lens
     AppliedTerminology AppliedTerminology (Maybe [Term]) (Maybe [Term])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppliedTerminology' {Maybe [Term]
terms :: Maybe [Term]
$sel:terms:AppliedTerminology' :: AppliedTerminology -> Maybe [Term]
terms} -> Maybe [Term]
terms) (\s :: AppliedTerminology
s@AppliedTerminology' {} Maybe [Term]
a -> AppliedTerminology
s {$sel:terms:AppliedTerminology' :: Maybe [Term]
terms = Maybe [Term]
a} :: AppliedTerminology) ((Maybe [Term] -> f (Maybe [Term]))
 -> AppliedTerminology -> f AppliedTerminology)
-> ((Maybe [Term] -> f (Maybe [Term]))
    -> Maybe [Term] -> f (Maybe [Term]))
-> (Maybe [Term] -> f (Maybe [Term]))
-> AppliedTerminology
-> f AppliedTerminology
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Term] [Term] [Term] [Term]
-> Iso (Maybe [Term]) (Maybe [Term]) (Maybe [Term]) (Maybe [Term])
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 [Term] [Term] [Term] [Term]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name of the custom terminology applied to the input text by Amazon
-- Translate for the translated text response.
appliedTerminology_name :: Lens.Lens' AppliedTerminology (Prelude.Maybe Prelude.Text)
appliedTerminology_name :: (Maybe Text -> f (Maybe Text))
-> AppliedTerminology -> f AppliedTerminology
appliedTerminology_name = (AppliedTerminology -> Maybe Text)
-> (AppliedTerminology -> Maybe Text -> AppliedTerminology)
-> Lens
     AppliedTerminology AppliedTerminology (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AppliedTerminology' {Maybe Text
name :: Maybe Text
$sel:name:AppliedTerminology' :: AppliedTerminology -> Maybe Text
name} -> Maybe Text
name) (\s :: AppliedTerminology
s@AppliedTerminology' {} Maybe Text
a -> AppliedTerminology
s {$sel:name:AppliedTerminology' :: Maybe Text
name = Maybe Text
a} :: AppliedTerminology)

instance Core.FromJSON AppliedTerminology where
  parseJSON :: Value -> Parser AppliedTerminology
parseJSON =
    String
-> (Object -> Parser AppliedTerminology)
-> Value
-> Parser AppliedTerminology
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AppliedTerminology"
      ( \Object
x ->
          Maybe [Term] -> Maybe Text -> AppliedTerminology
AppliedTerminology'
            (Maybe [Term] -> Maybe Text -> AppliedTerminology)
-> Parser (Maybe [Term])
-> Parser (Maybe Text -> AppliedTerminology)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Term]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Terms" Parser (Maybe (Maybe [Term]))
-> Maybe [Term] -> Parser (Maybe [Term])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Term]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> AppliedTerminology)
-> Parser (Maybe Text) -> Parser AppliedTerminology
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 AppliedTerminology

instance Prelude.NFData AppliedTerminology