{-# 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.Glue.Types.TransformEncryption
-- 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.Glue.Types.TransformEncryption where

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.MLUserDataEncryption
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The encryption-at-rest settings of the transform that apply to accessing
-- user data. Machine learning transforms can access user data encrypted in
-- Amazon S3 using KMS.
--
-- Additionally, imported labels and trained transforms can now be
-- encrypted using a customer provided KMS key.
--
-- /See:/ 'newTransformEncryption' smart constructor.
data TransformEncryption = TransformEncryption'
  { -- | An @MLUserDataEncryption@ object containing the encryption mode and
    -- customer-provided KMS key ID.
    TransformEncryption -> Maybe MLUserDataEncryption
mlUserDataEncryption :: Prelude.Maybe MLUserDataEncryption,
    -- | The name of the security configuration.
    TransformEncryption -> Maybe Text
taskRunSecurityConfigurationName :: Prelude.Maybe Prelude.Text
  }
  deriving (TransformEncryption -> TransformEncryption -> Bool
(TransformEncryption -> TransformEncryption -> Bool)
-> (TransformEncryption -> TransformEncryption -> Bool)
-> Eq TransformEncryption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TransformEncryption -> TransformEncryption -> Bool
$c/= :: TransformEncryption -> TransformEncryption -> Bool
== :: TransformEncryption -> TransformEncryption -> Bool
$c== :: TransformEncryption -> TransformEncryption -> Bool
Prelude.Eq, ReadPrec [TransformEncryption]
ReadPrec TransformEncryption
Int -> ReadS TransformEncryption
ReadS [TransformEncryption]
(Int -> ReadS TransformEncryption)
-> ReadS [TransformEncryption]
-> ReadPrec TransformEncryption
-> ReadPrec [TransformEncryption]
-> Read TransformEncryption
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TransformEncryption]
$creadListPrec :: ReadPrec [TransformEncryption]
readPrec :: ReadPrec TransformEncryption
$creadPrec :: ReadPrec TransformEncryption
readList :: ReadS [TransformEncryption]
$creadList :: ReadS [TransformEncryption]
readsPrec :: Int -> ReadS TransformEncryption
$creadsPrec :: Int -> ReadS TransformEncryption
Prelude.Read, Int -> TransformEncryption -> ShowS
[TransformEncryption] -> ShowS
TransformEncryption -> String
(Int -> TransformEncryption -> ShowS)
-> (TransformEncryption -> String)
-> ([TransformEncryption] -> ShowS)
-> Show TransformEncryption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TransformEncryption] -> ShowS
$cshowList :: [TransformEncryption] -> ShowS
show :: TransformEncryption -> String
$cshow :: TransformEncryption -> String
showsPrec :: Int -> TransformEncryption -> ShowS
$cshowsPrec :: Int -> TransformEncryption -> ShowS
Prelude.Show, (forall x. TransformEncryption -> Rep TransformEncryption x)
-> (forall x. Rep TransformEncryption x -> TransformEncryption)
-> Generic TransformEncryption
forall x. Rep TransformEncryption x -> TransformEncryption
forall x. TransformEncryption -> Rep TransformEncryption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TransformEncryption x -> TransformEncryption
$cfrom :: forall x. TransformEncryption -> Rep TransformEncryption x
Prelude.Generic)

-- |
-- Create a value of 'TransformEncryption' 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:
--
-- 'mlUserDataEncryption', 'transformEncryption_mlUserDataEncryption' - An @MLUserDataEncryption@ object containing the encryption mode and
-- customer-provided KMS key ID.
--
-- 'taskRunSecurityConfigurationName', 'transformEncryption_taskRunSecurityConfigurationName' - The name of the security configuration.
newTransformEncryption ::
  TransformEncryption
newTransformEncryption :: TransformEncryption
newTransformEncryption =
  TransformEncryption' :: Maybe MLUserDataEncryption -> Maybe Text -> TransformEncryption
