{-# 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.WorkSpacesWeb.ListIdentityProviders
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves a list of identity providers for a specific web portal.
module Amazonka.WorkSpacesWeb.ListIdentityProviders
  ( -- * Creating a Request
    ListIdentityProviders (..),
    newListIdentityProviders,

    -- * Request Lenses
    listIdentityProviders_maxResults,
    listIdentityProviders_nextToken,
    listIdentityProviders_portalArn,

    -- * Destructuring the Response
    ListIdentityProvidersResponse (..),
    newListIdentityProvidersResponse,

    -- * Response Lenses
    listIdentityProvidersResponse_identityProviders,
    listIdentityProvidersResponse_nextToken,
    listIdentityProvidersResponse_httpStatus,
  )
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
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.WorkSpacesWeb.Types

-- | /See:/ 'newListIdentityProviders' smart constructor.
data ListIdentityProviders = ListIdentityProviders'
  { -- | The maximum number of results to be included in the next page.
    ListIdentityProviders -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The pagination token used to retrieve the next page of results for this
    -- operation.
    ListIdentityProviders -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the web portal.
    ListIdentityProviders -> Text
portalArn :: Prelude.Text
  }
  deriving (ListIdentityProviders -> ListIdentityProviders -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListIdentityProviders -> ListIdentityProviders -> Bool
$c/= :: ListIdentityProviders -> ListIdentityProviders -> Bool
== :: ListIdentityProviders -> ListIdentityProviders -> Bool
$c== :: ListIdentityProviders -> ListIdentityProviders -> Bool
Prelude.Eq, ReadPrec [ListIdentityProviders]
ReadPrec ListIdentityProviders
Int -> ReadS ListIdentityProviders
ReadS [ListIdentityProviders]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListIdentityProviders]
$creadListPrec :: ReadPrec [ListIdentityProviders]
readPrec :: ReadPrec ListIdentityProviders
$creadPrec :: ReadPrec ListIdentityProviders
readList :: ReadS [ListIdentityProviders]
$creadList :: ReadS [ListIdentityProviders]
readsPrec :: Int -> ReadS ListIdentityProviders
$creadsPrec :: Int -> ReadS ListIdentityProviders
Prelude.Read, Int -> ListIdentityProviders -> ShowS
[ListIdentityProviders] -> ShowS
ListIdentityProviders -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListIdentityProviders] -> ShowS
$cshowList :: [ListIdentityProviders] -> ShowS
show :: ListIdentityProviders -> String
$cshow :: ListIdentityProviders -> String
showsPrec :: Int -> ListIdentityProviders -> ShowS
$cshowsPrec :: Int -> ListIdentityProviders -> ShowS
Prelude.Show, forall x. Rep ListIdentityProviders x -> ListIdentityProviders
forall x. ListIdentityProviders -> Rep ListIdentityProviders x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListIdentityProviders x -> ListIdentityProviders
$cfrom :: forall x. ListIdentityProviders -> Rep ListIdentityProviders x
Prelude.Generic)

-- |
-- Create a value of 'ListIdentityProviders' 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:
--
-- 'maxResults', 'listIdentityProviders_maxResults' - The maximum number of results to be included in the next page.
--
-- 'nextToken', 'listIdentityProviders_nextToken' - The pagination token used to retrieve the next page of results for this
-- operation.
--
-- 'portalArn', 'listIdentityProviders_portalArn' - The ARN of the web portal.
newListIdentityProviders ::
  -- | 'portalArn'
  Prelude.Text ->
  ListIdentityProviders
newListIdentityProviders :: Text -> ListIdentityProviders
newListIdentityProviders Text
pPortalArn_ =
  ListIdentityProviders'
    { $sel:maxResults:ListIdentityProviders' :: Maybe Natural
maxResults =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListIdentityProviders' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:portalArn:ListIdentityProviders' :: Text
portalArn = Text
pPortalArn_
    }

-- | The maximum number of results to be included in the next page.
listIdentityProviders_maxResults :: Lens.Lens' ListIdentityProviders (Prelude.Maybe Prelude.Natural)
listIdentityProviders_maxResults :: Lens' ListIdentityProviders (Maybe Natural)
listIdentityProviders_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIdentityProviders' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListIdentityProviders' :: ListIdentityProviders -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListIdentityProviders
s@ListIdentityProviders' {} Maybe Natural
a -> ListIdentityProviders
s {$sel:maxResults:ListIdentityProviders' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListIdentityProviders)

-- | The pagination token used to retrieve the next page of results for this
-- operation.
listIdentityProviders_nextToken :: Lens.Lens' ListIdentityProviders (Prelude.Maybe Prelude.Text)
listIdentityProviders_nextToken :: Lens' ListIdentityProviders (Maybe Text)
listIdentityProviders_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIdentityProviders' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListIdentityProviders' :: ListIdentityProviders -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListIdentityProviders
s@ListIdentityProviders' {} Maybe Text
a -> ListIdentityProviders
s {$sel:nextToken:ListIdentityProviders' :: Maybe Text
nextToken = Maybe Text
a} :: ListIdentityProviders)

