{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $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 :: Lens' EncryptionConfig EncryptionType
encryptionConfig_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 :: Lens' EncryptionConfig Text
encryptionConfig_keyId = 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 Data.FromJSON EncryptionConfig where
  parseJSON :: Value -> Parser EncryptionConfig
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EncryptionConfig"
      ( \Object
x ->
          EncryptionType -> Text -> EncryptionConfig
EncryptionConfig'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"EncryptionType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"KeyId")
      )

instance Prelude.Hashable EncryptionConfig where
  hashWithSalt :: Int -> EncryptionConfig -> Int
hashWithSalt Int
_salt EncryptionConfig' {Text
EncryptionType
keyId :: Text
encryptionType :: EncryptionType
$sel:keyId:EncryptionConfig' :: EncryptionConfig -> Text
$sel:encryptionType:EncryptionConfig' :: EncryptionConfig -> EncryptionType
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` EncryptionType
encryptionType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
keyId

instance Prelude.NFData EncryptionConfig where
  rnf :: EncryptionConfig -> ()
rnf EncryptionConfig' {Text
EncryptionType
keyId :: Text
encryptionType :: EncryptionType
$sel:keyId:EncryptionConfig' :: EncryptionConfig -> Text
$sel:encryptionType:EncryptionConfig' :: EncryptionConfig -> EncryptionType
..} =
    forall a. NFData a => a -> ()
Prelude.rnf EncryptionType
encryptionType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
keyId

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"EncryptionType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= EncryptionType
encryptionType),
            forall a. a -> Maybe a
Prelude.Just (Key
"KeyId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
keyId)
          ]
      )