TransformEncryption'
    { $sel:mlUserDataEncryption:TransformEncryption' :: Maybe MLUserDataEncryption
mlUserDataEncryption =
        Maybe MLUserDataEncryption
forall a. Maybe a
Prelude.Nothing,
      $sel:taskRunSecurityConfigurationName:TransformEncryption' :: Maybe Text
taskRunSecurityConfigurationName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | An @MLUserDataEncryption@ object containing the encryption mode and
-- customer-provided KMS key ID.
transformEncryption_mlUserDataEncryption :: Lens.Lens' TransformEncryption (Prelude.Maybe MLUserDataEncryption)
transformEncryption_mlUserDataEncryption :: (Maybe MLUserDataEncryption -> f (Maybe MLUserDataEncryption))
-> TransformEncryption -> f TransformEncryption
transformEncryption_mlUserDataEncryption = (TransformEncryption -> Maybe MLUserDataEncryption)
-> (TransformEncryption
    -> Maybe MLUserDataEncryption -> TransformEncryption)
-> Lens
     TransformEncryption
     TransformEncryption
     (Maybe MLUserDataEncryption)
     (Maybe MLUserDataEncryption)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransformEncryption' {Maybe MLUserDataEncryption
mlUserDataEncryption :: Maybe MLUserDataEncryption
$sel:mlUserDataEncryption:TransformEncryption' :: TransformEncryption -> Maybe MLUserDataEncryption
mlUserDataEncryption} -> Maybe MLUserDataEncryption
mlUserDataEncryption) (\s :: TransformEncryption
s@TransformEncryption' {} Maybe MLUserDataEncryption
a -> TransformEncryption
s {$sel:mlUserDataEncryption:TransformEncryption' :: Maybe MLUserDataEncryption
mlUserDataEncryption = Maybe MLUserDataEncryption
a} :: TransformEncryption)

-- | The name of the security configuration.
transformEncryption_taskRunSecurityConfigurationName :: Lens.Lens' TransformEncryption (Prelude.Maybe Prelude.Text)
transformEncryption_taskRunSecurityConfigurationName :: (Maybe Text -> f (Maybe Text))
-> TransformEncryption -> f TransformEncryption
transformEncryption_taskRunSecurityConfigurationName = (TransformEncryption -> Maybe Text)
-> (TransformEncryption -> Maybe Text -> TransformEncryption)
-> Lens
     TransformEncryption TransformEncryption (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TransformEncryption' {Maybe Text
taskRunSecurityConfigurationName :: Maybe Text
$sel:taskRunSecurityConfigurationName:TransformEncryption' :: TransformEncryption -> Maybe Text
taskRunSecurityConfigurationName} -> Maybe Text
taskRunSecurityConfigurationName) (\s :: TransformEncryption
s@TransformEncryption' {} Maybe Text
a -> TransformEncryption
s {$sel:taskRunSecurityConfigurationName:TransformEncryption' :: Maybe Text
taskRunSecurityConfigurationName = Maybe Text
a} :: TransformEncryption)

instance Core.FromJSON TransformEncryption where
  parseJSON :: Value -> Parser TransformEncryption
parseJSON =
    String
-> (Object -> Parser TransformEncryption)
-> Value
-> Parser TransformEncryption
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TransformEncryption"
      ( \Object
x ->
          Maybe MLUserDataEncryption -> Maybe Text -> TransformEncryption
TransformEncryption'
            (Maybe MLUserDataEncryption -> Maybe Text -> TransformEncryption)
-> Parser (Maybe MLUserDataEncryption)
-> Parser (Maybe Text -> TransformEncryption)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe MLUserDataEncryption)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MlUserDataEncryption")
            Parser (Maybe Text -> TransformEncryption)
-> Parser (Maybe Text) -> Parser TransformEncryption
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
"TaskRunSecurityConfigurationName")
      )

instance Prelude.Hashable TransformEncryption

instance Prelude.NFData TransformEncryption

instance Core.ToJSON TransformEncryption where
  toJSON :: TransformEncryption -> Value
toJSON TransformEncryption' {Maybe Text
Maybe MLUserDataEncryption
taskRunSecurityConfigurationName :: Maybe Text
mlUserDataEncryption :: Maybe MLUserDataEncryption
$sel:taskRunSecurityConfigurationName:TransformEncryption' :: TransformEncryption -> Maybe Text
$sel:mlUserDataEncryption:TransformEncryption' :: TransformEncryption -> Maybe MLUserDataEncryption
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"MlUserDataEncryption" Text -> MLUserDataEncryption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (MLUserDataEncryption -> Pair)
-> Maybe MLUserDataEncryption -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe MLUserDataEncryption
mlUserDataEncryption,
            (Text
"TaskRunSecurityConfigurationName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
taskRunSecurityConfigurationName
          ]
      )