{-# 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.MediaConvert.Types.MsSmoothEncryptionSettings
-- 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.MediaConvert.Types.MsSmoothEncryptionSettings where

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

-- | If you are using DRM, set DRM System (MsSmoothEncryptionSettings) to
-- specify the value SpekeKeyProvider.
--
-- /See:/ 'newMsSmoothEncryptionSettings' smart constructor.
data MsSmoothEncryptionSettings = MsSmoothEncryptionSettings'
  { -- | If your output group type is HLS, DASH, or Microsoft Smooth, use these
    -- settings when doing DRM encryption with a SPEKE-compliant key provider.
    -- If your output group type is CMAF, use the SpekeKeyProviderCmaf settings
    -- instead.
    MsSmoothEncryptionSettings -> Maybe SpekeKeyProvider
spekeKeyProvider :: Prelude.Maybe SpekeKeyProvider
  }
  deriving (MsSmoothEncryptionSettings -> MsSmoothEncryptionSettings -> Bool
(MsSmoothEncryptionSettings -> MsSmoothEncryptionSettings -> Bool)
-> (MsSmoothEncryptionSettings
    -> MsSmoothEncryptionSettings -> Bool)
-> Eq MsSmoothEncryptionSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MsSmoothEncryptionSettings -> MsSmoothEncryptionSettings -> Bool
$c/= :: MsSmoothEncryptionSettings -> MsSmoothEncryptionSettings -> Bool
== :: MsSmoothEncryptionSettings -> MsSmoothEncryptionSettings -> Bool
$c== :: MsSmoothEncryptionSettings -> MsSmoothEncryptionSettings -> Bool
Prelude.Eq, ReadPrec [MsSmoothEncryptionSettings]
ReadPrec MsSmoothEncryptionSettings
Int -> ReadS MsSmoothEncryptionSettings
ReadS [MsSmoothEncryptionSettings]
(Int -> ReadS MsSmoothEncryptionSettings)
-> ReadS [MsSmoothEncryptionSettings]
-> ReadPrec MsSmoothEncryptionSettings
-> ReadPrec [MsSmoothEncryptionSettings]
-> Read MsSmoothEncryptionSettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MsSmoothEncryptionSettings]
$creadListPrec :: ReadPrec [MsSmoothEncryptionSettings]
readPrec :: ReadPrec MsSmoothEncryptionSettings
$creadPrec :: ReadPrec MsSmoothEncryptionSettings
readList :: ReadS [MsSmoothEncryptionSettings]
$creadList :: ReadS [MsSmoothEncryptionSettings]
readsPrec :: Int -> ReadS MsSmoothEncryptionSettings
$creadsPrec :: Int -> ReadS MsSmoothEncryptionSettings
Prelude.Read, Int -> MsSmoothEncryptionSettings -> ShowS
[MsSmoothEncryptionSettings] -> ShowS
MsSmoothEncryptionSettings -> String
(Int -> MsSmoothEncryptionSettings -> ShowS)
-> (MsSmoothEncryptionSettings -> String)
-> ([MsSmoothEncryptionSettings] -> ShowS)
-> Show MsSmoothEncryptionSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MsSmoothEncryptionSettings] -> ShowS
$cshowList :: [MsSmoothEncryptionSettings] -> ShowS
show :: MsSmoothEncryptionSettings -> String
$cshow :: MsSmoothEncryptionSettings -> String
showsPrec :: Int -> MsSmoothEncryptionSettings -> ShowS
$cshowsPrec :: Int -> MsSmoothEncryptionSettings -> ShowS
Prelude.Show, (forall x.
 MsSmoothEncryptionSettings -> Rep MsSmoothEncryptionSettings x)
-> (forall x.
    Rep MsSmoothEncryptionSettings x -> MsSmoothEncryptionSettings)
-> Generic MsSmoothEncryptionSettings
forall x.
Rep MsSmoothEncryptionSettings x -> MsSmoothEncryptionSettings
forall x.
MsSmoothEncryptionSettings -> Rep MsSmoothEncryptionSettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep MsSmoothEncryptionSettings x -> MsSmoothEncryptionSettings
$cfrom :: forall x.
MsSmoothEncryptionSettings -> Rep MsSmoothEncryptionSettings x
Prelude.Generic)

