{-# 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.Nimble.Types.StudioEncryptionConfiguration
-- 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.Nimble.Types.StudioEncryptionConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Nimble.Types.StudioEncryptionConfigurationKeyType
import qualified Amazonka.Prelude as Prelude

-- | Configuration of the encryption method that is used for the studio.
--
-- /See:/ 'newStudioEncryptionConfiguration' smart constructor.
data StudioEncryptionConfiguration = StudioEncryptionConfiguration'
  { -- | The ARN for a KMS key that is used to encrypt studio data.
    StudioEncryptionConfiguration -> Maybe Text
keyArn :: Prelude.Maybe Prelude.Text,
    -- | The type of KMS key that is used to encrypt studio data.
    StudioEncryptionConfiguration
-> StudioEncryptionConfigurationKeyType
keyType :: StudioEncryptionConfigurationKeyType
  }
  deriving (StudioEncryptionConfiguration
-> StudioEncryptionConfiguration -> Bool
(StudioEncryptionConfiguration
 -> StudioEncryptionConfiguration -> Bool)
-> (StudioEncryptionConfiguration
    -> StudioEncryptionConfiguration -> Bool)
-> Eq StudioEncryptionConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StudioEncryptionConfiguration
-> StudioEncryptionConfiguration -> Bool
$c/= :: StudioEncryptionConfiguration
-> StudioEncryptionConfiguration -> Bool
== :: StudioEncryptionConfiguration
-> StudioEncryptionConfiguration -> Bool
$c== :: StudioEncryptionConfiguration
-> StudioEncryptionConfiguration -> Bool
Prelude.Eq, ReadPrec [StudioEncryptionConfiguration]
ReadPrec StudioEncryptionConfiguration
Int -> ReadS StudioEncryptionConfiguration
ReadS [StudioEncryptionConfiguration]
(Int -> ReadS StudioEncryptionConfiguration)
-> ReadS [StudioEncryptionConfiguration]
-> ReadPrec StudioEncryptionConfiguration
-> ReadPrec [StudioEncryptionConfiguration]
-> Read StudioEncryptionConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StudioEncryptionConfiguration]
$creadListPrec :: ReadPrec [StudioEncryptionConfiguration]
readPrec :: ReadPrec StudioEncryptionConfiguration
$creadPrec :: ReadPrec StudioEncryptionConfiguration
readList :: ReadS [StudioEncryptionConfiguration]
$creadList :: ReadS [StudioEncryptionConfiguration]
readsPrec :: Int -> ReadS StudioEncryptionConfiguration
$creadsPrec :: Int -> ReadS StudioEncryptionConfiguration
Prelude.Read, Int -> StudioEncryptionConfiguration -> ShowS
[StudioEncryptionConfiguration] -> ShowS
StudioEncryptionConfiguration -> String
(Int -> StudioEncryptionConfiguration -> ShowS)
-> (StudioEncryptionConfiguration -> String)
-> ([StudioEncryptionConfiguration] -> ShowS)
-> Show StudioEncryptionConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StudioEncryptionConfiguration] -> ShowS
$cshowList :: [StudioEncryptionConfiguration] -> ShowS
show :: StudioEncryptionConfiguration -> String
$cshow :: StudioEncryptionConfiguration -> String
showsPrec :: Int -> StudioEncryptionConfiguration -> ShowS
$cshowsPrec :: Int -> StudioEncryptionConfiguration -> ShowS
Prelude.Show, (forall x.
 StudioEncryptionConfiguration
 -> Rep StudioEncryptionConfiguration x)
-> (forall x.
    Rep StudioEncryptionConfiguration x
    -> StudioEncryptionConfiguration)
-> Generic StudioEncryptionConfiguration
forall x.
Rep StudioEncryptionConfiguration x
-> StudioEncryptionConfiguration
forall x.
StudioEncryptionConfiguration
-> Rep StudioEncryptionConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StudioEncryptionConfiguration x
-> StudioEncryptionConfiguration
$cfrom :: forall x.
StudioEncryptionConfiguration
-> Rep StudioEncryptionConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'StudioEncryptionConfiguration' 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:
--
-- 'keyArn', 'studioEncryptionConfiguration_keyArn' - The ARN for a KMS key that is used to encrypt studio data.
--
-- 'keyType', 'studioEncryptionConfiguration_keyType' - The type of KMS key that is used to encrypt studio data.
newStudioEncryptionConfiguration ::
  -- | 'keyType'
  StudioEncryptionConfigurationKeyType ->
  StudioEncryptionConfiguration
