{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.CognitoIdentityProvider.CreateIdentityProvider
-- 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)
--
-- Creates an identity provider for a user pool.
module Amazonka.CognitoIdentityProvider.CreateIdentityProvider
  ( -- * Creating a Request
    CreateIdentityProvider (..),
    newCreateIdentityProvider,

    -- * Request Lenses
    createIdentityProvider_idpIdentifiers,
    createIdentityProvider_attributeMapping,
    createIdentityProvider_userPoolId,
    createIdentityProvider_providerName,
    createIdentityProvider_providerType,
    createIdentityProvider_providerDetails,

    -- * Destructuring the Response
    CreateIdentityProviderResponse (..),
    newCreateIdentityProviderResponse,

    -- * Response Lenses
    createIdentityProviderResponse_httpStatus,
    createIdentityProviderResponse_identityProvider,
  )
where

import Amazonka.CognitoIdentityProvider.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newCreateIdentityProvider' smart constructor.
data CreateIdentityProvider = CreateIdentityProvider'
  { -- | A list of identity provider identifiers.
    CreateIdentityProvider -> Maybe [Text]
idpIdentifiers :: Prelude.Maybe [Prelude.Text],
    -- | A mapping of identity provider attributes to standard and custom user
    -- pool attributes.
    CreateIdentityProvider -> Maybe (HashMap Text Text)
attributeMapping :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The user pool ID.
    CreateIdentityProvider -> Text
userPoolId :: Prelude.Text,
    -- | The identity provider name.
    CreateIdentityProvider -> Text
providerName :: Prelude.Text,
    -- | The identity provider type.
    CreateIdentityProvider -> IdentityProviderTypeType
providerType :: IdentityProviderTypeType,
    -- | The identity provider details. The following list describes the provider
    -- detail keys for each identity provider type.
    --
    -- -   For Google and Login with Amazon:
    --
    --     -   client_id
    --
    --     -   client_secret
    --
    --     -   authorize_scopes
    --
    -- -   For Facebook:
    --
    --     -   client_id
    --
    --     -   client_secret
    --
    --     -   authorize_scopes
    --
    --     -   api_version
    --
    -- -   For Sign in with Apple:
    --
    --     -   client_id
    --
    --     -   team_id
    --
    --     -   key_id
    --
    --     -   private_key
    --
    --     -   authorize_scopes
    --
    -- -   For OIDC providers:
    --
    --     -   client_id
    --
    --     -   client_secret
    --
    --     -   attributes_request_method
    --
    --     -   oidc_issuer
    --
    --     -   authorize_scopes
    --
    --     -   authorize_url /if not available from discovery URL specified by
    --         oidc_issuer key/
    --
    --     -   token_url /if not available from discovery URL specified by
    --         oidc_issuer key/
    --
    --     -   attributes_url /if not available from discovery URL specified by
    --         oidc_issuer key/
    --
    --     -   jwks_uri /if not available from discovery URL specified by
    --         oidc_issuer key/
    --
    -- -   For SAML providers:
    --
    --     -   MetadataFile OR MetadataURL
    --
    --     -   IDPSignout /optional/
    CreateIdentityProvider -> HashMap Text Text
providerDetails :: Prelude.HashMap Prelude.Text Prelude.Text
  }
  deriving (CreateIdentityProvider -> CreateIdentityProvider -> Bool
(CreateIdentityProvider -> CreateIdentityProvider -> Bool)
-> (CreateIdentityProvider -> CreateIdentityProvider -> Bool)
-> Eq CreateIdentityProvider
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateIdentityProvider -> CreateIdentityProvider -> Bool
$c/= :: CreateIdentityProvider -> CreateIdentityProvider -> Bool
== :: CreateIdentityProvider -> CreateIdentityProvider -> Bool
$c== :: CreateIdentityProvider -> CreateIdentityProvider -> Bool
Prelude.Eq, ReadPrec [CreateIdentityProvider]
ReadPrec CreateIdentityProvider
Int -> ReadS CreateIdentityProvider
ReadS [CreateIdentityProvider]
(Int -> ReadS CreateIdentityProvider)
-> ReadS [CreateIdentityProvider]
-> ReadPrec CreateIdentityProvider
-> ReadPrec [CreateIdentityProvider]
-> Read CreateIdentityProvider
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateIdentityProvider]
$creadListPrec :: ReadPrec [CreateIdentityProvider]
readPrec :: ReadPrec CreateIdentityProvider
$creadPrec :: ReadPrec CreateIdentityProvider
readList :: ReadS [CreateIdentityProvider]
$creadList :: ReadS [CreateIdentityProvider]
readsPrec :: Int -> ReadS CreateIdentityProvider
$creadsPrec :: Int -> ReadS CreateIdentityProvider
Prelude.Read, Int -> CreateIdentityProvider -> ShowS
[CreateIdentityProvider] -> ShowS
CreateIdentityProvider -> String
(Int -> CreateIdentityProvider -> ShowS)
-> (CreateIdentityProvider -> String)
-> ([CreateIdentityProvider] -> ShowS)
-> Show CreateIdentityProvider
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateIdentityProvider] -> ShowS
$cshowList :: [CreateIdentityProvider] -> ShowS
show :: CreateIdentityProvider -> String
$cshow :: CreateIdentityProvider -> String
showsPrec :: Int -> CreateIdentityProvider -> ShowS
$cshowsPrec :: Int -> CreateIdentityProvider -> ShowS
Prelude.Show, (forall x. CreateIdentityProvider -> Rep CreateIdentityProvider x)
-> (forall x.
    Rep CreateIdentityProvider x -> CreateIdentityProvider)
