{-# 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.ListUsers
-- 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)
--
-- Lists the users in the Amazon Cognito user pool.
--
-- This operation returns paginated results.
module Amazonka.CognitoIdentityProvider.ListUsers
  ( -- * Creating a Request
    ListUsers (..),
    newListUsers,

    -- * Request Lenses
    listUsers_paginationToken,
    listUsers_attributesToGet,
    listUsers_limit,
    listUsers_filter,
    listUsers_userPoolId,

    -- * Destructuring the Response
    ListUsersResponse (..),
    newListUsersResponse,

    -- * Response Lenses
    listUsersResponse_paginationToken,
    listUsersResponse_users,
    listUsersResponse_httpStatus,
  )
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

-- | Represents the request to list users.
--
-- /See:/ 'newListUsers' smart constructor.
data ListUsers = ListUsers'
  { -- | An identifier that was returned from the previous call to this
    -- operation, which can be used to return the next set of items in the
    -- list.
    ListUsers -> Maybe Text
paginationToken :: Prelude.Maybe Prelude.Text,
    -- | An array of strings, where each string is the name of a user attribute
    -- to be returned for each user in the search results. If the array is
    -- null, all attributes are returned.
    ListUsers -> Maybe [Text]
attributesToGet :: Prelude.Maybe [Prelude.Text],
    -- | Maximum number of users to be returned.
    ListUsers -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | A filter string of the form \"/AttributeName/ /Filter-Type/
    -- \"/AttributeValue/\"\". Quotation marks within the filter string must be
    -- escaped using the backslash (\\) character. For example, \"@family_name@
    -- = \\\"Reddy\\\"\".
    --
    -- -   /AttributeName/: The name of the attribute to search for. You can
    --     only search for one attribute at a time.
    --
    -- -   /Filter-Type/: For an exact match, use =, for example,
    --     \"@given_name@ = \\\"Jon\\\"\". For a prefix (\"starts with\")
    --     match, use ^=, for example, \"@given_name@ ^= \\\"Jon\\\"\".
    --
    -- -   /AttributeValue/: The attribute value that must be matched for each
    --     user.
    --
    -- If the filter string is empty, @ListUsers@ returns all users in the user
    -- pool.
    --
    -- You can only search for the following standard attributes:
    --
    -- -   @username@ (case-sensitive)
    --
    -- -   @email@
    --
    -- -   @phone_number@
    --
    -- -   @name@
    --
    -- -   @given_name@
    --
    -- -   @family_name@
    --
    -- -   @preferred_username@
    --
    -- -   @cognito:user_status@ (called __Status__ in the Console)
    --     (case-insensitive)
    --
    -- -   @status (called Enabled in the Console) (case-sensitive)@
    --
    -- -   @sub@
    --
    -- Custom attributes are not searchable.
    --
    -- For more information, see
    -- <https://docs.aws.amazon.com/cognito/latest/developerguide/how-to-manage-user-accounts.html#cognito-user-pools-searching-for-users-using-listusers-api Searching for Users Using the ListUsers API>
    -- and
    -- <https://docs.aws.amazon.com/cognito/latest/developerguide/how-to-manage-user-accounts.html#cognito-user-pools-searching-for-users-listusers-api-examples Examples of Using the ListUsers API>
    -- in the /Amazon Cognito Developer Guide/.
    ListUsers -> Maybe Text
filter' :: Prelude.Maybe Prelude.Text,
    -- | The user pool ID for the user pool on which the search should be
    -- performed.
    ListUsers -> Text
userPoolId :: Prelude.Text
  }
  deriving (ListUsers -> ListUsers -> Bool
(ListUsers -> ListUsers -> Bool)
-> (ListUsers -> ListUsers -> Bool) -> Eq ListUsers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListUsers -> ListUsers -> Bool
$c/= :: ListUsers -> ListUsers -> Bool
== :: ListUsers -> ListUsers -> Bool
$c== :: ListUsers -> ListUsers -> Bool
Prelude.Eq, ReadPrec [ListUsers]
ReadPrec ListUsers
Int -> ReadS ListUsers
ReadS [ListUsers]
(Int -> ReadS ListUsers)
-> ReadS [ListUsers]
-> ReadPrec ListUsers
-> ReadPrec [ListUsers]
-> Read ListUsers
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListUsers]
$creadListPrec :: ReadPrec [ListUsers]
readPrec :: ReadPrec ListUsers
$creadPrec :: ReadPrec ListUsers
readList :: ReadS [ListUsers]
$creadList :: ReadS [ListUsers]
readsPrec :: Int -> ReadS ListUsers
$creadsPrec :: Int -> ReadS ListUsers
Prelude.Read, Int -> ListUsers -> ShowS
[ListUsers] -> ShowS
ListUsers -> String
(Int -> ListUsers -> ShowS)
-> (ListUsers -> String)
-> ([ListUsers] -> ShowS)
-> Show ListUsers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListUsers] -> ShowS
$cshowList :: [ListUsers] -> ShowS
show :: ListUsers -> String
$cshow :: ListUsers -> String
showsPrec :: Int -> ListUsers -> ShowS
$cshowsPrec :: Int -> ListUsers -> ShowS
Prelude.Show, (forall x. ListUsers -> Rep ListUsers x)
-> (forall x. Rep ListUsers x -> ListUsers) -> Generic ListUsers
forall x. Rep ListUsers x -> ListUsers
forall x. ListUsers -> Rep ListUsers x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListUsers x -> ListUsers
$cfrom :: forall x. ListUsers -> Rep ListUsers x
Prelude.Generic)

