{-# 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.SpekeKeyProvider
-- 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.SpekeKeyProvider where

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

-- | 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.
--
-- /See:/ 'newSpekeKeyProvider' smart constructor.
data SpekeKeyProvider = SpekeKeyProvider'
  { -- | Specify the resource ID that your SPEKE-compliant key provider uses to
    -- identify this content.
    SpekeKeyProvider -> Maybe Text
resourceId :: Prelude.Maybe Prelude.Text,
    -- | If you want your key provider to encrypt the content keys that it
    -- provides to MediaConvert, set up a certificate with a master key using
    -- AWS Certificate Manager. Specify the certificate\'s Amazon Resource Name
    -- (ARN) here.
    SpekeKeyProvider -> Maybe Text
certificateArn :: Prelude.Maybe Prelude.Text,
    -- | Specify the URL to the key server that your SPEKE-compliant DRM key
    -- provider uses to provide keys for encrypting your content.
    SpekeKeyProvider -> Maybe Text
url :: Prelude.Maybe Prelude.Text,
    -- | Relates to SPEKE implementation. DRM system identifiers. DASH output
    -- groups support a max of two system ids. Other group types support one
    -- system id. See https:\/\/dashif.org\/identifiers\/content_protection\/
    -- for more details.
    SpekeKeyProvider -> Maybe [Text]
systemIds :: Prelude.Maybe [Prelude.Text]
  }
  deriving (SpekeKeyProvider -> SpekeKeyProvider -> Bool
(SpekeKeyProvider -> SpekeKeyProvider -> Bool)
-> (SpekeKeyProvider -> SpekeKeyProvider -> Bool)
-> Eq SpekeKeyProvider
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SpekeKeyProvider -> SpekeKeyProvider -> Bool
$c/= :: SpekeKeyProvider -> SpekeKeyProvider -> Bool
== :: SpekeKeyProvider -> SpekeKeyProvider -> Bool
$c== :: SpekeKeyProvider -> SpekeKeyProvider -> Bool
Prelude.Eq, ReadPrec [SpekeKeyProvider]
ReadPrec SpekeKeyProvider
Int -> ReadS SpekeKeyProvider
ReadS [SpekeKeyProvider]
(Int -> ReadS SpekeKeyProvider)
-> ReadS [SpekeKeyProvider]
-> ReadPrec SpekeKeyProvider
-> ReadPrec [SpekeKeyProvider]
-> Read SpekeKeyProvider
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SpekeKeyProvider]
$creadListPrec :: ReadPrec [SpekeKeyProvider]
readPrec :: ReadPrec SpekeKeyProvider
$creadPrec :: ReadPrec SpekeKeyProvider
readList :: ReadS [SpekeKeyProvider]
$creadList :: ReadS [SpekeKeyProvider]
readsPrec :: Int -> ReadS SpekeKeyProvider
$creadsPrec :: Int -> ReadS SpekeKeyProvider
Prelude.Read, Int -> SpekeKeyProvider -> ShowS
[SpekeKeyProvider] -> ShowS
SpekeKeyProvider -> String
(Int -> SpekeKeyProvider -> ShowS)
-> (SpekeKeyProvider -> String)
-> ([SpekeKeyProvider] -> ShowS)
-> Show SpekeKeyProvider
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SpekeKeyProvider] -> ShowS
$cshowList :: [SpekeKeyProvider] -> ShowS
show :: SpekeKeyProvider -> String
$cshow :: SpekeKeyProvider -> String
showsPrec :: Int -> SpekeKeyProvider -> ShowS
$cshowsPrec :: Int -> SpekeKeyProvider -> ShowS
Prelude.Show, (forall x. SpekeKeyProvider -> Rep SpekeKeyProvider x)
-> (forall x. Rep SpekeKeyProvider x -> SpekeKeyProvider)
-> Generic SpekeKeyProvider
forall x. Rep SpekeKeyProvider x -> SpekeKeyProvider
forall x. SpekeKeyProvider -> Rep SpekeKeyProvider x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SpekeKeyProvider x -> SpekeKeyProvider
$cfrom :: forall x. SpekeKeyProvider -> Rep SpekeKeyProvider x
Prelude.Generic)

