{-# 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.ElasticTranscoder.Types.HlsContentProtection
-- 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.ElasticTranscoder.Types.HlsContentProtection where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | The HLS content protection settings, if any, that you want Elastic
-- Transcoder to apply to your output files.
--
-- /See:/ 'newHlsContentProtection' smart constructor.
data HlsContentProtection = HlsContentProtection'
  { -- | If Elastic Transcoder is generating your key for you, you must leave
    -- this field blank.
    --
    -- The series of random bits created by a random bit generator, unique for
    -- every encryption operation, that you want Elastic Transcoder to use to
    -- encrypt your output files. The initialization vector must be
    -- base64-encoded, and it must be exactly 16 bytes before being
    -- base64-encoded.
    HlsContentProtection -> Maybe Text
initializationVector :: Prelude.Maybe Prelude.Text,
    -- | If you want Elastic Transcoder to generate a key for you, leave this
    -- field blank.
    --
    -- If you choose to supply your own key, you must encrypt the key by using
    -- AWS KMS. The key must be base64-encoded, and it must be one of the
    -- following bit lengths before being base64-encoded:
    --
    -- @128@, @192@, or @256@.
    HlsContentProtection -> Maybe Text
key :: Prelude.Maybe Prelude.Text,
    -- | If Elastic Transcoder is generating your key for you, you must leave
    -- this field blank.
    --
    -- The MD5 digest of the key that you want Elastic Transcoder to use to
    -- encrypt your output file, and that you want Elastic Transcoder to use as
    -- a checksum to make sure your key was not corrupted in transit. The key
    -- MD5 must be base64-encoded, and it must be exactly 16 bytes before being
    -- base64- encoded.
    HlsContentProtection -> Maybe Text
keyMd5 :: Prelude.Maybe Prelude.Text,
    -- | Specify whether you want Elastic Transcoder to write your HLS license
    -- key to an Amazon S3 bucket. If you choose @WithVariantPlaylists@,
    -- @LicenseAcquisitionUrl@ must be left blank and Elastic Transcoder writes
    -- your data key into the same bucket as the associated playlist.
    HlsContentProtection -> Maybe Text
keyStoragePolicy :: Prelude.Maybe Prelude.Text,
    -- | The location of the license key required to decrypt your HLS playlist.
    -- The URL must be an absolute path, and is referenced in the URI attribute
    -- of the EXT-X-KEY metadata tag in the playlist file.
    HlsContentProtection -> Maybe Text
licenseAcquisitionUrl :: Prelude.Maybe Prelude.Text,
    -- | The content protection method for your output. The only valid value is:
    -- @aes-128@.
    --
    -- This value is written into the method attribute of the @EXT-X-KEY@
    -- metadata tag in the output playlist.
    HlsContentProtection -> Maybe Text
method :: Prelude.Maybe Prelude.Text
  }
  deriving (HlsContentProtection -> HlsContentProtection -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HlsContentProtection -> HlsContentProtection -> Bool
$c/= :: HlsContentProtection -> HlsContentProtection -> Bool
== :: HlsContentProtection -> HlsContentProtection -> Bool
$c== :: HlsContentProtection -> HlsContentProtection -> Bool
Prelude.Eq, ReadPrec [HlsContentProtection]
ReadPrec HlsContentProtection
Int -> ReadS HlsContentProtection
ReadS [HlsContentProtection]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HlsContentProtection]
$creadListPrec :: ReadPrec [HlsContentProtection]
readPrec :: ReadPrec HlsContentProtection
$creadPrec :: ReadPrec HlsContentProtection
readList :: ReadS [HlsContentProtection]
$creadList :: ReadS [HlsContentProtection]
readsPrec :: Int -> ReadS HlsContentProtection
$creadsPrec :: Int -> ReadS HlsContentProtection
Prelude.Read, Int -> HlsContentProtection -> ShowS
[HlsContentProtection] -> ShowS
HlsContentProtection -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HlsContentProtection] -> ShowS
$cshowList :: [HlsContentProtection] -> ShowS
show :: HlsContentProtection -> String
$cshow :: HlsContentProtection -> String
showsPrec :: Int -> HlsContentProtection -> ShowS
$cshowsPrec :: Int -> HlsContentProtection -> ShowS
Prelude.Show, forall x. Rep HlsContentProtection x -> HlsContentProtection
forall x. HlsContentProtection -> Rep HlsContentProtection x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HlsContentProtection x -> HlsContentProtection
$cfrom :: forall x. HlsContentProtection -> Rep HlsContentProtection x
Prelude.Generic)