-> Generic CreateIdentityProvider
forall x. Rep CreateIdentityProvider x -> CreateIdentityProvider
forall x. CreateIdentityProvider -> Rep CreateIdentityProvider x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateIdentityProvider x -> CreateIdentityProvider
$cfrom :: forall x. CreateIdentityProvider -> Rep CreateIdentityProvider x
Prelude.Generic)

-- |
-- Create a value of 'CreateIdentityProvider' 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:
--
-- 'idpIdentifiers', 'createIdentityProvider_idpIdentifiers' - A list of identity provider identifiers.
--
-- 'attributeMapping', 'createIdentityProvider_attributeMapping' - A mapping of identity provider attributes to standard and custom user
-- pool attributes.
--
-- 'userPoolId', 'createIdentityProvider_userPoolId' - The user pool ID.
--
-- 'providerName', 'createIdentityProvider_providerName' - The identity provider name.
--
-- 'providerType', 'createIdentityProvider_providerType' - The identity provider type.
--
-- 'providerDetails', 'createIdentityProvider_providerDetails' - The identity provider details. The following list describes the provider
-- detail keys for each identity provider type.
--
-- -   For Google and Login with Amazon:
--
--     -   client_id
--
--     -   client_secret
--
--     -   authorize_scopes
--
-- -   For Facebook:
--
--     -   client_id
--
--     -   client_secret
--
--     -   authorize_scopes
--
--     -   api_version
--
-- -   For Sign in with Apple:
--
--     -   client_id
--
--     -   team_id
--
--     -   key_id
--
--     -   private_key
--
--     -   authorize_scopes
--
-- -   For OIDC providers:
--
--     -   client_id
--
--     -   client_secret
--
--     -   attributes_request_method
--
--     -   oidc_issuer
--
--     -   authorize_scopes
--
--     -   authorize_url /if not available from discovery URL specified by
--         oidc_issuer key/
--
--     -   token_url /if not available from discovery URL specified by
--         oidc_issuer key/
--
--     -   attributes_url /if not available from discovery URL specified by
--         oidc_issuer key/
--
--     -   jwks_uri /if not available from discovery URL specified by
--         oidc_issuer key/
--
-- -   For SAML providers:
--
--     -   MetadataFile OR MetadataURL
--
--     -   IDPSignout /optional/
newCreateIdentityProvider ::
  -- | 'userPoolId'
  Prelude.Text ->
  -- | 'providerName'
  Prelude.Text ->
  -- | 'providerType'
  IdentityProviderTypeType ->
  CreateIdentityProvider
