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

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types.CloudWatchEncryption
import Amazonka.Glue.Types.JobBookmarksEncryption
import Amazonka.Glue.Types.S3Encryption
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Specifies an encryption configuration.
--
-- /See:/ 'newEncryptionConfiguration' smart constructor.
data EncryptionConfiguration = EncryptionConfiguration'
  { -- | The encryption configuration for Amazon Simple Storage Service (Amazon
    -- S3) data.
    EncryptionConfiguration -> Maybe [S3Encryption]
s3Encryption :: Prelude.Maybe [S3Encryption],
    -- | The encryption configuration for job bookmarks.
    EncryptionConfiguration -> Maybe JobBookmarksEncryption
jobBookmarksEncryption :: Prelude.Maybe JobBookmarksEncryption,
    -- | The encryption configuration for Amazon CloudWatch.
    EncryptionConfiguration -> Maybe CloudWatchEncryption
cloudWatchEncryption :: Prelude.Maybe CloudWatchEncryption
  }
  deriving (EncryptionConfiguration -> EncryptionConfiguration -> Bool
(EncryptionConfiguration -> EncryptionConfiguration -> Bool)
-> (EncryptionConfiguration -> EncryptionConfiguration -> Bool)
-> Eq EncryptionConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EncryptionConfiguration -> EncryptionConfiguration -> Bool
$c/= :: EncryptionConfiguration -> EncryptionConfiguration -> Bool
== :: EncryptionConfiguration -> EncryptionConfiguration -> Bool
$c== :: EncryptionConfiguration -> EncryptionConfiguration -> Bool
Prelude.Eq, ReadPrec [EncryptionConfiguration]
ReadPrec EncryptionConfiguration
Int -> ReadS EncryptionConfiguration
ReadS [EncryptionConfiguration]
(Int -> ReadS EncryptionConfiguration)
-> ReadS [EncryptionConfiguration]
-> ReadPrec EncryptionConfiguration
-> ReadPrec [EncryptionConfiguration]
-> Read EncryptionConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EncryptionConfiguration]
$creadListPrec :: ReadPrec [EncryptionConfiguration]
readPrec :: ReadPrec EncryptionConfiguration
$creadPrec :: ReadPrec EncryptionConfiguration
readList :: ReadS [EncryptionConfiguration]
$creadList :: ReadS [EncryptionConfiguration]
readsPrec :: Int -> ReadS EncryptionConfiguration
$creadsPrec :: Int -> ReadS EncryptionConfiguration
Prelude.Read, Int -> EncryptionConfiguration -> ShowS
[EncryptionConfiguration] -> ShowS
EncryptionConfiguration -> String
(Int -> EncryptionConfiguration -> ShowS)
-> (EncryptionConfiguration -> String)
-> ([EncryptionConfiguration] -> ShowS)
-> Show EncryptionConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EncryptionConfiguration] -> ShowS
$cshowList :: [EncryptionConfiguration] -> ShowS
show :: EncryptionConfiguration -> String
$cshow :: EncryptionConfiguration -> String
showsPrec :: Int -> EncryptionConfiguration -> ShowS
$cshowsPrec :: Int -> EncryptionConfiguration -> ShowS
Prelude.Show, (forall x.
 EncryptionConfiguration -> Rep EncryptionConfiguration x)
-> (forall x.
    Rep EncryptionConfiguration x -> EncryptionConfiguration)
-> Generic EncryptionConfiguration
forall x. Rep EncryptionConfiguration x -> EncryptionConfiguration
forall x. EncryptionConfiguration -> Rep EncryptionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EncryptionConfiguration x -> EncryptionConfiguration
$cfrom :: forall x. EncryptionConfiguration -> Rep EncryptionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'EncryptionConfiguration' 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:
--
-- 's3Encryption', 'encryptionConfiguration_s3Encryption' - The encryption configuration for Amazon Simple Storage Service (Amazon
-- S3) data.
--
-- 'jobBookmarksEncryption', 'encryptionConfiguration_jobBookmarksEncryption' - The encryption configuration for job bookmarks.
--
-- 'cloudWatchEncryption', 'encryptionConfiguration_cloudWatchEncryption' - The encryption configuration for Amazon CloudWatch.
newEncryptionConfiguration ::
  EncryptionConfiguration
newEncryptionConfiguration :: EncryptionConfiguration
newEncryptionConfiguration =
  EncryptionConfiguration' :: Maybe [S3Encryption]
