{-# 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.MediaPackage.Types.EncryptionContractConfiguration
-- 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.MediaPackage.Types.EncryptionContractConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MediaPackage.Types.PresetSpeke20Audio
import Amazonka.MediaPackage.Types.PresetSpeke20Video
import qualified Amazonka.Prelude as Prelude

-- | Use encryptionContractConfiguration to configure one or more content
-- encryption keys for your endpoints that use SPEKE 2.0. The encryption
-- contract defines which content keys are used to encrypt the audio and
-- video tracks in your stream. To configure the encryption contract,
-- specify which audio and video encryption presets to use. Note the
-- following considerations when using encryptionContractConfiguration:
-- encryptionContractConfiguration can be used for DASH or CMAF endpoints
-- that use SPEKE 2.0. SPEKE 2.0 relies on the CPIX 2.3 specification. You
-- must disable key rotation for this endpoint by setting
-- keyRotationIntervalSeconds to 0.
--
-- /See:/ 'newEncryptionContractConfiguration' smart constructor.
data EncryptionContractConfiguration = EncryptionContractConfiguration'
  { -- | A collection of audio encryption presets.
    EncryptionContractConfiguration -> PresetSpeke20Audio
presetSpeke20Audio :: PresetSpeke20Audio,
    -- | A collection of video encryption presets.
    EncryptionContractConfiguration -> PresetSpeke20Video
presetSpeke20Video :: PresetSpeke20Video
  }
  deriving (EncryptionContractConfiguration
-> EncryptionContractConfiguration -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EncryptionContractConfiguration
-> EncryptionContractConfiguration -> Bool
$c/= :: EncryptionContractConfiguration
-> EncryptionContractConfiguration -> Bool
== :: EncryptionContractConfiguration
-> EncryptionContractConfiguration -> Bool
$c== :: EncryptionContractConfiguration
-> EncryptionContractConfiguration -> Bool
Prelude.Eq, ReadPrec [EncryptionContractConfiguration]
ReadPrec EncryptionContractConfiguration
Int -> ReadS EncryptionContractConfiguration
ReadS [EncryptionContractConfiguration]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EncryptionContractConfiguration]
$creadListPrec :: ReadPrec [EncryptionContractConfiguration]
readPrec :: ReadPrec EncryptionContractConfiguration
$creadPrec :: ReadPrec EncryptionContractConfiguration
readList :: ReadS [EncryptionContractConfiguration]
$creadList :: ReadS [EncryptionContractConfiguration]
readsPrec :: Int -> ReadS EncryptionContractConfiguration
$creadsPrec :: Int -> ReadS EncryptionContractConfiguration
Prelude.Read, Int -> EncryptionContractConfiguration -> ShowS
[EncryptionContractConfiguration] -> ShowS
EncryptionContractConfiguration -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EncryptionContractConfiguration] -> ShowS
$cshowList :: [EncryptionContractConfiguration] -> ShowS
show :: EncryptionContractConfiguration -> String
$cshow :: EncryptionContractConfiguration -> String
showsPrec :: Int -> EncryptionContractConfiguration -> ShowS
$cshowsPrec :: Int -> EncryptionContractConfiguration -> ShowS
Prelude.Show, forall x.
Rep EncryptionContractConfiguration x
-> EncryptionContractConfiguration
forall x.
EncryptionContractConfiguration
-> Rep EncryptionContractConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep EncryptionContractConfiguration x
-> EncryptionContractConfiguration
$cfrom :: forall x.
EncryptionContractConfiguration
-> Rep EncryptionContractConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'EncryptionContractConfiguration' 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:
--
-- 'presetSpeke20Audio', 'encryptionContractConfiguration_presetSpeke20Audio' - A collection of audio encryption presets.
--
-- 'presetSpeke20Video', 'encryptionContractConfiguration_presetSpeke20Video' - A collection of video encryption presets.
newEncryptionContractConfiguration ::
  -- | 'presetSpeke20Audio'
  PresetSpeke20Audio ->
  -- | 'presetSpeke20Video'
  PresetSpeke20Video ->
  EncryptionContractConfiguration
newEncryptionContractConfiguration :: PresetSpeke20Audio
-> PresetSpeke20Video -> EncryptionContractConfiguration
newEncryptionContractConfiguration
  PresetSpeke20Audio
pPresetSpeke20Audio_
  PresetSpeke20Video
pPresetSpeke20Video_ =
    EncryptionContractConfiguration'
      { $sel:presetSpeke20Audio:EncryptionContractConfiguration' :: PresetSpeke20Audio
presetSpeke20Audio =
          PresetSpeke20Audio
pPresetSpeke20Audio_,
        $sel:presetSpeke20Video:EncryptionContractConfiguration' :: PresetSpeke20Video
presetSpeke20Video = PresetSpeke20Video
pPresetSpeke20Video_
      }