newCreateIdentityProvider :: Text -> Text -> IdentityProviderTypeType -> CreateIdentityProvider
newCreateIdentityProvider
  Text
pUserPoolId_
  Text
pProviderName_
  IdentityProviderTypeType
pProviderType_ =
    CreateIdentityProvider' :: Maybe [Text]
-> Maybe (HashMap Text Text)
-> Text
-> Text
-> IdentityProviderTypeType
-> HashMap Text Text
-> CreateIdentityProvider
CreateIdentityProvider'
      { $sel:idpIdentifiers:CreateIdentityProvider' :: Maybe [Text]
idpIdentifiers =
          Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
        $sel:attributeMapping:CreateIdentityProvider' :: Maybe (HashMap Text Text)
attributeMapping = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
        $sel:userPoolId:CreateIdentityProvider' :: Text
userPoolId = Text
pUserPoolId_,
        $sel:providerName:CreateIdentityProvider' :: Text
providerName = Text
pProviderName_,
        $sel:providerType:CreateIdentityProvider' :: IdentityProviderTypeType
providerType = IdentityProviderTypeType
pProviderType_,
        $sel:providerDetails:CreateIdentityProvider' :: HashMap Text Text
providerDetails = HashMap Text Text
forall a. Monoid a => a
Prelude.mempty
      }

-- | A list of identity provider identifiers.
createIdentityProvider_idpIdentifiers :: Lens.Lens' CreateIdentityProvider (Prelude.Maybe [Prelude.Text])
createIdentityProvider_idpIdentifiers :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateIdentityProvider -> f CreateIdentityProvider
createIdentityProvider_idpIdentifiers = (CreateIdentityProvider -> Maybe [Text])
-> (CreateIdentityProvider
    -> Maybe [Text] -> CreateIdentityProvider)
-> Lens
     CreateIdentityProvider
     CreateIdentityProvider
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIdentityProvider' {Maybe [Text]
idpIdentifiers :: Maybe [Text]
$sel:idpIdentifiers:CreateIdentityProvider' :: CreateIdentityProvider -> Maybe [Text]
idpIdentifiers} -> Maybe [Text]
idpIdentifiers) (\s :: CreateIdentityProvider
s@CreateIdentityProvider' {} Maybe [Text]
a -> CreateIdentityProvider
s {$sel:idpIdentifiers:CreateIdentityProvider' :: Maybe [Text]
idpIdentifiers = Maybe [Text]
a} :: CreateIdentityProvider) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateIdentityProvider -> f CreateIdentityProvider)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateIdentityProvider
-> f CreateIdentityProvider
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A mapping of identity provider attributes to standard and custom user
-- pool attributes.
createIdentityProvider_attributeMapping :: Lens.Lens' CreateIdentityProvider (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createIdentityProvider_attributeMapping :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateIdentityProvider -> f CreateIdentityProvider
createIdentityProvider_attributeMapping = (CreateIdentityProvider -> Maybe (HashMap Text Text))
-> (CreateIdentityProvider
    -> Maybe (HashMap Text Text) -> CreateIdentityProvider)
