{-# 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.PlayReadyDrm
-- 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.PlayReadyDrm 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 PlayReady DRM settings, if any, that you want Elastic Transcoder to
-- apply to the output files associated with this playlist.
--
-- PlayReady DRM encrypts your media files using @aes-ctr@ encryption.
--
-- If you use DRM for an @HLSv3@ playlist, your outputs must have a master
-- playlist.
--
-- /See:/ 'newPlayReadyDrm' smart constructor.
data PlayReadyDrm = PlayReadyDrm'
  { -- | The type of DRM, if any, that you want Elastic Transcoder to apply to
    -- the output files associated with this playlist.
    PlayReadyDrm -> Maybe Text
format :: Prelude.Maybe Prelude.Text,
    -- | 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 files. The initialization vector must be base64-encoded,
    -- and it must be exactly 8 bytes long before being base64-encoded. If no
    -- initialization vector is provided, Elastic Transcoder generates one for
    -- you.
    PlayReadyDrm -> Maybe Text
initializationVector :: Prelude.Maybe Prelude.Text,
    -- | The DRM key for your file, provided by your DRM license provider. The
    -- key must be base64-encoded, and it must be one of the following bit
    -- lengths before being base64-encoded:
    --
    -- @128@, @192@, or @256@.
    --
    -- The key must also be encrypted by using AWS KMS.
    PlayReadyDrm -> Maybe Text
key :: Prelude.Maybe Prelude.Text,
    -- | The ID for your DRM key, so that your DRM license provider knows which
    -- key to provide.
    --
    -- The key ID must be provided in big endian, and Elastic Transcoder
    -- converts it to little endian before inserting it into the PlayReady DRM
    -- headers. If you are unsure whether your license server provides your key
    -- ID in big or little endian, check with your DRM provider.
    PlayReadyDrm -> Maybe Text
keyId :: Prelude.Maybe Prelude.Text,
    -- | The MD5 digest of the key used for DRM on your 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.
    PlayReadyDrm -> Maybe Text
keyMd5 :: Prelude.Maybe Prelude.Text,
    -- | The location of the license key required to play DRM content. The URL
    -- must be an absolute path, and is referenced by the PlayReady header. The
    -- PlayReady header is referenced in the protection header of the client
    -- manifest for Smooth Streaming outputs, and in the EXT-X-DXDRM and
    -- EXT-XDXDRMINFO metadata tags for HLS playlist outputs. An example URL
    -- looks like this: @https:\/\/www.example.com\/exampleKey\/@
    PlayReadyDrm -> Maybe Text
licenseAcquisitionUrl :: Prelude.Maybe Prelude.Text
  }
  deriving (PlayReadyDrm -> PlayReadyDrm -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PlayReadyDrm -> PlayReadyDrm -> Bool
$c/= :: PlayReadyDrm -> PlayReadyDrm -> Bool
== :: PlayReadyDrm -> PlayReadyDrm -> Bool
$c== :: PlayReadyDrm -> PlayReadyDrm -> Bool
Prelude.Eq, ReadPrec [PlayReadyDrm]
ReadPrec PlayReadyDrm
Int -> ReadS PlayReadyDrm
ReadS [PlayReadyDrm]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PlayReadyDrm]
$creadListPrec :: ReadPrec [PlayReadyDrm]
readPrec :: ReadPrec PlayReadyDrm
$creadPrec :: ReadPrec PlayReadyDrm
readList :: ReadS [PlayReadyDrm]
$creadList :: ReadS [PlayReadyDrm]
readsPrec :: Int -> ReadS PlayReadyDrm
$creadsPrec :: Int -> ReadS PlayReadyDrm
Prelude.Read, Int -> PlayReadyDrm -> ShowS
[PlayReadyDrm] -> ShowS
PlayReadyDrm -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PlayReadyDrm] -> ShowS
$cshowList :: [PlayReadyDrm] -> ShowS
show :: PlayReadyDrm -> String
$cshow :: PlayReadyDrm -> String
showsPrec :: Int -> PlayReadyDrm -> ShowS
$cshowsPrec :: Int -> PlayReadyDrm -> ShowS
Prelude.Show, forall x. Rep PlayReadyDrm x -> PlayReadyDrm
forall x. PlayReadyDrm -> Rep PlayReadyDrm x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PlayReadyDrm x -> PlayReadyDrm
$cfrom :: forall x. PlayReadyDrm -> Rep PlayReadyDrm x
Prelude.Generic)

