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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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'
  { -- | 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 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,
    -- | Specify the encryption mode that you used to encrypt your input files.
    InputDecryptionSettings -> Maybe DecryptionMode
decryptionMode :: Prelude.Maybe DecryptionMode,
    -- | 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
  }
  deriving (InputDecryptionSettings -> InputDecryptionSettings -> Bool
(InputDecryptionSettings -> InputDecryptionSettings -> Bool)
-> (InputDecryptionSettings -> InputDecryptionSettings -> Bool)
-> Eq InputDecryptionSettings
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]
(Int -> ReadS InputDecryptionSettings)
-> ReadS [InputDecryptionSettings]
-> ReadPrec InputDecryptionSettings
-> ReadPrec [InputDecryptionSettings]
-> Read 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
(Int -> InputDecryptionSettings -> ShowS)
-> (InputDecryptionSettings -> String)
-> ([InputDecryptionSettings] -> ShowS)
-> Show InputDecryptionSettings
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.
 InputDecryptionSettings -> Rep InputDecryptionSettings x)
-> (forall x.
    Rep InputDecryptionSettings x -> InputDecryptionSettings)
-> Generic InputDecryptionSettings
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:
--
-- '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.
--
-- '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.
--
-- 'decryptionMode', 'inputDecryptionSettings_decryptionMode' - Specify the encryption mode that you used to encrypt your input files.
--
-- '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.
newInputDecryptionSettings ::
  InputDecryptionSettings
newInputDecryptionSettings :: InputDecryptionSettings
newInputDecryptionSettings =
  InputDecryptionSettings' :: Maybe Text
-> Maybe Text
-> Maybe DecryptionMode
-> Maybe Text
-> InputDecryptionSettings
InputDecryptionSettings'
    { $sel:encryptedDecryptionKey:InputDecryptionSettings' :: Maybe Text
encryptedDecryptionKey =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:kmsKeyRegion:InputDecryptionSettings' :: Maybe Text
kmsKeyRegion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:decryptionMode:InputDecryptionSettings' :: Maybe DecryptionMode
decryptionMode = Maybe DecryptionMode
forall a. Maybe a
Prelude.Nothing,
      $sel:initializationVector:InputDecryptionSettings' :: Maybe Text
initializationVector = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> InputDecryptionSettings -> f InputDecryptionSettings
inputDecryptionSettings_encryptedDecryptionKey = (InputDecryptionSettings -> Maybe Text)
-> (InputDecryptionSettings
    -> Maybe Text -> InputDecryptionSettings)
-> Lens
     InputDecryptionSettings
     InputDecryptionSettings
     (Maybe Text)
     (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text))
-> InputDecryptionSettings -> f InputDecryptionSettings
inputDecryptionSettings_kmsKeyRegion = (InputDecryptionSettings -> Maybe Text)
-> (InputDecryptionSettings
    -> Maybe Text -> InputDecryptionSettings)
-> Lens
     InputDecryptionSettings
     InputDecryptionSettings
     (Maybe Text)
     (Maybe Text)
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)

-- | Specify the encryption mode that you used to encrypt your input files.
inputDecryptionSettings_decryptionMode :: Lens.Lens' InputDecryptionSettings (Prelude.Maybe DecryptionMode)
inputDecryptionSettings_decryptionMode :: (Maybe DecryptionMode -> f (Maybe DecryptionMode))
-> InputDecryptionSettings -> f InputDecryptionSettings
inputDecryptionSettings_decryptionMode = (InputDecryptionSettings -> Maybe DecryptionMode)
-> (InputDecryptionSettings
    -> Maybe DecryptionMode -> InputDecryptionSettings)
-> Lens
     InputDecryptionSettings
     InputDecryptionSettings
     (Maybe DecryptionMode)
     (Maybe 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)

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> InputDecryptionSettings -> f InputDecryptionSettings
inputDecryptionSettings_initializationVector = (InputDecryptionSettings -> Maybe Text)
-> (InputDecryptionSettings
    -> Maybe Text -> InputDecryptionSettings)
-> Lens
     InputDecryptionSettings
     InputDecryptionSettings
     (Maybe Text)
     (Maybe Text)
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)

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

instance Prelude.Hashable InputDecryptionSettings

instance Prelude.NFData InputDecryptionSettings

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