{-# 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.AlexaBusiness.SearchUsers
-- 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)
--
-- Searches users and lists the ones that meet a set of filter and sort
-- criteria.
--
-- This operation returns paginated results.
module Amazonka.AlexaBusiness.SearchUsers
  ( -- * Creating a Request
    SearchUsers (..),
    newSearchUsers,

    -- * Request Lenses
    searchUsers_filters,
    searchUsers_sortCriteria,
    searchUsers_nextToken,
    searchUsers_maxResults,

    -- * Destructuring the Response
    SearchUsersResponse (..),
    newSearchUsersResponse,

    -- * Response Lenses
    searchUsersResponse_users,
    searchUsersResponse_nextToken,
    searchUsersResponse_totalCount,
    searchUsersResponse_httpStatus,
  )
where

import Amazonka.AlexaBusiness.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:/ 'newSearchUsers' smart constructor.
data SearchUsers = SearchUsers'
  { -- | The filters to use for listing a specific set of users. Required.
    -- Supported filter keys are UserId, FirstName, LastName, Email, and
    -- EnrollmentStatus.
    SearchUsers -> Maybe [Filter]
filters :: Prelude.Maybe [Filter],
    -- | The sort order to use in listing the filtered set of users. Required.
    -- Supported sort keys are UserId, FirstName, LastName, Email, and
    -- EnrollmentStatus.
    SearchUsers -> Maybe [Sort]
sortCriteria :: Prelude.Maybe [Sort],
    -- | An optional token returned from a prior request. Use this token for
    -- pagination of results from this action. If this parameter is specified,
    -- the response includes only results beyond the token, up to the value
    -- specified by @MaxResults@. Required.
    SearchUsers -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to include in the response. If more
    -- results exist than the specified @MaxResults@ value, a token is included
    -- in the response so that the remaining results can be retrieved.
    -- Required.
    SearchUsers -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (SearchUsers -> SearchUsers -> Bool
(SearchUsers -> SearchUsers -> Bool)
-> (SearchUsers -> SearchUsers -> Bool) -> Eq SearchUsers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchUsers -> SearchUsers -> Bool
$c/= :: SearchUsers -> SearchUsers -> Bool
== :: SearchUsers -> SearchUsers -> Bool
$c== :: SearchUsers -> SearchUsers -> Bool
Prelude.Eq, ReadPrec [SearchUsers]
ReadPrec SearchUsers
Int -> ReadS SearchUsers
ReadS [SearchUsers]
(Int -> ReadS SearchUsers)
-> ReadS [SearchUsers]
-> ReadPrec SearchUsers
-> ReadPrec [SearchUsers]
-> Read SearchUsers
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchUsers]
$creadListPrec :: ReadPrec [SearchUsers]
readPrec :: ReadPrec SearchUsers
$creadPrec :: ReadPrec SearchUsers
readList :: ReadS [SearchUsers]
$creadList :: ReadS [SearchUsers]
readsPrec :: Int -> ReadS SearchUsers
$creadsPrec :: Int -> ReadS SearchUsers
Prelude.Read, Int -> SearchUsers -> ShowS
[SearchUsers] -> ShowS
SearchUsers -> String
(Int -> SearchUsers -> ShowS)
-> (SearchUsers -> String)
-> ([SearchUsers] -> ShowS)
-> Show SearchUsers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchUsers] -> ShowS
$cshowList :: [SearchUsers] -> ShowS
show :: SearchUsers -> String
$cshow :: SearchUsers -> String
showsPrec :: Int -> SearchUsers -> ShowS
$cshowsPrec :: Int -> SearchUsers -> ShowS
Prelude.Show, (forall x. SearchUsers -> Rep SearchUsers x)
-> (forall x. Rep SearchUsers x -> SearchUsers)
-> Generic SearchUsers
forall x. Rep SearchUsers x -> SearchUsers
forall x. SearchUsers -> Rep SearchUsers x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchUsers x -> SearchUsers
$cfrom :: forall x. SearchUsers -> Rep SearchUsers x
Prelude.Generic)

