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

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

-- | Specifies how Amazon Simple Storage Service (Amazon S3) data should be
-- encrypted.
--
-- /See:/ 'newS3Encryption' smart constructor.
data S3Encryption = S3Encryption'
  { -- | The encryption mode to use for Amazon S3 data.
    S3Encryption -> Maybe S3EncryptionMode
s3EncryptionMode :: Prelude.Maybe S3EncryptionMode,
    -- | The Amazon Resource Name (ARN) of the KMS key to be used to encrypt the
    -- data.
    S3Encryption -> Maybe Text
kmsKeyArn :: Prelude.Maybe Prelude.Text
  }
  deriving (S3Encryption -> S3Encryption -> Bool
(S3Encryption -> S3Encryption -> Bool)
-> (S3Encryption -> S3Encryption -> Bool) -> Eq S3Encryption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: S3Encryption -> S3Encryption -> Bool
$c/= :: S3Encryption -> S3Encryption -> Bool
== :: S3Encryption -> S3Encryption -> Bool
$c== :: S3Encryption -> S3Encryption -> Bool
Prelude.Eq, ReadPrec [S3Encryption]
ReadPrec S3Encryption
Int -> ReadS S3Encryption
ReadS [S3Encryption]
(Int -> ReadS S3Encryption)
-> ReadS [S3Encryption]
-> ReadPrec S3Encryption
-> ReadPrec [S3Encryption]
-> Read S3Encryption
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [S3Encryption]
$creadListPrec :: ReadPrec [S3Encryption]
readPrec :: ReadPrec S3Encryption
$creadPrec :: ReadPrec S3Encryption
readList :: ReadS [S3Encryption]
$creadList :: ReadS [S3Encryption]
readsPrec :: Int -> ReadS S3Encryption
$creadsPrec :: Int -> ReadS S3Encryption
Prelude.Read, Int -> S3Encryption -> ShowS
[S3Encryption] -> ShowS
S3Encryption -> String
(Int -> S3Encryption -> ShowS)
-> (S3Encryption -> String)
-> ([S3Encryption] -> ShowS)
-> Show S3Encryption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [S3Encryption] -> ShowS
$cshowList :: [S3Encryption] -> ShowS
show :: S3Encryption -> String
$cshow :: S3Encryption -> String
showsPrec :: Int -> S3Encryption -> ShowS
$cshowsPrec :: Int -> S3Encryption -> ShowS
Prelude.Show, (forall x. S3Encryption -> Rep S3Encryption x)
-> (forall x. Rep S3Encryption x -> S3Encryption)
-> Generic S3Encryption
forall x. Rep S3Encryption x -> S3Encryption
forall x. S3Encryption -> Rep S3Encryption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep S3Encryption x -> S3Encryption
$cfrom :: forall x. S3Encryption -> Rep S3Encryption x
Prelude.Generic)

-- |
-- Create a value of 'S3Encryption' 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:
--
-- 's3EncryptionMode', 's3Encryption_s3EncryptionMode' - The encryption mode to use for Amazon S3 data.
--
-- 'kmsKeyArn', 's3Encryption_kmsKeyArn' - The Amazon Resource Name (ARN) of the KMS key to be used to encrypt the
-- data.
newS3Encryption ::
  S3Encryption
newS3Encryption :: S3Encryption
newS3Encryption =
  S3Encryption' :: Maybe S3EncryptionMode -> Maybe Text -> S3Encryption
S3Encryption'
    { $sel:s3EncryptionMode:S3Encryption' :: Maybe S3EncryptionMode
s3EncryptionMode = Maybe S3EncryptionMode
forall a. Maybe a
Prelude.Nothing,
      $sel:kmsKeyArn:S3Encryption' :: Maybe Text
kmsKeyArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The encryption mode to use for Amazon S3 data.
s3Encryption_s3EncryptionMode :: Lens.Lens' S3Encryption (Prelude.Maybe S3EncryptionMode)
s3Encryption_s3EncryptionMode :: (Maybe S3EncryptionMode -> f (Maybe S3EncryptionMode))
-> S3Encryption -> f S3Encryption
s3Encryption_s3EncryptionMode = (S3Encryption -> Maybe S3EncryptionMode)
-> (S3Encryption -> Maybe S3EncryptionMode -> S3Encryption)
-> Lens
     S3Encryption
     S3Encryption
     (Maybe S3EncryptionMode)
     (Maybe S3EncryptionMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Encryption' {Maybe S3EncryptionMode
s3EncryptionMode :: Maybe S3EncryptionMode
$sel:s3EncryptionMode:S3Encryption' :: S3Encryption -> Maybe S3EncryptionMode
s3EncryptionMode} -> Maybe S3EncryptionMode
s3EncryptionMode) (\s :: S3Encryption
s@S3Encryption' {} Maybe S3EncryptionMode
a -> S3Encryption
s {$sel:s3EncryptionMode:S3Encryption' :: Maybe S3EncryptionMode
s3EncryptionMode = Maybe S3EncryptionMode
a} :: S3Encryption)

-- | The Amazon Resource Name (ARN) of the KMS key to be used to encrypt the
-- data.
s3Encryption_kmsKeyArn :: Lens.Lens' S3Encryption (Prelude.Maybe Prelude.Text)
s3Encryption_kmsKeyArn :: (Maybe Text -> f (Maybe Text)) -> S3Encryption -> f S3Encryption
s3Encryption_kmsKeyArn = (S3Encryption -> Maybe Text)
-> (S3Encryption -> Maybe Text -> S3Encryption)
-> Lens S3Encryption S3Encryption (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\S3Encryption' {Maybe Text
kmsKeyArn :: Maybe Text
$sel:kmsKeyArn:S3Encryption' :: S3Encryption -> Maybe Text
kmsKeyArn} -> Maybe Text
kmsKeyArn) (\s :: S3Encryption
s@S3Encryption' {} Maybe Text
a -> S3Encryption
s {$sel:kmsKeyArn:S3Encryption' :: Maybe Text
kmsKeyArn = Maybe Text
a} :: S3Encryption)

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

instance Prelude.Hashable S3Encryption

instance Prelude.NFData S3Encryption

instance Core.ToJSON S3Encryption where
  toJSON :: S3Encryption -> Value
toJSON S3Encryption' {Maybe Text
Maybe S3EncryptionMode
kmsKeyArn :: Maybe Text
s3EncryptionMode :: Maybe S3EncryptionMode
$sel:kmsKeyArn:S3Encryption' :: S3Encryption -> Maybe Text
$sel:s3EncryptionMode:S3Encryption' :: S3Encryption -> Maybe S3EncryptionMode
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"S3EncryptionMode" Text -> S3EncryptionMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (S3EncryptionMode -> Pair) -> Maybe S3EncryptionMode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe S3EncryptionMode
s3EncryptionMode,
            (Text
"KmsKeyArn" 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
kmsKeyArn
          ]
      )