-- |
-- Create a value of 'SpekeKeyProvider' 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:
--
-- 'resourceId', 'spekeKeyProvider_resourceId' - Specify the resource ID that your SPEKE-compliant key provider uses to
-- identify this content.
--
-- 'certificateArn', 'spekeKeyProvider_certificateArn' - If you want your key provider to encrypt the content keys that it
-- provides to MediaConvert, set up a certificate with a master key using
-- AWS Certificate Manager. Specify the certificate\'s Amazon Resource Name
-- (ARN) here.
--
-- 'url', 'spekeKeyProvider_url' - Specify the URL to the key server that your SPEKE-compliant DRM key
-- provider uses to provide keys for encrypting your content.
--
-- 'systemIds', 'spekeKeyProvider_systemIds' - Relates to SPEKE implementation. DRM system identifiers. DASH output
-- groups support a max of two system ids. Other group types support one
-- system id. See https:\/\/dashif.org\/identifiers\/content_protection\/
-- for more details.
newSpekeKeyProvider ::
  SpekeKeyProvider
newSpekeKeyProvider :: SpekeKeyProvider
newSpekeKeyProvider =
  SpekeKeyProvider' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe [Text] -> SpekeKeyProvider
SpekeKeyProvider'
    { $sel:resourceId:SpekeKeyProvider' :: Maybe Text
resourceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:certificateArn:SpekeKeyProvider' :: Maybe Text
certificateArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:url:SpekeKeyProvider' :: Maybe Text
url = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:systemIds:SpekeKeyProvider' :: Maybe [Text]
systemIds = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | Specify the resource ID that your SPEKE-compliant key provider uses to
-- identify this content.
spekeKeyProvider_resourceId :: Lens.Lens' SpekeKeyProvider (Prelude.Maybe Prelude.Text)
spekeKeyProvider_resourceId :: (Maybe Text -> f (Maybe Text))
-> SpekeKeyProvider -> f SpekeKeyProvider
spekeKeyProvider_resourceId = (SpekeKeyProvider -> Maybe Text)
-> (SpekeKeyProvider -> Maybe Text -> SpekeKeyProvider)
-> Lens SpekeKeyProvider SpekeKeyProvider (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpekeKeyProvider' {Maybe Text
resourceId :: Maybe Text
$sel:resourceId:SpekeKeyProvider' :: SpekeKeyProvider -> Maybe Text
resourceId} -> Maybe Text
resourceId) (\s :: SpekeKeyProvider
s@SpekeKeyProvider' {} Maybe Text
a -> SpekeKeyProvider
s {$sel:resourceId:SpekeKeyProvider' :: Maybe Text
resourceId = Maybe Text
a} :: SpekeKeyProvider)

-- | If you want your key provider to encrypt the content keys that it
-- provides to MediaConvert, set up a certificate with a master key using
-- AWS Certificate Manager. Specify the certificate\'s Amazon Resource Name
-- (ARN) here.
spekeKeyProvider_certificateArn :: Lens.Lens' SpekeKeyProvider (Prelude.Maybe Prelude.Text)
spekeKeyProvider_certificateArn :: (Maybe Text -> f (Maybe Text))
-> SpekeKeyProvider -> f SpekeKeyProvider
spekeKeyProvider_certificateArn = (SpekeKeyProvider -> Maybe Text)
-> (SpekeKeyProvider -> Maybe Text -> SpekeKeyProvider)
-> Lens SpekeKeyProvider SpekeKeyProvider (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpekeKeyProvider' {Maybe Text
certificateArn :: Maybe Text
$sel:certificateArn:SpekeKeyProvider' :: SpekeKeyProvider -> Maybe Text
certificateArn} -> Maybe Text
certificateArn) (\s :: SpekeKeyProvider
s@SpekeKeyProvider' {} Maybe Text
a -> SpekeKeyProvider
s {$sel:certificateArn:SpekeKeyProvider' :: Maybe Text
certificateArn = Maybe Text
a} :: SpekeKeyProvider)

