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

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

-- | Specifies how Amazon CloudWatch data should be encrypted.
--
-- /See:/ 'newCloudWatchEncryption' smart constructor.
data CloudWatchEncryption = CloudWatchEncryption'
  { -- | The encryption mode to use for CloudWatch data.
    CloudWatchEncryption -> Maybe CloudWatchEncryptionMode
cloudWatchEncryptionMode :: Prelude.Maybe CloudWatchEncryptionMode,
    -- | The Amazon Resource Name (ARN) of the KMS key to be used to encrypt the
    -- data.
    CloudWatchEncryption -> Maybe Text
kmsKeyArn :: Prelude.Maybe Prelude.Text
  }
  deriving (CloudWatchEncryption -> CloudWatchEncryption -> Bool
(CloudWatchEncryption -> CloudWatchEncryption -> Bool)
-> (CloudWatchEncryption -> CloudWatchEncryption -> Bool)
-> Eq CloudWatchEncryption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CloudWatchEncryption -> CloudWatchEncryption -> Bool
$c/= :: CloudWatchEncryption -> CloudWatchEncryption -> Bool
== :: CloudWatchEncryption -> CloudWatchEncryption -> Bool
$c== :: CloudWatchEncryption -> CloudWatchEncryption -> Bool
Prelude.Eq, ReadPrec [CloudWatchEncryption]
ReadPrec CloudWatchEncryption
Int -> ReadS CloudWatchEncryption
ReadS [CloudWatchEncryption]
(Int -> ReadS CloudWatchEncryption)
-> ReadS [CloudWatchEncryption]
-> ReadPrec CloudWatchEncryption
-> ReadPrec [CloudWatchEncryption]
-> Read CloudWatchEncryption
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CloudWatchEncryption]
$creadListPrec :: ReadPrec [CloudWatchEncryption]
readPrec :: ReadPrec CloudWatchEncryption
$creadPrec :: ReadPrec CloudWatchEncryption
readList :: ReadS [CloudWatchEncryption]
$creadList :: ReadS [CloudWatchEncryption]
readsPrec :: Int -> ReadS CloudWatchEncryption
$creadsPrec :: Int -> ReadS CloudWatchEncryption
Prelude.Read, Int -> CloudWatchEncryption -> ShowS
[CloudWatchEncryption] -> ShowS
CloudWatchEncryption -> String
(Int -> CloudWatchEncryption -> ShowS)
-> (CloudWatchEncryption -> String)
-> ([CloudWatchEncryption] -> ShowS)
-> Show CloudWatchEncryption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CloudWatchEncryption] -> ShowS
$cshowList :: [CloudWatchEncryption] -> ShowS
show :: CloudWatchEncryption -> String
$cshow :: CloudWatchEncryption -> String
showsPrec :: Int -> CloudWatchEncryption -> ShowS
$cshowsPrec :: Int -> CloudWatchEncryption -> ShowS
Prelude.Show, (forall x. CloudWatchEncryption -> Rep CloudWatchEncryption x)
-> (forall x. Rep CloudWatchEncryption x -> CloudWatchEncryption)
-> Generic CloudWatchEncryption
forall x. Rep CloudWatchEncryption x -> CloudWatchEncryption
forall x. CloudWatchEncryption -> Rep CloudWatchEncryption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CloudWatchEncryption x -> CloudWatchEncryption
$cfrom :: forall x. CloudWatchEncryption -> Rep CloudWatchEncryption x
Prelude.Generic)

-- |
-- Create a value of 'CloudWatchEncryption' 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:
--
-- 'cloudWatchEncryptionMode', 'cloudWatchEncryption_cloudWatchEncryptionMode' - The encryption mode to use for CloudWatch data.
--
-- 'kmsKeyArn', 'cloudWatchEncryption_kmsKeyArn' - The Amazon Resource Name (ARN) of the KMS key to be used to encrypt the
-- data.
newCloudWatchEncryption ::
  CloudWatchEncryption
newCloudWatchEncryption :: CloudWatchEncryption
newCloudWatchEncryption =
  CloudWatchEncryption' :: Maybe CloudWatchEncryptionMode