-> Lens
     CreateIdentityProvider
     CreateIdentityProvider
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIdentityProvider' {Maybe (HashMap Text Text)
attributeMapping :: Maybe (HashMap Text Text)
$sel:attributeMapping:CreateIdentityProvider' :: CreateIdentityProvider -> Maybe (HashMap Text Text)
attributeMapping} -> Maybe (HashMap Text Text)
attributeMapping) (\s :: CreateIdentityProvider
s@CreateIdentityProvider' {} Maybe (HashMap Text Text)
a -> CreateIdentityProvider
s {$sel:attributeMapping:CreateIdentityProvider' :: Maybe (HashMap Text Text)
attributeMapping = Maybe (HashMap Text Text)
a} :: CreateIdentityProvider) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateIdentityProvider -> f CreateIdentityProvider)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateIdentityProvider
-> f CreateIdentityProvider
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The user pool ID.
createIdentityProvider_userPoolId :: Lens.Lens' CreateIdentityProvider Prelude.Text
createIdentityProvider_userPoolId :: (Text -> f Text)
-> CreateIdentityProvider -> f CreateIdentityProvider
createIdentityProvider_userPoolId = (CreateIdentityProvider -> Text)
-> (CreateIdentityProvider -> Text -> CreateIdentityProvider)
-> Lens CreateIdentityProvider CreateIdentityProvider Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIdentityProvider' {Text
userPoolId :: Text
$sel:userPoolId:CreateIdentityProvider' :: CreateIdentityProvider -> Text
userPoolId} -> Text
userPoolId) (\s :: CreateIdentityProvider
s@CreateIdentityProvider' {} Text
a -> CreateIdentityProvider
s {$sel:userPoolId:CreateIdentityProvider' :: Text
userPoolId = Text
a} :: CreateIdentityProvider)

-- | The identity provider name.
createIdentityProvider_providerName :: Lens.Lens' CreateIdentityProvider Prelude.Text
createIdentityProvider_providerName :: (Text -> f Text)
-> CreateIdentityProvider -> f CreateIdentityProvider
createIdentityProvider_providerName = (CreateIdentityProvider -> Text)
-> (CreateIdentityProvider -> Text -> CreateIdentityProvider)
-> Lens CreateIdentityProvider CreateIdentityProvider Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIdentityProvider' {Text
providerName :: Text
$sel:providerName:CreateIdentityProvider' :: CreateIdentityProvider -> Text
providerName} -> Text
providerName) (\s :: CreateIdentityProvider
s@CreateIdentityProvider' {} Text
a -> CreateIdentityProvider
s {$sel:providerName:CreateIdentityProvider' :: Text
providerName = Text
a} :: CreateIdentityProvider)

-- | The identity provider type.
createIdentityProvider_providerType :: Lens.Lens' CreateIdentityProvider IdentityProviderTypeType
createIdentityProvider_providerType :: (IdentityProviderTypeType -> f IdentityProviderTypeType)
-> CreateIdentityProvider -> f CreateIdentityProvider
createIdentityProvider_providerType = (CreateIdentityProvider -> IdentityProviderTypeType)
-> (CreateIdentityProvider
    -> IdentityProviderTypeType -> CreateIdentityProvider)
-> Lens
     CreateIdentityProvider
     CreateIdentityProvider
     IdentityProviderTypeType
     IdentityProviderTypeType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIdentityProvider' {IdentityProviderTypeType
providerType :: IdentityProviderTypeType
$sel:providerType:CreateIdentityProvider' :: CreateIdentityProvider -> IdentityProviderTypeType
providerType} -> IdentityProviderTypeType
providerType) (\s :: CreateIdentityProvider
s@CreateIdentityProvider' {} IdentityProviderTypeType
a -> CreateIdentityProvider
s {$sel:providerType:CreateIdentityProvider' :: IdentityProviderTypeType
providerType = IdentityProviderTypeType
a} :: CreateIdentityProvider)

