{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Nimble.Types.StudioEncryptionConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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.
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'
    { $sel:keyArn:StudioEncryptionConfiguration' :: Maybe Text
keyArn =
        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 :: Lens' StudioEncryptionConfiguration (Maybe Text)
studioEncryptionConfiguration_keyArn = 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 :: Lens'
  StudioEncryptionConfiguration StudioEncryptionConfigurationKeyType
studioEncryptionConfiguration_keyType = 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 Data.FromJSON StudioEncryptionConfiguration where
  parseJSON :: Value -> Parser StudioEncryptionConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"StudioEncryptionConfiguration"
      ( \Object
x ->
          Maybe Text
-> StudioEncryptionConfigurationKeyType
-> StudioEncryptionConfiguration
StudioEncryptionConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"keyArn")
            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
"keyType")
      )

instance
  Prelude.Hashable
    StudioEncryptionConfiguration
  where
  hashWithSalt :: Int -> StudioEncryptionConfiguration -> Int
hashWithSalt Int
_salt StudioEncryptionConfiguration' {Maybe Text
StudioEncryptionConfigurationKeyType
keyType :: StudioEncryptionConfigurationKeyType
keyArn :: Maybe Text
$sel:keyType:StudioEncryptionConfiguration' :: StudioEncryptionConfiguration
-> StudioEncryptionConfigurationKeyType
$sel:keyArn:StudioEncryptionConfiguration' :: StudioEncryptionConfiguration -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
keyArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` StudioEncryptionConfigurationKeyType
keyType

instance Prelude.NFData StudioEncryptionConfiguration where
  rnf :: StudioEncryptionConfiguration -> ()
rnf StudioEncryptionConfiguration' {Maybe Text
StudioEncryptionConfigurationKeyType
keyType :: StudioEncryptionConfigurationKeyType
keyArn :: Maybe Text
$sel:keyType:StudioEncryptionConfiguration' :: StudioEncryptionConfiguration
-> StudioEncryptionConfigurationKeyType
$sel:keyArn:StudioEncryptionConfiguration' :: StudioEncryptionConfiguration -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
keyArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf StudioEncryptionConfigurationKeyType
keyType

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"keyArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
keyArn,
            forall a. a -> Maybe a
Prelude.Just (Key
"keyType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= StudioEncryptionConfigurationKeyType
keyType)
          ]
      )