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

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

-- | Use these settings to set up encryption with a static key provider.
--
-- /See:/ 'newStaticKeyProvider' smart constructor.
data StaticKeyProvider = StaticKeyProvider'
  { -- | Relates to DRM implementation. Use a 32-character hexidecimal string to
    -- specify Key Value (StaticKeyValue).
    StaticKeyProvider -> Maybe Text
staticKeyValue :: Prelude.Maybe Prelude.Text,
    -- | Relates to DRM implementation. The location of the license server used
    -- for protecting content.
    StaticKeyProvider -> Maybe Text
url :: Prelude.Maybe Prelude.Text,
    -- | Relates to DRM implementation. Sets the value of the KEYFORMAT
    -- attribute. Must be \'identity\' or a reverse DNS string. May be omitted
    -- to indicate an implicit value of \'identity\'.
    StaticKeyProvider -> Maybe Text
keyFormat :: Prelude.Maybe Prelude.Text,
    -- | Relates to DRM implementation. Either a single positive integer version
    -- value or a slash delimited list of version values (1\/2\/3).
    StaticKeyProvider -> Maybe Text
keyFormatVersions :: Prelude.Maybe Prelude.Text
  }
  deriving (StaticKeyProvider -> StaticKeyProvider -> Bool
(StaticKeyProvider -> StaticKeyProvider -> Bool)
-> (StaticKeyProvider -> StaticKeyProvider -> Bool)
-> Eq StaticKeyProvider
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StaticKeyProvider -> StaticKeyProvider -> Bool
$c/= :: StaticKeyProvider -> StaticKeyProvider -> Bool
== :: StaticKeyProvider -> StaticKeyProvider -> Bool
$c== :: StaticKeyProvider -> StaticKeyProvider -> Bool
Prelude.Eq, ReadPrec [StaticKeyProvider]
ReadPrec StaticKeyProvider
Int -> ReadS StaticKeyProvider
ReadS [StaticKeyProvider]
(Int -> ReadS StaticKeyProvider)
-> ReadS [StaticKeyProvider]
-> ReadPrec StaticKeyProvider
-> ReadPrec [StaticKeyProvider]
-> Read StaticKeyProvider
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StaticKeyProvider]
$creadListPrec :: ReadPrec [StaticKeyProvider]
readPrec :: ReadPrec StaticKeyProvider
$creadPrec :: ReadPrec StaticKeyProvider
readList :: ReadS [StaticKeyProvider]
$creadList :: ReadS [StaticKeyProvider]
readsPrec :: Int -> ReadS StaticKeyProvider
$creadsPrec :: Int -> ReadS StaticKeyProvider
Prelude.Read, Int -> StaticKeyProvider -> ShowS
[StaticKeyProvider] -> ShowS
StaticKeyProvider -> String
(Int -> StaticKeyProvider -> ShowS)
-> (StaticKeyProvider -> String)
-> ([StaticKeyProvider] -> ShowS)
-> Show StaticKeyProvider
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StaticKeyProvider] -> ShowS
$cshowList :: [StaticKeyProvider] -> ShowS
show :: StaticKeyProvider -> String
$cshow :: StaticKeyProvider -> String
showsPrec :: Int -> StaticKeyProvider -> ShowS
$cshowsPrec :: Int -> StaticKeyProvider -> ShowS
Prelude.Show, (forall x. StaticKeyProvider -> Rep StaticKeyProvider x)
-> (forall x. Rep StaticKeyProvider x -> StaticKeyProvider)
-> Generic StaticKeyProvider
forall x. Rep StaticKeyProvider x -> StaticKeyProvider
forall x. StaticKeyProvider -> Rep StaticKeyProvider x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StaticKeyProvider x -> StaticKeyProvider
$cfrom :: forall x. StaticKeyProvider -> Rep StaticKeyProvider x
Prelude.Generic)