-- | The identity provider details. The following list describes the provider
-- detail keys for each identity provider type.
--
-- -   For Google and Login with Amazon:
--
--     -   client_id
--
--     -   client_secret
--
--     -   authorize_scopes
--
-- -   For Facebook:
--
--     -   client_id
--
--     -   client_secret
--
--     -   authorize_scopes
--
--     -   api_version
--
-- -   For Sign in with Apple:
--
--     -   client_id
--
--     -   team_id
--
--     -   key_id
--
--     -   private_key
--
--     -   authorize_scopes
--
-- -   For OIDC providers:
--
--     -   client_id
--
--     -   client_secret
--
--     -   attributes_request_method
--
--     -   oidc_issuer
--
--     -   authorize_scopes
--
--     -   authorize_url /if not available from discovery URL specified by
--         oidc_issuer key/
--
--     -   token_url /if not available from discovery URL specified by
--         oidc_issuer key/
--
--     -   attributes_url /if not available from discovery URL specified by
--         oidc_issuer key/
--
--     -   jwks_uri /if not available from discovery URL specified by
--         oidc_issuer key/
--
-- -   For SAML providers:
--
--     -   MetadataFile OR MetadataURL
--
--     -   IDPSignout /optional/
createIdentityProvider_providerDetails :: Lens.Lens' CreateIdentityProvider (Prelude.HashMap Prelude.Text Prelude.Text)
createIdentityProvider_providerDetails :: (HashMap Text Text -> f (HashMap Text Text))
-> CreateIdentityProvider -> f CreateIdentityProvider
createIdentityProvider_providerDetails = (CreateIdentityProvider -> HashMap Text Text)
-> (CreateIdentityProvider
    -> HashMap Text Text -> CreateIdentityProvider)
-> Lens
     CreateIdentityProvider
     CreateIdentityProvider
     (HashMap Text Text)
     (HashMap Text Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIdentityProvider' {HashMap Text Text
providerDetails :: HashMap Text Text
$sel:providerDetails:CreateIdentityProvider' :: CreateIdentityProvider -> HashMap Text Text
providerDetails} -> HashMap Text Text
providerDetails) (\s :: CreateIdentityProvider
s@CreateIdentityProvider' {} HashMap Text Text
a -> CreateIdentityProvider
s {$sel:providerDetails:CreateIdentityProvider' :: HashMap Text Text
providerDetails = HashMap Text Text
a} :: CreateIdentityProvider) ((HashMap Text Text -> f (HashMap Text Text))
 -> CreateIdentityProvider -> f CreateIdentityProvider)
-> ((HashMap Text Text -> f (HashMap Text Text))
    -> HashMap Text Text -> f (HashMap Text Text))
-> (HashMap Text Text -> f (HashMap Text Text))
-> CreateIdentityProvider
-> f CreateIdentityProvider
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest CreateIdentityProvider where
  type
    AWSResponse CreateIdentityProvider =
      CreateIdentityProviderResponse
  request :: CreateIdentityProvider -> Request CreateIdentityProvider
request = Service -> CreateIdentityProvider -> Request CreateIdentityProvider
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy CreateIdentityProvider
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateIdentityProvider)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse CreateIdentityProvider))
-> Logger
-> Service
-> Proxy CreateIdentityProvider
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse CreateIdentityProvider)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> IdentityProviderType -> CreateIdentityProviderResponse
CreateIdentityProviderResponse'
            (Int -> IdentityProviderType -> CreateIdentityProviderResponse)
-> Either String Int
-> Either
     String (IdentityProviderType -> CreateIdentityProviderResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either
  String (IdentityProviderType -> CreateIdentityProviderResponse)
-> Either String IdentityProviderType
-> Either String CreateIdentityProviderResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String IdentityProviderType
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"IdentityProvider")
      )

instance Prelude.Hashable CreateIdentityProvider

instance Prelude.NFData CreateIdentityProvider

instance Core.ToHeaders CreateIdentityProvider where
  toHeaders :: CreateIdentityProvider -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateIdentityProvider -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSCognitoIdentityProviderService.CreateIdentityProvider" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON CreateIdentityProvider where
  toJSON :: CreateIdentityProvider -> Value
