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

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.ConnectionPasswordEncryption
import Amazonka.Glue.Types.EncryptionAtRest
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains configuration information for maintaining Data Catalog
-- security.
--
-- /See:/ 'newDataCatalogEncryptionSettings' smart constructor.
data DataCatalogEncryptionSettings = DataCatalogEncryptionSettings'
  { -- | Specifies the encryption-at-rest configuration for the Data Catalog.
    DataCatalogEncryptionSettings -> Maybe EncryptionAtRest
encryptionAtRest :: Prelude.Maybe EncryptionAtRest,
    -- | When connection password protection is enabled, the Data Catalog uses a
    -- customer-provided key to encrypt the password as part of
    -- @CreateConnection@ or @UpdateConnection@ and store it in the
    -- @ENCRYPTED_PASSWORD@ field in the connection properties. You can enable
    -- catalog encryption or only password encryption.
    DataCatalogEncryptionSettings -> Maybe ConnectionPasswordEncryption
connectionPasswordEncryption :: Prelude.Maybe ConnectionPasswordEncryption
  }
  deriving (DataCatalogEncryptionSettings
-> DataCatalogEncryptionSettings -> Bool
(DataCatalogEncryptionSettings
 -> DataCatalogEncryptionSettings -> Bool)
-> (DataCatalogEncryptionSettings
    -> DataCatalogEncryptionSettings -> Bool)
-> Eq DataCatalogEncryptionSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataCatalogEncryptionSettings
-> DataCatalogEncryptionSettings -> Bool
$c/= :: DataCatalogEncryptionSettings
-> DataCatalogEncryptionSettings -> Bool
== :: DataCatalogEncryptionSettings
-> DataCatalogEncryptionSettings -> Bool
$c== :: DataCatalogEncryptionSettings
-> DataCatalogEncryptionSettings -> Bool
Prelude.Eq, ReadPrec [DataCatalogEncryptionSettings]
ReadPrec DataCatalogEncryptionSettings
Int -> ReadS DataCatalogEncryptionSettings
ReadS [DataCatalogEncryptionSettings]
(Int -> ReadS DataCatalogEncryptionSettings)
-> ReadS [DataCatalogEncryptionSettings]
-> ReadPrec DataCatalogEncryptionSettings
-> ReadPrec [DataCatalogEncryptionSettings]
-> Read DataCatalogEncryptionSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataCatalogEncryptionSettings]
$creadListPrec :: ReadPrec [DataCatalogEncryptionSettings]
readPrec :: ReadPrec DataCatalogEncryptionSettings
$creadPrec :: ReadPrec DataCatalogEncryptionSettings
readList :: ReadS [DataCatalogEncryptionSettings]
$creadList :: ReadS [DataCatalogEncryptionSettings]
readsPrec :: Int -> ReadS DataCatalogEncryptionSettings
$creadsPrec :: Int -> ReadS DataCatalogEncryptionSettings
Prelude.Read, Int -> DataCatalogEncryptionSettings -> ShowS
[DataCatalogEncryptionSettings] -> ShowS
DataCatalogEncryptionSettings -> String
(Int -> DataCatalogEncryptionSettings -> ShowS)
-> (DataCatalogEncryptionSettings -> String)
-> ([DataCatalogEncryptionSettings] -> ShowS)
-> Show DataCatalogEncryptionSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataCatalogEncryptionSettings] -> ShowS
$cshowList :: [DataCatalogEncryptionSettings] -> ShowS
show :: DataCatalogEncryptionSettings -> String
$cshow :: DataCatalogEncryptionSettings -> String
showsPrec :: Int -> DataCatalogEncryptionSettings -> ShowS
$cshowsPrec :: Int -> DataCatalogEncryptionSettings -> ShowS
Prelude.Show, (forall x.
 DataCatalogEncryptionSettings
 -> Rep DataCatalogEncryptionSettings x)
-> (forall x.
    Rep DataCatalogEncryptionSettings x
    -> DataCatalogEncryptionSettings)
