{-# 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-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.TerminologyData where

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

-- | The data associated with the custom terminology.
--
-- /See:/ 'newTerminologyData' smart constructor.
data TerminologyData = 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.
    TerminologyData -> Sensitive Base64
file :: Core.Sensitive Core.Base64,
    -- | The data format of the custom terminology. Either CSV or TMX.
    TerminologyData -> TerminologyDataFormat
format :: TerminologyDataFormat
  }
  deriving (TerminologyData -> TerminologyData -> Bool
(TerminologyData -> TerminologyData -> Bool)
-> (TerminologyData -> TerminologyData -> Bool)
-> Eq TerminologyData
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
(Int -> TerminologyData -> ShowS)
-> (TerminologyData -> String)
-> ([TerminologyData] -> ShowS)
-> Show TerminologyData
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. TerminologyData -> Rep TerminologyData x)
-> (forall x. Rep TerminologyData x -> TerminologyData)
-> Generic TerminologyData
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:
--
-- '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. Either CSV or TMX.
newTerminologyData ::
  -- | 'file'
  Prelude.ByteString ->
  -- | 'format'
  TerminologyDataFormat ->
  TerminologyData
newTerminologyData :: ByteString -> TerminologyDataFormat -> TerminologyData
newTerminologyData ByteString
pFile_ TerminologyDataFormat
pFormat_ =
  TerminologyData' :: Sensitive Base64 -> TerminologyDataFormat -> TerminologyData
TerminologyData'
    { $sel:file:TerminologyData' :: Sensitive Base64
file =
        Tagged Base64 (Identity Base64)
-> Tagged (Sensitive Base64) (Identity (Sensitive Base64))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Base64 (Identity Base64)
 -> Tagged (Sensitive Base64) (Identity (Sensitive Base64)))
-> (Tagged ByteString (Identity ByteString)
    -> Tagged Base64 (Identity Base64))
-> Tagged ByteString (Identity ByteString)
-> Tagged (Sensitive Base64) (Identity (Sensitive Base64))
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. Tagged ByteString (Identity ByteString)
-> Tagged Base64 (Identity Base64)
Iso' Base64 ByteString
Core._Base64 (Tagged ByteString (Identity ByteString)
 -> Tagged (Sensitive Base64) (Identity (Sensitive Base64)))
-> ByteString -> Sensitive Base64
forall t b. AReview t b -> b -> t
Lens.# ByteString
pFile_,
      $sel:format:TerminologyData' :: TerminologyDataFormat
format = TerminologyDataFormat
pFormat_
    }

-- | 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 :: (ByteString -> f ByteString)
-> TerminologyData -> f TerminologyData
terminologyData_file = (TerminologyData -> Sensitive Base64)
-> (TerminologyData -> Sensitive Base64 -> TerminologyData)
-> Lens
     TerminologyData
     TerminologyData
     (Sensitive Base64)
     (Sensitive Base64)
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) ((Sensitive Base64 -> f (Sensitive Base64))
 -> TerminologyData -> f TerminologyData)
-> ((ByteString -> f ByteString)
    -> Sensitive Base64 -> f (Sensitive Base64))
-> (ByteString -> f ByteString)
-> TerminologyData
-> f TerminologyData
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Base64 -> f Base64) -> Sensitive Base64 -> f (Sensitive Base64)
forall a. Iso' (Sensitive a) a
Core._Sensitive ((Base64 -> f Base64) -> Sensitive Base64 -> f (Sensitive Base64))
-> ((ByteString -> f ByteString) -> Base64 -> f Base64)
-> (ByteString -> f ByteString)
-> Sensitive Base64
-> f (Sensitive Base64)
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (ByteString -> f ByteString) -> Base64 -> f Base64
Iso' Base64 ByteString
Core._Base64

-- | The data format of the custom terminology. Either CSV or TMX.
terminologyData_format :: Lens.Lens' TerminologyData TerminologyDataFormat
terminologyData_format :: (TerminologyDataFormat -> f TerminologyDataFormat)
-> TerminologyData -> f TerminologyData
terminologyData_format = (TerminologyData -> TerminologyDataFormat)
-> (TerminologyData -> TerminologyDataFormat -> TerminologyData)
-> Lens
     TerminologyData
     TerminologyData
     TerminologyDataFormat
     TerminologyDataFormat
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

instance Prelude.NFData TerminologyData

instance Core.ToJSON TerminologyData where
  toJSON :: TerminologyData -> Value
toJSON TerminologyData' {Sensitive Base64
TerminologyDataFormat
format :: TerminologyDataFormat
file :: Sensitive Base64
$sel:format:TerminologyData' :: TerminologyData -> TerminologyDataFormat
$sel:file:TerminologyData' :: TerminologyData -> Sensitive Base64
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"File" Text -> Sensitive Base64 -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Base64
file),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Format" Text -> TerminologyDataFormat -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TerminologyDataFormat
format)
          ]
      )