-- |
-- Create a value of 'SearchUsers' 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:
--
-- 'filters', 'searchUsers_filters' - The filters to use for listing a specific set of users. Required.
-- Supported filter keys are UserId, FirstName, LastName, Email, and
-- EnrollmentStatus.
--
-- 'sortCriteria', 'searchUsers_sortCriteria' - The sort order to use in listing the filtered set of users. Required.
-- Supported sort keys are UserId, FirstName, LastName, Email, and
-- EnrollmentStatus.
--
-- 'nextToken', 'searchUsers_nextToken' - An optional token returned from a prior request. Use this token for
-- pagination of results from this action. If this parameter is specified,
-- the response includes only results beyond the token, up to the value
-- specified by @MaxResults@. Required.
--
-- 'maxResults', 'searchUsers_maxResults' - The maximum number of results to include in the response. If more
-- results exist than the specified @MaxResults@ value, a token is included
-- in the response so that the remaining results can be retrieved.
-- Required.
newSearchUsers ::
  SearchUsers
newSearchUsers :: SearchUsers
newSearchUsers =
  SearchUsers' :: Maybe [Filter]
-> Maybe [Sort] -> Maybe Text -> Maybe Natural -> SearchUsers
SearchUsers'
    { $sel:filters:SearchUsers' :: Maybe [Filter]
filters = Maybe [Filter]
forall a. Maybe a
Prelude.Nothing,
      $sel:sortCriteria:SearchUsers' :: Maybe [Sort]
sortCriteria = Maybe [Sort]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:SearchUsers' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:SearchUsers' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The filters to use for listing a specific set of users. Required.
-- Supported filter keys are UserId, FirstName, LastName, Email, and
-- EnrollmentStatus.
searchUsers_filters :: Lens.Lens' SearchUsers (Prelude.Maybe [Filter])
searchUsers_filters :: (Maybe [Filter] -> f (Maybe [Filter]))
-> SearchUsers -> f SearchUsers
searchUsers_filters = (SearchUsers -> Maybe [Filter])
-> (SearchUsers -> Maybe [Filter] -> SearchUsers)
-> Lens SearchUsers SearchUsers (Maybe [Filter]) (Maybe [Filter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchUsers' {Maybe [Filter]
filters :: Maybe [Filter]
$sel:filters:SearchUsers' :: SearchUsers -> Maybe [Filter]
filters} -> Maybe [Filter]
filters) (\s :: SearchUsers
s@SearchUsers' {} Maybe [Filter]
a -> SearchUsers
s {$sel:filters:SearchUsers' :: Maybe [Filter]
filters = Maybe [Filter]
a} :: SearchUsers) ((Maybe [Filter] -> f (Maybe [Filter]))
 -> SearchUsers -> f SearchUsers)
-> ((Maybe [Filter] -> f (Maybe [Filter]))
    -> Maybe [Filter] -> f (Maybe [Filter]))
-> (Maybe [Filter] -> f (Maybe [Filter]))
-> SearchUsers
-> f SearchUsers
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Filter] [Filter] [Filter] [Filter]
-> Iso
     (Maybe [Filter]) (Maybe [Filter]) (Maybe [Filter]) (Maybe [Filter])
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 [Filter] [Filter] [Filter] [Filter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The sort order to use in listing the filtered set of users. Required.
-- Supported sort keys are UserId, FirstName, LastName, Email, and
-- EnrollmentStatus.
searchUsers_sortCriteria :: Lens.Lens' SearchUsers (Prelude.Maybe [Sort])
searchUsers_sortCriteria :: (Maybe [Sort] -> f (Maybe [Sort])) -> SearchUsers -> f SearchUsers
searchUsers_sortCriteria = (SearchUsers -> Maybe [Sort])
-> (SearchUsers -> Maybe [Sort] -> SearchUsers)
-> Lens SearchUsers SearchUsers (Maybe [Sort]) (Maybe [Sort])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchUsers' {Maybe [Sort]
sortCriteria :: Maybe [Sort]
$sel:sortCriteria:SearchUsers' :: SearchUsers -> Maybe [Sort]
sortCriteria} -> Maybe [Sort]
sortCriteria) (\s :: SearchUsers
s@SearchUsers' {} Maybe [Sort]
a -> SearchUsers
s {$sel:sortCriteria:SearchUsers' :: Maybe [Sort]
sortCriteria = Maybe [Sort]
a} :: SearchUsers) ((Maybe [Sort] -> f (Maybe [Sort]))
 -> SearchUsers -> f SearchUsers)