-- |
-- Create a value of 'ListUsers' 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:
--
-- 'paginationToken', 'listUsers_paginationToken' - An identifier that was returned from the previous call to this
-- operation, which can be used to return the next set of items in the
-- list.
--
-- 'attributesToGet', 'listUsers_attributesToGet' - An array of strings, where each string is the name of a user attribute
-- to be returned for each user in the search results. If the array is
-- null, all attributes are returned.
--
-- 'limit', 'listUsers_limit' - Maximum number of users to be returned.
--
-- 'filter'', 'listUsers_filter' - A filter string of the form \"/AttributeName/ /Filter-Type/
-- \"/AttributeValue/\"\". Quotation marks within the filter string must be
-- escaped using the backslash (\\) character. For example, \"@family_name@
-- = \\\"Reddy\\\"\".
--
-- -   /AttributeName/: The name of the attribute to search for. You can
--     only search for one attribute at a time.
--
-- -   /Filter-Type/: For an exact match, use =, for example,
--     \"@given_name@ = \\\"Jon\\\"\". For a prefix (\"starts with\")
--     match, use ^=, for example, \"@given_name@ ^= \\\"Jon\\\"\".
--
-- -   /AttributeValue/: The attribute value that must be matched for each
--     user.
--
-- If the filter string is empty, @ListUsers@ returns all users in the user
-- pool.
--
-- You can only search for the following standard attributes:
--
-- -   @username@ (case-sensitive)
--
-- -   @email@
--
-- -   @phone_number@
--
-- -   @name@
--
-- -   @given_name@
--
-- -   @family_name@
--
-- -   @preferred_username@
--
-- -   @cognito:user_status@ (called __Status__ in the Console)
--     (case-insensitive)
--
-- -   @status (called Enabled in the Console) (case-sensitive)@
--
-- -   @sub@
--
-- Custom attributes are not searchable.
--
-- For more information, see
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/how-to-manage-user-accounts.html#cognito-user-pools-searching-for-users-using-listusers-api Searching for Users Using the ListUsers API>
-- and
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/how-to-manage-user-accounts.html#cognito-user-pools-searching-for-users-listusers-api-examples Examples of Using the ListUsers API>
-- in the /Amazon Cognito Developer Guide/.
--
-- 'userPoolId', 'listUsers_userPoolId' - The user pool ID for the user pool on which the search should be
-- performed.
newListUsers ::
  -- | 'userPoolId'
  Prelude.Text ->
  ListUsers
newListUsers :: Text -> ListUsers
newListUsers Text
pUserPoolId_ =
  ListUsers' :: Maybe Text
-> Maybe [Text] -> Maybe Natural -> Maybe Text -> Text -> ListUsers
ListUsers'
    { $sel:paginationToken:ListUsers' :: Maybe Text
paginationToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:attributesToGet:ListUsers' :: Maybe [Text]
attributesToGet = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:ListUsers' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:filter':ListUsers' :: Maybe Text
filter' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:userPoolId:ListUsers' :: Text
userPoolId = Text
pUserPoolId_
    }

