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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaPackageVOD.Types.EncryptionMethod
import Amazonka.MediaPackageVOD.Types.SpekeKeyProvider
import qualified Amazonka.Prelude as Prelude

-- | An HTTP Live Streaming (HLS) encryption configuration.
--
-- /See:/ 'newHlsEncryption' smart constructor.
data HlsEncryption = HlsEncryption'
  { -- | A constant initialization vector for encryption (optional). When not
    -- specified the initialization vector will be periodically rotated.
    HlsEncryption -> Maybe Text
constantInitializationVector :: Prelude.Maybe Prelude.Text,
    -- | The encryption method to use.
    HlsEncryption -> Maybe EncryptionMethod
encryptionMethod :: Prelude.Maybe EncryptionMethod,
    HlsEncryption -> SpekeKeyProvider
spekeKeyProvider :: SpekeKeyProvider
  }
  deriving (HlsEncryption -> HlsEncryption -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HlsEncryption -> HlsEncryption -> Bool
$c/= :: HlsEncryption -> HlsEncryption -> Bool
== :: HlsEncryption -> HlsEncryption -> Bool
$c== :: HlsEncryption -> HlsEncryption -> Bool
Prelude.Eq, ReadPrec [HlsEncryption]
ReadPrec HlsEncryption
Int -> ReadS HlsEncryption
ReadS [HlsEncryption]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HlsEncryption]
$creadListPrec :: ReadPrec [HlsEncryption]
readPrec :: ReadPrec HlsEncryption
$creadPrec :: ReadPrec HlsEncryption
readList :: ReadS [HlsEncryption]
$creadList :: ReadS [HlsEncryption]
readsPrec :: Int -> ReadS HlsEncryption
$creadsPrec :: Int -> ReadS HlsEncryption
Prelude.Read, Int -> HlsEncryption -> ShowS
[HlsEncryption] -> ShowS
HlsEncryption -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HlsEncryption] -> ShowS
$cshowList :: [HlsEncryption] -> ShowS
show :: HlsEncryption -> String
$cshow :: HlsEncryption -> String
showsPrec :: Int -> HlsEncryption -> ShowS
$cshowsPrec :: Int -> HlsEncryption -> ShowS
Prelude.Show, forall x. Rep HlsEncryption x -> HlsEncryption
forall x. HlsEncryption -> Rep HlsEncryption x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HlsEncryption x -> HlsEncryption
$cfrom :: forall x. HlsEncryption -> Rep HlsEncryption x
Prelude.Generic)

-- |
-- Create a value of 'HlsEncryption' 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', 'hlsEncryption_constantInitializationVector' - A constant initialization vector for encryption (optional). When not
-- specified the initialization vector will be periodically rotated.
--
-- 'encryptionMethod', 'hlsEncryption_encryptionMethod' - The encryption method to use.
--
-- 'spekeKeyProvider', 'hlsEncryption_spekeKeyProvider' - Undocumented member.
newHlsEncryption ::
  -- | 'spekeKeyProvider'
  SpekeKeyProvider ->
  HlsEncryption
newHlsEncryption :: SpekeKeyProvider -> HlsEncryption
newHlsEncryption SpekeKeyProvider
pSpekeKeyProvider_ =
  HlsEncryption'
    { $sel:constantInitializationVector:HlsEncryption' :: Maybe Text
constantInitializationVector =
        forall a. Maybe a
Prelude.Nothing,
      $sel:encryptionMethod:HlsEncryption' :: Maybe EncryptionMethod
encryptionMethod = forall a. Maybe a
Prelude.Nothing,
      $sel:spekeKeyProvider:HlsEncryption' :: SpekeKeyProvider
spekeKeyProvider = SpekeKeyProvider
pSpekeKeyProvider_
    }

-- | A constant initialization vector for encryption (optional). When not
-- specified the initialization vector will be periodically rotated.
hlsEncryption_constantInitializationVector :: Lens.Lens' HlsEncryption (Prelude.Maybe Prelude.Text)
hlsEncryption_constantInitializationVector :: Lens' HlsEncryption (Maybe Text)
hlsEncryption_constantInitializationVector = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsEncryption' {Maybe Text
constantInitializationVector :: Maybe Text
$sel:constantInitializationVector:HlsEncryption' :: HlsEncryption -> Maybe Text
constantInitializationVector} -> Maybe Text
constantInitializationVector) (\s :: HlsEncryption
s@HlsEncryption' {} Maybe Text
a -> HlsEncryption
s {$sel:constantInitializationVector:HlsEncryption' :: Maybe Text
constantInitializationVector = Maybe Text
a} :: HlsEncryption)

-- | The encryption method to use.
hlsEncryption_encryptionMethod :: Lens.Lens' HlsEncryption (Prelude.Maybe EncryptionMethod)
hlsEncryption_encryptionMethod :: Lens' HlsEncryption (Maybe EncryptionMethod)
hlsEncryption_encryptionMethod = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsEncryption' {Maybe EncryptionMethod
encryptionMethod :: Maybe EncryptionMethod
$sel:encryptionMethod:HlsEncryption' :: HlsEncryption -> Maybe EncryptionMethod
encryptionMethod} -> Maybe EncryptionMethod
encryptionMethod) (\s :: HlsEncryption
s@HlsEncryption' {} Maybe EncryptionMethod
a -> HlsEncryption
s {$sel:encryptionMethod:HlsEncryption' :: Maybe EncryptionMethod
encryptionMethod = Maybe EncryptionMethod
a} :: HlsEncryption)

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

instance Data.FromJSON HlsEncryption where
  parseJSON :: Value -> Parser HlsEncryption
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"HlsEncryption"
      ( \Object
x ->
          Maybe Text
-> Maybe EncryptionMethod -> SpekeKeyProvider -> HlsEncryption
HlsEncryption'
            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
"constantInitializationVector")
            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
"encryptionMethod")
            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
"spekeKeyProvider")
      )

instance Prelude.Hashable HlsEncryption where
  hashWithSalt :: Int -> HlsEncryption -> Int
hashWithSalt Int
_salt HlsEncryption' {Maybe Text
Maybe EncryptionMethod
SpekeKeyProvider
spekeKeyProvider :: SpekeKeyProvider
encryptionMethod :: Maybe EncryptionMethod
constantInitializationVector :: Maybe Text
$sel:spekeKeyProvider:HlsEncryption' :: HlsEncryption -> SpekeKeyProvider
$sel:encryptionMethod:HlsEncryption' :: HlsEncryption -> Maybe EncryptionMethod
$sel:constantInitializationVector:HlsEncryption' :: HlsEncryption -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
constantInitializationVector
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe EncryptionMethod
encryptionMethod
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SpekeKeyProvider
spekeKeyProvider

instance Prelude.NFData HlsEncryption where
  rnf :: HlsEncryption -> ()
rnf HlsEncryption' {Maybe Text
Maybe EncryptionMethod
SpekeKeyProvider
spekeKeyProvider :: SpekeKeyProvider
encryptionMethod :: Maybe EncryptionMethod
constantInitializationVector :: Maybe Text
$sel:spekeKeyProvider:HlsEncryption' :: HlsEncryption -> SpekeKeyProvider
$sel:encryptionMethod:HlsEncryption' :: HlsEncryption -> Maybe EncryptionMethod
$sel:constantInitializationVector:HlsEncryption' :: HlsEncryption -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
constantInitializationVector
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe EncryptionMethod
encryptionMethod
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf SpekeKeyProvider
spekeKeyProvider

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