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

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

-- | Specifies the encryption-at-rest configuration for the Data Catalog.
--
-- /See:/ 'newEncryptionAtRest' smart constructor.
data EncryptionAtRest = EncryptionAtRest'
  { -- | The ID of the KMS key to use for encryption at rest.
    EncryptionAtRest -> Maybe Text
sseAwsKmsKeyId :: Prelude.Maybe Prelude.Text,
    -- | The encryption-at-rest mode for encrypting Data Catalog data.
    EncryptionAtRest -> CatalogEncryptionMode
catalogEncryptionMode :: CatalogEncryptionMode
  }
  deriving (EncryptionAtRest -> EncryptionAtRest -> Bool
(EncryptionAtRest -> EncryptionAtRest -> Bool)
-> (EncryptionAtRest -> EncryptionAtRest -> Bool)
-> Eq EncryptionAtRest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EncryptionAtRest -> EncryptionAtRest -> Bool
$c/= :: EncryptionAtRest -> EncryptionAtRest -> Bool
== :: EncryptionAtRest -> EncryptionAtRest -> Bool
$c== :: EncryptionAtRest -> EncryptionAtRest -> Bool
Prelude.Eq, ReadPrec [EncryptionAtRest]
ReadPrec EncryptionAtRest
Int -> ReadS EncryptionAtRest
ReadS [EncryptionAtRest]
(Int -> ReadS EncryptionAtRest)
-> ReadS [EncryptionAtRest]
-> ReadPrec EncryptionAtRest
-> ReadPrec [EncryptionAtRest]
-> Read EncryptionAtRest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EncryptionAtRest]
$creadListPrec :: ReadPrec [EncryptionAtRest]
readPrec :: ReadPrec EncryptionAtRest
$creadPrec :: ReadPrec EncryptionAtRest
readList :: ReadS [EncryptionAtRest]
$creadList :: ReadS [EncryptionAtRest]
readsPrec :: Int -> ReadS EncryptionAtRest
$creadsPrec :: Int -> ReadS EncryptionAtRest
Prelude.Read, Int -> EncryptionAtRest -> ShowS
[EncryptionAtRest] -> ShowS
EncryptionAtRest -> String
(Int -> EncryptionAtRest -> ShowS)
-> (EncryptionAtRest -> String)
-> ([EncryptionAtRest] -> ShowS)
-> Show EncryptionAtRest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EncryptionAtRest] -> ShowS
$cshowList :: [EncryptionAtRest] -> ShowS
show :: EncryptionAtRest -> String
$cshow :: EncryptionAtRest -> String
showsPrec :: Int -> EncryptionAtRest -> ShowS
$cshowsPrec :: Int -> EncryptionAtRest -> ShowS
Prelude.Show, (forall x. EncryptionAtRest -> Rep EncryptionAtRest x)
-> (forall x. Rep EncryptionAtRest x -> EncryptionAtRest)
-> Generic EncryptionAtRest
forall x. Rep EncryptionAtRest x -> EncryptionAtRest
forall x. EncryptionAtRest -> Rep EncryptionAtRest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EncryptionAtRest x -> EncryptionAtRest
$cfrom :: forall x. EncryptionAtRest -> Rep EncryptionAtRest x
Prelude.Generic)

-- |
-- Create a value of 'EncryptionAtRest' 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:
--
-- 'sseAwsKmsKeyId', 'encryptionAtRest_sseAwsKmsKeyId' - The ID of the KMS key to use for encryption at rest.
--
-- 'catalogEncryptionMode', 'encryptionAtRest_catalogEncryptionMode' - The encryption-at-rest mode for encrypting Data Catalog data.
newEncryptionAtRest ::
  -- | 'catalogEncryptionMode'
  CatalogEncryptionMode ->
  EncryptionAtRest
newEncryptionAtRest :: CatalogEncryptionMode -> EncryptionAtRest
newEncryptionAtRest CatalogEncryptionMode
pCatalogEncryptionMode_ =
  EncryptionAtRest' :: Maybe Text -> CatalogEncryptionMode -> EncryptionAtRest