-> ((Maybe [Sort] -> f (Maybe [Sort]))
    -> Maybe [Sort] -> f (Maybe [Sort]))
-> (Maybe [Sort] -> f (Maybe [Sort]))
-> SearchUsers
-> f SearchUsers
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Sort] [Sort] [Sort] [Sort]
-> Iso (Maybe [Sort]) (Maybe [Sort]) (Maybe [Sort]) (Maybe [Sort])
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 [Sort] [Sort] [Sort] [Sort]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | An optional token returned from a prior request. Use this token for
-- pagination of results from this action. If this parameter is specified,
-- the response includes only results beyond the token, up to the value
-- specified by @MaxResults@. Required.
searchUsers_nextToken :: Lens.Lens' SearchUsers (Prelude.Maybe Prelude.Text)
searchUsers_nextToken :: (Maybe Text -> f (Maybe Text)) -> SearchUsers -> f SearchUsers
searchUsers_nextToken = (SearchUsers -> Maybe Text)
-> (SearchUsers -> Maybe Text -> SearchUsers)
-> Lens SearchUsers SearchUsers (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchUsers' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SearchUsers' :: SearchUsers -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SearchUsers
s@SearchUsers' {} Maybe Text
a -> SearchUsers
s {$sel:nextToken:SearchUsers' :: Maybe Text
nextToken = Maybe Text
a} :: SearchUsers)

-- | The maximum number of results to include in the response. If more
-- results exist than the specified @MaxResults@ value, a token is included
-- in the response so that the remaining results can be retrieved.
-- Required.
searchUsers_maxResults :: Lens.Lens' SearchUsers (Prelude.Maybe Prelude.Natural)
searchUsers_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> SearchUsers -> f SearchUsers
searchUsers_maxResults = (SearchUsers -> Maybe Natural)
-> (SearchUsers -> Maybe Natural -> SearchUsers)
-> Lens SearchUsers SearchUsers (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchUsers' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:SearchUsers' :: SearchUsers -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: SearchUsers
s@SearchUsers' {} Maybe Natural
a -> SearchUsers
s {$sel:maxResults:SearchUsers' :: Maybe Natural
maxResults = Maybe Natural
a} :: SearchUsers)

instance Core.AWSPager SearchUsers where
  page :: SearchUsers -> AWSResponse SearchUsers -> Maybe SearchUsers
page SearchUsers
rq AWSResponse SearchUsers
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse SearchUsers
SearchUsersResponse
rs
            SearchUsersResponse
-> Getting (First Text) SearchUsersResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> SearchUsersResponse -> Const (First Text) SearchUsersResponse
Lens' SearchUsersResponse (Maybe Text)
searchUsersResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> SearchUsersResponse -> Const (First Text) SearchUsersResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) SearchUsersResponse 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 SearchUsers
forall a. Maybe a
Prelude.Nothing
    | Maybe [UserData] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse SearchUsers
SearchUsersResponse
rs
            SearchUsersResponse
-> Getting (First [UserData]) SearchUsersResponse [UserData]
-> Maybe [UserData]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [UserData] -> Const (First [UserData]) (Maybe [UserData]))
-> SearchUsersResponse
-> Const (First [UserData]) SearchUsersResponse
Lens' SearchUsersResponse (Maybe [UserData])
searchUsersResponse_users ((Maybe [UserData] -> Const (First [UserData]) (Maybe [UserData]))
 -> SearchUsersResponse
 -> Const (First [UserData]) SearchUsersResponse)
