{-# 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.MediaTailor.Types.SecretsManagerAccessTokenConfiguration
-- 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.MediaTailor.Types.SecretsManagerAccessTokenConfiguration where

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

-- | AWS Secrets Manager access token configuration parameters. For
-- information about Secrets Manager access token authentication, see
-- <https://docs.aws.amazon.com/mediatailor/latest/ug/channel-assembly-access-configuration-access-token.html Working with AWS Secrets Manager access token authentication>.
--
-- /See:/ 'newSecretsManagerAccessTokenConfiguration' smart constructor.
data SecretsManagerAccessTokenConfiguration = SecretsManagerAccessTokenConfiguration'
  { -- | The name of the HTTP header used to supply the access token in requests
    -- to the source location.
    SecretsManagerAccessTokenConfiguration -> Maybe Text
headerName :: Prelude.Maybe Prelude.Text,
    -- | The AWS Secrets Manager
    -- <https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_CreateSecret.html#SecretsManager-CreateSecret-request-SecretString.html SecretString>
    -- key associated with the access token. MediaTailor uses the key to look
    -- up SecretString key and value pair containing the access token.
    SecretsManagerAccessTokenConfiguration -> Maybe Text
secretStringKey :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the AWS Secrets Manager secret that
    -- contains the access token.
    SecretsManagerAccessTokenConfiguration -> Maybe Text
secretArn :: Prelude.Maybe Prelude.Text
  }
  deriving (SecretsManagerAccessTokenConfiguration
-> SecretsManagerAccessTokenConfiguration -> Bool
(SecretsManagerAccessTokenConfiguration
 -> SecretsManagerAccessTokenConfiguration -> Bool)
-> (SecretsManagerAccessTokenConfiguration
    -> SecretsManagerAccessTokenConfiguration -> Bool)
-> Eq SecretsManagerAccessTokenConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SecretsManagerAccessTokenConfiguration
-> SecretsManagerAccessTokenConfiguration -> Bool
$c/= :: SecretsManagerAccessTokenConfiguration
-> SecretsManagerAccessTokenConfiguration -> Bool
== :: SecretsManagerAccessTokenConfiguration
-> SecretsManagerAccessTokenConfiguration -> Bool
$c== :: SecretsManagerAccessTokenConfiguration
-> SecretsManagerAccessTokenConfiguration -> Bool
Prelude.Eq, ReadPrec [SecretsManagerAccessTokenConfiguration]
ReadPrec SecretsManagerAccessTokenConfiguration
Int -> ReadS SecretsManagerAccessTokenConfiguration
ReadS [SecretsManagerAccessTokenConfiguration]
(Int -> ReadS SecretsManagerAccessTokenConfiguration)
-> ReadS [SecretsManagerAccessTokenConfiguration]
-> ReadPrec SecretsManagerAccessTokenConfiguration
-> ReadPrec [SecretsManagerAccessTokenConfiguration]
-> Read SecretsManagerAccessTokenConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SecretsManagerAccessTokenConfiguration]
$creadListPrec :: ReadPrec [SecretsManagerAccessTokenConfiguration]
readPrec :: ReadPrec SecretsManagerAccessTokenConfiguration
$creadPrec :: ReadPrec SecretsManagerAccessTokenConfiguration
readList :: ReadS [SecretsManagerAccessTokenConfiguration]
$creadList :: ReadS [SecretsManagerAccessTokenConfiguration]
readsPrec :: Int -> ReadS SecretsManagerAccessTokenConfiguration
$creadsPrec :: Int -> ReadS SecretsManagerAccessTokenConfiguration
Prelude.Read, Int -> SecretsManagerAccessTokenConfiguration -> ShowS
[SecretsManagerAccessTokenConfiguration] -> ShowS
SecretsManagerAccessTokenConfiguration -> String
(Int -> SecretsManagerAccessTokenConfiguration -> ShowS)
-> (SecretsManagerAccessTokenConfiguration -> String)
-> ([SecretsManagerAccessTokenConfiguration] -> ShowS)
-> Show SecretsManagerAccessTokenConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SecretsManagerAccessTokenConfiguration] -> ShowS
$cshowList :: [SecretsManagerAccessTokenConfiguration] -> ShowS
show :: SecretsManagerAccessTokenConfiguration -> String
$cshow :: SecretsManagerAccessTokenConfiguration -> String
showsPrec :: Int -> SecretsManagerAccessTokenConfiguration -> ShowS
$cshowsPrec :: Int -> SecretsManagerAccessTokenConfiguration -> ShowS
Prelude.Show, (forall x.
 SecretsManagerAccessTokenConfiguration
 -> Rep SecretsManagerAccessTokenConfiguration x)
