{-# 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.MediaConvert.Types.InputDecryptionSettings
-- 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.MediaConvert.Types.InputDecryptionSettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaConvert.Types.DecryptionMode
import qualified Amazonka.Prelude as Prelude

-- | Settings for decrypting any input files that you encrypt before you
-- upload them to Amazon S3. MediaConvert can decrypt files only when you
-- use AWS Key Management Service (KMS) to encrypt the data key that you
-- use to encrypt your content.
--
-- /See:/ 'newInputDecryptionSettings' smart constructor.
data InputDecryptionSettings = InputDecryptionSettings'
  { -- | Specify the encryption mode that you used to encrypt your input files.
    InputDecryptionSettings -> Maybe DecryptionMode
decryptionMode :: Prelude.Maybe DecryptionMode,
    -- | Warning! Don\'t provide your encryption key in plaintext. Your job
    -- settings could be intercepted, making your encrypted content vulnerable.
    -- Specify the encrypted version of the data key that you used to encrypt
    -- your content. The data key must be encrypted by AWS Key Management
    -- Service (KMS). The key can be 128, 192, or 256 bits.
    InputDecryptionSettings -> Maybe Text
encryptedDecryptionKey :: Prelude.Maybe Prelude.Text,
    -- | Specify the initialization vector that you used when you encrypted your
    -- content before uploading it to Amazon S3. You can use a 16-byte
    -- initialization vector with any encryption mode. Or, you can use a
    -- 12-byte initialization vector with GCM or CTR. MediaConvert accepts only
    -- initialization vectors that are base64-encoded.
    InputDecryptionSettings -> Maybe Text
initializationVector :: Prelude.Maybe Prelude.Text,
    -- | Specify the AWS Region for AWS Key Management Service (KMS) that you
    -- used to encrypt your data key, if that Region is different from the one
    -- you are using for AWS Elemental MediaConvert.
    InputDecryptionSettings -> Maybe Text
kmsKeyRegion :: Prelude.Maybe Prelude.Text
  }
  deriving (InputDecryptionSettings -> InputDecryptionSettings -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InputDecryptionSettings -> InputDecryptionSettings -> Bool
$c/= :: InputDecryptionSettings -> InputDecryptionSettings -> Bool
== :: InputDecryptionSettings -> InputDecryptionSettings -> Bool
$c== :: InputDecryptionSettings -> InputDecryptionSettings -> Bool
Prelude.Eq, ReadPrec [InputDecryptionSettings]
ReadPrec InputDecryptionSettings
Int -> ReadS InputDecryptionSettings
ReadS [InputDecryptionSettings]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InputDecryptionSettings]
$creadListPrec :: ReadPrec [InputDecryptionSettings]
readPrec :: ReadPrec InputDecryptionSettings
$creadPrec :: ReadPrec InputDecryptionSettings
readList :: ReadS [InputDecryptionSettings]
$creadList :: ReadS [InputDecryptionSettings]
readsPrec :: Int -> ReadS InputDecryptionSettings
$creadsPrec :: Int -> ReadS InputDecryptionSettings
Prelude.Read, Int -> InputDecryptionSettings -> ShowS
[InputDecryptionSettings] -> ShowS
InputDecryptionSettings -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InputDecryptionSettings] -> ShowS
$cshowList :: [InputDecryptionSettings] -> ShowS
show :: InputDecryptionSettings -> String
$cshow :: InputDecryptionSettings -> String
showsPrec :: Int -> InputDecryptionSettings -> ShowS
$cshowsPrec :: Int -> InputDecryptionSettings -> ShowS
Prelude.Show, forall x. Rep InputDecryptionSettings x -> InputDecryptionSettings
forall x. InputDecryptionSettings -> Rep InputDecryptionSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InputDecryptionSettings x -> InputDecryptionSettings
$cfrom :: forall x. InputDecryptionSettings -> Rep InputDecryptionSettings x
Prelude.Generic)

-- |
-- Create a value of 'InputDecryptionSettings' 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:
--
-- 'decryptionMode', 'inputDecryptionSettings_decryptionMode' - Specify the encryption mode that you used to encrypt your input files.
--
-- 'encryptedDecryptionKey', 'inputDecryptionSettings_encryptedDecryptionKey' - Warning! Don\'t provide your encryption key in plaintext. Your job
-- settings could be intercepted, making your encrypted content vulnerable.
-- Specify the encrypted version of the data key that you used to encrypt
-- your content. The data key must be encrypted by AWS Key Management
-- Service (KMS). The key can be 128, 192, or 256 bits.
--
-- 'initializationVector', 'inputDecryptionSettings_initializationVector' - Specify the initialization vector that you used when you encrypted your
-- content before uploading it to Amazon S3. You can use a 16-byte
-- initialization vector with any encryption mode. Or, you can use a
-- 12-byte initialization vector with GCM or CTR. MediaConvert accepts only
-- initialization vectors that are base64-encoded.
--
-- 'kmsKeyRegion', 'inputDecryptionSettings_kmsKeyRegion' - Specify the AWS Region for AWS Key Management Service (KMS) that you
-- used to encrypt your data key, if that Region is different from the one
-- you are using for AWS Elemental MediaConvert.
newInputDecryptionSettings ::
  InputDecryptionSettings