-> Maybe JobBookmarksEncryption
-> Maybe CloudWatchEncryption
-> EncryptionConfiguration
EncryptionConfiguration'
    { $sel:s3Encryption:EncryptionConfiguration' :: Maybe [S3Encryption]
s3Encryption =
        Maybe [S3Encryption]
forall a. Maybe a
Prelude.Nothing,
      $sel:jobBookmarksEncryption:EncryptionConfiguration' :: Maybe JobBookmarksEncryption
jobBookmarksEncryption = Maybe JobBookmarksEncryption
forall a. Maybe a
Prelude.Nothing,
      $sel:cloudWatchEncryption:EncryptionConfiguration' :: Maybe CloudWatchEncryption
cloudWatchEncryption = Maybe CloudWatchEncryption
forall a. Maybe a
Prelude.Nothing
    }

-- | The encryption configuration for Amazon Simple Storage Service (Amazon
-- S3) data.
encryptionConfiguration_s3Encryption :: Lens.Lens' EncryptionConfiguration (Prelude.Maybe [S3Encryption])
encryptionConfiguration_s3Encryption :: (Maybe [S3Encryption] -> f (Maybe [S3Encryption]))
-> EncryptionConfiguration -> f EncryptionConfiguration
encryptionConfiguration_s3Encryption = (EncryptionConfiguration -> Maybe [S3Encryption])
-> (EncryptionConfiguration
    -> Maybe [S3Encryption] -> EncryptionConfiguration)
-> Lens
     EncryptionConfiguration
     EncryptionConfiguration
     (Maybe [S3Encryption])
     (Maybe [S3Encryption])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionConfiguration' {Maybe [S3Encryption]
s3Encryption :: Maybe [S3Encryption]
$sel:s3Encryption:EncryptionConfiguration' :: EncryptionConfiguration -> Maybe [S3Encryption]
s3Encryption} -> Maybe [S3Encryption]
s3Encryption) (\s :: EncryptionConfiguration
s@EncryptionConfiguration' {} Maybe [S3Encryption]
a -> EncryptionConfiguration
s {$sel:s3Encryption:EncryptionConfiguration' :: Maybe [S3Encryption]
s3Encryption = Maybe [S3Encryption]
a} :: EncryptionConfiguration) ((Maybe [S3Encryption] -> f (Maybe [S3Encryption]))
 -> EncryptionConfiguration -> f EncryptionConfiguration)
-> ((Maybe [S3Encryption] -> f (Maybe [S3Encryption]))
    -> Maybe [S3Encryption] -> f (Maybe [S3Encryption]))
-> (Maybe [S3Encryption] -> f (Maybe [S3Encryption]))
-> EncryptionConfiguration
-> f EncryptionConfiguration
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [S3Encryption] [S3Encryption] [S3Encryption] [S3Encryption]
-> Iso
     (Maybe [S3Encryption])
     (Maybe [S3Encryption])
     (Maybe [S3Encryption])
     (Maybe [S3Encryption])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [S3Encryption] [S3Encryption] [S3Encryption] [S3Encryption]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The encryption configuration for job bookmarks.
encryptionConfiguration_jobBookmarksEncryption :: Lens.Lens' EncryptionConfiguration (Prelude.Maybe JobBookmarksEncryption)
encryptionConfiguration_jobBookmarksEncryption :: (Maybe JobBookmarksEncryption -> f (Maybe JobBookmarksEncryption))
-> EncryptionConfiguration -> f EncryptionConfiguration
encryptionConfiguration_jobBookmarksEncryption = (EncryptionConfiguration -> Maybe JobBookmarksEncryption)
-> (EncryptionConfiguration
    -> Maybe JobBookmarksEncryption -> EncryptionConfiguration)
-> Lens
     EncryptionConfiguration
     EncryptionConfiguration
     (Maybe JobBookmarksEncryption)
     (Maybe JobBookmarksEncryption)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionConfiguration' {Maybe JobBookmarksEncryption
jobBookmarksEncryption :: Maybe JobBookmarksEncryption
$sel:jobBookmarksEncryption:EncryptionConfiguration' :: EncryptionConfiguration -> Maybe JobBookmarksEncryption
jobBookmarksEncryption} -> Maybe JobBookmarksEncryption
jobBookmarksEncryption) (\s :: EncryptionConfiguration
s@EncryptionConfiguration' {} Maybe JobBookmarksEncryption
a -> EncryptionConfiguration
s {$sel:jobBookmarksEncryption:EncryptionConfiguration' :: Maybe JobBookmarksEncryption
jobBookmarksEncryption = Maybe JobBookmarksEncryption
a} :: EncryptionConfiguration)