-> (forall x.
    Rep SecretsManagerAccessTokenConfiguration x
    -> SecretsManagerAccessTokenConfiguration)
-> Generic SecretsManagerAccessTokenConfiguration
forall x.
Rep SecretsManagerAccessTokenConfiguration x
-> SecretsManagerAccessTokenConfiguration
forall x.
SecretsManagerAccessTokenConfiguration
-> Rep SecretsManagerAccessTokenConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SecretsManagerAccessTokenConfiguration x
-> SecretsManagerAccessTokenConfiguration
$cfrom :: forall x.
SecretsManagerAccessTokenConfiguration
-> Rep SecretsManagerAccessTokenConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'SecretsManagerAccessTokenConfiguration' 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:
--
-- 'headerName', 'secretsManagerAccessTokenConfiguration_headerName' - The name of the HTTP header used to supply the access token in requests
-- to the source location.
--
-- 'secretStringKey', 'secretsManagerAccessTokenConfiguration_secretStringKey' - The AWS Secrets Manager
-- <https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_CreateSecret.html#SecretsManager-CreateSecret-request-SecretString.html SecretString>
-- key associated with the access token. MediaTailor uses the key to look
-- up SecretString key and value pair containing the access token.
--
-- 'secretArn', 'secretsManagerAccessTokenConfiguration_secretArn' - The Amazon Resource Name (ARN) of the AWS Secrets Manager secret that
-- contains the access token.
newSecretsManagerAccessTokenConfiguration ::
  SecretsManagerAccessTokenConfiguration
newSecretsManagerAccessTokenConfiguration :: SecretsManagerAccessTokenConfiguration
newSecretsManagerAccessTokenConfiguration =
  SecretsManagerAccessTokenConfiguration' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> SecretsManagerAccessTokenConfiguration
SecretsManagerAccessTokenConfiguration'
    { $sel:headerName:SecretsManagerAccessTokenConfiguration' :: Maybe Text
headerName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:secretStringKey:SecretsManagerAccessTokenConfiguration' :: Maybe Text
secretStringKey = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:secretArn:SecretsManagerAccessTokenConfiguration' :: Maybe Text
secretArn = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the HTTP header used to supply the access token in requests
-- to the source location.
secretsManagerAccessTokenConfiguration_headerName :: Lens.Lens' SecretsManagerAccessTokenConfiguration (Prelude.Maybe Prelude.Text)
secretsManagerAccessTokenConfiguration_headerName :: (Maybe Text -> f (Maybe Text))
-> SecretsManagerAccessTokenConfiguration
-> f SecretsManagerAccessTokenConfiguration
secretsManagerAccessTokenConfiguration_headerName = (SecretsManagerAccessTokenConfiguration -> Maybe Text)
-> (SecretsManagerAccessTokenConfiguration
    -> Maybe Text -> SecretsManagerAccessTokenConfiguration)
-> Lens
     SecretsManagerAccessTokenConfiguration
     SecretsManagerAccessTokenConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecretsManagerAccessTokenConfiguration' {Maybe Text
headerName :: Maybe Text
$sel:headerName:SecretsManagerAccessTokenConfiguration' :: SecretsManagerAccessTokenConfiguration -> Maybe Text
headerName} -> Maybe Text
headerName) (\s :: SecretsManagerAccessTokenConfiguration
s@SecretsManagerAccessTokenConfiguration' {} Maybe Text
a -> SecretsManagerAccessTokenConfiguration
s {$sel:headerName:SecretsManagerAccessTokenConfiguration' :: Maybe Text
headerName = Maybe Text
a} :: SecretsManagerAccessTokenConfiguration)

-- | The AWS Secrets Manager
-- <https://docs.aws.amazon.com/secretsmanager/latest/apireference/API_CreateSecret.html#SecretsManager-CreateSecret-request-SecretString.html SecretString>
-- key associated with the access token. MediaTailor uses the key to look
-- up SecretString key and value pair containing the access token.
secretsManagerAccessTokenConfiguration_secretStringKey :: Lens.Lens' SecretsManagerAccessTokenConfiguration (Prelude.Maybe Prelude.Text)
secretsManagerAccessTokenConfiguration_secretStringKey :: (Maybe Text -> f (Maybe Text))
-> SecretsManagerAccessTokenConfiguration
-> f SecretsManagerAccessTokenConfiguration
secretsManagerAccessTokenConfiguration_secretStringKey = (SecretsManagerAccessTokenConfiguration -> Maybe Text)
-> (SecretsManagerAccessTokenConfiguration
    -> Maybe Text -> SecretsManagerAccessTokenConfiguration)