newInputDecryptionSettings :: InputDecryptionSettings
newInputDecryptionSettings =
  InputDecryptionSettings'
    { $sel:decryptionMode:InputDecryptionSettings' :: Maybe DecryptionMode
decryptionMode =
        forall a. Maybe a
Prelude.Nothing,
      $sel:encryptedDecryptionKey:InputDecryptionSettings' :: Maybe Text
encryptedDecryptionKey = forall a. Maybe a
Prelude.Nothing,
      $sel:initializationVector:InputDecryptionSettings' :: Maybe Text
initializationVector = forall a. Maybe a
Prelude.Nothing,
      $sel:kmsKeyRegion:InputDecryptionSettings' :: Maybe Text
kmsKeyRegion = forall a. Maybe a
Prelude.Nothing
    }

-- | Specify the encryption mode that you used to encrypt your input files.
inputDecryptionSettings_decryptionMode :: Lens.Lens' InputDecryptionSettings (Prelude.Maybe DecryptionMode)
inputDecryptionSettings_decryptionMode :: Lens' InputDecryptionSettings (Maybe DecryptionMode)
inputDecryptionSettings_decryptionMode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputDecryptionSettings' {Maybe DecryptionMode
decryptionMode :: Maybe DecryptionMode
$sel:decryptionMode:InputDecryptionSettings' :: InputDecryptionSettings -> Maybe DecryptionMode
decryptionMode} -> Maybe DecryptionMode
decryptionMode) (\s :: InputDecryptionSettings
s@InputDecryptionSettings' {} Maybe DecryptionMode
a -> InputDecryptionSettings
s {$sel:decryptionMode:InputDecryptionSettings' :: Maybe DecryptionMode
decryptionMode = Maybe DecryptionMode
a} :: InputDecryptionSettings)

-- | Warning! Don\'t provide your encryption key in plaintext. Your job
-- settings could be intercepted, making your encrypted content vulnerable.
-- Specify the encrypted version of the data key that you used to encrypt
-- your content. The data key must be encrypted by AWS Key Management
-- Service (KMS). The key can be 128, 192, or 256 bits.
inputDecryptionSettings_encryptedDecryptionKey :: Lens.Lens' InputDecryptionSettings (Prelude.Maybe Prelude.Text)
inputDecryptionSettings_encryptedDecryptionKey :: Lens' InputDecryptionSettings (Maybe Text)
inputDecryptionSettings_encryptedDecryptionKey = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputDecryptionSettings' {Maybe Text
encryptedDecryptionKey :: Maybe Text
$sel:encryptedDecryptionKey:InputDecryptionSettings' :: InputDecryptionSettings -> Maybe Text
encryptedDecryptionKey} -> Maybe Text
encryptedDecryptionKey) (\s :: InputDecryptionSettings
s@InputDecryptionSettings' {} Maybe Text
a -> InputDecryptionSettings
s {$sel:encryptedDecryptionKey:InputDecryptionSettings' :: Maybe Text
encryptedDecryptionKey = Maybe Text
a} :: InputDecryptionSettings)

-- | Specify the initialization vector that you used when you encrypted your
-- content before uploading it to Amazon S3. You can use a 16-byte
-- initialization vector with any encryption mode. Or, you can use a
-- 12-byte initialization vector with GCM or CTR. MediaConvert accepts only
-- initialization vectors that are base64-encoded.
inputDecryptionSettings_initializationVector :: Lens.Lens' InputDecryptionSettings (Prelude.Maybe Prelude.Text)
inputDecryptionSettings_initializationVector :: Lens' InputDecryptionSettings (Maybe Text)
inputDecryptionSettings_initializationVector = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputDecryptionSettings' {Maybe Text
initializationVector :: Maybe Text
$sel:initializationVector:InputDecryptionSettings' :: InputDecryptionSettings -> Maybe Text
initializationVector} -> Maybe Text
initializationVector) (\s :: InputDecryptionSettings
s@InputDecryptionSettings' {} Maybe Text
a -> InputDecryptionSettings
s {$sel:initializationVector:InputDecryptionSettings' :: Maybe Text
initializationVector = Maybe Text
a} :: InputDecryptionSettings)