-- | An identifier that was returned from the previous call to this
-- operation, which can be used to return the next set of items in the
-- list.
listUsers_paginationToken :: Lens.Lens' ListUsers (Prelude.Maybe Prelude.Text)
listUsers_paginationToken :: (Maybe Text -> f (Maybe Text)) -> ListUsers -> f ListUsers
listUsers_paginationToken = (ListUsers -> Maybe Text)
-> (ListUsers -> Maybe Text -> ListUsers)
-> Lens ListUsers ListUsers (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListUsers' {Maybe Text
paginationToken :: Maybe Text
$sel:paginationToken:ListUsers' :: ListUsers -> Maybe Text
paginationToken} -> Maybe Text
paginationToken) (\s :: ListUsers
s@ListUsers' {} Maybe Text
a -> ListUsers
s {$sel:paginationToken:ListUsers' :: Maybe Text
paginationToken = Maybe Text
a} :: ListUsers)

-- | An array of strings, where each string is the name of a user attribute
-- to be returned for each user in the search results. If the array is
-- null, all attributes are returned.
listUsers_attributesToGet :: Lens.Lens' ListUsers (Prelude.Maybe [Prelude.Text])
listUsers_attributesToGet :: (Maybe [Text] -> f (Maybe [Text])) -> ListUsers -> f ListUsers
listUsers_attributesToGet = (ListUsers -> Maybe [Text])
-> (ListUsers -> Maybe [Text] -> ListUsers)
-> Lens ListUsers ListUsers (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListUsers' {Maybe [Text]
attributesToGet :: Maybe [Text]
$sel:attributesToGet:ListUsers' :: ListUsers -> Maybe [Text]
attributesToGet} -> Maybe [Text]
attributesToGet) (\s :: ListUsers
s@ListUsers' {} Maybe [Text]
a -> ListUsers
s {$sel:attributesToGet:ListUsers' :: Maybe [Text]
attributesToGet = Maybe [Text]
a} :: ListUsers) ((Maybe [Text] -> f (Maybe [Text])) -> ListUsers -> f ListUsers)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ListUsers
-> f ListUsers
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

-- | Maximum number of users to be returned.
listUsers_limit :: Lens.Lens' ListUsers (Prelude.Maybe Prelude.Natural)
listUsers_limit :: (Maybe Natural -> f (Maybe Natural)) -> ListUsers -> f ListUsers
listUsers_limit = (ListUsers -> Maybe Natural)
-> (ListUsers -> Maybe Natural -> ListUsers)
-> Lens ListUsers ListUsers (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListUsers' {Maybe Natural
limit :: Maybe Natural
$sel:limit:ListUsers' :: ListUsers -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: ListUsers
s@ListUsers' {} Maybe Natural
a -> ListUsers
s {$sel:limit:ListUsers' :: Maybe Natural
limit = Maybe Natural
a} :: ListUsers)