-- | A collection of audio encryption presets.
encryptionContractConfiguration_presetSpeke20Audio :: Lens.Lens' EncryptionContractConfiguration PresetSpeke20Audio
encryptionContractConfiguration_presetSpeke20Audio :: Lens' EncryptionContractConfiguration PresetSpeke20Audio
encryptionContractConfiguration_presetSpeke20Audio = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionContractConfiguration' {PresetSpeke20Audio
presetSpeke20Audio :: PresetSpeke20Audio
$sel:presetSpeke20Audio:EncryptionContractConfiguration' :: EncryptionContractConfiguration -> PresetSpeke20Audio
presetSpeke20Audio} -> PresetSpeke20Audio
presetSpeke20Audio) (\s :: EncryptionContractConfiguration
s@EncryptionContractConfiguration' {} PresetSpeke20Audio
a -> EncryptionContractConfiguration
s {$sel:presetSpeke20Audio:EncryptionContractConfiguration' :: PresetSpeke20Audio
presetSpeke20Audio = PresetSpeke20Audio
a} :: EncryptionContractConfiguration)

-- | A collection of video encryption presets.
encryptionContractConfiguration_presetSpeke20Video :: Lens.Lens' EncryptionContractConfiguration PresetSpeke20Video
encryptionContractConfiguration_presetSpeke20Video :: Lens' EncryptionContractConfiguration PresetSpeke20Video
encryptionContractConfiguration_presetSpeke20Video = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EncryptionContractConfiguration' {PresetSpeke20Video
presetSpeke20Video :: PresetSpeke20Video
$sel:presetSpeke20Video:EncryptionContractConfiguration' :: EncryptionContractConfiguration -> PresetSpeke20Video
presetSpeke20Video} -> PresetSpeke20Video
presetSpeke20Video) (\s :: EncryptionContractConfiguration
s@EncryptionContractConfiguration' {} PresetSpeke20Video
a -> EncryptionContractConfiguration
s {$sel:presetSpeke20Video:EncryptionContractConfiguration' :: PresetSpeke20Video
presetSpeke20Video = PresetSpeke20Video
a} :: EncryptionContractConfiguration)

instance
  Data.FromJSON
    EncryptionContractConfiguration
  where
  parseJSON :: Value -> Parser EncryptionContractConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EncryptionContractConfiguration"
      ( \Object
x ->
          PresetSpeke20Audio
-> PresetSpeke20Video -> EncryptionContractConfiguration
EncryptionContractConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"presetSpeke20Audio")
            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
"presetSpeke20Video")
      )

instance
  Prelude.Hashable
    EncryptionContractConfiguration
  where
  hashWithSalt :: Int -> EncryptionContractConfiguration -> Int
hashWithSalt
    Int
_salt
    EncryptionContractConfiguration' {PresetSpeke20Audio
PresetSpeke20Video
presetSpeke20Video :: PresetSpeke20Video
presetSpeke20Audio :: PresetSpeke20Audio
$sel:presetSpeke20Video:EncryptionContractConfiguration' :: EncryptionContractConfiguration -> PresetSpeke20Video
$sel:presetSpeke20Audio:EncryptionContractConfiguration' :: EncryptionContractConfiguration -> PresetSpeke20Audio
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` PresetSpeke20Audio
presetSpeke20Audio
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` PresetSpeke20Video
presetSpeke20Video

instance
  Prelude.NFData
    EncryptionContractConfiguration
  where
  rnf :: EncryptionContractConfiguration -> ()
rnf EncryptionContractConfiguration' {PresetSpeke20Audio
PresetSpeke20Video
presetSpeke20Video :: PresetSpeke20Video
presetSpeke20Audio :: PresetSpeke20Audio
$sel:presetSpeke20Video:EncryptionContractConfiguration' :: EncryptionContractConfiguration -> PresetSpeke20Video
$sel:presetSpeke20Audio:EncryptionContractConfiguration' :: EncryptionContractConfiguration -> PresetSpeke20Audio
..} =
    forall a. NFData a => a -> ()
Prelude.rnf PresetSpeke20Audio
presetSpeke20Audio
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf PresetSpeke20Video
presetSpeke20Video

instance Data.ToJSON EncryptionContractConfiguration where
  toJSON :: EncryptionContractConfiguration -> Value
toJSON EncryptionContractConfiguration' {PresetSpeke20Audio
PresetSpeke20Video
presetSpeke20Video :: PresetSpeke20Video
presetSpeke20Audio :: PresetSpeke20Audio
$sel:presetSpeke20Video:EncryptionContractConfiguration' :: EncryptionContractConfiguration -> PresetSpeke20Video
$sel:presetSpeke20Audio:EncryptionContractConfiguration' :: EncryptionContractConfiguration -> PresetSpeke20Audio
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"presetSpeke20Audio" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= PresetSpeke20Audio
presetSpeke20Audio),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"presetSpeke20Video" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= PresetSpeke20Video
presetSpeke20Video)
          ]
      )