-> (([UserData] -> Const (First [UserData]) [UserData])
    -> Maybe [UserData] -> Const (First [UserData]) (Maybe [UserData]))
-> Getting (First [UserData]) SearchUsersResponse [UserData]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([UserData] -> Const (First [UserData]) [UserData])
-> Maybe [UserData] -> Const (First [UserData]) (Maybe [UserData])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe SearchUsers
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      SearchUsers -> Maybe SearchUsers
forall a. a -> Maybe a
Prelude.Just (SearchUsers -> Maybe SearchUsers)
-> SearchUsers -> Maybe SearchUsers
forall a b. (a -> b) -> a -> b
Prelude.$
        SearchUsers
rq
          SearchUsers -> (SearchUsers -> SearchUsers) -> SearchUsers
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> SearchUsers -> Identity SearchUsers
Lens SearchUsers SearchUsers (Maybe Text) (Maybe Text)
searchUsers_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> SearchUsers -> Identity SearchUsers)
-> Maybe Text -> SearchUsers -> SearchUsers
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse SearchUsers
SearchUsersResponse
rs
          SearchUsersResponse
-> Getting (First Text) SearchUsersResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> SearchUsersResponse -> Const (First Text) SearchUsersResponse
Lens' SearchUsersResponse (Maybe Text)
searchUsersResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> SearchUsersResponse -> Const (First Text) SearchUsersResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) SearchUsersResponse 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 SearchUsers where
  type AWSResponse SearchUsers = SearchUsersResponse
  request :: SearchUsers -> Request SearchUsers
request = Service -> SearchUsers -> Request SearchUsers
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy SearchUsers
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SearchUsers)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse SearchUsers))
-> Logger
-> Service
-> Proxy SearchUsers
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SearchUsers)))
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 [UserData]
-> Maybe Text -> Maybe Int -> Int -> SearchUsersResponse
SearchUsersResponse'
            (Maybe [UserData]
 -> Maybe Text -> Maybe Int -> Int -> SearchUsersResponse)
-> Either String (Maybe [UserData])
-> Either
     String (Maybe Text -> Maybe Int -> Int -> SearchUsersResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [UserData]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Users" Either String (Maybe (Maybe [UserData]))
-> Maybe [UserData] -> Either String (Maybe [UserData])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [UserData]
forall a. Monoid a => a
Prelude.mempty)
            Either
  String (Maybe Text -> Maybe Int -> Int -> SearchUsersResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Int -> Int -> SearchUsersResponse)
forall (f :: * -> *) a b. Applicative f => 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
"NextToken")
            Either String (Maybe Int -> Int -> SearchUsersResponse)
-> Either String (Maybe Int)
-> Either String (Int -> SearchUsersResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Int)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"TotalCount")
            Either String (Int -> SearchUsersResponse)
-> Either String Int -> Either String SearchUsersResponse
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 SearchUsers

instance Prelude.NFData SearchUsers

instance Core.ToHeaders SearchUsers where
  toHeaders :: SearchUsers -> ResponseHeaders
toHeaders =
    ResponseHeaders -> SearchUsers -> 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
"AlexaForBusiness.SearchUsers" ::
                          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 SearchUsers where
  toJSON :: SearchUsers -> Value
toJSON SearchUsers' {Maybe Natural
Maybe [Filter]
Maybe [Sort]
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
sortCriteria :: Maybe [Sort]
filters :: Maybe [Filter]
$sel:maxResults:SearchUsers' :: SearchUsers -> Maybe Natural
$sel:nextToken:SearchUsers' :: SearchUsers -> Maybe Text
$sel:sortCriteria:SearchUsers' :: SearchUsers -> Maybe [Sort]
$sel:filters:SearchUsers' :: SearchUsers -> Maybe [Filter]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Filters" Text -> [Filter] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Filter] -> Pair) -> Maybe [Filter] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Filter]
filters,
            (Text
"SortCriteria" Text -> [Sort] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Sort] -> Pair) -> Maybe [Sort] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Sort]
sortCriteria,
            (Text
"NextToken" 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
nextToken,
            (Text
"MaxResults" 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
maxResults
          ]
      )

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

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

-- | /See:/ 'newSearchUsersResponse' smart constructor.
data SearchUsersResponse = SearchUsersResponse'
  { -- | The users that meet the specified set of filter criteria, in sort order.
    SearchUsersResponse -> Maybe [UserData]
users :: Prelude.Maybe [UserData],
    -- | The token returned to indicate that there is more data available.
    SearchUsersResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The total number of users returned.
    SearchUsersResponse -> Maybe Int
totalCount :: Prelude.Maybe Prelude.Int,
    -- | The response's http status code.
    SearchUsersResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (SearchUsersResponse -> SearchUsersResponse -> Bool
(SearchUsersResponse -> SearchUsersResponse -> Bool)
-> (SearchUsersResponse -> SearchUsersResponse -> Bool)
-> Eq SearchUsersResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchUsersResponse -> SearchUsersResponse -> Bool
$c/= :: SearchUsersResponse -> SearchUsersResponse -> Bool
== :: SearchUsersResponse -> SearchUsersResponse -> Bool
$c== :: SearchUsersResponse -> SearchUsersResponse -> Bool
Prelude.Eq, ReadPrec [SearchUsersResponse]
ReadPrec SearchUsersResponse
Int -> ReadS SearchUsersResponse
ReadS [SearchUsersResponse]
(Int -> ReadS SearchUsersResponse)
-> ReadS [SearchUsersResponse]
-> ReadPrec SearchUsersResponse
-> ReadPrec [SearchUsersResponse]
-> Read SearchUsersResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchUsersResponse]
$creadListPrec :: ReadPrec [SearchUsersResponse]
readPrec :: ReadPrec SearchUsersResponse
$creadPrec :: ReadPrec SearchUsersResponse
readList :: ReadS [SearchUsersResponse]
$creadList :: ReadS [SearchUsersResponse]
readsPrec :: Int -> ReadS SearchUsersResponse
$creadsPrec :: Int -> ReadS SearchUsersResponse
Prelude.Read, Int -> SearchUsersResponse -> ShowS
[SearchUsersResponse] -> ShowS
SearchUsersResponse -> String
(Int -> SearchUsersResponse -> ShowS)
-> (SearchUsersResponse -> String)
-> ([SearchUsersResponse] -> ShowS)
-> Show SearchUsersResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchUsersResponse] -> ShowS
$cshowList :: [SearchUsersResponse] -> ShowS
show :: SearchUsersResponse -> String
$cshow :: SearchUsersResponse -> String
showsPrec :: Int -> SearchUsersResponse -> ShowS
$cshowsPrec :: Int -> SearchUsersResponse -> ShowS
Prelude.Show, (forall x. SearchUsersResponse -> Rep SearchUsersResponse x)
-> (forall x. Rep SearchUsersResponse x -> SearchUsersResponse)
-> Generic SearchUsersResponse
forall x. Rep SearchUsersResponse x -> SearchUsersResponse
forall x. SearchUsersResponse -> Rep SearchUsersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SearchUsersResponse x -> SearchUsersResponse
$cfrom :: forall x. SearchUsersResponse -> Rep SearchUsersResponse x
Prelude.Generic)

-- |
-- Create a value of 'SearchUsersResponse' 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:
--
-- 'users', 'searchUsersResponse_users' - The users that meet the specified set of filter criteria, in sort order.
--
-- 'nextToken', 'searchUsersResponse_nextToken' - The token returned to indicate that there is more data available.
--
-- 'totalCount', 'searchUsersResponse_totalCount' - The total number of users returned.
--
-- 'httpStatus', 'searchUsersResponse_httpStatus' - The response's http status code.
newSearchUsersResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  SearchUsersResponse
newSearchUsersResponse :: Int -> SearchUsersResponse
newSearchUsersResponse Int
pHttpStatus_ =
  SearchUsersResponse' :: Maybe [UserData]
-> Maybe Text -> Maybe Int -> Int -> SearchUsersResponse
SearchUsersResponse'
    { $sel:users:SearchUsersResponse' :: Maybe [UserData]
users = Maybe [UserData]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:SearchUsersResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:totalCount:SearchUsersResponse' :: Maybe Int
totalCount = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:SearchUsersResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The users that meet the specified set of filter criteria, in sort order.
searchUsersResponse_users :: Lens.Lens' SearchUsersResponse (Prelude.Maybe [UserData])
searchUsersResponse_users :: (Maybe [UserData] -> f (Maybe [UserData]))
-> SearchUsersResponse -> f SearchUsersResponse
searchUsersResponse_users = (SearchUsersResponse -> Maybe [UserData])
-> (SearchUsersResponse -> Maybe [UserData] -> SearchUsersResponse)
-> Lens' SearchUsersResponse (Maybe [UserData])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchUsersResponse' {Maybe [UserData]
users :: Maybe [UserData]
$sel:users:SearchUsersResponse' :: SearchUsersResponse -> Maybe [UserData]
users} -> Maybe [UserData]
users) (\s :: SearchUsersResponse
s@SearchUsersResponse' {} Maybe [UserData]
a -> SearchUsersResponse
s {$sel:users:SearchUsersResponse' :: Maybe [UserData]
users = Maybe [UserData]
a} :: SearchUsersResponse) ((Maybe [UserData] -> f (Maybe [UserData]))
 -> SearchUsersResponse -> f SearchUsersResponse)
-> ((Maybe [UserData] -> f (Maybe [UserData]))
    -> Maybe [UserData] -> f (Maybe [UserData]))
-> (Maybe [UserData] -> f (Maybe [UserData]))
-> SearchUsersResponse
-> f SearchUsersResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [UserData] [UserData] [UserData] [UserData]
-> Iso
     (Maybe [UserData])
     (Maybe [UserData])
     (Maybe [UserData])
     (Maybe [UserData])
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 [UserData] [UserData] [UserData] [UserData]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token returned to indicate that there is more data available.
searchUsersResponse_nextToken :: Lens.Lens' SearchUsersResponse (Prelude.Maybe Prelude.Text)
searchUsersResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> SearchUsersResponse -> f SearchUsersResponse
searchUsersResponse_nextToken = (SearchUsersResponse -> Maybe Text)
-> (SearchUsersResponse -> Maybe Text -> SearchUsersResponse)
-> Lens' SearchUsersResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchUsersResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SearchUsersResponse' :: SearchUsersResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SearchUsersResponse
s@SearchUsersResponse' {} Maybe Text
a -> SearchUsersResponse
s {$sel:nextToken:SearchUsersResponse' :: Maybe Text
nextToken = Maybe Text
a} :: SearchUsersResponse)

-- | The total number of users returned.
searchUsersResponse_totalCount :: Lens.Lens' SearchUsersResponse (Prelude.Maybe Prelude.Int)
searchUsersResponse_totalCount :: (Maybe Int -> f (Maybe Int))
-> SearchUsersResponse -> f SearchUsersResponse
searchUsersResponse_totalCount = (SearchUsersResponse -> Maybe Int)
-> (SearchUsersResponse -> Maybe Int -> SearchUsersResponse)
-> Lens
     SearchUsersResponse SearchUsersResponse (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchUsersResponse' {Maybe Int
totalCount :: Maybe Int
$sel:totalCount:SearchUsersResponse' :: SearchUsersResponse -> Maybe Int
totalCount} -> Maybe Int
totalCount) (\s :: SearchUsersResponse
s@SearchUsersResponse' {} Maybe Int
a -> SearchUsersResponse
s {$sel:totalCount:SearchUsersResponse' :: Maybe Int
totalCount = Maybe Int
a} :: SearchUsersResponse)

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

instance Prelude.NFData SearchUsersResponse