toJSON CreateIdentityProvider' {Maybe [Text]
Maybe (HashMap Text Text)
Text
HashMap Text Text
IdentityProviderTypeType
providerDetails :: HashMap Text Text
providerType :: IdentityProviderTypeType
providerName :: Text
userPoolId :: Text
attributeMapping :: Maybe (HashMap Text Text)
idpIdentifiers :: Maybe [Text]
$sel:providerDetails:CreateIdentityProvider' :: CreateIdentityProvider -> HashMap Text Text
$sel:providerType:CreateIdentityProvider' :: CreateIdentityProvider -> IdentityProviderTypeType
$sel:providerName:CreateIdentityProvider' :: CreateIdentityProvider -> Text
$sel:userPoolId:CreateIdentityProvider' :: CreateIdentityProvider -> Text
$sel:attributeMapping:CreateIdentityProvider' :: CreateIdentityProvider -> Maybe (HashMap Text Text)
$sel:idpIdentifiers:CreateIdentityProvider' :: CreateIdentityProvider -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"IdpIdentifiers" 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]
idpIdentifiers,
            (Text
"AttributeMapping" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
attributeMapping,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"UserPoolId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
userPoolId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ProviderName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
providerName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ProviderType" Text -> IdentityProviderTypeType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= IdentityProviderTypeType
providerType),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ProviderDetails" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HashMap Text Text
providerDetails)
          ]
      )

instance Core.ToPath CreateIdentityProvider where
  toPath :: CreateIdentityProvider -> ByteString
toPath = ByteString -> CreateIdentityProvider -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery CreateIdentityProvider where
  toQuery :: CreateIdentityProvider -> QueryString
toQuery = QueryString -> CreateIdentityProvider -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newCreateIdentityProviderResponse' smart constructor.
data CreateIdentityProviderResponse = CreateIdentityProviderResponse'
  { -- | The response's http status code.
    CreateIdentityProviderResponse -> Int
httpStatus :: Prelude.Int,
    -- | The newly created identity provider object.
    CreateIdentityProviderResponse -> IdentityProviderType
identityProvider :: IdentityProviderType
  }
  deriving (CreateIdentityProviderResponse
-> CreateIdentityProviderResponse -> Bool
(CreateIdentityProviderResponse
 -> CreateIdentityProviderResponse -> Bool)
-> (CreateIdentityProviderResponse
    -> CreateIdentityProviderResponse -> Bool)
-> Eq CreateIdentityProviderResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateIdentityProviderResponse
-> CreateIdentityProviderResponse -> Bool
$c/= :: CreateIdentityProviderResponse
-> CreateIdentityProviderResponse -> Bool
== :: CreateIdentityProviderResponse
-> CreateIdentityProviderResponse -> Bool
$c== :: CreateIdentityProviderResponse
-> CreateIdentityProviderResponse -> Bool
Prelude.Eq, ReadPrec [CreateIdentityProviderResponse]
ReadPrec CreateIdentityProviderResponse
Int -> ReadS CreateIdentityProviderResponse
ReadS [CreateIdentityProviderResponse]
(Int -> ReadS CreateIdentityProviderResponse)
-> ReadS [CreateIdentityProviderResponse]
-> ReadPrec CreateIdentityProviderResponse
-> ReadPrec [CreateIdentityProviderResponse]
-> Read CreateIdentityProviderResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateIdentityProviderResponse]
$creadListPrec :: ReadPrec [CreateIdentityProviderResponse]
readPrec :: ReadPrec CreateIdentityProviderResponse
$creadPrec :: ReadPrec CreateIdentityProviderResponse
readList :: ReadS [CreateIdentityProviderResponse]
$creadList :: ReadS [CreateIdentityProviderResponse]
readsPrec :: Int -> ReadS CreateIdentityProviderResponse
$creadsPrec :: Int -> ReadS CreateIdentityProviderResponse
Prelude.Read, Int -> CreateIdentityProviderResponse -> ShowS
[CreateIdentityProviderResponse] -> ShowS
CreateIdentityProviderResponse -> String
(Int -> CreateIdentityProviderResponse -> ShowS)
-> (CreateIdentityProviderResponse -> String)
-> ([CreateIdentityProviderResponse] -> ShowS)
-> Show CreateIdentityProviderResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateIdentityProviderResponse] -> ShowS
$cshowList :: [CreateIdentityProviderResponse] -> ShowS
show :: CreateIdentityProviderResponse -> String
$cshow :: CreateIdentityProviderResponse -> String
showsPrec :: Int -> CreateIdentityProviderResponse -> ShowS
$cshowsPrec :: Int -> CreateIdentityProviderResponse -> ShowS
Prelude.Show, (forall x.
 CreateIdentityProviderResponse
 -> Rep CreateIdentityProviderResponse x)