-> Maybe Text -> CloudWatchEncryption
CloudWatchEncryption'
    { $sel:cloudWatchEncryptionMode:CloudWatchEncryption' :: Maybe CloudWatchEncryptionMode
cloudWatchEncryptionMode =
        Maybe CloudWatchEncryptionMode
forall a. Maybe a
Prelude.Nothing,
      $sel:kmsKeyArn:CloudWatchEncryption' :: Maybe Text
kmsKeyArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The encryption mode to use for CloudWatch data.
cloudWatchEncryption_cloudWatchEncryptionMode :: Lens.Lens' CloudWatchEncryption (Prelude.Maybe CloudWatchEncryptionMode)
cloudWatchEncryption_cloudWatchEncryptionMode :: (Maybe CloudWatchEncryptionMode
 -> f (Maybe CloudWatchEncryptionMode))
-> CloudWatchEncryption -> f CloudWatchEncryption
cloudWatchEncryption_cloudWatchEncryptionMode = (CloudWatchEncryption -> Maybe CloudWatchEncryptionMode)
-> (CloudWatchEncryption
    -> Maybe CloudWatchEncryptionMode -> CloudWatchEncryption)
-> Lens
     CloudWatchEncryption
     CloudWatchEncryption
     (Maybe CloudWatchEncryptionMode)
     (Maybe CloudWatchEncryptionMode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchEncryption' {Maybe CloudWatchEncryptionMode
cloudWatchEncryptionMode :: Maybe CloudWatchEncryptionMode
$sel:cloudWatchEncryptionMode:CloudWatchEncryption' :: CloudWatchEncryption -> Maybe CloudWatchEncryptionMode
cloudWatchEncryptionMode} -> Maybe CloudWatchEncryptionMode
cloudWatchEncryptionMode) (\s :: CloudWatchEncryption
s@CloudWatchEncryption' {} Maybe CloudWatchEncryptionMode
a -> CloudWatchEncryption
s {$sel:cloudWatchEncryptionMode:CloudWatchEncryption' :: Maybe CloudWatchEncryptionMode
cloudWatchEncryptionMode = Maybe CloudWatchEncryptionMode
a} :: CloudWatchEncryption)

-- | The Amazon Resource Name (ARN) of the KMS key to be used to encrypt the
-- data.
cloudWatchEncryption_kmsKeyArn :: Lens.Lens' CloudWatchEncryption (Prelude.Maybe Prelude.Text)
cloudWatchEncryption_kmsKeyArn :: (Maybe Text -> f (Maybe Text))
-> CloudWatchEncryption -> f CloudWatchEncryption
cloudWatchEncryption_kmsKeyArn = (CloudWatchEncryption -> Maybe Text)
-> (CloudWatchEncryption -> Maybe Text -> CloudWatchEncryption)
-> Lens
     CloudWatchEncryption CloudWatchEncryption (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CloudWatchEncryption' {Maybe Text
kmsKeyArn :: Maybe Text
$sel:kmsKeyArn:CloudWatchEncryption' :: CloudWatchEncryption -> Maybe Text
kmsKeyArn} -> Maybe Text
kmsKeyArn) (\s :: CloudWatchEncryption
s@CloudWatchEncryption' {} Maybe Text
a -> CloudWatchEncryption
s {$sel:kmsKeyArn:CloudWatchEncryption' :: Maybe Text
kmsKeyArn = Maybe Text
a} :: CloudWatchEncryption)

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

instance Prelude.Hashable CloudWatchEncryption

instance Prelude.NFData CloudWatchEncryption

instance Core.ToJSON CloudWatchEncryption where
  toJSON :: CloudWatchEncryption -> Value
toJSON CloudWatchEncryption' {Maybe Text
Maybe CloudWatchEncryptionMode
kmsKeyArn :: Maybe Text
cloudWatchEncryptionMode :: Maybe CloudWatchEncryptionMode
$sel:kmsKeyArn:CloudWatchEncryption' :: CloudWatchEncryption -> Maybe Text
$sel:cloudWatchEncryptionMode:CloudWatchEncryption' :: CloudWatchEncryption -> Maybe CloudWatchEncryptionMode
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"CloudWatchEncryptionMode" Text -> CloudWatchEncryptionMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (CloudWatchEncryptionMode -> Pair)
-> Maybe CloudWatchEncryptionMode -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CloudWatchEncryptionMode
cloudWatchEncryptionMode,
            (Text
"KmsKeyArn" 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
kmsKeyArn
          ]
      )