-- | Specify the AWS Region for AWS Key Management Service (KMS) that you
-- used to encrypt your data key, if that Region is different from the one
-- you are using for AWS Elemental MediaConvert.
inputDecryptionSettings_kmsKeyRegion :: Lens.Lens' InputDecryptionSettings (Prelude.Maybe Prelude.Text)
inputDecryptionSettings_kmsKeyRegion :: Lens' InputDecryptionSettings (Maybe Text)
inputDecryptionSettings_kmsKeyRegion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InputDecryptionSettings' {Maybe Text
kmsKeyRegion :: Maybe Text
$sel:kmsKeyRegion:InputDecryptionSettings' :: InputDecryptionSettings -> Maybe Text
kmsKeyRegion} -> Maybe Text
kmsKeyRegion) (\s :: InputDecryptionSettings
s@InputDecryptionSettings' {} Maybe Text
a -> InputDecryptionSettings
s {$sel:kmsKeyRegion:InputDecryptionSettings' :: Maybe Text
kmsKeyRegion = Maybe Text
a} :: InputDecryptionSettings)

instance Data.FromJSON InputDecryptionSettings where
  parseJSON :: Value -> Parser InputDecryptionSettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"InputDecryptionSettings"
      ( \Object
x ->
          Maybe DecryptionMode
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> InputDecryptionSettings
InputDecryptionSettings'
            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
"decryptionMode")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"encryptedDecryptionKey")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"initializationVector")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"kmsKeyRegion")
      )

instance Prelude.Hashable InputDecryptionSettings where
  hashWithSalt :: Int -> InputDecryptionSettings -> Int
hashWithSalt Int
_salt InputDecryptionSettings' {Maybe Text
Maybe DecryptionMode
kmsKeyRegion :: Maybe Text
initializationVector :: Maybe Text
encryptedDecryptionKey :: Maybe Text
decryptionMode :: Maybe DecryptionMode
$sel:kmsKeyRegion:InputDecryptionSettings' :: InputDecryptionSettings -> Maybe Text
$sel:initializationVector:InputDecryptionSettings' :: InputDecryptionSettings -> Maybe Text
$sel:encryptedDecryptionKey:InputDecryptionSettings' :: InputDecryptionSettings -> Maybe Text
$sel:decryptionMode:InputDecryptionSettings' :: InputDecryptionSettings -> Maybe DecryptionMode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DecryptionMode
decryptionMode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
encryptedDecryptionKey
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
initializationVector
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
kmsKeyRegion

instance Prelude.NFData InputDecryptionSettings where
  rnf :: InputDecryptionSettings -> ()
rnf InputDecryptionSettings' {Maybe Text
Maybe DecryptionMode
kmsKeyRegion :: Maybe Text
initializationVector :: Maybe Text
encryptedDecryptionKey :: Maybe Text
decryptionMode :: Maybe DecryptionMode
$sel:kmsKeyRegion:InputDecryptionSettings' :: InputDecryptionSettings -> Maybe Text
$sel:initializationVector:InputDecryptionSettings' :: InputDecryptionSettings -> Maybe Text
$sel:encryptedDecryptionKey:InputDecryptionSettings' :: InputDecryptionSettings -> Maybe Text
$sel:decryptionMode:InputDecryptionSettings' :: InputDecryptionSettings -> Maybe DecryptionMode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe DecryptionMode
decryptionMode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
encryptedDecryptionKey
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
initializationVector
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
kmsKeyRegion

instance Data.ToJSON InputDecryptionSettings where
  toJSON :: InputDecryptionSettings -> Value
toJSON InputDecryptionSettings' {Maybe Text
Maybe DecryptionMode
kmsKeyRegion :: Maybe Text
initializationVector :: Maybe Text
encryptedDecryptionKey :: Maybe Text
decryptionMode :: Maybe DecryptionMode
$sel:kmsKeyRegion:InputDecryptionSettings' :: InputDecryptionSettings -> Maybe Text
$sel:initializationVector:InputDecryptionSettings' :: InputDecryptionSettings -> Maybe Text
$sel:encryptedDecryptionKey:InputDecryptionSettings' :: InputDecryptionSettings -> Maybe Text
$sel:decryptionMode:InputDecryptionSettings' :: InputDecryptionSettings -> Maybe DecryptionMode
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"decryptionMode" 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 DecryptionMode
decryptionMode,
            (Key
"encryptedDecryptionKey" 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
encryptedDecryptionKey,
            (Key
"initializationVector" 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
initializationVector,
            (Key
"kmsKeyRegion" 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
kmsKeyRegion
          ]
      )