-- | The encryption configuration for Amazon CloudWatch.
encryptionConfiguration_cloudWatchEncryption :: Lens.Lens' EncryptionConfiguration (Prelude.Maybe CloudWatchEncryption)
encryptionConfiguration_cloudWatchEncryption :: (Maybe CloudWatchEncryption -> f (Maybe CloudWatchEncryption))
-> EncryptionConfiguration -> f EncryptionConfiguration
encryptionConfiguration_cloudWatchEncryption = (EncryptionConfiguration -> Maybe CloudWatchEncryption)
-> (EncryptionConfiguration
    -> Maybe CloudWatchEncryption -> EncryptionConfiguration)
-> Lens
     EncryptionConfiguration
     EncryptionConfiguration
     (Maybe CloudWatchEncryption)
     (Maybe CloudWatchEncryption)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionConfiguration' {Maybe CloudWatchEncryption
cloudWatchEncryption :: Maybe CloudWatchEncryption
$sel:cloudWatchEncryption:EncryptionConfiguration' :: EncryptionConfiguration -> Maybe CloudWatchEncryption
cloudWatchEncryption} -> Maybe CloudWatchEncryption
cloudWatchEncryption) (\s :: EncryptionConfiguration
s@EncryptionConfiguration' {} Maybe CloudWatchEncryption
a -> EncryptionConfiguration
s {$sel:cloudWatchEncryption:EncryptionConfiguration' :: Maybe CloudWatchEncryption
cloudWatchEncryption = Maybe CloudWatchEncryption
a} :: EncryptionConfiguration)

instance Core.FromJSON EncryptionConfiguration where
  parseJSON :: Value -> Parser EncryptionConfiguration
parseJSON =
    String
-> (Object -> Parser EncryptionConfiguration)
-> Value
-> Parser EncryptionConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"EncryptionConfiguration"
      ( \Object
x ->
          Maybe [S3Encryption]
-> Maybe JobBookmarksEncryption
-> Maybe CloudWatchEncryption
-> EncryptionConfiguration
EncryptionConfiguration'
            (Maybe [S3Encryption]
 -> Maybe JobBookmarksEncryption
 -> Maybe CloudWatchEncryption
 -> EncryptionConfiguration)
-> Parser (Maybe [S3Encryption])
-> Parser
     (Maybe JobBookmarksEncryption
      -> Maybe CloudWatchEncryption -> EncryptionConfiguration)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [S3Encryption]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"S3Encryption" Parser (Maybe (Maybe [S3Encryption]))
-> Maybe [S3Encryption] -> Parser (Maybe [S3Encryption])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [S3Encryption]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe JobBookmarksEncryption
   -> Maybe CloudWatchEncryption -> EncryptionConfiguration)
-> Parser (Maybe JobBookmarksEncryption)
-> Parser (Maybe CloudWatchEncryption -> EncryptionConfiguration)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe JobBookmarksEncryption)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"JobBookmarksEncryption")
            Parser (Maybe CloudWatchEncryption -> EncryptionConfiguration)
-> Parser (Maybe CloudWatchEncryption)
-> Parser EncryptionConfiguration
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe CloudWatchEncryption)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CloudWatchEncryption")
      )

instance Prelude.Hashable EncryptionConfiguration

instance Prelude.NFData EncryptionConfiguration

instance Core.ToJSON EncryptionConfiguration where
  toJSON :: EncryptionConfiguration -> Value
toJSON EncryptionConfiguration' {Maybe [S3Encryption]
Maybe CloudWatchEncryption
Maybe JobBookmarksEncryption
cloudWatchEncryption :: Maybe CloudWatchEncryption
jobBookmarksEncryption :: Maybe JobBookmarksEncryption
s3Encryption :: Maybe [S3Encryption]
$sel:cloudWatchEncryption:EncryptionConfiguration' :: EncryptionConfiguration -> Maybe CloudWatchEncryption
$sel:jobBookmarksEncryption:EncryptionConfiguration' :: EncryptionConfiguration -> Maybe JobBookmarksEncryption
$sel:s3Encryption:EncryptionConfiguration' :: EncryptionConfiguration -> Maybe [S3Encryption]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"S3Encryption" Text -> [S3Encryption] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([S3Encryption] -> Pair) -> Maybe [S3Encryption] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [S3Encryption]
s3Encryption,
            (Text
"JobBookmarksEncryption" Text -> JobBookmarksEncryption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (JobBookmarksEncryption -> Pair)
-> Maybe JobBookmarksEncryption -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe JobBookmarksEncryption
jobBookmarksEncryption,
            (Text
"CloudWatchEncryption" Text -> CloudWatchEncryption -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CloudWatchEncryption -> Pair)
-> Maybe CloudWatchEncryption -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CloudWatchEncryption
cloudWatchEncryption
          ]
      )