{-# 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.Connect.Types.EncryptionConfig
-- 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.Connect.Types.EncryptionConfig where

import Amazonka.Connect.Types.EncryptionType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The encryption configuration.
--
-- /See:/ 'newEncryptionConfig' smart constructor.
data EncryptionConfig = EncryptionConfig'
  { -- | The type of encryption.
    EncryptionConfig -> EncryptionType
encryptionType :: EncryptionType,
    -- | The full ARN of the encryption key.
    --
    -- Be sure to provide the full ARN of the encryption key, not just the ID.
    EncryptionConfig -> Text
keyId :: Prelude.Text
  }
  deriving (EncryptionConfig -> EncryptionConfig -> Bool
(EncryptionConfig -> EncryptionConfig -> Bool)
-> (EncryptionConfig -> EncryptionConfig -> Bool)
-> Eq EncryptionConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EncryptionConfig -> EncryptionConfig -> Bool
$c/= :: EncryptionConfig -> EncryptionConfig -> Bool
== :: EncryptionConfig -> EncryptionConfig -> Bool
$c== :: EncryptionConfig -> EncryptionConfig -> Bool
Prelude.Eq, ReadPrec [EncryptionConfig]
ReadPrec EncryptionConfig
Int -> ReadS EncryptionConfig
ReadS [EncryptionConfig]
(Int -> ReadS EncryptionConfig)
-> ReadS [EncryptionConfig]
-> ReadPrec EncryptionConfig
-> ReadPrec [EncryptionConfig]
-> Read EncryptionConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EncryptionConfig]
$creadListPrec :: ReadPrec [EncryptionConfig]
readPrec :: ReadPrec EncryptionConfig
$creadPrec :: ReadPrec EncryptionConfig
readList :: ReadS [EncryptionConfig]
$creadList :: ReadS [EncryptionConfig]
readsPrec :: Int -> ReadS EncryptionConfig
$creadsPrec :: Int -> ReadS EncryptionConfig
Prelude.Read, Int -> EncryptionConfig -> ShowS
[EncryptionConfig] -> ShowS
EncryptionConfig -> String
(Int -> EncryptionConfig -> ShowS)
-> (EncryptionConfig -> String)
-> ([EncryptionConfig] -> ShowS)
-> Show EncryptionConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EncryptionConfig] -> ShowS
$cshowList :: [EncryptionConfig] -> ShowS
show :: EncryptionConfig -> String
$cshow :: EncryptionConfig -> String
showsPrec :: Int -> EncryptionConfig -> ShowS
$cshowsPrec :: Int -> EncryptionConfig -> ShowS
Prelude.Show, (forall x. EncryptionConfig -> Rep EncryptionConfig x)
-> (forall x. Rep EncryptionConfig x -> EncryptionConfig)
-> Generic EncryptionConfig
forall x. Rep EncryptionConfig x -> EncryptionConfig
forall x. EncryptionConfig -> Rep EncryptionConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EncryptionConfig x -> EncryptionConfig
$cfrom :: forall x. EncryptionConfig -> Rep EncryptionConfig x
Prelude.Generic)

-- |
-- Create a value of 'EncryptionConfig' 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:
--
-- 'encryptionType', 'encryptionConfig_encryptionType' - The type of encryption.
--
-- 'keyId', 'encryptionConfig_keyId' - The full ARN of the encryption key.
--
-- Be sure to provide the full ARN of the encryption key, not just the ID.
newEncryptionConfig ::
  -- | 'encryptionType'
  EncryptionType ->
  -- | 'keyId'
  Prelude.Text ->
  EncryptionConfig
newEncryptionConfig :: EncryptionType -> Text -> EncryptionConfig
newEncryptionConfig EncryptionType
pEncryptionType_ Text
pKeyId_ =
  EncryptionConfig' :: EncryptionType -> Text -> EncryptionConfig
EncryptionConfig'
    { $sel:encryptionType:EncryptionConfig' :: EncryptionType
encryptionType =
        EncryptionType
pEncryptionType_,
      $sel:keyId:EncryptionConfig' :: Text
keyId = Text
pKeyId_
    }

-- | The type of encryption.
encryptionConfig_encryptionType :: Lens.Lens' EncryptionConfig EncryptionType
encryptionConfig_encryptionType :: (EncryptionType -> f EncryptionType)
-> EncryptionConfig -> f EncryptionConfig
encryptionConfig_encryptionType = (EncryptionConfig -> EncryptionType)
-> (EncryptionConfig -> EncryptionType -> EncryptionConfig)
-> Lens
     EncryptionConfig EncryptionConfig EncryptionType EncryptionType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionConfig' {EncryptionType
encryptionType :: EncryptionType
$sel:encryptionType:EncryptionConfig' :: EncryptionConfig -> EncryptionType
encryptionType} -> EncryptionType
encryptionType) (\s :: EncryptionConfig
s@EncryptionConfig' {} EncryptionType
a -> EncryptionConfig
s {$sel:encryptionType:EncryptionConfig' :: EncryptionType
encryptionType = EncryptionType
a} :: EncryptionConfig)

-- | The full ARN of the encryption key.
--
-- Be sure to provide the full ARN of the encryption key, not just the ID.
encryptionConfig_keyId :: Lens.Lens' EncryptionConfig Prelude.Text
encryptionConfig_keyId :: (Text -> f Text) -> EncryptionConfig -> f EncryptionConfig
encryptionConfig_keyId = (EncryptionConfig -> Text)
-> (EncryptionConfig -> Text -> EncryptionConfig)
-> Lens EncryptionConfig EncryptionConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionConfig' {Text
keyId :: Text
$sel:keyId:EncryptionConfig' :: EncryptionConfig -> Text
keyId} -> Text
keyId) (\s :: EncryptionConfig
s@EncryptionConfig' {} Text
a -> EncryptionConfig
s {$sel:keyId:EncryptionConfig' :: Text
keyId = Text
a} :: EncryptionConfig)

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

instance Prelude.Hashable EncryptionConfig

instance Prelude.NFData EncryptionConfig

instance Core.ToJSON EncryptionConfig where
  toJSON :: EncryptionConfig -> Value
toJSON EncryptionConfig' {Text
EncryptionType
keyId :: Text
encryptionType :: EncryptionType
$sel:keyId:EncryptionConfig' :: EncryptionConfig -> Text
$sel:encryptionType:EncryptionConfig' :: EncryptionConfig -> EncryptionType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"EncryptionType" Text -> EncryptionType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= EncryptionType
encryptionType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"KeyId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
keyId)
          ]
      )