-- |
-- Create a value of 'StaticKeyProvider' 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:
--
-- 'staticKeyValue', 'staticKeyProvider_staticKeyValue' - Relates to DRM implementation. Use a 32-character hexidecimal string to
-- specify Key Value (StaticKeyValue).
--
-- 'url', 'staticKeyProvider_url' - Relates to DRM implementation. The location of the license server used
-- for protecting content.
--
-- 'keyFormat', 'staticKeyProvider_keyFormat' - Relates to DRM implementation. Sets the value of the KEYFORMAT
-- attribute. Must be \'identity\' or a reverse DNS string. May be omitted
-- to indicate an implicit value of \'identity\'.
--
-- 'keyFormatVersions', 'staticKeyProvider_keyFormatVersions' - Relates to DRM implementation. Either a single positive integer version
-- value or a slash delimited list of version values (1\/2\/3).
newStaticKeyProvider ::
  StaticKeyProvider
newStaticKeyProvider :: StaticKeyProvider
newStaticKeyProvider =
  StaticKeyProvider' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> StaticKeyProvider
StaticKeyProvider'
    { $sel:staticKeyValue:StaticKeyProvider' :: Maybe Text
staticKeyValue =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:url:StaticKeyProvider' :: Maybe Text
url = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:keyFormat:StaticKeyProvider' :: Maybe Text
keyFormat = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:keyFormatVersions:StaticKeyProvider' :: Maybe Text
keyFormatVersions = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Relates to DRM implementation. Use a 32-character hexidecimal string to
-- specify Key Value (StaticKeyValue).
staticKeyProvider_staticKeyValue :: Lens.Lens' StaticKeyProvider (Prelude.Maybe Prelude.Text)
staticKeyProvider_staticKeyValue :: (Maybe Text -> f (Maybe Text))
-> StaticKeyProvider -> f StaticKeyProvider
staticKeyProvider_staticKeyValue = (StaticKeyProvider -> Maybe Text)
-> (StaticKeyProvider -> Maybe Text -> StaticKeyProvider)
-> Lens
     StaticKeyProvider StaticKeyProvider (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StaticKeyProvider' {Maybe Text
staticKeyValue :: Maybe Text
$sel:staticKeyValue:StaticKeyProvider' :: StaticKeyProvider -> Maybe Text
staticKeyValue} -> Maybe Text
staticKeyValue) (\s :: StaticKeyProvider
s@StaticKeyProvider' {} Maybe Text
a -> StaticKeyProvider
s {$sel:staticKeyValue:StaticKeyProvider' :: Maybe Text
staticKeyValue = Maybe Text
a} :: StaticKeyProvider)

-- | Relates to DRM implementation. The location of the license server used
-- for protecting content.
staticKeyProvider_url :: Lens.Lens' StaticKeyProvider (Prelude.Maybe Prelude.Text)
staticKeyProvider_url :: (Maybe Text -> f (Maybe Text))
-> StaticKeyProvider -> f StaticKeyProvider
staticKeyProvider_url = (StaticKeyProvider -> Maybe Text)
-> (StaticKeyProvider -> Maybe Text -> StaticKeyProvider)
-> Lens
     StaticKeyProvider StaticKeyProvider (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StaticKeyProvider' {Maybe Text
url :: Maybe Text
$sel:url:StaticKeyProvider' :: StaticKeyProvider -> Maybe Text
url} -> Maybe Text
url) (\s :: StaticKeyProvider
s@StaticKeyProvider' {} Maybe Text
a -> StaticKeyProvider
s {$sel:url:StaticKeyProvider' :: Maybe Text
url = Maybe Text
a} :: StaticKeyProvider)