-- |
-- Create a value of 'MsSmoothEncryptionSettings' 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:
--
-- 'spekeKeyProvider', 'msSmoothEncryptionSettings_spekeKeyProvider' - If your output group type is HLS, DASH, or Microsoft Smooth, use these
-- settings when doing DRM encryption with a SPEKE-compliant key provider.
-- If your output group type is CMAF, use the SpekeKeyProviderCmaf settings
-- instead.
newMsSmoothEncryptionSettings ::
  MsSmoothEncryptionSettings
newMsSmoothEncryptionSettings :: MsSmoothEncryptionSettings
newMsSmoothEncryptionSettings =
  MsSmoothEncryptionSettings' :: Maybe SpekeKeyProvider -> MsSmoothEncryptionSettings
MsSmoothEncryptionSettings'
    { $sel:spekeKeyProvider:MsSmoothEncryptionSettings' :: Maybe SpekeKeyProvider
spekeKeyProvider =
        Maybe SpekeKeyProvider
forall a. Maybe a
Prelude.Nothing
    }

-- | If your output group type is HLS, DASH, or Microsoft Smooth, use these
-- settings when doing DRM encryption with a SPEKE-compliant key provider.
-- If your output group type is CMAF, use the SpekeKeyProviderCmaf settings
-- instead.
msSmoothEncryptionSettings_spekeKeyProvider :: Lens.Lens' MsSmoothEncryptionSettings (Prelude.Maybe SpekeKeyProvider)
msSmoothEncryptionSettings_spekeKeyProvider :: (Maybe SpekeKeyProvider -> f (Maybe SpekeKeyProvider))
-> MsSmoothEncryptionSettings -> f MsSmoothEncryptionSettings
msSmoothEncryptionSettings_spekeKeyProvider = (MsSmoothEncryptionSettings -> Maybe SpekeKeyProvider)
-> (MsSmoothEncryptionSettings
    -> Maybe SpekeKeyProvider -> MsSmoothEncryptionSettings)
-> Lens
     MsSmoothEncryptionSettings
     MsSmoothEncryptionSettings
     (Maybe SpekeKeyProvider)
     (Maybe SpekeKeyProvider)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MsSmoothEncryptionSettings' {Maybe SpekeKeyProvider
spekeKeyProvider :: Maybe SpekeKeyProvider
$sel:spekeKeyProvider:MsSmoothEncryptionSettings' :: MsSmoothEncryptionSettings -> Maybe SpekeKeyProvider
spekeKeyProvider} -> Maybe SpekeKeyProvider
spekeKeyProvider) (\s :: MsSmoothEncryptionSettings
s@MsSmoothEncryptionSettings' {} Maybe SpekeKeyProvider
a -> MsSmoothEncryptionSettings
s {$sel:spekeKeyProvider:MsSmoothEncryptionSettings' :: Maybe SpekeKeyProvider
spekeKeyProvider = Maybe SpekeKeyProvider
a} :: MsSmoothEncryptionSettings)

instance Core.FromJSON MsSmoothEncryptionSettings where
  parseJSON :: Value -> Parser MsSmoothEncryptionSettings
parseJSON =
    String
-> (Object -> Parser MsSmoothEncryptionSettings)
-> Value
-> Parser MsSmoothEncryptionSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MsSmoothEncryptionSettings"
      ( \Object
x ->
          Maybe SpekeKeyProvider -> MsSmoothEncryptionSettings
MsSmoothEncryptionSettings'
            (Maybe SpekeKeyProvider -> MsSmoothEncryptionSettings)
-> Parser (Maybe SpekeKeyProvider)
-> Parser MsSmoothEncryptionSettings
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe SpekeKeyProvider)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"spekeKeyProvider")
      )

instance Prelude.Hashable MsSmoothEncryptionSettings

instance Prelude.NFData MsSmoothEncryptionSettings

instance Core.ToJSON MsSmoothEncryptionSettings where
  toJSON :: MsSmoothEncryptionSettings -> Value
toJSON MsSmoothEncryptionSettings' {Maybe SpekeKeyProvider
spekeKeyProvider :: Maybe SpekeKeyProvider
$sel:spekeKeyProvider:MsSmoothEncryptionSettings' :: MsSmoothEncryptionSettings -> Maybe SpekeKeyProvider
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"spekeKeyProvider" Text -> SpekeKeyProvider -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (SpekeKeyProvider -> Pair) -> Maybe SpekeKeyProvider -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SpekeKeyProvider
spekeKeyProvider
          ]
      )