-- |
-- Create a value of 'PlayReadyDrm' 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:
--
-- 'format', 'playReadyDrm_format' - The type of DRM, if any, that you want Elastic Transcoder to apply to
-- the output files associated with this playlist.
--
-- 'initializationVector', 'playReadyDrm_initializationVector' - 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 files. The initialization vector must be base64-encoded,
-- and it must be exactly 8 bytes long before being base64-encoded. If no
-- initialization vector is provided, Elastic Transcoder generates one for
-- you.
--
-- 'key', 'playReadyDrm_key' - The DRM key for your file, provided by your DRM license provider. The
-- key must be base64-encoded, and it must be one of the following bit
-- lengths before being base64-encoded:
--
-- @128@, @192@, or @256@.
--
-- The key must also be encrypted by using AWS KMS.
--
-- 'keyId', 'playReadyDrm_keyId' - The ID for your DRM key, so that your DRM license provider knows which
-- key to provide.
--
-- The key ID must be provided in big endian, and Elastic Transcoder
-- converts it to little endian before inserting it into the PlayReady DRM
-- headers. If you are unsure whether your license server provides your key
-- ID in big or little endian, check with your DRM provider.
--
-- 'keyMd5', 'playReadyDrm_keyMd5' - The MD5 digest of the key used for DRM on your 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.
--
-- 'licenseAcquisitionUrl', 'playReadyDrm_licenseAcquisitionUrl' - The location of the license key required to play DRM content. The URL
-- must be an absolute path, and is referenced by the PlayReady header. The
-- PlayReady header is referenced in the protection header of the client
-- manifest for Smooth Streaming outputs, and in the EXT-X-DXDRM and
-- EXT-XDXDRMINFO metadata tags for HLS playlist outputs. An example URL
-- looks like this: @https:\/\/www.example.com\/exampleKey\/@
newPlayReadyDrm ::
  PlayReadyDrm
newPlayReadyDrm :: PlayReadyDrm
newPlayReadyDrm =
  PlayReadyDrm'
    { $sel:format:PlayReadyDrm' :: Maybe Text
format = forall a. Maybe a
Prelude.Nothing,
      $sel:initializationVector:PlayReadyDrm' :: Maybe Text
initializationVector = forall a. Maybe a
Prelude.Nothing,
      $sel:key:PlayReadyDrm' :: Maybe Text
key = forall a. Maybe a
Prelude.Nothing,
      $sel:keyId:PlayReadyDrm' :: Maybe Text
keyId = forall a. Maybe a
Prelude.Nothing,
      $sel:keyMd5:PlayReadyDrm' :: Maybe Text
keyMd5 = forall a. Maybe a
Prelude.Nothing,
      $sel:licenseAcquisitionUrl:PlayReadyDrm' :: Maybe Text
licenseAcquisitionUrl = forall a. Maybe a
Prelude.Nothing
    }

-- | The type of DRM, if any, that you want Elastic Transcoder to apply to
-- the output files associated with this playlist.
playReadyDrm_format :: Lens.Lens' PlayReadyDrm (Prelude.Maybe Prelude.Text)
playReadyDrm_format :: Lens' PlayReadyDrm (Maybe Text)
playReadyDrm_format = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlayReadyDrm' {Maybe Text
format :: Maybe Text
$sel:format:PlayReadyDrm' :: PlayReadyDrm -> Maybe Text
format} -> Maybe Text
format) (\s :: PlayReadyDrm
s@PlayReadyDrm' {} Maybe Text
a -> PlayReadyDrm
s {$sel:format:PlayReadyDrm' :: Maybe Text
format = Maybe Text
a} :: PlayReadyDrm)

-- | 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 files. The initialization vector must be base64-encoded,
-- and it must be exactly 8 bytes long before being base64-encoded. If no
-- initialization vector is provided, Elastic Transcoder generates one for
-- you.
playReadyDrm_initializationVector :: Lens.Lens' PlayReadyDrm (Prelude.Maybe Prelude.Text)
playReadyDrm_initializationVector :: Lens' PlayReadyDrm (Maybe Text)
playReadyDrm_initializationVector = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlayReadyDrm' {Maybe Text
initializationVector :: Maybe Text
$sel:initializationVector:PlayReadyDrm' :: PlayReadyDrm -> Maybe Text
initializationVector} -> Maybe Text
initializationVector) (\s :: PlayReadyDrm
s@PlayReadyDrm' {} Maybe Text
a -> PlayReadyDrm
s {$sel:initializationVector:PlayReadyDrm' :: Maybe Text
initializationVector = Maybe Text
a} :: PlayReadyDrm)

-- | The DRM key for your file, provided by your DRM license provider. The
-- key must be base64-encoded, and it must be one of the following bit
-- lengths before being base64-encoded:
--
-- @128@, @192@, or @256@.
--
-- The key must also be encrypted by using AWS KMS.
playReadyDrm_key :: Lens.Lens' PlayReadyDrm (Prelude.Maybe Prelude.Text)
playReadyDrm_key :: Lens' PlayReadyDrm (Maybe Text)
playReadyDrm_key = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlayReadyDrm' {Maybe Text
key :: Maybe Text
$sel:key:PlayReadyDrm' :: PlayReadyDrm -> Maybe Text
key} -> Maybe Text
key) (\s :: PlayReadyDrm
s@PlayReadyDrm' {} Maybe Text
a -> PlayReadyDrm
s {$sel:key:PlayReadyDrm' :: Maybe Text
key = Maybe Text
a} :: PlayReadyDrm)

