{-# 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.MediaPackageVOD.Types.Authorization
-- 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.MediaPackageVOD.Types.Authorization where

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

-- | CDN Authorization credentials
--
-- /See:/ 'newAuthorization' smart constructor.
data Authorization = Authorization'
  { -- | The Amazon Resource Name (ARN) for the IAM role that allows MediaPackage
    -- to communicate with AWS Secrets Manager.
    Authorization -> Text
secretsRoleArn :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) for the secret in AWS Secrets Manager
    -- that is used for CDN authorization.
    Authorization -> Text
cdnIdentifierSecret :: Prelude.Text
  }
  deriving (Authorization -> Authorization -> Bool
(Authorization -> Authorization -> Bool)
-> (Authorization -> Authorization -> Bool) -> Eq Authorization
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Authorization -> Authorization -> Bool
$c/= :: Authorization -> Authorization -> Bool
== :: Authorization -> Authorization -> Bool
$c== :: Authorization -> Authorization -> Bool
Prelude.Eq, ReadPrec [Authorization]
ReadPrec Authorization
Int -> ReadS Authorization
ReadS [Authorization]
(Int -> ReadS Authorization)
-> ReadS [Authorization]
-> ReadPrec Authorization
-> ReadPrec [Authorization]
-> Read Authorization
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Authorization]
$creadListPrec :: ReadPrec [Authorization]
readPrec :: ReadPrec Authorization
$creadPrec :: ReadPrec Authorization
readList :: ReadS [Authorization]
$creadList :: ReadS [Authorization]
readsPrec :: Int -> ReadS Authorization
$creadsPrec :: Int -> ReadS Authorization
Prelude.Read, Int -> Authorization -> ShowS
[Authorization] -> ShowS
Authorization -> String
(Int -> Authorization -> ShowS)
-> (Authorization -> String)
-> ([Authorization] -> ShowS)
-> Show Authorization
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Authorization] -> ShowS
$cshowList :: [Authorization] -> ShowS
show :: Authorization -> String
$cshow :: Authorization -> String
showsPrec :: Int -> Authorization -> ShowS
$cshowsPrec :: Int -> Authorization -> ShowS
Prelude.Show, (forall x. Authorization -> Rep Authorization x)
-> (forall x. Rep Authorization x -> Authorization)
-> Generic Authorization
forall x. Rep Authorization x -> Authorization
forall x. Authorization -> Rep Authorization x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Authorization x -> Authorization
$cfrom :: forall x. Authorization -> Rep Authorization x
Prelude.Generic)

-- |
-- Create a value of 'Authorization' 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:
--
-- 'secretsRoleArn', 'authorization_secretsRoleArn' - The Amazon Resource Name (ARN) for the IAM role that allows MediaPackage
-- to communicate with AWS Secrets Manager.
--
-- 'cdnIdentifierSecret', 'authorization_cdnIdentifierSecret' - The Amazon Resource Name (ARN) for the secret in AWS Secrets Manager
-- that is used for CDN authorization.
newAuthorization ::
  -- | 'secretsRoleArn'
  Prelude.Text ->
  -- | 'cdnIdentifierSecret'
  Prelude.Text ->
  Authorization
newAuthorization :: Text -> Text -> Authorization
newAuthorization
  Text
pSecretsRoleArn_
  Text
pCdnIdentifierSecret_ =
    Authorization' :: Text -> Text -> Authorization
Authorization'
      { $sel:secretsRoleArn:Authorization' :: Text
secretsRoleArn = Text
pSecretsRoleArn_,
        $sel:cdnIdentifierSecret:Authorization' :: Text
cdnIdentifierSecret = Text
pCdnIdentifierSecret_
      }

-- | The Amazon Resource Name (ARN) for the IAM role that allows MediaPackage
-- to communicate with AWS Secrets Manager.
authorization_secretsRoleArn :: Lens.Lens' Authorization Prelude.Text
authorization_secretsRoleArn :: (Text -> f Text) -> Authorization -> f Authorization
authorization_secretsRoleArn = (Authorization -> Text)
-> (Authorization -> Text -> Authorization)
-> Lens Authorization Authorization Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Authorization' {Text
secretsRoleArn :: Text
$sel:secretsRoleArn:Authorization' :: Authorization -> Text
secretsRoleArn} -> Text
secretsRoleArn) (\s :: Authorization
s@Authorization' {} Text
a -> Authorization
s {$sel:secretsRoleArn:Authorization' :: Text
secretsRoleArn = Text
a} :: Authorization)

-- | The Amazon Resource Name (ARN) for the secret in AWS Secrets Manager
-- that is used for CDN authorization.
authorization_cdnIdentifierSecret :: Lens.Lens' Authorization Prelude.Text
authorization_cdnIdentifierSecret :: (Text -> f Text) -> Authorization -> f Authorization
authorization_cdnIdentifierSecret = (Authorization -> Text)
-> (Authorization -> Text -> Authorization)
-> Lens Authorization Authorization Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Authorization' {Text
cdnIdentifierSecret :: Text
$sel:cdnIdentifierSecret:Authorization' :: Authorization -> Text
cdnIdentifierSecret} -> Text
cdnIdentifierSecret) (\s :: Authorization
s@Authorization' {} Text
a -> Authorization
s {$sel:cdnIdentifierSecret:Authorization' :: Text
cdnIdentifierSecret = Text
a} :: Authorization)

instance Core.FromJSON Authorization where
  parseJSON :: Value -> Parser Authorization
parseJSON =
    String
-> (Object -> Parser Authorization)
-> Value
-> Parser Authorization
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Authorization"
      ( \Object
x ->
          Text -> Text -> Authorization
Authorization'
            (Text -> Text -> Authorization)
-> Parser Text -> Parser (Text -> Authorization)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"secretsRoleArn")
            Parser (Text -> Authorization)
-> Parser Text -> Parser Authorization
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
"cdnIdentifierSecret")
      )

instance Prelude.Hashable Authorization

instance Prelude.NFData Authorization

instance Core.ToJSON Authorization where
  toJSON :: Authorization -> Value
toJSON Authorization' {Text
cdnIdentifierSecret :: Text
secretsRoleArn :: Text
$sel:cdnIdentifierSecret:Authorization' :: Authorization -> Text
$sel:secretsRoleArn:Authorization' :: Authorization -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"secretsRoleArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
secretsRoleArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"cdnIdentifierSecret" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
cdnIdentifierSecret)
          ]
      )