{-# 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.SageMaker.Types.OidcConfig
-- 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.SageMaker.Types.OidcConfig where

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

-- | Use this parameter to configure your OIDC Identity Provider (IdP).
--
-- /See:/ 'newOidcConfig' smart constructor.
data OidcConfig = OidcConfig'
  { -- | The OIDC IdP client ID used to configure your private workforce.
    OidcConfig -> Text
clientId :: Prelude.Text,
    -- | The OIDC IdP client secret used to configure your private workforce.
    OidcConfig -> Sensitive Text
clientSecret :: Core.Sensitive Prelude.Text,
    -- | The OIDC IdP issuer used to configure your private workforce.
    OidcConfig -> Text
issuer :: Prelude.Text,
    -- | The OIDC IdP authorization endpoint used to configure your private
    -- workforce.
    OidcConfig -> Text
authorizationEndpoint :: Prelude.Text,
    -- | The OIDC IdP token endpoint used to configure your private workforce.
    OidcConfig -> Text
tokenEndpoint :: Prelude.Text,
    -- | The OIDC IdP user information endpoint used to configure your private
    -- workforce.
    OidcConfig -> Text
userInfoEndpoint :: Prelude.Text,
    -- | The OIDC IdP logout endpoint used to configure your private workforce.
    OidcConfig -> Text
logoutEndpoint :: Prelude.Text,
    -- | The OIDC IdP JSON Web Key Set (Jwks) URI used to configure your private
    -- workforce.
    OidcConfig -> Text
jwksUri :: Prelude.Text
  }
  deriving (OidcConfig -> OidcConfig -> Bool
(OidcConfig -> OidcConfig -> Bool)
-> (OidcConfig -> OidcConfig -> Bool) -> Eq OidcConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OidcConfig -> OidcConfig -> Bool
$c/= :: OidcConfig -> OidcConfig -> Bool
== :: OidcConfig -> OidcConfig -> Bool
$c== :: OidcConfig -> OidcConfig -> Bool
Prelude.Eq, Int -> OidcConfig -> ShowS
[OidcConfig] -> ShowS
OidcConfig -> String
(Int -> OidcConfig -> ShowS)
-> (OidcConfig -> String)
-> ([OidcConfig] -> ShowS)
-> Show OidcConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OidcConfig] -> ShowS
$cshowList :: [OidcConfig] -> ShowS
show :: OidcConfig -> String
$cshow :: OidcConfig -> String
showsPrec :: Int -> OidcConfig -> ShowS
$cshowsPrec :: Int -> OidcConfig -> ShowS
Prelude.Show, (forall x. OidcConfig -> Rep OidcConfig x)
-> (forall x. Rep OidcConfig x -> OidcConfig) -> Generic OidcConfig
forall x. Rep OidcConfig x -> OidcConfig
forall x. OidcConfig -> Rep OidcConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OidcConfig x -> OidcConfig
$cfrom :: forall x. OidcConfig -> Rep OidcConfig x
Prelude.Generic)

-- |
-- Create a value of 'OidcConfig' 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:
--
-- 'clientId', 'oidcConfig_clientId' - The OIDC IdP client ID used to configure your private workforce.
--
-- 'clientSecret', 'oidcConfig_clientSecret' - The OIDC IdP client secret used to configure your private workforce.
--
-- 'issuer', 'oidcConfig_issuer' - The OIDC IdP issuer used to configure your private workforce.
--
-- 'authorizationEndpoint', 'oidcConfig_authorizationEndpoint' - The OIDC IdP authorization endpoint used to configure your private
-- workforce.
--
-- 'tokenEndpoint', 'oidcConfig_tokenEndpoint' - The OIDC IdP token endpoint used to configure your private workforce.
--
-- 'userInfoEndpoint', 'oidcConfig_userInfoEndpoint' - The OIDC IdP user information endpoint used to configure your private
-- workforce.
--
-- 'logoutEndpoint', 'oidcConfig_logoutEndpoint' - The OIDC IdP logout endpoint used to configure your private workforce.
--
-- 'jwksUri', 'oidcConfig_jwksUri' - The OIDC IdP JSON Web Key Set (Jwks) URI used to configure your private
-- workforce.
newOidcConfig ::
  -- | 'clientId'
  Prelude.Text ->
  -- | 'clientSecret'
  Prelude.Text ->
  -- | 'issuer'
  Prelude.Text ->
  -- | 'authorizationEndpoint'
  Prelude.Text ->
  -- | 'tokenEndpoint'
  Prelude.Text ->
  -- | 'userInfoEndpoint'
  Prelude.Text ->
  -- | 'logoutEndpoint'
  Prelude.Text ->
  -- | 'jwksUri'
  Prelude.Text ->
  OidcConfig
newOidcConfig :: Text
-> Text
-> Text
-> Text
-> Text
-> Text
-> Text
-> Text
-> OidcConfig
newOidcConfig
  Text
pClientId_
  Text
