{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Glue.Types.S3Encryption where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Glue.Types.S3EncryptionMode
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 Amazon Resource Name (ARN) of the KMS key to be used to encrypt the
    -- data.
    S3Encryption -> Maybe Text
kmsKeyArn :: Prelude.Maybe Prelude.Text,
    -- | The encryption mode to use for Amazon S3 data.
    S3Encryption -> Maybe S3EncryptionMode
s3EncryptionMode :: Prelude.Maybe S3EncryptionMode
  }
  deriving (S3Encryption -> S3Encryption -> Bool
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]
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
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. 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:
--
-- 'kmsKeyArn', 's3Encryption_kmsKeyArn' - The Amazon Resource Name (ARN) of the KMS key to be used to encrypt the
-- data.
--
-- 's3EncryptionMode', 's3Encryption_s3EncryptionMode' - The encryption mode to use for Amazon S3 data.
newS3Encryption ::
  S3Encryption
newS3Encryption :: S3Encryption
newS3Encryption =
  S3Encryption'
    { $sel:kmsKeyArn:S3Encryption' :: Maybe Text
kmsKeyArn = forall a. Maybe a
Prelude.Nothing,
      $sel:s3EncryptionMode:S3Encryption' :: Maybe S3EncryptionMode
s3EncryptionMode = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' S3Encryption (Maybe Text)
s3Encryption_kmsKeyArn = 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)

-- | The encryption mode to use for Amazon S3 data.
s3Encryption_s3EncryptionMode :: Lens.Lens' S3Encryption (Prelude.Maybe S3EncryptionMode)
s3Encryption_s3EncryptionMode :: Lens' S3Encryption (Maybe S3EncryptionMode)
s3Encryption_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)

instance Data.FromJSON S3Encryption where
  parseJSON :: Value -> Parser S3Encryption
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"S3Encryption"
      ( \Object
x ->
          Maybe Text -> Maybe S3EncryptionMode -> S3Encryption
S3Encryption'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"KmsKeyArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"S3EncryptionMode")
      )

instance Prelude.Hashable S3Encryption where
  hashWithSalt :: Int -> S3Encryption -> Int
hashWithSalt Int
_salt S3Encryption' {Maybe Text
Maybe S3EncryptionMode
s3EncryptionMode :: Maybe S3EncryptionMode
kmsKeyArn :: Maybe Text
$sel:s3EncryptionMode:S3Encryption' :: S3Encryption -> Maybe S3EncryptionMode
$sel:kmsKeyArn:S3Encryption' :: S3Encryption -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kmsKeyArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe S3EncryptionMode
s3EncryptionMode

instance Prelude.NFData S3Encryption where
  rnf :: S3Encryption -> ()
rnf S3Encryption' {Maybe Text
Maybe S3EncryptionMode
s3EncryptionMode :: Maybe S3EncryptionMode
kmsKeyArn :: Maybe Text
$sel:s3EncryptionMode:S3Encryption' :: S3Encryption -> Maybe S3EncryptionMode
$sel:kmsKeyArn:S3Encryption' :: S3Encryption -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe S3EncryptionMode
s3EncryptionMode

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