-- | The ARN of the web portal.
listIdentityProviders_portalArn :: Lens.Lens' ListIdentityProviders Prelude.Text
listIdentityProviders_portalArn :: Lens' ListIdentityProviders Text
listIdentityProviders_portalArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIdentityProviders' {Text
portalArn :: Text
$sel:portalArn:ListIdentityProviders' :: ListIdentityProviders -> Text
portalArn} -> Text
portalArn) (\s :: ListIdentityProviders
s@ListIdentityProviders' {} Text
a -> ListIdentityProviders
s {$sel:portalArn:ListIdentityProviders' :: Text
portalArn = Text
a} :: ListIdentityProviders)

instance Core.AWSRequest ListIdentityProviders where
  type
    AWSResponse ListIdentityProviders =
      ListIdentityProvidersResponse
  request :: (Service -> Service)
-> ListIdentityProviders -> Request ListIdentityProviders
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListIdentityProviders
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListIdentityProviders)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [IdentityProviderSummary]
-> Maybe Text -> Int -> ListIdentityProvidersResponse
ListIdentityProvidersResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"identityProviders"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"nextToken")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListIdentityProviders where
  hashWithSalt :: Int -> ListIdentityProviders -> Int
hashWithSalt Int
_salt ListIdentityProviders' {Maybe Natural
Maybe Text
Text
portalArn :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:portalArn:ListIdentityProviders' :: ListIdentityProviders -> Text
$sel:nextToken:ListIdentityProviders' :: ListIdentityProviders -> Maybe Text
$sel:maxResults:ListIdentityProviders' :: ListIdentityProviders -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
maxResults
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
portalArn

instance Prelude.NFData ListIdentityProviders where
  rnf :: ListIdentityProviders -> ()
rnf ListIdentityProviders' {Maybe Natural
Maybe Text
Text
portalArn :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:portalArn:ListIdentityProviders' :: ListIdentityProviders -> Text
$sel:nextToken:ListIdentityProviders' :: ListIdentityProviders -> Maybe Text
$sel:maxResults:ListIdentityProviders' :: ListIdentityProviders -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
maxResults
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
portalArn

instance Data.ToHeaders ListIdentityProviders where
  toHeaders :: ListIdentityProviders -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath ListIdentityProviders where
  toPath :: ListIdentityProviders -> ByteString
toPath ListIdentityProviders' {Maybe Natural
Maybe Text
Text
portalArn :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:portalArn:ListIdentityProviders' :: ListIdentityProviders -> Text
$sel:nextToken:ListIdentityProviders' :: ListIdentityProviders -> Maybe Text
$sel:maxResults:ListIdentityProviders' :: ListIdentityProviders -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/portals/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
portalArn,
        ByteString
"/identityProviders"
      ]

instance Data.ToQuery ListIdentityProviders where
  toQuery :: ListIdentityProviders -> QueryString