-- |
-- Create a value of 'HlsContentProtection' 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:
--
-- 'initializationVector', 'hlsContentProtection_initializationVector' - If Elastic Transcoder is generating your key for you, you must leave
-- this field blank.
--
-- The series of random bits created by a random bit generator, unique for
-- every encryption operation, that you want Elastic Transcoder to use to
-- encrypt your output files. The initialization vector must be
-- base64-encoded, and it must be exactly 16 bytes before being
-- base64-encoded.
--
-- 'key', 'hlsContentProtection_key' - If you want Elastic Transcoder to generate a key for you, leave this
-- field blank.
--
-- If you choose to supply your own key, you must encrypt the key by using
-- AWS KMS. The key must be base64-encoded, and it must be one of the
-- following bit lengths before being base64-encoded:
--
-- @128@, @192@, or @256@.
--
-- 'keyMd5', 'hlsContentProtection_keyMd5' - If Elastic Transcoder is generating your key for you, you must leave
-- this field blank.
--
-- The MD5 digest of the key that you want Elastic Transcoder to use to
-- encrypt your output file, and that you want Elastic Transcoder to use as
-- a checksum to make sure your key was not corrupted in transit. The key
-- MD5 must be base64-encoded, and it must be exactly 16 bytes before being
-- base64- encoded.
--
-- 'keyStoragePolicy', 'hlsContentProtection_keyStoragePolicy' - Specify whether you want Elastic Transcoder to write your HLS license
-- key to an Amazon S3 bucket. If you choose @WithVariantPlaylists@,
-- @LicenseAcquisitionUrl@ must be left blank and Elastic Transcoder writes
-- your data key into the same bucket as the associated playlist.
--
-- 'licenseAcquisitionUrl', 'hlsContentProtection_licenseAcquisitionUrl' - The location of the license key required to decrypt your HLS playlist.
-- The URL must be an absolute path, and is referenced in the URI attribute
-- of the EXT-X-KEY metadata tag in the playlist file.
--
-- 'method', 'hlsContentProtection_method' - The content protection method for your output. The only valid value is:
-- @aes-128@.
--
-- This value is written into the method attribute of the @EXT-X-KEY@
-- metadata tag in the output playlist.
newHlsContentProtection ::
  HlsContentProtection
newHlsContentProtection :: HlsContentProtection
newHlsContentProtection =
  HlsContentProtection'
    { $sel:initializationVector:HlsContentProtection' :: Maybe Text
initializationVector =
        forall a. Maybe a
Prelude.Nothing,
      $sel:key:HlsContentProtection' :: Maybe Text
key = forall a. Maybe a
Prelude.Nothing,
      $sel:keyMd5:HlsContentProtection' :: Maybe Text
keyMd5 = forall a. Maybe a
Prelude.Nothing,
      $sel:keyStoragePolicy:HlsContentProtection' :: Maybe Text
keyStoragePolicy = forall a. Maybe a
Prelude.Nothing,
      $sel:licenseAcquisitionUrl:HlsContentProtection' :: Maybe Text
licenseAcquisitionUrl = forall a. Maybe a
Prelude.Nothing,
      $sel:method:HlsContentProtection' :: Maybe Text
method = forall a. Maybe a
Prelude.Nothing
    }

-- | If Elastic Transcoder is generating your key for you, you must leave
-- this field blank.
--
-- The series of random bits created by a random bit generator, unique for
-- every encryption operation, that you want Elastic Transcoder to use to
-- encrypt your output files. The initialization vector must be
-- base64-encoded, and it must be exactly 16 bytes before being
-- base64-encoded.
hlsContentProtection_initializationVector :: Lens.Lens' HlsContentProtection (Prelude.Maybe Prelude.Text)
hlsContentProtection_initializationVector :: Lens' HlsContentProtection (Maybe Text)
hlsContentProtection_initializationVector = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsContentProtection' {Maybe Text
initializationVector :: Maybe Text
$sel:initializationVector:HlsContentProtection' :: HlsContentProtection -> Maybe Text
initializationVector} -> Maybe Text
initializationVector) (\s :: HlsContentProtection
s@HlsContentProtection' {} Maybe Text
a -> HlsContentProtection
s {$sel:initializationVector:HlsContentProtection' :: Maybe Text
initializationVector = Maybe Text
a} :: HlsContentProtection)

