{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.MediaLive.Types.StaticKeySettings where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:keyProviderServer:StaticKeySettings' :: Maybe InputLocation
keyProviderServer =
        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 :: Lens' StaticKeySettings (Maybe InputLocation)
staticKeySettings_keyProviderServer = 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 :: Lens' StaticKeySettings Text
staticKeySettings_staticKeyValue = 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 Data.FromJSON StaticKeySettings where
  parseJSON :: Value -> Parser StaticKeySettings
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"StaticKeySettings"
      ( \Object
x ->
          Maybe InputLocation -> Text -> StaticKeySettings
StaticKeySettings'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"keyProviderServer")
            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
"staticKeyValue")
      )

instance Prelude.Hashable StaticKeySettings where
  hashWithSalt :: Int -> StaticKeySettings -> Int
hashWithSalt Int
_salt StaticKeySettings' {Maybe InputLocation
Text
staticKeyValue :: Text
keyProviderServer :: Maybe InputLocation
$sel:staticKeyValue:StaticKeySettings' :: StaticKeySettings -> Text
$sel:keyProviderServer:StaticKeySettings' :: StaticKeySettings -> Maybe InputLocation
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InputLocation
keyProviderServer
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
staticKeyValue

instance Prelude.NFData StaticKeySettings where
  rnf :: StaticKeySettings -> ()
rnf StaticKeySettings' {Maybe InputLocation
Text
staticKeyValue :: Text
keyProviderServer :: Maybe InputLocation
$sel:staticKeyValue:StaticKeySettings' :: StaticKeySettings -> Text
$sel:keyProviderServer:StaticKeySettings' :: StaticKeySettings -> Maybe InputLocation
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe InputLocation
keyProviderServer
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
staticKeyValue

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"keyProviderServer" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe InputLocation
keyProviderServer,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"staticKeyValue" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
staticKeyValue)
          ]
      )