-> Lens
     SecretsManagerAccessTokenConfiguration
     SecretsManagerAccessTokenConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecretsManagerAccessTokenConfiguration' {Maybe Text
secretStringKey :: Maybe Text
$sel:secretStringKey:SecretsManagerAccessTokenConfiguration' :: SecretsManagerAccessTokenConfiguration -> Maybe Text
secretStringKey} -> Maybe Text
secretStringKey) (\s :: SecretsManagerAccessTokenConfiguration
s@SecretsManagerAccessTokenConfiguration' {} Maybe Text
a -> SecretsManagerAccessTokenConfiguration
s {$sel:secretStringKey:SecretsManagerAccessTokenConfiguration' :: Maybe Text
secretStringKey = Maybe Text
a} :: SecretsManagerAccessTokenConfiguration)

-- | The Amazon Resource Name (ARN) of the AWS Secrets Manager secret that
-- contains the access token.
secretsManagerAccessTokenConfiguration_secretArn :: Lens.Lens' SecretsManagerAccessTokenConfiguration (Prelude.Maybe Prelude.Text)
secretsManagerAccessTokenConfiguration_secretArn :: (Maybe Text -> f (Maybe Text))
-> SecretsManagerAccessTokenConfiguration
-> f SecretsManagerAccessTokenConfiguration
secretsManagerAccessTokenConfiguration_secretArn = (SecretsManagerAccessTokenConfiguration -> Maybe Text)
-> (SecretsManagerAccessTokenConfiguration
    -> Maybe Text -> SecretsManagerAccessTokenConfiguration)
-> Lens
     SecretsManagerAccessTokenConfiguration
     SecretsManagerAccessTokenConfiguration
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecretsManagerAccessTokenConfiguration' {Maybe Text
secretArn :: Maybe Text
$sel:secretArn:SecretsManagerAccessTokenConfiguration' :: SecretsManagerAccessTokenConfiguration -> Maybe Text
secretArn} -> Maybe Text
secretArn) (\s :: SecretsManagerAccessTokenConfiguration
s@SecretsManagerAccessTokenConfiguration' {} Maybe Text
a -> SecretsManagerAccessTokenConfiguration
s {$sel:secretArn:SecretsManagerAccessTokenConfiguration' :: Maybe Text
secretArn = Maybe Text
a} :: SecretsManagerAccessTokenConfiguration)

instance
  Core.FromJSON
    SecretsManagerAccessTokenConfiguration
  where
  parseJSON :: Value -> Parser SecretsManagerAccessTokenConfiguration
parseJSON =
    String
-> (Object -> Parser SecretsManagerAccessTokenConfiguration)
-> Value
-> Parser SecretsManagerAccessTokenConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SecretsManagerAccessTokenConfiguration"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> SecretsManagerAccessTokenConfiguration
SecretsManagerAccessTokenConfiguration'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> SecretsManagerAccessTokenConfiguration)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> SecretsManagerAccessTokenConfiguration)
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
"HeaderName")
            Parser
  (Maybe Text
   -> Maybe Text -> SecretsManagerAccessTokenConfiguration)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> SecretsManagerAccessTokenConfiguration)
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
"SecretStringKey")
            Parser (Maybe Text -> SecretsManagerAccessTokenConfiguration)
-> Parser (Maybe Text)
-> Parser SecretsManagerAccessTokenConfiguration
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
"SecretArn")
      )

instance
  Prelude.Hashable
    SecretsManagerAccessTokenConfiguration

instance
  Prelude.NFData
    SecretsManagerAccessTokenConfiguration

instance
  Core.ToJSON
    SecretsManagerAccessTokenConfiguration
  where
  toJSON :: SecretsManagerAccessTokenConfiguration -> Value
toJSON SecretsManagerAccessTokenConfiguration' {Maybe Text
secretArn :: Maybe Text
secretStringKey :: Maybe Text
headerName :: Maybe Text
$sel:secretArn:SecretsManagerAccessTokenConfiguration' :: SecretsManagerAccessTokenConfiguration -> Maybe Text
$sel:secretStringKey:SecretsManagerAccessTokenConfiguration' :: SecretsManagerAccessTokenConfiguration -> Maybe Text
$sel:headerName:SecretsManagerAccessTokenConfiguration' :: SecretsManagerAccessTokenConfiguration -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"HeaderName" 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
headerName,
            (Text
"SecretStringKey" 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
secretStringKey,
            (Text
"SecretArn" 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
secretArn
          ]
      )