{-# 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.TerminologyData
-- 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.Translate.Types.TerminologyData 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.Translate.Types.Directionality
import Amazonka.Translate.Types.TerminologyDataFormat

-- | The data associated with the custom terminology. For information about
-- the custom terminology file, see
-- <https://docs.aws.amazon.com/translate/latest/dg/creating-custom-terminology.html Creating a Custom Terminology>.
--
-- /See:/ 'newTerminologyData' smart constructor.
data TerminologyData = TerminologyData'
  { -- | The directionality of your terminology resource indicates whether it has
    -- one source language (uni-directional) or multiple (multi-directional).
    --
    -- [UNI]
    --     The terminology resource has one source language (for example, the
    --     first column in a CSV file), and all of its other languages are
    --     target languages.
    --
    -- [MULTI]
    --     Any language in the terminology resource can be the source language
    --     or a target language. A single multi-directional terminology
    --     resource can be used for jobs that translate different language
    --     pairs. For example, if the terminology contains English and Spanish
    --     terms, it can be used for jobs that translate English to Spanish and
    --     Spanish to English.
    --
    -- When you create a custom terminology resource without specifying the
    -- directionality, it behaves as uni-directional terminology, although this
    -- parameter will have a null value.
    TerminologyData -> Maybe Directionality
directionality :: Prelude.Maybe Directionality,
    -- | The file containing the custom terminology data. Your version of the AWS
    -- SDK performs a Base64-encoding on this field before sending a request to
    -- the AWS service. Users of the SDK should not perform Base64-encoding
    -- themselves.
    TerminologyData -> Sensitive Base64
file :: Data.Sensitive Data.Base64,
    -- | The data format of the custom terminology.
    TerminologyData -> TerminologyDataFormat
format :: TerminologyDataFormat
  }
  deriving (TerminologyData -> TerminologyData -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TerminologyData -> TerminologyData -> Bool
$c/= :: TerminologyData -> TerminologyData -> Bool
== :: TerminologyData -> TerminologyData -> Bool
$c== :: TerminologyData -> TerminologyData -> Bool
Prelude.Eq, Int -> TerminologyData -> ShowS
[TerminologyData] -> ShowS
TerminologyData -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TerminologyData] -> ShowS
$cshowList :: [TerminologyData] -> ShowS
show :: TerminologyData -> String
$cshow :: TerminologyData -> String
showsPrec :: Int -> TerminologyData -> ShowS
$cshowsPrec :: Int -> TerminologyData -> ShowS
Prelude.Show, forall x. Rep TerminologyData x -> TerminologyData
forall x. TerminologyData -> Rep TerminologyData x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TerminologyData x -> TerminologyData
$cfrom :: forall x. TerminologyData -> Rep TerminologyData x
Prelude.Generic)

-- |
-- Create a value of 'TerminologyData' 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:
--
-- 'directionality', 'terminologyData_directionality' - The directionality of your terminology resource indicates whether it has
-- one source language (uni-directional) or multiple (multi-directional).
--
-- [UNI]
--     The terminology resource has one source language (for example, the
--     first column in a CSV file), and all of its other languages are
--     target languages.
--
-- [MULTI]
--     Any language in the terminology resource can be the source language
--     or a target language. A single multi-directional terminology
--     resource can be used for jobs that translate different language
--     pairs. For example, if the terminology contains English and Spanish
--     terms, it can be used for jobs that translate English to Spanish and
--     Spanish to English.
--
-- When you create a custom terminology resource without specifying the
-- directionality, it behaves as uni-directional terminology, although this
-- parameter will have a null value.
--
-- 'file', 'terminologyData_file' - The file containing the custom terminology data. Your version of the AWS
-- SDK performs a Base64-encoding on this field before sending a request to
-- the AWS service. Users of the SDK should not perform Base64-encoding
-- themselves.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
--
-- 'format', 'terminologyData_format' - The data format of the custom terminology.
newTerminologyData ::
  -- | 'file'
  Prelude.ByteString ->
  -- | 'format'
  TerminologyDataFormat ->
  TerminologyData
newTerminologyData :: ByteString -> TerminologyDataFormat -> TerminologyData
newTerminologyData ByteString
pFile_ TerminologyDataFormat
pFormat_ =
  TerminologyData'
    { $sel:directionality:TerminologyData' :: Maybe Directionality
directionality = forall a. Maybe a
Prelude.Nothing,
      $sel:file:TerminologyData' :: Sensitive Base64
file =
        forall a. Iso' (Sensitive a) a
Data._Sensitive forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Iso' Base64 ByteString
Data._Base64 forall t b. AReview t b -> b -> t
Lens.# ByteString
pFile_,
      $sel:format:TerminologyData' :: TerminologyDataFormat
format = TerminologyDataFormat
pFormat_
    }