-- | Relates to DRM implementation. Sets the value of the KEYFORMAT
-- attribute. Must be \'identity\' or a reverse DNS string. May be omitted
-- to indicate an implicit value of \'identity\'.
staticKeyProvider_keyFormat :: Lens.Lens' StaticKeyProvider (Prelude.Maybe Prelude.Text)
staticKeyProvider_keyFormat :: (Maybe Text -> f (Maybe Text))
-> StaticKeyProvider -> f StaticKeyProvider
staticKeyProvider_keyFormat = (StaticKeyProvider -> Maybe Text)
-> (StaticKeyProvider -> Maybe Text -> StaticKeyProvider)
-> Lens
     StaticKeyProvider StaticKeyProvider (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StaticKeyProvider' {Maybe Text
keyFormat :: Maybe Text
$sel:keyFormat:StaticKeyProvider' :: StaticKeyProvider -> Maybe Text
keyFormat} -> Maybe Text
keyFormat) (\s :: StaticKeyProvider
s@StaticKeyProvider' {} Maybe Text
a -> StaticKeyProvider
s {$sel:keyFormat:StaticKeyProvider' :: Maybe Text
keyFormat = Maybe Text
a} :: StaticKeyProvider)

-- | Relates to DRM implementation. Either a single positive integer version
-- value or a slash delimited list of version values (1\/2\/3).
staticKeyProvider_keyFormatVersions :: Lens.Lens' StaticKeyProvider (Prelude.Maybe Prelude.Text)
staticKeyProvider_keyFormatVersions :: (Maybe Text -> f (Maybe Text))
-> StaticKeyProvider -> f StaticKeyProvider
staticKeyProvider_keyFormatVersions = (StaticKeyProvider -> Maybe Text)
-> (StaticKeyProvider -> Maybe Text -> StaticKeyProvider)
-> Lens
     StaticKeyProvider StaticKeyProvider (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StaticKeyProvider' {Maybe Text
keyFormatVersions :: Maybe Text
$sel:keyFormatVersions:StaticKeyProvider' :: StaticKeyProvider -> Maybe Text
keyFormatVersions} -> Maybe Text
keyFormatVersions) (\s :: StaticKeyProvider
s@StaticKeyProvider' {} Maybe Text
a -> StaticKeyProvider
s {$sel:keyFormatVersions:StaticKeyProvider' :: Maybe Text
keyFormatVersions = Maybe Text
a} :: StaticKeyProvider)

instance Core.FromJSON StaticKeyProvider where
  parseJSON :: Value -> Parser StaticKeyProvider
parseJSON =
    String
-> (Object -> Parser StaticKeyProvider)
-> Value
-> Parser StaticKeyProvider
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StaticKeyProvider"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> StaticKeyProvider
StaticKeyProvider'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> Maybe Text -> StaticKeyProvider)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> StaticKeyProvider)
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
"staticKeyValue")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> StaticKeyProvider)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> StaticKeyProvider)
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 -> Maybe Text -> StaticKeyProvider)
-> Parser (Maybe Text) -> Parser (Maybe Text -> StaticKeyProvider)
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
"keyFormat")
            Parser (Maybe Text -> StaticKeyProvider)
-> Parser (Maybe Text) -> Parser StaticKeyProvider
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
"keyFormatVersions")
      )

instance Prelude.Hashable StaticKeyProvider

instance Prelude.NFData StaticKeyProvider

instance Core.ToJSON StaticKeyProvider where
  toJSON :: StaticKeyProvider -> Value
toJSON StaticKeyProvider' {Maybe Text
keyFormatVersions :: Maybe Text
keyFormat :: Maybe Text
url :: Maybe Text
staticKeyValue :: Maybe Text
$sel:keyFormatVersions:StaticKeyProvider' :: StaticKeyProvider -> Maybe Text
$sel:keyFormat:StaticKeyProvider' :: StaticKeyProvider -> Maybe Text
$sel:url:StaticKeyProvider' :: StaticKeyProvider -> Maybe Text
$sel:staticKeyValue:StaticKeyProvider' :: StaticKeyProvider -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"staticKeyValue" 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
staticKeyValue,
            (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
"keyFormat" 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
keyFormat,
            (Text
"keyFormatVersions" 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
keyFormatVersions
          ]
      )