-> Generic DataCatalogEncryptionSettings
forall x.
Rep DataCatalogEncryptionSettings x
-> DataCatalogEncryptionSettings
forall x.
DataCatalogEncryptionSettings
-> Rep DataCatalogEncryptionSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DataCatalogEncryptionSettings x
-> DataCatalogEncryptionSettings
$cfrom :: forall x.
DataCatalogEncryptionSettings
-> Rep DataCatalogEncryptionSettings x
Prelude.Generic)

-- |
-- Create a value of 'DataCatalogEncryptionSettings' 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:
--
-- 'encryptionAtRest', 'dataCatalogEncryptionSettings_encryptionAtRest' - Specifies the encryption-at-rest configuration for the Data Catalog.
--
-- 'connectionPasswordEncryption', 'dataCatalogEncryptionSettings_connectionPasswordEncryption' - When connection password protection is enabled, the Data Catalog uses a
-- customer-provided key to encrypt the password as part of
-- @CreateConnection@ or @UpdateConnection@ and store it in the
-- @ENCRYPTED_PASSWORD@ field in the connection properties. You can enable
-- catalog encryption or only password encryption.
newDataCatalogEncryptionSettings ::
  DataCatalogEncryptionSettings
newDataCatalogEncryptionSettings :: DataCatalogEncryptionSettings
newDataCatalogEncryptionSettings =
  DataCatalogEncryptionSettings' :: Maybe EncryptionAtRest
-> Maybe ConnectionPasswordEncryption
-> DataCatalogEncryptionSettings
DataCatalogEncryptionSettings'
    { $sel:encryptionAtRest:DataCatalogEncryptionSettings' :: Maybe EncryptionAtRest
encryptionAtRest =
        Maybe EncryptionAtRest
forall a. Maybe a
Prelude.Nothing,
      $sel:connectionPasswordEncryption:DataCatalogEncryptionSettings' :: Maybe ConnectionPasswordEncryption
connectionPasswordEncryption =
        Maybe ConnectionPasswordEncryption
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the encryption-at-rest configuration for the Data Catalog.
dataCatalogEncryptionSettings_encryptionAtRest :: Lens.Lens' DataCatalogEncryptionSettings (Prelude.Maybe EncryptionAtRest)
dataCatalogEncryptionSettings_encryptionAtRest :: (Maybe EncryptionAtRest -> f (Maybe EncryptionAtRest))
-> DataCatalogEncryptionSettings -> f DataCatalogEncryptionSettings
dataCatalogEncryptionSettings_encryptionAtRest = (DataCatalogEncryptionSettings -> Maybe EncryptionAtRest)
-> (DataCatalogEncryptionSettings
    -> Maybe EncryptionAtRest -> DataCatalogEncryptionSettings)
-> Lens
     DataCatalogEncryptionSettings
     DataCatalogEncryptionSettings
     (Maybe EncryptionAtRest)
     (Maybe EncryptionAtRest)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataCatalogEncryptionSettings' {Maybe EncryptionAtRest
encryptionAtRest :: Maybe EncryptionAtRest
$sel:encryptionAtRest:DataCatalogEncryptionSettings' :: DataCatalogEncryptionSettings -> Maybe EncryptionAtRest
encryptionAtRest} -> Maybe EncryptionAtRest
encryptionAtRest) (\s :: DataCatalogEncryptionSettings
s@DataCatalogEncryptionSettings' {} Maybe EncryptionAtRest
a -> DataCatalogEncryptionSettings
s {$sel:encryptionAtRest:DataCatalogEncryptionSettings' :: Maybe EncryptionAtRest
encryptionAtRest = Maybe EncryptionAtRest
a} :: DataCatalogEncryptionSettings)

-- | When connection password protection is enabled, the Data Catalog uses a
-- customer-provided key to encrypt the password as part of
-- @CreateConnection@ or @UpdateConnection@ and store it in the
-- @ENCRYPTED_PASSWORD@ field in the connection properties. You can enable
-- catalog encryption or only password encryption.
dataCatalogEncryptionSettings_connectionPasswordEncryption :: Lens.Lens' DataCatalogEncryptionSettings (Prelude.Maybe ConnectionPasswordEncryption)
dataCatalogEncryptionSettings_connectionPasswordEncryption :: (Maybe ConnectionPasswordEncryption
 -> f (Maybe ConnectionPasswordEncryption))
