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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes a custom encryption key that App Runner uses to encrypt copies
-- of the source repository and service logs.
--
-- /See:/ 'newEncryptionConfiguration' smart constructor.
data EncryptionConfiguration = EncryptionConfiguration'
  { -- | The ARN of the KMS key that\'s used for encryption.
    EncryptionConfiguration -> Text
kmsKey :: Prelude.Text
  }
  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:
--
-- 'kmsKey', 'encryptionConfiguration_kmsKey' - The ARN of the KMS key that\'s used for encryption.
newEncryptionConfiguration ::
  -- | 'kmsKey'
  Prelude.Text ->
  EncryptionConfiguration
newEncryptionConfiguration :: Text -> EncryptionConfiguration
newEncryptionConfiguration Text
pKmsKey_ =
  EncryptionConfiguration' :: Text -> EncryptionConfiguration
EncryptionConfiguration' {$sel:kmsKey:EncryptionConfiguration' :: Text
kmsKey = Text
pKmsKey_}

-- | The ARN of the KMS key that\'s used for encryption.
encryptionConfiguration_kmsKey :: Lens.Lens' EncryptionConfiguration Prelude.Text
encryptionConfiguration_kmsKey :: (Text -> f Text)
-> EncryptionConfiguration -> f EncryptionConfiguration
encryptionConfiguration_kmsKey = (EncryptionConfiguration -> Text)
-> (EncryptionConfiguration -> Text -> EncryptionConfiguration)
-> Lens EncryptionConfiguration EncryptionConfiguration Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionConfiguration' {Text
kmsKey :: Text
$sel:kmsKey:EncryptionConfiguration' :: EncryptionConfiguration -> Text
kmsKey} -> Text
kmsKey) (\s :: EncryptionConfiguration
s@EncryptionConfiguration' {} Text
a -> EncryptionConfiguration
s {$sel:kmsKey:EncryptionConfiguration' :: Text
kmsKey = Text
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 ->
          Text -> EncryptionConfiguration
EncryptionConfiguration'
            (Text -> EncryptionConfiguration)
-> Parser Text -> Parser EncryptionConfiguration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"KmsKey")
      )

instance Prelude.Hashable EncryptionConfiguration

instance Prelude.NFData EncryptionConfiguration

instance Core.ToJSON EncryptionConfiguration where
  toJSON :: EncryptionConfiguration -> Value
toJSON EncryptionConfiguration' {Text
kmsKey :: Text
$sel:kmsKey:EncryptionConfiguration' :: EncryptionConfiguration -> Text
..} =
    [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
"KmsKey" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
kmsKey)]
      )