-- | Specify the URL to the key server that your SPEKE-compliant DRM key
-- provider uses to provide keys for encrypting your content.
spekeKeyProvider_url :: Lens.Lens' SpekeKeyProvider (Prelude.Maybe Prelude.Text)
spekeKeyProvider_url :: (Maybe Text -> f (Maybe Text))
-> SpekeKeyProvider -> f SpekeKeyProvider
spekeKeyProvider_url = (SpekeKeyProvider -> Maybe Text)
-> (SpekeKeyProvider -> Maybe Text -> SpekeKeyProvider)
-> Lens SpekeKeyProvider SpekeKeyProvider (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpekeKeyProvider' {Maybe Text
url :: Maybe Text
$sel:url:SpekeKeyProvider' :: SpekeKeyProvider -> Maybe Text
url} -> Maybe Text
url) (\s :: SpekeKeyProvider
s@SpekeKeyProvider' {} Maybe Text
a -> SpekeKeyProvider
s {$sel:url:SpekeKeyProvider' :: Maybe Text
url = Maybe Text
a} :: SpekeKeyProvider)

-- | Relates to SPEKE implementation. DRM system identifiers. DASH output
-- groups support a max of two system ids. Other group types support one
-- system id. See https:\/\/dashif.org\/identifiers\/content_protection\/
-- for more details.
spekeKeyProvider_systemIds :: Lens.Lens' SpekeKeyProvider (Prelude.Maybe [Prelude.Text])
spekeKeyProvider_systemIds :: (Maybe [Text] -> f (Maybe [Text]))
-> SpekeKeyProvider -> f SpekeKeyProvider
spekeKeyProvider_systemIds = (SpekeKeyProvider -> Maybe [Text])
-> (SpekeKeyProvider -> Maybe [Text] -> SpekeKeyProvider)
-> Lens
     SpekeKeyProvider SpekeKeyProvider (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpekeKeyProvider' {Maybe [Text]
systemIds :: Maybe [Text]
$sel:systemIds:SpekeKeyProvider' :: SpekeKeyProvider -> Maybe [Text]
systemIds} -> Maybe [Text]
systemIds) (\s :: SpekeKeyProvider
s@SpekeKeyProvider' {} Maybe [Text]
a -> SpekeKeyProvider
s {$sel:systemIds:SpekeKeyProvider' :: Maybe [Text]
systemIds = Maybe [Text]
a} :: SpekeKeyProvider) ((Maybe [Text] -> f (Maybe [Text]))
 -> SpekeKeyProvider -> f SpekeKeyProvider)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> SpekeKeyProvider
-> f SpekeKeyProvider
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON SpekeKeyProvider where
  parseJSON :: Value -> Parser SpekeKeyProvider
parseJSON =
    String
-> (Object -> Parser SpekeKeyProvider)
-> Value
-> Parser SpekeKeyProvider
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SpekeKeyProvider"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Maybe [Text] -> SpekeKeyProvider
SpekeKeyProvider'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> Maybe [Text] -> SpekeKeyProvider)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe [Text] -> SpekeKeyProvider)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"resourceId")
            Parser
  (Maybe Text -> Maybe Text -> Maybe [Text] -> SpekeKeyProvider)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe [Text] -> SpekeKeyProvider)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"certificateArn")
            Parser (Maybe Text -> Maybe [Text] -> SpekeKeyProvider)
-> Parser (Maybe Text) -> Parser (Maybe [Text] -> SpekeKeyProvider)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"url")
            Parser (Maybe [Text] -> SpekeKeyProvider)
-> Parser (Maybe [Text]) -> Parser SpekeKeyProvider
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"systemIds" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable SpekeKeyProvider

instance Prelude.NFData SpekeKeyProvider

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