-- | If you want Elastic Transcoder to generate a key for you, leave this
-- field blank.
--
-- If you choose to supply your own key, you must encrypt the key by using
-- AWS KMS. The key must be base64-encoded, and it must be one of the
-- following bit lengths before being base64-encoded:
--
-- @128@, @192@, or @256@.
hlsContentProtection_key :: Lens.Lens' HlsContentProtection (Prelude.Maybe Prelude.Text)
hlsContentProtection_key :: Lens' HlsContentProtection (Maybe Text)
hlsContentProtection_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsContentProtection' {Maybe Text
key :: Maybe Text
$sel:key:HlsContentProtection' :: HlsContentProtection -> Maybe Text
key} -> Maybe Text
key) (\s :: HlsContentProtection
s@HlsContentProtection' {} Maybe Text
a -> HlsContentProtection
s {$sel:key:HlsContentProtection' :: Maybe Text
key = Maybe Text
a} :: HlsContentProtection)

-- | If Elastic Transcoder is generating your key for you, you must leave
-- this field blank.
--
-- The MD5 digest of the key that you want Elastic Transcoder to use to
-- encrypt your output file, and that you want Elastic Transcoder to use as
-- a checksum to make sure your key was not corrupted in transit. The key
-- MD5 must be base64-encoded, and it must be exactly 16 bytes before being
-- base64- encoded.
hlsContentProtection_keyMd5 :: Lens.Lens' HlsContentProtection (Prelude.Maybe Prelude.Text)
hlsContentProtection_keyMd5 :: Lens' HlsContentProtection (Maybe Text)
hlsContentProtection_keyMd5 = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsContentProtection' {Maybe Text
keyMd5 :: Maybe Text
$sel:keyMd5:HlsContentProtection' :: HlsContentProtection -> Maybe Text
keyMd5} -> Maybe Text
keyMd5) (\s :: HlsContentProtection
s@HlsContentProtection' {} Maybe Text
a -> HlsContentProtection
s {$sel:keyMd5:HlsContentProtection' :: Maybe Text
keyMd5 = Maybe Text
a} :: HlsContentProtection)

-- | Specify whether you want Elastic Transcoder to write your HLS license
-- key to an Amazon S3 bucket. If you choose @WithVariantPlaylists@,
-- @LicenseAcquisitionUrl@ must be left blank and Elastic Transcoder writes
-- your data key into the same bucket as the associated playlist.
hlsContentProtection_keyStoragePolicy :: Lens.Lens' HlsContentProtection (Prelude.Maybe Prelude.Text)
hlsContentProtection_keyStoragePolicy :: Lens' HlsContentProtection (Maybe Text)
hlsContentProtection_keyStoragePolicy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsContentProtection' {Maybe Text
keyStoragePolicy :: Maybe Text
$sel:keyStoragePolicy:HlsContentProtection' :: HlsContentProtection -> Maybe Text
keyStoragePolicy} -> Maybe Text
keyStoragePolicy) (\s :: HlsContentProtection
s@HlsContentProtection' {} Maybe Text
a -> HlsContentProtection
s {$sel:keyStoragePolicy:HlsContentProtection' :: Maybe Text
keyStoragePolicy = Maybe Text
a} :: HlsContentProtection)

-- | The location of the license key required to decrypt your HLS playlist.
-- The URL must be an absolute path, and is referenced in the URI attribute
-- of the EXT-X-KEY metadata tag in the playlist file.
hlsContentProtection_licenseAcquisitionUrl :: Lens.Lens' HlsContentProtection (Prelude.Maybe Prelude.Text)
hlsContentProtection_licenseAcquisitionUrl :: Lens' HlsContentProtection (Maybe Text)
hlsContentProtection_licenseAcquisitionUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsContentProtection' {Maybe Text
licenseAcquisitionUrl :: Maybe Text
$sel:licenseAcquisitionUrl:HlsContentProtection' :: HlsContentProtection -> Maybe Text
licenseAcquisitionUrl} -> Maybe Text
licenseAcquisitionUrl) (\s :: HlsContentProtection
s@HlsContentProtection' {} Maybe Text
a -> HlsContentProtection
s {$sel:licenseAcquisitionUrl:HlsContentProtection' :: Maybe Text
licenseAcquisitionUrl = Maybe Text
a} :: HlsContentProtection)