-> DataCatalogEncryptionSettings -> f DataCatalogEncryptionSettings
dataCatalogEncryptionSettings_connectionPasswordEncryption = (DataCatalogEncryptionSettings
 -> Maybe ConnectionPasswordEncryption)
-> (DataCatalogEncryptionSettings
    -> Maybe ConnectionPasswordEncryption
    -> DataCatalogEncryptionSettings)
-> Lens
     DataCatalogEncryptionSettings
     DataCatalogEncryptionSettings
     (Maybe ConnectionPasswordEncryption)
     (Maybe ConnectionPasswordEncryption)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataCatalogEncryptionSettings' {Maybe ConnectionPasswordEncryption
connectionPasswordEncryption :: Maybe ConnectionPasswordEncryption
$sel:connectionPasswordEncryption:DataCatalogEncryptionSettings' :: DataCatalogEncryptionSettings -> Maybe ConnectionPasswordEncryption
connectionPasswordEncryption} -> Maybe ConnectionPasswordEncryption
connectionPasswordEncryption) (\s :: DataCatalogEncryptionSettings
s@DataCatalogEncryptionSettings' {} Maybe ConnectionPasswordEncryption
a -> DataCatalogEncryptionSettings
s {$sel:connectionPasswordEncryption:DataCatalogEncryptionSettings' :: Maybe ConnectionPasswordEncryption
connectionPasswordEncryption = Maybe ConnectionPasswordEncryption
a} :: DataCatalogEncryptionSettings)

instance Core.FromJSON DataCatalogEncryptionSettings where
  parseJSON :: Value -> Parser DataCatalogEncryptionSettings
parseJSON =
    String
-> (Object -> Parser DataCatalogEncryptionSettings)
-> Value
-> Parser DataCatalogEncryptionSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DataCatalogEncryptionSettings"
      ( \Object
x ->
          Maybe EncryptionAtRest
-> Maybe ConnectionPasswordEncryption
-> DataCatalogEncryptionSettings
DataCatalogEncryptionSettings'
            (Maybe EncryptionAtRest
 -> Maybe ConnectionPasswordEncryption
 -> DataCatalogEncryptionSettings)
-> Parser (Maybe EncryptionAtRest)
-> Parser
     (Maybe ConnectionPasswordEncryption
      -> DataCatalogEncryptionSettings)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe EncryptionAtRest)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EncryptionAtRest")
            Parser
  (Maybe ConnectionPasswordEncryption
   -> DataCatalogEncryptionSettings)
-> Parser (Maybe ConnectionPasswordEncryption)
-> Parser DataCatalogEncryptionSettings
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ConnectionPasswordEncryption)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ConnectionPasswordEncryption")
      )

instance
  Prelude.Hashable
    DataCatalogEncryptionSettings

instance Prelude.NFData DataCatalogEncryptionSettings

instance Core.ToJSON DataCatalogEncryptionSettings where
  toJSON :: DataCatalogEncryptionSettings -> Value
toJSON DataCatalogEncryptionSettings' {Maybe ConnectionPasswordEncryption
Maybe EncryptionAtRest
connectionPasswordEncryption :: Maybe ConnectionPasswordEncryption
encryptionAtRest :: Maybe EncryptionAtRest
$sel:connectionPasswordEncryption:DataCatalogEncryptionSettings' :: DataCatalogEncryptionSettings -> Maybe ConnectionPasswordEncryption
$sel:encryptionAtRest:DataCatalogEncryptionSettings' :: DataCatalogEncryptionSettings -> Maybe EncryptionAtRest
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EncryptionAtRest" Text -> EncryptionAtRest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (EncryptionAtRest -> Pair) -> Maybe EncryptionAtRest -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EncryptionAtRest
encryptionAtRest,
            (Text
"ConnectionPasswordEncryption" Text -> ConnectionPasswordEncryption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ConnectionPasswordEncryption -> Pair)
-> Maybe ConnectionPasswordEncryption -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ConnectionPasswordEncryption
connectionPasswordEncryption
          ]
      )