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

-- | 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 :: Data.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
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
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. 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'
      { $sel:clientId:OidcConfig' :: Text
clientId = Text
pClientId_,
        $sel:clientSecret:OidcConfig' :: Sensitive Text
clientSecret = forall a. Iso' (Sensitive a) a
Data._Sensitive 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 :: Lens' OidcConfig Text
oidcConfig_clientId = 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 :: Lens' OidcConfig Text
oidcConfig_clientSecret = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The OIDC IdP issuer used to configure your private workforce.
oidcConfig_issuer :: Lens.Lens' OidcConfig Prelude.Text
oidcConfig_issuer :: Lens' OidcConfig Text
oidcConfig_issuer = 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 :: Lens' OidcConfig Text
oidcConfig_authorizationEndpoint = 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 :: Lens' OidcConfig Text
oidcConfig_tokenEndpoint = 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 :: Lens' OidcConfig Text
oidcConfig_userInfoEndpoint = 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 :: Lens' OidcConfig Text
oidcConfig_logoutEndpoint = 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 :: Lens' OidcConfig Text
oidcConfig_jwksUri = 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 where
  hashWithSalt :: Int -> OidcConfig -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clientId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
clientSecret
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
issuer
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
authorizationEndpoint
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
tokenEndpoint
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userInfoEndpoint
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
logoutEndpoint
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
jwksUri

instance Prelude.NFData OidcConfig where
  rnf :: OidcConfig -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
clientId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
clientSecret
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
issuer
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
authorizationEndpoint
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
tokenEndpoint
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
userInfoEndpoint
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
logoutEndpoint
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
jwksUri

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"ClientId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
clientId),
            forall a. a -> Maybe a
Prelude.Just (Key
"ClientSecret" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
clientSecret),
            forall a. a -> Maybe a
Prelude.Just (Key
"Issuer" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
issuer),
            forall a. a -> Maybe a
Prelude.Just
              ( Key
"AuthorizationEndpoint"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
authorizationEndpoint
              ),
            forall a. a -> Maybe a
Prelude.Just (Key
"TokenEndpoint" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
tokenEndpoint),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"UserInfoEndpoint" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
userInfoEndpoint),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"LogoutEndpoint" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
logoutEndpoint),
            forall a. a -> Maybe a
Prelude.Just (Key
"JwksUri" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
jwksUri)
          ]
      )