EncryptionAtRest'
    { $sel:sseAwsKmsKeyId:EncryptionAtRest' :: Maybe Text
sseAwsKmsKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:catalogEncryptionMode:EncryptionAtRest' :: CatalogEncryptionMode
catalogEncryptionMode = CatalogEncryptionMode
pCatalogEncryptionMode_
    }

-- | The ID of the KMS key to use for encryption at rest.
encryptionAtRest_sseAwsKmsKeyId :: Lens.Lens' EncryptionAtRest (Prelude.Maybe Prelude.Text)
encryptionAtRest_sseAwsKmsKeyId :: (Maybe Text -> f (Maybe Text))
-> EncryptionAtRest -> f EncryptionAtRest
encryptionAtRest_sseAwsKmsKeyId = (EncryptionAtRest -> Maybe Text)
-> (EncryptionAtRest -> Maybe Text -> EncryptionAtRest)
-> Lens EncryptionAtRest EncryptionAtRest (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionAtRest' {Maybe Text
sseAwsKmsKeyId :: Maybe Text
$sel:sseAwsKmsKeyId:EncryptionAtRest' :: EncryptionAtRest -> Maybe Text
sseAwsKmsKeyId} -> Maybe Text
sseAwsKmsKeyId) (\s :: EncryptionAtRest
s@EncryptionAtRest' {} Maybe Text
a -> EncryptionAtRest
s {$sel:sseAwsKmsKeyId:EncryptionAtRest' :: Maybe Text
sseAwsKmsKeyId = Maybe Text
a} :: EncryptionAtRest)

-- | The encryption-at-rest mode for encrypting Data Catalog data.
encryptionAtRest_catalogEncryptionMode :: Lens.Lens' EncryptionAtRest CatalogEncryptionMode
encryptionAtRest_catalogEncryptionMode :: (CatalogEncryptionMode -> f CatalogEncryptionMode)
-> EncryptionAtRest -> f EncryptionAtRest
encryptionAtRest_catalogEncryptionMode = (EncryptionAtRest -> CatalogEncryptionMode)
-> (EncryptionAtRest -> CatalogEncryptionMode -> EncryptionAtRest)
-> Lens
     EncryptionAtRest
     EncryptionAtRest
     CatalogEncryptionMode
     CatalogEncryptionMode
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionAtRest' {CatalogEncryptionMode
catalogEncryptionMode :: CatalogEncryptionMode
$sel:catalogEncryptionMode:EncryptionAtRest' :: EncryptionAtRest -> CatalogEncryptionMode
catalogEncryptionMode} -> CatalogEncryptionMode
catalogEncryptionMode) (\s :: EncryptionAtRest
s@EncryptionAtRest' {} CatalogEncryptionMode
a -> EncryptionAtRest
s {$sel:catalogEncryptionMode:EncryptionAtRest' :: CatalogEncryptionMode
catalogEncryptionMode = CatalogEncryptionMode
a} :: EncryptionAtRest)

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

instance Prelude.Hashable EncryptionAtRest

instance Prelude.NFData EncryptionAtRest

instance Core.ToJSON EncryptionAtRest where
  toJSON :: EncryptionAtRest -> Value
toJSON EncryptionAtRest' {Maybe Text
CatalogEncryptionMode
catalogEncryptionMode :: CatalogEncryptionMode
sseAwsKmsKeyId :: Maybe Text
$sel:catalogEncryptionMode:EncryptionAtRest' :: EncryptionAtRest -> CatalogEncryptionMode
$sel:sseAwsKmsKeyId:EncryptionAtRest' :: EncryptionAtRest -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SseAwsKmsKeyId" 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
sseAwsKmsKeyId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"CatalogEncryptionMode"
                  Text -> CatalogEncryptionMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= CatalogEncryptionMode
catalogEncryptionMode
              )
          ]
      )