newStudioEncryptionConfiguration :: StudioEncryptionConfigurationKeyType
-> StudioEncryptionConfiguration
newStudioEncryptionConfiguration StudioEncryptionConfigurationKeyType
pKeyType_ =
  StudioEncryptionConfiguration' :: Maybe Text
-> StudioEncryptionConfigurationKeyType
-> StudioEncryptionConfiguration
StudioEncryptionConfiguration'
    { $sel:keyArn:StudioEncryptionConfiguration' :: Maybe Text
keyArn =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:keyType:StudioEncryptionConfiguration' :: StudioEncryptionConfigurationKeyType
keyType = StudioEncryptionConfigurationKeyType
pKeyType_
    }

-- | The ARN for a KMS key that is used to encrypt studio data.
studioEncryptionConfiguration_keyArn :: Lens.Lens' StudioEncryptionConfiguration (Prelude.Maybe Prelude.Text)
studioEncryptionConfiguration_keyArn :: (Maybe Text -> f (Maybe Text))
-> StudioEncryptionConfiguration -> f StudioEncryptionConfiguration
studioEncryptionConfiguration_keyArn = (StudioEncryptionConfiguration -> Maybe Text)
-> (StudioEncryptionConfiguration
    -> Maybe Text -> StudioEncryptionConfiguration)
-> Lens
     StudioEncryptionConfiguration
     StudioEncryptionConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StudioEncryptionConfiguration' {Maybe Text
keyArn :: Maybe Text
$sel:keyArn:StudioEncryptionConfiguration' :: StudioEncryptionConfiguration -> Maybe Text
keyArn} -> Maybe Text
keyArn) (\s :: StudioEncryptionConfiguration
s@StudioEncryptionConfiguration' {} Maybe Text
a -> StudioEncryptionConfiguration
s {$sel:keyArn:StudioEncryptionConfiguration' :: Maybe Text
keyArn = Maybe Text
a} :: StudioEncryptionConfiguration)

-- | The type of KMS key that is used to encrypt studio data.
studioEncryptionConfiguration_keyType :: Lens.Lens' StudioEncryptionConfiguration StudioEncryptionConfigurationKeyType
studioEncryptionConfiguration_keyType :: (StudioEncryptionConfigurationKeyType
 -> f StudioEncryptionConfigurationKeyType)
-> StudioEncryptionConfiguration -> f StudioEncryptionConfiguration
studioEncryptionConfiguration_keyType = (StudioEncryptionConfiguration
 -> StudioEncryptionConfigurationKeyType)
-> (StudioEncryptionConfiguration
    -> StudioEncryptionConfigurationKeyType
    -> StudioEncryptionConfiguration)
-> Lens
     StudioEncryptionConfiguration
     StudioEncryptionConfiguration
     StudioEncryptionConfigurationKeyType
     StudioEncryptionConfigurationKeyType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StudioEncryptionConfiguration' {StudioEncryptionConfigurationKeyType
keyType :: StudioEncryptionConfigurationKeyType
$sel:keyType:StudioEncryptionConfiguration' :: StudioEncryptionConfiguration
-> StudioEncryptionConfigurationKeyType
keyType} -> StudioEncryptionConfigurationKeyType
keyType) (\s :: StudioEncryptionConfiguration
s@StudioEncryptionConfiguration' {} StudioEncryptionConfigurationKeyType
a -> StudioEncryptionConfiguration
s {$sel:keyType:StudioEncryptionConfiguration' :: StudioEncryptionConfigurationKeyType
keyType = StudioEncryptionConfigurationKeyType
a} :: StudioEncryptionConfiguration)

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

instance
  Prelude.Hashable
    StudioEncryptionConfiguration

instance Prelude.NFData StudioEncryptionConfiguration

instance Core.ToJSON StudioEncryptionConfiguration where
  toJSON :: StudioEncryptionConfiguration -> Value
toJSON StudioEncryptionConfiguration' {Maybe Text
StudioEncryptionConfigurationKeyType
keyType :: StudioEncryptionConfigurationKeyType
keyArn :: Maybe Text
$sel:keyType:StudioEncryptionConfiguration' :: StudioEncryptionConfiguration
-> StudioEncryptionConfigurationKeyType
$sel:keyArn:StudioEncryptionConfiguration' :: StudioEncryptionConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"keyArn" 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
keyArn,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"keyType" Text -> StudioEncryptionConfigurationKeyType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= StudioEncryptionConfigurationKeyType
keyType)
          ]
      )