-- | A filter string of the form \"/AttributeName/ /Filter-Type/
-- \"/AttributeValue/\"\". Quotation marks within the filter string must be
-- escaped using the backslash (\\) character. For example, \"@family_name@
-- = \\\"Reddy\\\"\".
--
-- -   /AttributeName/: The name of the attribute to search for. You can
--     only search for one attribute at a time.
--
-- -   /Filter-Type/: For an exact match, use =, for example,
--     \"@given_name@ = \\\"Jon\\\"\". For a prefix (\"starts with\")
--     match, use ^=, for example, \"@given_name@ ^= \\\"Jon\\\"\".
--
-- -   /AttributeValue/: The attribute value that must be matched for each
--     user.
--
-- If the filter string is empty, @ListUsers@ returns all users in the user
-- pool.
--
-- You can only search for the following standard attributes:
--
-- -   @username@ (case-sensitive)
--
-- -   @email@
--
-- -   @phone_number@
--
-- -   @name@
--
-- -   @given_name@
--
-- -   @family_name@
--
-- -   @preferred_username@
--
-- -   @cognito:user_status@ (called __Status__ in the Console)
--     (case-insensitive)
--
-- -   @status (called Enabled in the Console) (case-sensitive)@
--
-- -   @sub@
--
-- Custom attributes are not searchable.
--
-- For more information, see
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/how-to-manage-user-accounts.html#cognito-user-pools-searching-for-users-using-listusers-api Searching for Users Using the ListUsers API>
-- and
-- <https://docs.aws.amazon.com/cognito/latest/developerguide/how-to-manage-user-accounts.html#cognito-user-pools-searching-for-users-listusers-api-examples Examples of Using the ListUsers API>
-- in the /Amazon Cognito Developer Guide/.
listUsers_filter :: Lens.Lens' ListUsers (Prelude.Maybe Prelude.Text)
listUsers_filter :: (Maybe Text -> f (Maybe Text)) -> ListUsers -> f ListUsers
listUsers_filter = (ListUsers -> Maybe Text)
-> (ListUsers -> Maybe Text -> ListUsers)
-> Lens ListUsers ListUsers (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListUsers' {Maybe Text
filter' :: Maybe Text
$sel:filter':ListUsers' :: ListUsers -> Maybe Text
filter'} -> Maybe Text
filter') (\s :: ListUsers
s@ListUsers' {} Maybe Text
a -> ListUsers
s {$sel:filter':ListUsers' :: Maybe Text
filter' = Maybe Text
a} :: ListUsers)

-- | The user pool ID for the user pool on which the search should be
-- performed.
listUsers_userPoolId :: Lens.Lens' ListUsers Prelude.Text
listUsers_userPoolId :: (Text -> f Text) -> ListUsers -> f ListUsers
listUsers_userPoolId = (ListUsers -> Text)
-> (ListUsers -> Text -> ListUsers)
-> Lens ListUsers ListUsers Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListUsers' {Text
userPoolId :: Text
$sel:userPoolId:ListUsers' :: ListUsers -> Text
userPoolId} -> Text
userPoolId) (\s :: ListUsers
s@ListUsers' {} Text
a -> ListUsers
s {$sel:userPoolId:ListUsers' :: Text
userPoolId = Text
a} :: ListUsers)

instance Core.AWSPager ListUsers where
  page :: ListUsers -> AWSResponse ListUsers -> Maybe ListUsers
page ListUsers
rq AWSResponse ListUsers
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListUsers
ListUsersResponse
rs
            ListUsersResponse
-> Getting (First Text) ListUsersResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListUsersResponse -> Const (First Text) ListUsersResponse
Lens' ListUsersResponse (Maybe Text)
listUsersResponse_paginationToken
              ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListUsersResponse -> Const (First Text) ListUsersResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListUsersResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListUsers
forall a. Maybe a
Prelude.Nothing
    | Maybe [UserType] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListUsers
ListUsersResponse
rs
            ListUsersResponse
-> Getting (First [UserType]) ListUsersResponse [UserType]
-> Maybe [UserType]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [UserType] -> Const (First [UserType]) (Maybe [UserType]))
-> ListUsersResponse -> Const (First [UserType]) ListUsersResponse
Lens' ListUsersResponse (Maybe [UserType])
listUsersResponse_users ((Maybe [UserType] -> Const (First [UserType]) (Maybe [UserType]))
 -> ListUsersResponse -> Const (First [UserType]) ListUsersResponse)
-> (([UserType] -> Const (First [UserType]) [UserType])
    -> Maybe [UserType] -> Const (First [UserType]) (Maybe [UserType]))
-> Getting (First [UserType]) ListUsersResponse [UserType]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([UserType] -> Const (First [UserType]) [UserType])
-> Maybe [UserType] -> Const (First [UserType]) (Maybe [UserType])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListUsers
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListUsers -> Maybe ListUsers
forall a. a -> Maybe a
Prelude.Just (ListUsers -> Maybe ListUsers) -> ListUsers -> Maybe ListUsers
forall a b. (a -> b) -> a -> b
Prelude.$
        ListUsers
rq
          ListUsers -> (ListUsers -> ListUsers) -> ListUsers
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListUsers -> Identity ListUsers
Lens ListUsers ListUsers (Maybe Text) (Maybe Text)
listUsers_paginationToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListUsers -> Identity ListUsers)
-> Maybe Text -> ListUsers -> ListUsers
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListUsers
ListUsersResponse
rs
          ListUsersResponse