pClientSecret_
  Text
pIssuer_
  Text
pAuthorizationEndpoint_
  Text
pTokenEndpoint_
  Text
pUserInfoEndpoint_
  Text
pLogoutEndpoint_
  Text
pJwksUri_ =
    OidcConfig' :: Text
-> Sensitive Text
-> Text
-> Text
-> Text
-> Text
-> Text
-> Text
-> OidcConfig
OidcConfig'
      { $sel:clientId:OidcConfig' :: Text
clientId = Text
pClientId_,
        $sel:clientSecret:OidcConfig' :: Sensitive Text
clientSecret = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pClientSecret_,
        $sel:issuer:OidcConfig' :: Text
issuer = Text
pIssuer_,
        $sel:authorizationEndpoint:OidcConfig' :: Text
authorizationEndpoint = Text
pAuthorizationEndpoint_,
        $sel:tokenEndpoint:OidcConfig' :: Text
tokenEndpoint = Text
pTokenEndpoint_,
        $sel:userInfoEndpoint:OidcConfig' :: Text
userInfoEndpoint = Text
pUserInfoEndpoint_,
        $sel:logoutEndpoint:OidcConfig' :: Text
logoutEndpoint = Text
pLogoutEndpoint_,
        $sel:jwksUri:OidcConfig' :: Text
jwksUri = Text
pJwksUri_
      }

-- | The OIDC IdP client ID used to configure your private workforce.
oidcConfig_clientId :: Lens.Lens' OidcConfig Prelude.Text
oidcConfig_clientId :: (Text -> f Text) -> OidcConfig -> f OidcConfig
oidcConfig_clientId = (OidcConfig -> Text)
-> (OidcConfig -> Text -> OidcConfig)
-> Lens OidcConfig OidcConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OidcConfig' {Text
clientId :: Text
$sel:clientId:OidcConfig' :: OidcConfig -> Text
clientId} -> Text
clientId) (\s :: OidcConfig
s@OidcConfig' {} Text
a -> OidcConfig
s {$sel:clientId:OidcConfig' :: Text
clientId = Text
a} :: OidcConfig)

-- | The OIDC IdP client secret used to configure your private workforce.
oidcConfig_clientSecret :: Lens.Lens' OidcConfig Prelude.Text
oidcConfig_clientSecret :: (Text -> f Text) -> OidcConfig -> f OidcConfig
oidcConfig_clientSecret = (OidcConfig -> Sensitive Text)
-> (OidcConfig -> Sensitive Text -> OidcConfig)
-> Lens OidcConfig OidcConfig (Sensitive Text) (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OidcConfig' {Sensitive Text
clientSecret :: Sensitive Text
$sel:clientSecret:OidcConfig' :: OidcConfig -> Sensitive Text
clientSecret} -> Sensitive Text
clientSecret) (\s :: OidcConfig
s@OidcConfig' {} Sensitive Text
a -> OidcConfig
s {$sel:clientSecret:OidcConfig' :: Sensitive Text
clientSecret = Sensitive Text
a} :: OidcConfig) ((Sensitive Text -> f (Sensitive Text))
 -> OidcConfig -> f OidcConfig)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> OidcConfig
-> f OidcConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The OIDC IdP issuer used to configure your private workforce.
oidcConfig_issuer :: Lens.Lens' OidcConfig Prelude.Text
oidcConfig_issuer :: (Text -> f Text) -> OidcConfig -> f OidcConfig
oidcConfig_issuer = (OidcConfig -> Text)
-> (OidcConfig -> Text -> OidcConfig)
-> Lens OidcConfig OidcConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OidcConfig' {Text
issuer :: Text
$sel:issuer:OidcConfig' :: OidcConfig -> Text
issuer} -> Text
issuer) (\s :: OidcConfig
s@OidcConfig' {} Text
a -> OidcConfig
s {$sel:issuer:OidcConfig' :: Text
issuer = Text
a} :: OidcConfig)

-- | The OIDC IdP authorization endpoint used to configure your private
-- workforce.
oidcConfig_authorizationEndpoint :: Lens.Lens' OidcConfig Prelude.Text
oidcConfig_authorizationEndpoint :: (Text -> f Text) -> OidcConfig -> f OidcConfig
oidcConfig_authorizationEndpoint = (OidcConfig -> Text)
-> (OidcConfig -> Text -> OidcConfig)
-> Lens OidcConfig OidcConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OidcConfig' {Text
authorizationEndpoint :: Text
$sel:authorizationEndpoint:OidcConfig' :: OidcConfig -> Text
authorizationEndpoint} -> Text
authorizationEndpoint) (\s :: OidcConfig
s@OidcConfig' {} Text
a -> OidcConfig
s {$sel:authorizationEndpoint:OidcConfig' :: Text
authorizationEndpoint = Text
a} :: OidcConfig)