-- | The content protection method for your output. The only valid value is:
-- @aes-128@.
--
-- This value is written into the method attribute of the @EXT-X-KEY@
-- metadata tag in the output playlist.
hlsContentProtection_method :: Lens.Lens' HlsContentProtection (Prelude.Maybe Prelude.Text)
hlsContentProtection_method :: Lens' HlsContentProtection (Maybe Text)
hlsContentProtection_method = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HlsContentProtection' {Maybe Text
method :: Maybe Text
$sel:method:HlsContentProtection' :: HlsContentProtection -> Maybe Text
method} -> Maybe Text
method) (\s :: HlsContentProtection
s@HlsContentProtection' {} Maybe Text
a -> HlsContentProtection
s {$sel:method:HlsContentProtection' :: Maybe Text
method = Maybe Text
a} :: HlsContentProtection)

instance Data.FromJSON HlsContentProtection where
  parseJSON :: Value -> Parser HlsContentProtection
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"HlsContentProtection"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> HlsContentProtection
HlsContentProtection'
            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
"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
"Key")
            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
"KeyMd5")
            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
"KeyStoragePolicy")
            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
"LicenseAcquisitionUrl")
            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
"Method")
      )

instance Prelude.Hashable HlsContentProtection where
  hashWithSalt :: Int -> HlsContentProtection -> Int
hashWithSalt Int
_salt HlsContentProtection' {Maybe Text
method :: Maybe Text
licenseAcquisitionUrl :: Maybe Text
keyStoragePolicy :: Maybe Text
keyMd5 :: Maybe Text
key :: Maybe Text
initializationVector :: Maybe Text
$sel:method:HlsContentProtection' :: HlsContentProtection -> Maybe Text
$sel:licenseAcquisitionUrl:HlsContentProtection' :: HlsContentProtection -> Maybe Text
$sel:keyStoragePolicy:HlsContentProtection' :: HlsContentProtection -> Maybe Text
$sel:keyMd5:HlsContentProtection' :: HlsContentProtection -> Maybe Text
$sel:key:HlsContentProtection' :: HlsContentProtection -> Maybe Text
$sel:initializationVector:HlsContentProtection' :: HlsContentProtection -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
initializationVector
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
key
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
keyMd5
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
keyStoragePolicy
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
licenseAcquisitionUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
method

instance Prelude.NFData HlsContentProtection where
  rnf :: HlsContentProtection -> ()
rnf HlsContentProtection' {Maybe Text
method :: Maybe Text
licenseAcquisitionUrl :: Maybe Text
keyStoragePolicy :: Maybe Text
keyMd5 :: Maybe Text
key :: Maybe Text
initializationVector :: Maybe Text
$sel:method:HlsContentProtection' :: HlsContentProtection -> Maybe Text
$sel:licenseAcquisitionUrl:HlsContentProtection' :: HlsContentProtection -> Maybe Text
$sel:keyStoragePolicy:HlsContentProtection' :: HlsContentProtection -> Maybe Text
$sel:keyMd5:HlsContentProtection' :: HlsContentProtection -> Maybe Text
$sel:key:HlsContentProtection' :: HlsContentProtection -> Maybe Text
$sel:initializationVector:HlsContentProtection' :: HlsContentProtection -> Maybe Text
..} =
    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
key
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
keyMd5
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
keyStoragePolicy
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
licenseAcquisitionUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
method

instance Data.ToJSON HlsContentProtection where
  toJSON :: HlsContentProtection -> Value
toJSON HlsContentProtection' {Maybe Text
method :: Maybe Text
licenseAcquisitionUrl :: Maybe Text
keyStoragePolicy :: Maybe Text
keyMd5 :: Maybe Text
key :: Maybe Text
initializationVector :: Maybe Text
$sel:method:HlsContentProtection' :: HlsContentProtection -> Maybe Text
$sel:licenseAcquisitionUrl:HlsContentProtection' :: HlsContentProtection -> Maybe Text
$sel:keyStoragePolicy:HlsContentProtection' :: HlsContentProtection -> Maybe Text
$sel:keyMd5:HlsContentProtection' :: HlsContentProtection -> Maybe Text
$sel:key:HlsContentProtection' :: HlsContentProtection -> Maybe Text
$sel:initializationVector:HlsContentProtection' :: HlsContentProtection -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (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
"Key" 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
key,
            (Key
"KeyMd5" 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
keyMd5,
            (Key
"KeyStoragePolicy" 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
keyStoragePolicy,
            (Key
"LicenseAcquisitionUrl" 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
licenseAcquisitionUrl,
            (Key
"Method" 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
method
          ]
      )