-> Getting (First Text) ListUsersResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListUsersResponse -> Const (First Text) ListUsersResponse
Lens' ListUsersResponse (Maybe Text)
listUsersResponse_paginationToken
            ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListUsersResponse -> Const (First Text) ListUsersResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListUsersResponse Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> Const (First Text) Text)
-> Maybe Text -> Const (First Text) (Maybe Text)
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListUsers where
  type AWSResponse ListUsers = ListUsersResponse
  request :: ListUsers -> Request ListUsers
request = Service -> ListUsers -> Request ListUsers
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListUsers
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListUsers)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListUsers))
-> Logger
-> Service
-> Proxy ListUsers
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListUsers)))
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 ->
          Maybe Text -> Maybe [UserType] -> Int -> ListUsersResponse
ListUsersResponse'
            (Maybe Text -> Maybe [UserType] -> Int -> ListUsersResponse)
-> Either String (Maybe Text)
-> Either String (Maybe [UserType] -> Int -> ListUsersResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"PaginationToken")
            Either String (Maybe [UserType] -> Int -> ListUsersResponse)
-> Either String (Maybe [UserType])
-> Either String (Int -> ListUsersResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe (Maybe [UserType]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Users" Either String (Maybe (Maybe [UserType]))
-> Maybe [UserType] -> Either String (Maybe [UserType])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [UserType]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> ListUsersResponse)
-> Either String Int -> Either String ListUsersResponse
forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable ListUsers

instance Prelude.NFData ListUsers

instance Core.ToHeaders ListUsers where
  toHeaders :: ListUsers -> ResponseHeaders
toHeaders =
    ResponseHeaders -> ListUsers -> 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.ListUsers" ::
                          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 ListUsers where
  toJSON :: ListUsers -> Value
toJSON ListUsers' {Maybe Natural
Maybe [Text]
Maybe Text
Text
userPoolId :: Text
filter' :: Maybe Text
limit :: Maybe Natural
attributesToGet :: Maybe [Text]
paginationToken :: Maybe Text
$sel:userPoolId:ListUsers' :: ListUsers -> Text
$sel:filter':ListUsers' :: ListUsers -> Maybe Text
$sel:limit:ListUsers' :: ListUsers -> Maybe Natural
$sel:attributesToGet:ListUsers' :: ListUsers -> Maybe [Text]
$sel:paginationToken:ListUsers' :: ListUsers -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"PaginationToken" 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
paginationToken,
            (Text
"AttributesToGet" 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]
attributesToGet,
            (Text
"Limit" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
limit,
            (Text
"Filter" 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
filter',
            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)
          ]
      )

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

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

-- | The response from the request to list users.
--
-- /See:/ 'newListUsersResponse' smart constructor.
data ListUsersResponse = ListUsersResponse'
  { -- | An identifier that was returned from the previous call to this
    -- operation, which can be used to return the next set of items in the
    -- list.
    ListUsersResponse -> Maybe Text
paginationToken :: Prelude.Maybe Prelude.Text,
    -- | The users returned in the request to list users.
    ListUsersResponse -> Maybe [UserType]
users :: Prelude.Maybe [UserType],
    -- | The response's http status code.
    ListUsersResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListUsersResponse -> ListUsersResponse -> Bool
(ListUsersResponse -> ListUsersResponse -> Bool)
-> (ListUsersResponse -> ListUsersResponse -> Bool)
-> Eq ListUsersResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListUsersResponse -> ListUsersResponse -> Bool
$c/= :: ListUsersResponse -> ListUsersResponse -> Bool
== :: ListUsersResponse -> ListUsersResponse -> Bool
$c== :: ListUsersResponse -> ListUsersResponse -> Bool
Prelude.Eq, Int -> ListUsersResponse -> ShowS
[ListUsersResponse] -> ShowS
ListUsersResponse -> String
(Int -> ListUsersResponse -> ShowS)
-> (ListUsersResponse -> String)
-> ([ListUsersResponse] -> ShowS)
-> Show ListUsersResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListUsersResponse] -> ShowS
$cshowList :: [ListUsersResponse] -> ShowS
show :: ListUsersResponse -> String
$cshow :: ListUsersResponse -> String
showsPrec :: Int -> ListUsersResponse -> ShowS
$cshowsPrec :: Int -> ListUsersResponse -> ShowS
Prelude.Show, (forall x. ListUsersResponse -> Rep ListUsersResponse x)
-> (forall x. Rep ListUsersResponse x -> ListUsersResponse)
-> Generic ListUsersResponse
forall x. Rep ListUsersResponse x -> ListUsersResponse
forall x. ListUsersResponse -> Rep ListUsersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListUsersResponse x -> ListUsersResponse
$cfrom :: forall x. ListUsersResponse -> Rep ListUsersResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListUsersResponse' 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:
--
-- 'paginationToken', 'listUsersResponse_paginationToken' - An identifier that was returned from the previous call to this
-- operation, which can be used to return the next set of items in the
-- list.
--
-- 'users', 'listUsersResponse_users' - The users returned in the request to list users.
--
-- 'httpStatus', 'listUsersResponse_httpStatus' - The response's http status code.
newListUsersResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListUsersResponse
newListUsersResponse :: Int -> ListUsersResponse
newListUsersResponse Int
pHttpStatus_ =
  ListUsersResponse' :: Maybe Text -> Maybe [UserType] -> Int -> ListUsersResponse
