{-# 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.MediaLive.Types.StaticKeySettings
-- 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.MediaLive.Types.StaticKeySettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.MediaLive.Types.InputLocation
import qualified Amazonka.Prelude as Prelude

-- | Static Key Settings
--
-- /See:/ 'newStaticKeySettings' smart constructor.
data StaticKeySettings = StaticKeySettings'
  { -- | The URL of the license server used for protecting content.
    StaticKeySettings -> Maybe InputLocation
keyProviderServer :: Prelude.Maybe InputLocation,
    -- | Static key value as a 32 character hexadecimal string.
    StaticKeySettings -> Text
staticKeyValue :: Prelude.Text
  }
  deriving (StaticKeySettings -> StaticKeySettings -> Bool
(StaticKeySettings -> StaticKeySettings -> Bool)
-> (StaticKeySettings -> StaticKeySettings -> Bool)
-> Eq StaticKeySettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StaticKeySettings -> StaticKeySettings -> Bool
$c/= :: StaticKeySettings -> StaticKeySettings -> Bool
== :: StaticKeySettings -> StaticKeySettings -> Bool
$c== :: StaticKeySettings -> StaticKeySettings -> Bool
Prelude.Eq, ReadPrec [StaticKeySettings]
ReadPrec StaticKeySettings
Int -> ReadS StaticKeySettings
ReadS [StaticKeySettings]
(Int -> ReadS StaticKeySettings)
-> ReadS [StaticKeySettings]
-> ReadPrec StaticKeySettings
-> ReadPrec [StaticKeySettings]
-> Read StaticKeySettings
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StaticKeySettings]
$creadListPrec :: ReadPrec [StaticKeySettings]
readPrec :: ReadPrec StaticKeySettings
$creadPrec :: ReadPrec StaticKeySettings
readList :: ReadS [StaticKeySettings]
$creadList :: ReadS [StaticKeySettings]
readsPrec :: Int -> ReadS StaticKeySettings
$creadsPrec :: Int -> ReadS StaticKeySettings
Prelude.Read, Int -> StaticKeySettings -> ShowS
[StaticKeySettings] -> ShowS
StaticKeySettings -> String
(Int -> StaticKeySettings -> ShowS)
-> (StaticKeySettings -> String)
-> ([StaticKeySettings] -> ShowS)
-> Show StaticKeySettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StaticKeySettings] -> ShowS
$cshowList :: [StaticKeySettings] -> ShowS
show :: StaticKeySettings -> String
$cshow :: StaticKeySettings -> String
showsPrec :: Int -> StaticKeySettings -> ShowS
$cshowsPrec :: Int -> StaticKeySettings -> ShowS
Prelude.Show, (forall x. StaticKeySettings -> Rep StaticKeySettings x)
-> (forall x. Rep StaticKeySettings x -> StaticKeySettings)
-> Generic StaticKeySettings
forall x. Rep StaticKeySettings x -> StaticKeySettings
forall x. StaticKeySettings -> Rep StaticKeySettings x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StaticKeySettings x -> StaticKeySettings
$cfrom :: forall x. StaticKeySettings -> Rep StaticKeySettings x
Prelude.Generic)

-- |
-- Create a value of 'StaticKeySettings' 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:
--
-- 'keyProviderServer', 'staticKeySettings_keyProviderServer' - The URL of the license server used for protecting content.
--
-- 'staticKeyValue', 'staticKeySettings_staticKeyValue' - Static key value as a 32 character hexadecimal string.
newStaticKeySettings ::
  -- | 'staticKeyValue'
  Prelude.Text ->
  StaticKeySettings
newStaticKeySettings :: Text -> StaticKeySettings
newStaticKeySettings Text
pStaticKeyValue_ =
  StaticKeySettings' :: Maybe InputLocation -> Text -> StaticKeySettings
StaticKeySettings'
    { $sel:keyProviderServer:StaticKeySettings' :: Maybe InputLocation
keyProviderServer =
        Maybe InputLocation
forall a. Maybe a
Prelude.Nothing,
      $sel:staticKeyValue:StaticKeySettings' :: Text
staticKeyValue = Text
pStaticKeyValue_
    }

-- | The URL of the license server used for protecting content.
staticKeySettings_keyProviderServer :: Lens.Lens' StaticKeySettings (Prelude.Maybe InputLocation)
staticKeySettings_keyProviderServer :: (Maybe InputLocation -> f (Maybe InputLocation))
-> StaticKeySettings -> f StaticKeySettings
staticKeySettings_keyProviderServer = (StaticKeySettings -> Maybe InputLocation)
-> (StaticKeySettings -> Maybe InputLocation -> StaticKeySettings)
-> Lens
     StaticKeySettings
     StaticKeySettings
     (Maybe InputLocation)
     (Maybe InputLocation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StaticKeySettings' {Maybe InputLocation
keyProviderServer :: Maybe InputLocation
$sel:keyProviderServer:StaticKeySettings' :: StaticKeySettings -> Maybe InputLocation
keyProviderServer} -> Maybe InputLocation
keyProviderServer) (\s :: StaticKeySettings
s@StaticKeySettings' {} Maybe InputLocation
a -> StaticKeySettings
s {$sel:keyProviderServer:StaticKeySettings' :: Maybe InputLocation
keyProviderServer = Maybe InputLocation
a} :: StaticKeySettings)

-- | Static key value as a 32 character hexadecimal string.
staticKeySettings_staticKeyValue :: Lens.Lens' StaticKeySettings Prelude.Text
staticKeySettings_staticKeyValue :: (Text -> f Text) -> StaticKeySettings -> f StaticKeySettings
staticKeySettings_staticKeyValue = (StaticKeySettings -> Text)
-> (StaticKeySettings -> Text -> StaticKeySettings)
-> Lens StaticKeySettings StaticKeySettings Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StaticKeySettings' {Text
staticKeyValue :: Text
$sel:staticKeyValue:StaticKeySettings' :: StaticKeySettings -> Text
staticKeyValue} -> Text
staticKeyValue) (\s :: StaticKeySettings
s@StaticKeySettings' {} Text
a -> StaticKeySettings
s {$sel:staticKeyValue:StaticKeySettings' :: Text
staticKeyValue = Text
a} :: StaticKeySettings)

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

instance Prelude.Hashable StaticKeySettings

instance Prelude.NFData StaticKeySettings

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