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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.XRay.Types.EncryptionStatus
import Amazonka.XRay.Types.EncryptionType

-- | A configuration document that specifies encryption configuration
-- settings.
--
-- /See:/ 'newEncryptionConfig' smart constructor.
data EncryptionConfig = EncryptionConfig'
  { -- | The encryption status. While the status is @UPDATING@, X-Ray may encrypt
    -- data with a combination of the new and old settings.
    EncryptionConfig -> Maybe EncryptionStatus
status :: Prelude.Maybe EncryptionStatus,
    -- | The ID of the KMS key used for encryption, if applicable.
    EncryptionConfig -> Maybe Text
keyId :: Prelude.Maybe Prelude.Text,
    -- | The type of encryption. Set to @KMS@ for encryption with KMS keys. Set
    -- to @NONE@ for default encryption.
    EncryptionConfig -> Maybe EncryptionType
type' :: Prelude.Maybe EncryptionType
  }
  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:
--
-- 'status', 'encryptionConfig_status' - The encryption status. While the status is @UPDATING@, X-Ray may encrypt
-- data with a combination of the new and old settings.
--
-- 'keyId', 'encryptionConfig_keyId' - The ID of the KMS key used for encryption, if applicable.
--
-- 'type'', 'encryptionConfig_type' - The type of encryption. Set to @KMS@ for encryption with KMS keys. Set
-- to @NONE@ for default encryption.
newEncryptionConfig ::
  EncryptionConfig
newEncryptionConfig :: EncryptionConfig
newEncryptionConfig =
  EncryptionConfig' :: Maybe EncryptionStatus
-> Maybe Text -> Maybe EncryptionType -> EncryptionConfig
EncryptionConfig'
    { $sel:status:EncryptionConfig' :: Maybe EncryptionStatus
status = Maybe EncryptionStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:keyId:EncryptionConfig' :: Maybe Text
keyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':EncryptionConfig' :: Maybe EncryptionType
type' = Maybe EncryptionType
forall a. Maybe a
Prelude.Nothing
    }

-- | The encryption status. While the status is @UPDATING@, X-Ray may encrypt
-- data with a combination of the new and old settings.
encryptionConfig_status :: Lens.Lens' EncryptionConfig (Prelude.Maybe EncryptionStatus)
encryptionConfig_status :: (Maybe EncryptionStatus -> f (Maybe EncryptionStatus))
-> EncryptionConfig -> f EncryptionConfig
encryptionConfig_status = (EncryptionConfig -> Maybe EncryptionStatus)
-> (EncryptionConfig -> Maybe EncryptionStatus -> EncryptionConfig)
-> Lens
     EncryptionConfig
     EncryptionConfig
     (Maybe EncryptionStatus)
     (Maybe EncryptionStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionConfig' {Maybe EncryptionStatus
status :: Maybe EncryptionStatus
$sel:status:EncryptionConfig' :: EncryptionConfig -> Maybe EncryptionStatus
status} -> Maybe EncryptionStatus
status) (\s :: EncryptionConfig
s@EncryptionConfig' {} Maybe EncryptionStatus
a -> EncryptionConfig
s {$sel:status:EncryptionConfig' :: Maybe EncryptionStatus
status = Maybe EncryptionStatus
a} :: EncryptionConfig)

-- | The ID of the KMS key used for encryption, if applicable.
encryptionConfig_keyId :: Lens.Lens' EncryptionConfig (Prelude.Maybe Prelude.Text)
encryptionConfig_keyId :: (Maybe Text -> f (Maybe Text))
-> EncryptionConfig -> f EncryptionConfig
encryptionConfig_keyId = (EncryptionConfig -> Maybe Text)
-> (EncryptionConfig -> Maybe Text -> EncryptionConfig)
-> Lens EncryptionConfig EncryptionConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionConfig' {Maybe Text
keyId :: Maybe Text
$sel:keyId:EncryptionConfig' :: EncryptionConfig -> Maybe Text
keyId} -> Maybe Text
keyId) (\s :: EncryptionConfig
s@EncryptionConfig' {} Maybe Text
a -> EncryptionConfig
s {$sel:keyId:EncryptionConfig' :: Maybe Text
keyId = Maybe Text
a} :: EncryptionConfig)

-- | The type of encryption. Set to @KMS@ for encryption with KMS keys. Set
-- to @NONE@ for default encryption.
encryptionConfig_type :: Lens.Lens' EncryptionConfig (Prelude.Maybe EncryptionType)
encryptionConfig_type :: (Maybe EncryptionType -> f (Maybe EncryptionType))
-> EncryptionConfig -> f EncryptionConfig
encryptionConfig_type = (EncryptionConfig -> Maybe EncryptionType)
-> (EncryptionConfig -> Maybe EncryptionType -> EncryptionConfig)
-> Lens
     EncryptionConfig
     EncryptionConfig
     (Maybe EncryptionType)
     (Maybe EncryptionType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionConfig' {Maybe EncryptionType
type' :: Maybe EncryptionType
$sel:type':EncryptionConfig' :: EncryptionConfig -> Maybe EncryptionType
type'} -> Maybe EncryptionType
type') (\s :: EncryptionConfig
s@EncryptionConfig' {} Maybe EncryptionType
a -> EncryptionConfig
s {$sel:type':EncryptionConfig' :: Maybe EncryptionType
type' = Maybe EncryptionType
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 ->
          Maybe EncryptionStatus
-> Maybe Text -> Maybe EncryptionType -> EncryptionConfig
EncryptionConfig'
            (Maybe EncryptionStatus
 -> Maybe Text -> Maybe EncryptionType -> EncryptionConfig)
-> Parser (Maybe EncryptionStatus)
-> Parser (Maybe Text -> Maybe EncryptionType -> EncryptionConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe EncryptionStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser (Maybe Text -> Maybe EncryptionType -> EncryptionConfig)
-> Parser (Maybe Text)
-> Parser (Maybe EncryptionType -> EncryptionConfig)
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
"KeyId")
            Parser (Maybe EncryptionType -> EncryptionConfig)
-> Parser (Maybe EncryptionType) -> Parser EncryptionConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe EncryptionType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Type")
      )

instance Prelude.Hashable EncryptionConfig

instance Prelude.NFData EncryptionConfig