ListUsersResponse'
    { $sel:paginationToken:ListUsersResponse' :: Maybe Text
paginationToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:users:ListUsersResponse' :: Maybe [UserType]
users = Maybe [UserType]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListUsersResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An identifier that was returned from the previous call to this
-- operation, which can be used to return the next set of items in the
-- list.
listUsersResponse_paginationToken :: Lens.Lens' ListUsersResponse (Prelude.Maybe Prelude.Text)
listUsersResponse_paginationToken :: (Maybe Text -> f (Maybe Text))
-> ListUsersResponse -> f ListUsersResponse
listUsersResponse_paginationToken = (ListUsersResponse -> Maybe Text)
-> (ListUsersResponse -> Maybe Text -> ListUsersResponse)
-> Lens' ListUsersResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListUsersResponse' {Maybe Text
paginationToken :: Maybe Text
$sel:paginationToken:ListUsersResponse' :: ListUsersResponse -> Maybe Text
paginationToken} -> Maybe Text
paginationToken) (\s :: ListUsersResponse
s@ListUsersResponse' {} Maybe Text
a -> ListUsersResponse
s {$sel:paginationToken:ListUsersResponse' :: Maybe Text
paginationToken = Maybe Text
a} :: ListUsersResponse)

-- | The users returned in the request to list users.
listUsersResponse_users :: Lens.Lens' ListUsersResponse (Prelude.Maybe [UserType])
listUsersResponse_users :: (Maybe [UserType] -> f (Maybe [UserType]))
-> ListUsersResponse -> f ListUsersResponse
listUsersResponse_users = (ListUsersResponse -> Maybe [UserType])
-> (ListUsersResponse -> Maybe [UserType] -> ListUsersResponse)
-> Lens' ListUsersResponse (Maybe [UserType])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListUsersResponse' {Maybe [UserType]
users :: Maybe [UserType]
$sel:users:ListUsersResponse' :: ListUsersResponse -> Maybe [UserType]
users} -> Maybe [UserType]
users) (\s :: ListUsersResponse
s@ListUsersResponse' {} Maybe [UserType]
a -> ListUsersResponse
s {$sel:users:ListUsersResponse' :: Maybe [UserType]
users = Maybe [UserType]
a} :: ListUsersResponse) ((Maybe [UserType] -> f (Maybe [UserType]))
 -> ListUsersResponse -> f ListUsersResponse)
-> ((Maybe [UserType] -> f (Maybe [UserType]))
    -> Maybe [UserType] -> f (Maybe [UserType]))
-> (Maybe [UserType] -> f (Maybe [UserType]))
-> ListUsersResponse
-> f ListUsersResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [UserType] [UserType] [UserType] [UserType]
-> Iso
     (Maybe [UserType])
     (Maybe [UserType])
     (Maybe [UserType])
     (Maybe [UserType])
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 [UserType] [UserType] [UserType] [UserType]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListUsersResponse