{-# 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.MediaPackageVOD.Types.CmafEncryption
-- 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.MediaPackageVOD.Types.CmafEncryption where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaPackageVOD.Types.SpekeKeyProvider
import qualified Amazonka.Prelude as Prelude

-- | A CMAF encryption configuration.
--
-- /See:/ 'newCmafEncryption' smart constructor.
data CmafEncryption = CmafEncryption'
  { -- | An optional 128-bit, 16-byte hex value represented by a 32-character
    -- string, used in conjunction with the key for encrypting blocks. If you
    -- don\'t specify a value, then MediaPackage creates the constant
    -- initialization vector (IV).
    CmafEncryption -> Maybe Text
constantInitializationVector :: Prelude.Maybe Prelude.Text,
    CmafEncryption -> SpekeKeyProvider
spekeKeyProvider :: SpekeKeyProvider
  }
  deriving (CmafEncryption -> CmafEncryption -> Bool
(CmafEncryption -> CmafEncryption -> Bool)
-> (CmafEncryption -> CmafEncryption -> Bool) -> Eq CmafEncryption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CmafEncryption -> CmafEncryption -> Bool
$c/= :: CmafEncryption -> CmafEncryption -> Bool
== :: CmafEncryption -> CmafEncryption -> Bool
$c== :: CmafEncryption -> CmafEncryption -> Bool
Prelude.Eq, ReadPrec [CmafEncryption]
ReadPrec CmafEncryption
Int -> ReadS CmafEncryption
ReadS [CmafEncryption]
(Int -> ReadS CmafEncryption)
-> ReadS [CmafEncryption]
-> ReadPrec CmafEncryption
-> ReadPrec [CmafEncryption]
-> Read CmafEncryption
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CmafEncryption]
$creadListPrec :: ReadPrec [CmafEncryption]
readPrec :: ReadPrec CmafEncryption
$creadPrec :: ReadPrec CmafEncryption
readList :: ReadS [CmafEncryption]
$creadList :: ReadS [CmafEncryption]
readsPrec :: Int -> ReadS CmafEncryption
$creadsPrec :: Int -> ReadS CmafEncryption
Prelude.Read, Int -> CmafEncryption -> ShowS
[CmafEncryption] -> ShowS
CmafEncryption -> String
(Int -> CmafEncryption -> ShowS)
-> (CmafEncryption -> String)
-> ([CmafEncryption] -> ShowS)
-> Show CmafEncryption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CmafEncryption] -> ShowS
$cshowList :: [CmafEncryption] -> ShowS
show :: CmafEncryption -> String
$cshow :: CmafEncryption -> String
showsPrec :: Int -> CmafEncryption -> ShowS
$cshowsPrec :: Int -> CmafEncryption -> ShowS
Prelude.Show, (forall x. CmafEncryption -> Rep CmafEncryption x)
-> (forall x. Rep CmafEncryption x -> CmafEncryption)
-> Generic CmafEncryption
forall x. Rep CmafEncryption x -> CmafEncryption
forall x. CmafEncryption -> Rep CmafEncryption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CmafEncryption x -> CmafEncryption
$cfrom :: forall x. CmafEncryption -> Rep CmafEncryption x
Prelude.Generic)

-- |
-- Create a value of 'CmafEncryption' 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:
--
-- 'constantInitializationVector', 'cmafEncryption_constantInitializationVector' - An optional 128-bit, 16-byte hex value represented by a 32-character
-- string, used in conjunction with the key for encrypting blocks. If you
-- don\'t specify a value, then MediaPackage creates the constant
-- initialization vector (IV).
--
-- 'spekeKeyProvider', 'cmafEncryption_spekeKeyProvider' - Undocumented member.
newCmafEncryption ::
  -- | 'spekeKeyProvider'
  SpekeKeyProvider ->
  CmafEncryption
newCmafEncryption :: SpekeKeyProvider -> CmafEncryption
newCmafEncryption SpekeKeyProvider
pSpekeKeyProvider_ =
  CmafEncryption' :: Maybe Text -> SpekeKeyProvider -> CmafEncryption
CmafEncryption'
    { $sel:constantInitializationVector:CmafEncryption' :: Maybe Text
constantInitializationVector =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:spekeKeyProvider:CmafEncryption' :: SpekeKeyProvider
spekeKeyProvider = SpekeKeyProvider
pSpekeKeyProvider_
    }

-- | An optional 128-bit, 16-byte hex value represented by a 32-character
-- string, used in conjunction with the key for encrypting blocks. If you
-- don\'t specify a value, then MediaPackage creates the constant
-- initialization vector (IV).
cmafEncryption_constantInitializationVector :: Lens.Lens' CmafEncryption (Prelude.Maybe Prelude.Text)
cmafEncryption_constantInitializationVector :: (Maybe Text -> f (Maybe Text))
-> CmafEncryption -> f CmafEncryption
cmafEncryption_constantInitializationVector = (CmafEncryption -> Maybe Text)
-> (CmafEncryption -> Maybe Text -> CmafEncryption)
-> Lens CmafEncryption CmafEncryption (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CmafEncryption' {Maybe Text
constantInitializationVector :: Maybe Text
$sel:constantInitializationVector:CmafEncryption' :: CmafEncryption -> Maybe Text
constantInitializationVector} -> Maybe Text
constantInitializationVector) (\s :: CmafEncryption
s@CmafEncryption' {} Maybe Text
a -> CmafEncryption
s {$sel:constantInitializationVector:CmafEncryption' :: Maybe Text
constantInitializationVector = Maybe Text
a} :: CmafEncryption)

-- | Undocumented member.
cmafEncryption_spekeKeyProvider :: Lens.Lens' CmafEncryption SpekeKeyProvider
cmafEncryption_spekeKeyProvider :: (SpekeKeyProvider -> f SpekeKeyProvider)
-> CmafEncryption -> f CmafEncryption
cmafEncryption_spekeKeyProvider = (CmafEncryption -> SpekeKeyProvider)
-> (CmafEncryption -> SpekeKeyProvider -> CmafEncryption)
-> Lens
     CmafEncryption CmafEncryption SpekeKeyProvider SpekeKeyProvider
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CmafEncryption' {SpekeKeyProvider
spekeKeyProvider :: SpekeKeyProvider
$sel:spekeKeyProvider:CmafEncryption' :: CmafEncryption -> SpekeKeyProvider
spekeKeyProvider} -> SpekeKeyProvider
spekeKeyProvider) (\s :: CmafEncryption
s@CmafEncryption' {} SpekeKeyProvider
a -> CmafEncryption
s {$sel:spekeKeyProvider:CmafEncryption' :: SpekeKeyProvider
spekeKeyProvider = SpekeKeyProvider
a} :: CmafEncryption)

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

instance Prelude.Hashable CmafEncryption

instance Prelude.NFData CmafEncryption

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