-- | The ID for your DRM key, so that your DRM license provider knows which
-- key to provide.
--
-- The key ID must be provided in big endian, and Elastic Transcoder
-- converts it to little endian before inserting it into the PlayReady DRM
-- headers. If you are unsure whether your license server provides your key
-- ID in big or little endian, check with your DRM provider.
playReadyDrm_keyId :: Lens.Lens' PlayReadyDrm (Prelude.Maybe Prelude.Text)
playReadyDrm_keyId :: Lens' PlayReadyDrm (Maybe Text)
playReadyDrm_keyId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlayReadyDrm' {Maybe Text
keyId :: Maybe Text
$sel:keyId:PlayReadyDrm' :: PlayReadyDrm -> Maybe Text
keyId} -> Maybe Text
keyId) (\s :: PlayReadyDrm
s@PlayReadyDrm' {} Maybe Text
a -> PlayReadyDrm
s {$sel:keyId:PlayReadyDrm' :: Maybe Text
keyId = Maybe Text
a} :: PlayReadyDrm)

-- | The MD5 digest of the key used for DRM on your 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.
playReadyDrm_keyMd5 :: Lens.Lens' PlayReadyDrm (Prelude.Maybe Prelude.Text)
playReadyDrm_keyMd5 :: Lens' PlayReadyDrm (Maybe Text)
playReadyDrm_keyMd5 = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlayReadyDrm' {Maybe Text
keyMd5 :: Maybe Text
$sel:keyMd5:PlayReadyDrm' :: PlayReadyDrm -> Maybe Text
keyMd5} -> Maybe Text
keyMd5) (\s :: PlayReadyDrm
s@PlayReadyDrm' {} Maybe Text
a -> PlayReadyDrm
s {$sel:keyMd5:PlayReadyDrm' :: Maybe Text
keyMd5 = Maybe Text
a} :: PlayReadyDrm)

-- | The location of the license key required to play DRM content. The URL
-- must be an absolute path, and is referenced by the PlayReady header. The
-- PlayReady header is referenced in the protection header of the client
-- manifest for Smooth Streaming outputs, and in the EXT-X-DXDRM and
-- EXT-XDXDRMINFO metadata tags for HLS playlist outputs. An example URL
-- looks like this: @https:\/\/www.example.com\/exampleKey\/@
playReadyDrm_licenseAcquisitionUrl :: Lens.Lens' PlayReadyDrm (Prelude.Maybe Prelude.Text)
playReadyDrm_licenseAcquisitionUrl :: Lens' PlayReadyDrm (Maybe Text)
playReadyDrm_licenseAcquisitionUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PlayReadyDrm' {Maybe Text
licenseAcquisitionUrl :: Maybe Text
$sel:licenseAcquisitionUrl:PlayReadyDrm' :: PlayReadyDrm -> Maybe Text
licenseAcquisitionUrl} -> Maybe Text
licenseAcquisitionUrl) (\s :: PlayReadyDrm
s@PlayReadyDrm' {} Maybe Text
a -> PlayReadyDrm
s {$sel:licenseAcquisitionUrl:PlayReadyDrm' :: Maybe Text
licenseAcquisitionUrl = Maybe Text
a} :: PlayReadyDrm)

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

instance Prelude.Hashable PlayReadyDrm where
  hashWithSalt :: Int -> PlayReadyDrm -> Int
hashWithSalt Int
_salt PlayReadyDrm' {Maybe Text
licenseAcquisitionUrl :: Maybe Text
keyMd5 :: Maybe Text
keyId :: Maybe Text
key :: Maybe Text
initializationVector :: Maybe Text
format :: Maybe Text
$sel:licenseAcquisitionUrl:PlayReadyDrm' :: PlayReadyDrm -> Maybe Text
$sel:keyMd5:PlayReadyDrm' :: PlayReadyDrm -> Maybe Text
$sel:keyId:PlayReadyDrm' :: PlayReadyDrm -> Maybe Text
$sel:key:PlayReadyDrm' :: PlayReadyDrm -> Maybe Text
$sel:initializationVector:PlayReadyDrm' :: PlayReadyDrm -> Maybe Text
$sel:format:PlayReadyDrm' :: PlayReadyDrm -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
format
      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
keyId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
keyMd5
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
licenseAcquisitionUrl

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

instance Data.ToJSON PlayReadyDrm where
  toJSON :: PlayReadyDrm -> Value
toJSON PlayReadyDrm' {Maybe Text
licenseAcquisitionUrl :: Maybe Text
keyMd5 :: Maybe Text
keyId :: Maybe Text
key :: Maybe Text
initializationVector :: Maybe Text
format :: Maybe Text
$sel:licenseAcquisitionUrl:PlayReadyDrm' :: PlayReadyDrm -> Maybe Text
$sel:keyMd5:PlayReadyDrm' :: PlayReadyDrm -> Maybe Text
$sel:keyId:PlayReadyDrm' :: PlayReadyDrm -> Maybe Text
$sel:key:PlayReadyDrm' :: PlayReadyDrm -> Maybe Text
$sel:initializationVector:PlayReadyDrm' :: PlayReadyDrm -> Maybe Text
$sel:format:PlayReadyDrm' :: PlayReadyDrm -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Format" 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
format,
            (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
"KeyId" 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
keyId,
            (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
"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
          ]
      )