toQuery ListIdentityProviders' {Maybe Natural
Maybe Text
Text
portalArn :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:portalArn:ListIdentityProviders' :: ListIdentityProviders -> Text
$sel:nextToken:ListIdentityProviders' :: ListIdentityProviders -> Maybe Text
$sel:maxResults:ListIdentityProviders' :: ListIdentityProviders -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"maxResults" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"nextToken" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListIdentityProvidersResponse' smart constructor.
data ListIdentityProvidersResponse = ListIdentityProvidersResponse'
  { -- | The identity providers.
    ListIdentityProvidersResponse -> Maybe [IdentityProviderSummary]
identityProviders :: Prelude.Maybe [IdentityProviderSummary],
    -- | The pagination token used to retrieve the next page of results for this
    -- operation.
    ListIdentityProvidersResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListIdentityProvidersResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListIdentityProvidersResponse
-> ListIdentityProvidersResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListIdentityProvidersResponse
-> ListIdentityProvidersResponse -> Bool
$c/= :: ListIdentityProvidersResponse
-> ListIdentityProvidersResponse -> Bool
== :: ListIdentityProvidersResponse
-> ListIdentityProvidersResponse -> Bool
$c== :: ListIdentityProvidersResponse
-> ListIdentityProvidersResponse -> Bool
Prelude.Eq, Int -> ListIdentityProvidersResponse -> ShowS
[ListIdentityProvidersResponse] -> ShowS
ListIdentityProvidersResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListIdentityProvidersResponse] -> ShowS
$cshowList :: [ListIdentityProvidersResponse] -> ShowS
show :: ListIdentityProvidersResponse -> String
$cshow :: ListIdentityProvidersResponse -> String
showsPrec :: Int -> ListIdentityProvidersResponse -> ShowS
$cshowsPrec :: Int -> ListIdentityProvidersResponse -> ShowS
Prelude.Show, forall x.
Rep ListIdentityProvidersResponse x
-> ListIdentityProvidersResponse
forall x.
ListIdentityProvidersResponse
-> Rep ListIdentityProvidersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListIdentityProvidersResponse x
-> ListIdentityProvidersResponse
$cfrom :: forall x.
ListIdentityProvidersResponse
-> Rep ListIdentityProvidersResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListIdentityProvidersResponse' 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:
--
-- 'identityProviders', 'listIdentityProvidersResponse_identityProviders' - The identity providers.
--
-- 'nextToken', 'listIdentityProvidersResponse_nextToken' - The pagination token used to retrieve the next page of results for this
-- operation.
--
-- 'httpStatus', 'listIdentityProvidersResponse_httpStatus' - The response's http status code.
newListIdentityProvidersResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListIdentityProvidersResponse
newListIdentityProvidersResponse :: Int -> ListIdentityProvidersResponse
newListIdentityProvidersResponse Int
pHttpStatus_ =
  ListIdentityProvidersResponse'
    { $sel:identityProviders:ListIdentityProvidersResponse' :: Maybe [IdentityProviderSummary]
identityProviders =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListIdentityProvidersResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListIdentityProvidersResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The identity providers.
listIdentityProvidersResponse_identityProviders :: Lens.Lens' ListIdentityProvidersResponse (Prelude.Maybe [IdentityProviderSummary])
listIdentityProvidersResponse_identityProviders :: Lens'
  ListIdentityProvidersResponse (Maybe [IdentityProviderSummary])
listIdentityProvidersResponse_identityProviders = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIdentityProvidersResponse' {Maybe [IdentityProviderSummary]
identityProviders :: Maybe [IdentityProviderSummary]
$sel:identityProviders:ListIdentityProvidersResponse' :: ListIdentityProvidersResponse -> Maybe [IdentityProviderSummary]
identityProviders} -> Maybe [IdentityProviderSummary]
identityProviders) (\s :: ListIdentityProvidersResponse
s@ListIdentityProvidersResponse' {} Maybe [IdentityProviderSummary]
a -> ListIdentityProvidersResponse
s {$sel:identityProviders:ListIdentityProvidersResponse' :: Maybe [IdentityProviderSummary]
identityProviders = Maybe [IdentityProviderSummary]
a} :: ListIdentityProvidersResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The pagination token used to retrieve the next page of results for this
-- operation.
listIdentityProvidersResponse_nextToken :: Lens.Lens' ListIdentityProvidersResponse (Prelude.Maybe Prelude.Text)
listIdentityProvidersResponse_nextToken :: Lens' ListIdentityProvidersResponse (Maybe Text)
listIdentityProvidersResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListIdentityProvidersResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListIdentityProvidersResponse' :: ListIdentityProvidersResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListIdentityProvidersResponse
s@ListIdentityProvidersResponse' {} Maybe Text
a -> ListIdentityProvidersResponse
s {$sel:nextToken:ListIdentityProvidersResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListIdentityProvidersResponse)

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

instance Prelude.NFData ListIdentityProvidersResponse where
  rnf :: ListIdentityProvidersResponse -> ()
rnf ListIdentityProvidersResponse' {Int
Maybe [IdentityProviderSummary]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
identityProviders :: Maybe [IdentityProviderSummary]
$sel:httpStatus:ListIdentityProvidersResponse' :: ListIdentityProvidersResponse -> Int
$sel:nextToken:ListIdentityProvidersResponse' :: ListIdentityProvidersResponse -> Maybe Text
$sel:identityProviders:ListIdentityProvidersResponse' :: ListIdentityProvidersResponse -> Maybe [IdentityProviderSummary]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [IdentityProviderSummary]
identityProviders
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
nextToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus