{-# 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.DescribeIdentityProvider
-- 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)
--
-- Gets information about a specific identity provider.
module Amazonka.CognitoIdentityProvider.DescribeIdentityProvider
  ( -- * Creating a Request
    DescribeIdentityProvider (..),
    newDescribeIdentityProvider,

    -- * Request Lenses
    describeIdentityProvider_userPoolId,
    describeIdentityProvider_providerName,

    -- * Destructuring the Response
    DescribeIdentityProviderResponse (..),
    newDescribeIdentityProviderResponse,

    -- * Response Lenses
    describeIdentityProviderResponse_httpStatus,
    describeIdentityProviderResponse_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:/ 'newDescribeIdentityProvider' smart constructor.
data DescribeIdentityProvider = DescribeIdentityProvider'
  { -- | The user pool ID.
    DescribeIdentityProvider -> Text
userPoolId :: Prelude.Text,
    -- | The identity provider name.
    DescribeIdentityProvider -> Text
providerName :: Prelude.Text
  }
  deriving (DescribeIdentityProvider -> DescribeIdentityProvider -> Bool
(DescribeIdentityProvider -> DescribeIdentityProvider -> Bool)
-> (DescribeIdentityProvider -> DescribeIdentityProvider -> Bool)
-> Eq DescribeIdentityProvider
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeIdentityProvider -> DescribeIdentityProvider -> Bool
$c/= :: DescribeIdentityProvider -> DescribeIdentityProvider -> Bool
== :: DescribeIdentityProvider -> DescribeIdentityProvider -> Bool
$c== :: DescribeIdentityProvider -> DescribeIdentityProvider -> Bool
Prelude.Eq, ReadPrec [DescribeIdentityProvider]
ReadPrec DescribeIdentityProvider
Int -> ReadS DescribeIdentityProvider
ReadS [DescribeIdentityProvider]
(Int -> ReadS DescribeIdentityProvider)
-> ReadS [DescribeIdentityProvider]
-> ReadPrec DescribeIdentityProvider
-> ReadPrec [DescribeIdentityProvider]
-> Read DescribeIdentityProvider
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeIdentityProvider]
$creadListPrec :: ReadPrec [DescribeIdentityProvider]
readPrec :: ReadPrec DescribeIdentityProvider
$creadPrec :: ReadPrec DescribeIdentityProvider
readList :: ReadS [DescribeIdentityProvider]
$creadList :: ReadS [DescribeIdentityProvider]
readsPrec :: Int -> ReadS DescribeIdentityProvider
$creadsPrec :: Int -> ReadS DescribeIdentityProvider
Prelude.Read, Int -> DescribeIdentityProvider -> ShowS
[DescribeIdentityProvider] -> ShowS
DescribeIdentityProvider -> String
(Int -> DescribeIdentityProvider -> ShowS)
-> (DescribeIdentityProvider -> String)
-> ([DescribeIdentityProvider] -> ShowS)
-> Show DescribeIdentityProvider
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeIdentityProvider] -> ShowS
$cshowList :: [DescribeIdentityProvider] -> ShowS
show :: DescribeIdentityProvider -> String
$cshow :: DescribeIdentityProvider -> String
showsPrec :: Int -> DescribeIdentityProvider -> ShowS
$cshowsPrec :: Int -> DescribeIdentityProvider -> ShowS
Prelude.Show, (forall x.
 DescribeIdentityProvider -> Rep DescribeIdentityProvider x)
-> (forall x.
    Rep DescribeIdentityProvider x -> DescribeIdentityProvider)
-> Generic DescribeIdentityProvider
forall x.
Rep DescribeIdentityProvider x -> DescribeIdentityProvider
forall x.
DescribeIdentityProvider -> Rep DescribeIdentityProvider x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeIdentityProvider x -> DescribeIdentityProvider
$cfrom :: forall x.
DescribeIdentityProvider -> Rep DescribeIdentityProvider x
Prelude.Generic)

-- |
-- Create a value of 'DescribeIdentityProvider' 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:
--
-- 'userPoolId', 'describeIdentityProvider_userPoolId' - The user pool ID.
--
-- 'providerName', 'describeIdentityProvider_providerName' - The identity provider name.
newDescribeIdentityProvider ::
  -- | 'userPoolId'
  Prelude.Text ->
  -- | 'providerName'
  Prelude.Text ->
  DescribeIdentityProvider
newDescribeIdentityProvider :: Text -> Text -> DescribeIdentityProvider
newDescribeIdentityProvider
  Text