-- | The OIDC IdP token endpoint used to configure your private workforce.
oidcConfig_tokenEndpoint :: Lens.Lens' OidcConfig Prelude.Text
oidcConfig_tokenEndpoint :: (Text -> f Text) -> OidcConfig -> f OidcConfig
oidcConfig_tokenEndpoint = (OidcConfig -> Text)
-> (OidcConfig -> Text -> OidcConfig)
-> Lens OidcConfig OidcConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OidcConfig' {Text
tokenEndpoint :: Text
$sel:tokenEndpoint:OidcConfig' :: OidcConfig -> Text
tokenEndpoint} -> Text
tokenEndpoint) (\s :: OidcConfig
s@OidcConfig' {} Text
a -> OidcConfig
s {$sel:tokenEndpoint:OidcConfig' :: Text
tokenEndpoint = Text
a} :: OidcConfig)

-- | The OIDC IdP user information endpoint used to configure your private
-- workforce.
oidcConfig_userInfoEndpoint :: Lens.Lens' OidcConfig Prelude.Text
oidcConfig_userInfoEndpoint :: (Text -> f Text) -> OidcConfig -> f OidcConfig
oidcConfig_userInfoEndpoint = (OidcConfig -> Text)
-> (OidcConfig -> Text -> OidcConfig)
-> Lens OidcConfig OidcConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OidcConfig' {Text
userInfoEndpoint :: Text
$sel:userInfoEndpoint:OidcConfig' :: OidcConfig -> Text
userInfoEndpoint} -> Text
userInfoEndpoint) (\s :: OidcConfig
s@OidcConfig' {} Text
a -> OidcConfig
s {$sel:userInfoEndpoint:OidcConfig' :: Text
userInfoEndpoint = Text
a} :: OidcConfig)

-- | The OIDC IdP logout endpoint used to configure your private workforce.
oidcConfig_logoutEndpoint :: Lens.Lens' OidcConfig Prelude.Text
oidcConfig_logoutEndpoint :: (Text -> f Text) -> OidcConfig -> f OidcConfig
oidcConfig_logoutEndpoint = (OidcConfig -> Text)
-> (OidcConfig -> Text -> OidcConfig)
-> Lens OidcConfig OidcConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OidcConfig' {Text
logoutEndpoint :: Text
$sel:logoutEndpoint:OidcConfig' :: OidcConfig -> Text
logoutEndpoint} -> Text
logoutEndpoint) (\s :: OidcConfig
s@OidcConfig' {} Text
a -> OidcConfig
s {$sel:logoutEndpoint:OidcConfig' :: Text
logoutEndpoint = Text
a} :: OidcConfig)

-- | The OIDC IdP JSON Web Key Set (Jwks) URI used to configure your private
-- workforce.
oidcConfig_jwksUri :: Lens.Lens' OidcConfig Prelude.Text
oidcConfig_jwksUri :: (Text -> f Text) -> OidcConfig -> f OidcConfig
oidcConfig_jwksUri = (OidcConfig -> Text)
-> (OidcConfig -> Text -> OidcConfig)
-> Lens OidcConfig OidcConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OidcConfig' {Text
jwksUri :: Text
$sel:jwksUri:OidcConfig' :: OidcConfig -> Text
jwksUri} -> Text
jwksUri) (\s :: OidcConfig
s@OidcConfig' {} Text
a -> OidcConfig
s {$sel:jwksUri:OidcConfig' :: Text
jwksUri = Text
a} :: OidcConfig)

instance Prelude.Hashable OidcConfig

instance Prelude.NFData OidcConfig

instance Core.ToJSON OidcConfig where
  toJSON :: OidcConfig -> Value
toJSON OidcConfig' {Text
Sensitive Text
jwksUri :: Text
logoutEndpoint :: Text
userInfoEndpoint :: Text
tokenEndpoint :: Text
authorizationEndpoint :: Text
issuer :: Text
clientSecret :: Sensitive Text
clientId :: Text
$sel:jwksUri:OidcConfig' :: OidcConfig -> Text
$sel:logoutEndpoint:OidcConfig' :: OidcConfig -> Text
$sel:userInfoEndpoint:OidcConfig' :: OidcConfig -> Text
$sel:tokenEndpoint:OidcConfig' :: OidcConfig -> Text
$sel:authorizationEndpoint:OidcConfig' :: OidcConfig -> Text
$sel:issuer:OidcConfig' :: OidcConfig -> Text
$sel:clientSecret:OidcConfig' :: OidcConfig -> Sensitive Text
$sel:clientId:OidcConfig' :: OidcConfig -> 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
"ClientId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
clientId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ClientSecret" Text -> Sensitive Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Sensitive Text
clientSecret),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Issuer" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
issuer),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"AuthorizationEndpoint"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
authorizationEndpoint
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"TokenEndpoint" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
tokenEndpoint),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"UserInfoEndpoint" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
userInfoEndpoint),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"LogoutEndpoint" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
logoutEndpoint),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"JwksUri" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
jwksUri)
          ]
      )