-> (forall x.
    Rep CreateIdentityProviderResponse x
    -> CreateIdentityProviderResponse)
-> Generic CreateIdentityProviderResponse
forall x.
Rep CreateIdentityProviderResponse x
-> CreateIdentityProviderResponse
forall x.
CreateIdentityProviderResponse
-> Rep CreateIdentityProviderResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateIdentityProviderResponse x
-> CreateIdentityProviderResponse
$cfrom :: forall x.
CreateIdentityProviderResponse
-> Rep CreateIdentityProviderResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateIdentityProviderResponse' 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:
--
-- 'httpStatus', 'createIdentityProviderResponse_httpStatus' - The response's http status code.
--
-- 'identityProvider', 'createIdentityProviderResponse_identityProvider' - The newly created identity provider object.
newCreateIdentityProviderResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'identityProvider'
  IdentityProviderType ->
  CreateIdentityProviderResponse
newCreateIdentityProviderResponse :: Int -> IdentityProviderType -> CreateIdentityProviderResponse
newCreateIdentityProviderResponse
  Int
pHttpStatus_
  IdentityProviderType
pIdentityProvider_ =
    CreateIdentityProviderResponse' :: Int -> IdentityProviderType -> CreateIdentityProviderResponse
CreateIdentityProviderResponse'
      { $sel:httpStatus:CreateIdentityProviderResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:identityProvider:CreateIdentityProviderResponse' :: IdentityProviderType
identityProvider = IdentityProviderType
pIdentityProvider_
      }

-- | The response's http status code.
createIdentityProviderResponse_httpStatus :: Lens.Lens' CreateIdentityProviderResponse Prelude.Int
createIdentityProviderResponse_httpStatus :: (Int -> f Int)
-> CreateIdentityProviderResponse
-> f CreateIdentityProviderResponse
createIdentityProviderResponse_httpStatus = (CreateIdentityProviderResponse -> Int)
-> (CreateIdentityProviderResponse
    -> Int -> CreateIdentityProviderResponse)
-> Lens
     CreateIdentityProviderResponse
     CreateIdentityProviderResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIdentityProviderResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateIdentityProviderResponse' :: CreateIdentityProviderResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateIdentityProviderResponse
s@CreateIdentityProviderResponse' {} Int
a -> CreateIdentityProviderResponse
s {$sel:httpStatus:CreateIdentityProviderResponse' :: Int
httpStatus = Int
a} :: CreateIdentityProviderResponse)

-- | The newly created identity provider object.
createIdentityProviderResponse_identityProvider :: Lens.Lens' CreateIdentityProviderResponse IdentityProviderType
createIdentityProviderResponse_identityProvider :: (IdentityProviderType -> f IdentityProviderType)
-> CreateIdentityProviderResponse
-> f CreateIdentityProviderResponse
createIdentityProviderResponse_identityProvider = (CreateIdentityProviderResponse -> IdentityProviderType)
-> (CreateIdentityProviderResponse
    -> IdentityProviderType -> CreateIdentityProviderResponse)
-> Lens
     CreateIdentityProviderResponse
     CreateIdentityProviderResponse
     IdentityProviderType
     IdentityProviderType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateIdentityProviderResponse' {IdentityProviderType
identityProvider :: IdentityProviderType
$sel:identityProvider:CreateIdentityProviderResponse' :: CreateIdentityProviderResponse -> IdentityProviderType
identityProvider} -> IdentityProviderType
identityProvider) (\s :: CreateIdentityProviderResponse
s@CreateIdentityProviderResponse' {} IdentityProviderType
a -> CreateIdentityProviderResponse
s {$sel:identityProvider:CreateIdentityProviderResponse' :: IdentityProviderType
identityProvider = IdentityProviderType
a} :: CreateIdentityProviderResponse)

instance
  Prelude.NFData
    CreateIdentityProviderResponse