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

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

-- | The encryption key used to encrypt this object.
--
-- /See:/ 'newEncryptionKey' smart constructor.
data EncryptionKey = EncryptionKey'
  { -- | The type of encryption key used by Amazon Translate to encrypt custom
    -- terminologies.
    EncryptionKey -> EncryptionKeyType
type' :: EncryptionKeyType,
    -- | The Amazon Resource Name (ARN) of the encryption key being used to
    -- encrypt the custom terminology.
    EncryptionKey -> Text
id :: Prelude.Text
  }
  deriving (EncryptionKey -> EncryptionKey -> Bool
(EncryptionKey -> EncryptionKey -> Bool)
-> (EncryptionKey -> EncryptionKey -> Bool) -> Eq EncryptionKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EncryptionKey -> EncryptionKey -> Bool
$c/= :: EncryptionKey -> EncryptionKey -> Bool
== :: EncryptionKey -> EncryptionKey -> Bool
$c== :: EncryptionKey -> EncryptionKey -> Bool
Prelude.Eq, ReadPrec [EncryptionKey]
ReadPrec EncryptionKey
Int -> ReadS EncryptionKey
ReadS [EncryptionKey]
(Int -> ReadS EncryptionKey)
-> ReadS [EncryptionKey]
-> ReadPrec EncryptionKey
-> ReadPrec [EncryptionKey]
-> Read EncryptionKey
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EncryptionKey]
$creadListPrec :: ReadPrec [EncryptionKey]
readPrec :: ReadPrec EncryptionKey
$creadPrec :: ReadPrec EncryptionKey
readList :: ReadS [EncryptionKey]
$creadList :: ReadS [EncryptionKey]
readsPrec :: Int -> ReadS EncryptionKey
$creadsPrec :: Int -> ReadS EncryptionKey
Prelude.Read, Int -> EncryptionKey -> ShowS
[EncryptionKey] -> ShowS
EncryptionKey -> String
(Int -> EncryptionKey -> ShowS)
-> (EncryptionKey -> String)
-> ([EncryptionKey] -> ShowS)
-> Show EncryptionKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EncryptionKey] -> ShowS
$cshowList :: [EncryptionKey] -> ShowS
show :: EncryptionKey -> String
$cshow :: EncryptionKey -> String
showsPrec :: Int -> EncryptionKey -> ShowS
$cshowsPrec :: Int -> EncryptionKey -> ShowS
Prelude.Show, (forall x. EncryptionKey -> Rep EncryptionKey x)
-> (forall x. Rep EncryptionKey x -> EncryptionKey)
-> Generic EncryptionKey
forall x. Rep EncryptionKey x -> EncryptionKey
forall x. EncryptionKey -> Rep EncryptionKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EncryptionKey x -> EncryptionKey
$cfrom :: forall x. EncryptionKey -> Rep EncryptionKey x
Prelude.Generic)

-- |
-- Create a value of 'EncryptionKey' 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:
--
-- 'type'', 'encryptionKey_type' - The type of encryption key used by Amazon Translate to encrypt custom
-- terminologies.
--
-- 'id', 'encryptionKey_id' - The Amazon Resource Name (ARN) of the encryption key being used to
-- encrypt the custom terminology.
newEncryptionKey ::
  -- | 'type''
  EncryptionKeyType ->
  -- | 'id'
  Prelude.Text ->
  EncryptionKey
newEncryptionKey :: EncryptionKeyType -> Text -> EncryptionKey
newEncryptionKey EncryptionKeyType
pType_ Text
pId_ =
  EncryptionKey' :: EncryptionKeyType -> Text -> EncryptionKey
EncryptionKey' {$sel:type':EncryptionKey' :: EncryptionKeyType
type' = EncryptionKeyType
pType_, $sel:id:EncryptionKey' :: Text
id = Text
pId_}

-- | The type of encryption key used by Amazon Translate to encrypt custom
-- terminologies.
encryptionKey_type :: Lens.Lens' EncryptionKey EncryptionKeyType
encryptionKey_type :: (EncryptionKeyType -> f EncryptionKeyType)
-> EncryptionKey -> f EncryptionKey
encryptionKey_type = (EncryptionKey -> EncryptionKeyType)
-> (EncryptionKey -> EncryptionKeyType -> EncryptionKey)
-> Lens
     EncryptionKey EncryptionKey EncryptionKeyType EncryptionKeyType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionKey' {EncryptionKeyType
type' :: EncryptionKeyType
$sel:type':EncryptionKey' :: EncryptionKey -> EncryptionKeyType
type'} -> EncryptionKeyType
type') (\s :: EncryptionKey
s@EncryptionKey' {} EncryptionKeyType
a -> EncryptionKey
s {$sel:type':EncryptionKey' :: EncryptionKeyType
type' = EncryptionKeyType
a} :: EncryptionKey)

-- | The Amazon Resource Name (ARN) of the encryption key being used to
-- encrypt the custom terminology.
encryptionKey_id :: Lens.Lens' EncryptionKey Prelude.Text
encryptionKey_id :: (Text -> f Text) -> EncryptionKey -> f EncryptionKey
encryptionKey_id = (EncryptionKey -> Text)
-> (EncryptionKey -> Text -> EncryptionKey)
-> Lens EncryptionKey EncryptionKey Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionKey' {Text
id :: Text
$sel:id:EncryptionKey' :: EncryptionKey -> Text
id} -> Text
id) (\s :: EncryptionKey
s@EncryptionKey' {} Text
a -> EncryptionKey
s {$sel:id:EncryptionKey' :: Text
id = Text
a} :: EncryptionKey)

instance Core.FromJSON EncryptionKey where
  parseJSON :: Value -> Parser EncryptionKey
parseJSON =
    String
-> (Object -> Parser EncryptionKey)
-> Value
-> Parser EncryptionKey
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EncryptionKey"
      ( \Object
x ->
          EncryptionKeyType -> Text -> EncryptionKey
EncryptionKey'
            (EncryptionKeyType -> Text -> EncryptionKey)
-> Parser EncryptionKeyType -> Parser (Text -> EncryptionKey)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser EncryptionKeyType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type") Parser (Text -> EncryptionKey)
-> Parser Text -> Parser EncryptionKey
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Id")
      )

instance Prelude.Hashable EncryptionKey

instance Prelude.NFData EncryptionKey

instance Core.ToJSON EncryptionKey where
  toJSON :: EncryptionKey -> Value
toJSON EncryptionKey' {Text
EncryptionKeyType
id :: Text
type' :: EncryptionKeyType
$sel:id:EncryptionKey' :: EncryptionKey -> Text
$sel:type':EncryptionKey' :: EncryptionKey -> EncryptionKeyType
..} =
    [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
"Type" Text -> EncryptionKeyType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= EncryptionKeyType
type'),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id)
          ]
      )