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

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
      { $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 :: Lens' Authorization Text
authorization_secretsRoleArn = 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 :: Lens' Authorization Text
authorization_cdnIdentifierSecret = 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 Data.FromJSON Authorization where
  parseJSON :: Value -> Parser Authorization
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Authorization"
      ( \Object
x ->
          Text -> Text -> Authorization
Authorization'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"secretsRoleArn")
            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
"cdnIdentifierSecret")
      )

instance Prelude.Hashable Authorization where
  hashWithSalt :: Int -> Authorization -> Int
hashWithSalt Int
_salt Authorization' {Text
cdnIdentifierSecret :: Text
secretsRoleArn :: Text
$sel:cdnIdentifierSecret:Authorization' :: Authorization -> Text
$sel:secretsRoleArn:Authorization' :: Authorization -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
secretsRoleArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
cdnIdentifierSecret

instance Prelude.NFData Authorization where
  rnf :: Authorization -> ()
rnf Authorization' {Text
cdnIdentifierSecret :: Text
secretsRoleArn :: Text
$sel:cdnIdentifierSecret:Authorization' :: Authorization -> Text
$sel:secretsRoleArn:Authorization' :: Authorization -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
secretsRoleArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
cdnIdentifierSecret

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"secretsRoleArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
secretsRoleArn),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"cdnIdentifierSecret" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
cdnIdentifierSecret)
          ]
      )