pUserPoolId_
  Text
pProviderName_ =
    DescribeIdentityProvider' :: Text -> Text -> DescribeIdentityProvider
DescribeIdentityProvider'
      { $sel:userPoolId:DescribeIdentityProvider' :: Text
userPoolId =
          Text
pUserPoolId_,
        $sel:providerName:DescribeIdentityProvider' :: Text
providerName = Text
pProviderName_
      }

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

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

instance Core.AWSRequest DescribeIdentityProvider where
  type
    AWSResponse DescribeIdentityProvider =
      DescribeIdentityProviderResponse
  request :: DescribeIdentityProvider -> Request DescribeIdentityProvider
request = Service
-> DescribeIdentityProvider -> Request DescribeIdentityProvider
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeIdentityProvider
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeIdentityProvider)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeIdentityProvider))
-> Logger
-> Service
-> Proxy DescribeIdentityProvider
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeIdentityProvider)))
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 -> DescribeIdentityProviderResponse
DescribeIdentityProviderResponse'
            (Int -> IdentityProviderType -> DescribeIdentityProviderResponse)
-> Either String Int
-> Either
     String (IdentityProviderType -> DescribeIdentityProviderResponse)
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 -> DescribeIdentityProviderResponse)
-> Either String IdentityProviderType
-> Either String DescribeIdentityProviderResponse
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 DescribeIdentityProvider

instance Prelude.NFData DescribeIdentityProvider

instance Core.ToHeaders DescribeIdentityProvider where
  toHeaders :: DescribeIdentityProvider -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeIdentityProvider -> 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.DescribeIdentityProvider" ::
                          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 DescribeIdentityProvider where
  toJSON :: DescribeIdentityProvider -> Value
toJSON DescribeIdentityProvider' {Text
providerName :: Text
userPoolId :: Text
$sel:providerName:DescribeIdentityProvider' :: DescribeIdentityProvider -> Text
$sel:userPoolId:DescribeIdentityProvider' :: DescribeIdentityProvider -> 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
"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)
          ]
      )

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

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

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

-- |
-- Create a value of 'DescribeIdentityProviderResponse' 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', 'describeIdentityProviderResponse_httpStatus' - The response's http status code.
--
-- 'identityProvider', 'describeIdentityProviderResponse_identityProvider' - The identity provider that was deleted.
newDescribeIdentityProviderResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'identityProvider'
  IdentityProviderType ->
  DescribeIdentityProviderResponse
newDescribeIdentityProviderResponse :: Int -> IdentityProviderType -> DescribeIdentityProviderResponse
newDescribeIdentityProviderResponse
  Int
pHttpStatus_
  IdentityProviderType
pIdentityProvider_ =
    DescribeIdentityProviderResponse' :: Int -> IdentityProviderType -> DescribeIdentityProviderResponse
DescribeIdentityProviderResponse'
      { $sel:httpStatus:DescribeIdentityProviderResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:identityProvider:DescribeIdentityProviderResponse' :: IdentityProviderType
identityProvider = IdentityProviderType
pIdentityProvider_
      }

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

-- | The identity provider that was deleted.
describeIdentityProviderResponse_identityProvider :: Lens.Lens' DescribeIdentityProviderResponse IdentityProviderType
describeIdentityProviderResponse_identityProvider :: (IdentityProviderType -> f IdentityProviderType)
-> DescribeIdentityProviderResponse
-> f DescribeIdentityProviderResponse
describeIdentityProviderResponse_identityProvider = (DescribeIdentityProviderResponse -> IdentityProviderType)
-> (DescribeIdentityProviderResponse
    -> IdentityProviderType -> DescribeIdentityProviderResponse)
-> Lens
     DescribeIdentityProviderResponse
     DescribeIdentityProviderResponse
     IdentityProviderType
     IdentityProviderType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeIdentityProviderResponse' {IdentityProviderType
identityProvider :: IdentityProviderType
$sel:identityProvider:DescribeIdentityProviderResponse' :: DescribeIdentityProviderResponse -> IdentityProviderType
identityProvider} -> IdentityProviderType
identityProvider) (\s :: DescribeIdentityProviderResponse
s@DescribeIdentityProviderResponse' {} IdentityProviderType
a -> DescribeIdentityProviderResponse
s {$sel:identityProvider:DescribeIdentityProviderResponse' :: IdentityProviderType
identityProvider = IdentityProviderType
a} :: DescribeIdentityProviderResponse)

instance
  Prelude.NFData
    DescribeIdentityProviderResponse