{-# 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-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.DataCatalogEncryptionSettings 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.ConnectionPasswordEncryption
import Amazonka.Glue.Types.EncryptionAtRest
import qualified Amazonka.Prelude as Prelude

-- | Contains configuration information for maintaining Data Catalog
-- security.
--
-- /See:/ 'newDataCatalogEncryptionSettings' smart constructor.
data DataCatalogEncryptionSettings = 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 -> Maybe ConnectionPasswordEncryption
connectionPasswordEncryption :: Prelude.Maybe ConnectionPasswordEncryption,
    -- | Specifies the encryption-at-rest configuration for the Data Catalog.
    DataCatalogEncryptionSettings -> Maybe EncryptionAtRest
encryptionAtRest :: Prelude.Maybe EncryptionAtRest
  }
  deriving (DataCatalogEncryptionSettings
-> DataCatalogEncryptionSettings -> Bool
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]
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
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.
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:
--
-- '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.
--
-- 'encryptionAtRest', 'dataCatalogEncryptionSettings_encryptionAtRest' - Specifies the encryption-at-rest configuration for the Data Catalog.
newDataCatalogEncryptionSettings ::
  DataCatalogEncryptionSettings
newDataCatalogEncryptionSettings :: DataCatalogEncryptionSettings
newDataCatalogEncryptionSettings =
  DataCatalogEncryptionSettings'
    { $sel:connectionPasswordEncryption:DataCatalogEncryptionSettings' :: Maybe ConnectionPasswordEncryption
connectionPasswordEncryption =
        forall a. Maybe a
Prelude.Nothing,
      $sel:encryptionAtRest:DataCatalogEncryptionSettings' :: Maybe EncryptionAtRest
encryptionAtRest = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens'
  DataCatalogEncryptionSettings (Maybe ConnectionPasswordEncryption)
dataCatalogEncryptionSettings_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)

-- | Specifies the encryption-at-rest configuration for the Data Catalog.
dataCatalogEncryptionSettings_encryptionAtRest :: Lens.Lens' DataCatalogEncryptionSettings (Prelude.Maybe EncryptionAtRest)
dataCatalogEncryptionSettings_encryptionAtRest :: Lens' DataCatalogEncryptionSettings (Maybe EncryptionAtRest)
dataCatalogEncryptionSettings_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)

instance Data.FromJSON DataCatalogEncryptionSettings where
  parseJSON :: Value -> Parser DataCatalogEncryptionSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DataCatalogEncryptionSettings"
      ( \Object
x ->
          Maybe ConnectionPasswordEncryption
-> Maybe EncryptionAtRest -> DataCatalogEncryptionSettings
DataCatalogEncryptionSettings'
            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
"ConnectionPasswordEncryption")
            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
"EncryptionAtRest")
      )

instance
  Prelude.Hashable
    DataCatalogEncryptionSettings
  where
  hashWithSalt :: Int -> DataCatalogEncryptionSettings -> Int
hashWithSalt Int
_salt DataCatalogEncryptionSettings' {Maybe ConnectionPasswordEncryption
Maybe EncryptionAtRest
encryptionAtRest :: Maybe EncryptionAtRest
connectionPasswordEncryption :: Maybe ConnectionPasswordEncryption
$sel:encryptionAtRest:DataCatalogEncryptionSettings' :: DataCatalogEncryptionSettings -> Maybe EncryptionAtRest
$sel:connectionPasswordEncryption:DataCatalogEncryptionSettings' :: DataCatalogEncryptionSettings -> Maybe ConnectionPasswordEncryption
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ConnectionPasswordEncryption
connectionPasswordEncryption
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EncryptionAtRest
encryptionAtRest

instance Prelude.NFData DataCatalogEncryptionSettings where
  rnf :: DataCatalogEncryptionSettings -> ()
rnf DataCatalogEncryptionSettings' {Maybe ConnectionPasswordEncryption
Maybe EncryptionAtRest
encryptionAtRest :: Maybe EncryptionAtRest
connectionPasswordEncryption :: Maybe ConnectionPasswordEncryption
$sel:encryptionAtRest:DataCatalogEncryptionSettings' :: DataCatalogEncryptionSettings -> Maybe EncryptionAtRest
$sel:connectionPasswordEncryption:DataCatalogEncryptionSettings' :: DataCatalogEncryptionSettings -> Maybe ConnectionPasswordEncryption
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ConnectionPasswordEncryption
connectionPasswordEncryption
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EncryptionAtRest
encryptionAtRest

instance Data.ToJSON DataCatalogEncryptionSettings where
  toJSON :: DataCatalogEncryptionSettings -> Value
toJSON DataCatalogEncryptionSettings' {Maybe ConnectionPasswordEncryption
Maybe EncryptionAtRest
encryptionAtRest :: Maybe EncryptionAtRest
connectionPasswordEncryption :: Maybe ConnectionPasswordEncryption
$sel:encryptionAtRest:DataCatalogEncryptionSettings' :: DataCatalogEncryptionSettings -> Maybe EncryptionAtRest
$sel:connectionPasswordEncryption:DataCatalogEncryptionSettings' :: DataCatalogEncryptionSettings -> Maybe ConnectionPasswordEncryption
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ConnectionPasswordEncryption" 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 ConnectionPasswordEncryption
connectionPasswordEncryption,
            (Key
"EncryptionAtRest" 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 EncryptionAtRest
encryptionAtRest
          ]
      )