-- | The directionality of your terminology resource indicates whether it has
-- one source language (uni-directional) or multiple (multi-directional).
--
-- [UNI]
--     The terminology resource has one source language (for example, the
--     first column in a CSV file), and all of its other languages are
--     target languages.
--
-- [MULTI]
--     Any language in the terminology resource can be the source language
--     or a target language. A single multi-directional terminology
--     resource can be used for jobs that translate different language
--     pairs. For example, if the terminology contains English and Spanish
--     terms, it can be used for jobs that translate English to Spanish and
--     Spanish to English.
--
-- When you create a custom terminology resource without specifying the
-- directionality, it behaves as uni-directional terminology, although this
-- parameter will have a null value.
terminologyData_directionality :: Lens.Lens' TerminologyData (Prelude.Maybe Directionality)
terminologyData_directionality :: Lens' TerminologyData (Maybe Directionality)
terminologyData_directionality = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TerminologyData' {Maybe Directionality
directionality :: Maybe Directionality
$sel:directionality:TerminologyData' :: TerminologyData -> Maybe Directionality
directionality} -> Maybe Directionality
directionality) (\s :: TerminologyData
s@TerminologyData' {} Maybe Directionality
a -> TerminologyData
s {$sel:directionality:TerminologyData' :: Maybe Directionality
directionality = Maybe Directionality
a} :: TerminologyData)

-- | The file containing the custom terminology data. Your version of the AWS
-- SDK performs a Base64-encoding on this field before sending a request to
-- the AWS service. Users of the SDK should not perform Base64-encoding
-- themselves.--
-- -- /Note:/ This 'Lens' automatically encodes and decodes Base64 data.
-- -- The underlying isomorphism will encode to Base64 representation during
-- -- serialisation, and decode from Base64 representation during deserialisation.
-- -- This 'Lens' accepts and returns only raw unencoded data.
terminologyData_file :: Lens.Lens' TerminologyData Prelude.ByteString
terminologyData_file :: Lens' TerminologyData ByteString
terminologyData_file = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TerminologyData' {Sensitive Base64
file :: Sensitive Base64
$sel:file:TerminologyData' :: TerminologyData -> Sensitive Base64
file} -> Sensitive Base64
file) (\s :: TerminologyData
s@TerminologyData' {} Sensitive Base64
a -> TerminologyData
s {$sel:file:TerminologyData' :: Sensitive Base64
file = Sensitive Base64
a} :: TerminologyData) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Iso' Base64 ByteString
Data._Base64

-- | The data format of the custom terminology.
terminologyData_format :: Lens.Lens' TerminologyData TerminologyDataFormat
terminologyData_format :: Lens' TerminologyData TerminologyDataFormat
terminologyData_format = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TerminologyData' {TerminologyDataFormat
format :: TerminologyDataFormat
$sel:format:TerminologyData' :: TerminologyData -> TerminologyDataFormat
format} -> TerminologyDataFormat
format) (\s :: TerminologyData
s@TerminologyData' {} TerminologyDataFormat
a -> TerminologyData
s {$sel:format:TerminologyData' :: TerminologyDataFormat
format = TerminologyDataFormat
a} :: TerminologyData)

instance Prelude.Hashable TerminologyData where
  hashWithSalt :: Int -> TerminologyData -> Int
hashWithSalt Int
_salt TerminologyData' {Maybe Directionality
Sensitive Base64
TerminologyDataFormat
format :: TerminologyDataFormat
file :: Sensitive Base64
directionality :: Maybe Directionality
$sel:format:TerminologyData' :: TerminologyData -> TerminologyDataFormat
$sel:file:TerminologyData' :: TerminologyData -> Sensitive Base64
$sel:directionality:TerminologyData' :: TerminologyData -> Maybe Directionality
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Directionality
directionality
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Base64
file
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` TerminologyDataFormat
format

instance Prelude.NFData TerminologyData where
  rnf :: TerminologyData -> ()
rnf TerminologyData' {Maybe Directionality
Sensitive Base64
TerminologyDataFormat
format :: TerminologyDataFormat
file :: Sensitive Base64
directionality :: Maybe Directionality
$sel:format:TerminologyData' :: TerminologyData -> TerminologyDataFormat
$sel:file:TerminologyData' :: TerminologyData -> Sensitive Base64
$sel:directionality:TerminologyData' :: TerminologyData -> Maybe Directionality
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Directionality
directionality
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Base64
file
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf TerminologyDataFormat
format

instance Data.ToJSON TerminologyData where
  toJSON :: TerminologyData -> Value
toJSON TerminologyData' {Maybe Directionality
Sensitive Base64
TerminologyDataFormat
format :: TerminologyDataFormat
file :: Sensitive Base64
directionality :: Maybe Directionality
$sel:format:TerminologyData' :: TerminologyData -> TerminologyDataFormat
$sel:file:TerminologyData' :: TerminologyData -> Sensitive Base64
$sel:directionality:TerminologyData' :: TerminologyData -> Maybe Directionality
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Directionality" 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 Directionality
directionality,
            forall a. a -> Maybe a
Prelude.Just (Key
"File" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Base64
file),
            forall a. a -> Maybe a
Prelude.Just (Key
"Format" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= TerminologyDataFormat
format)
          ]
      )