{-# 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.WorkDocs.DescribeUsers
-- 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)
--
-- Describes the specified users. You can describe all users or filter the
-- results (for example, by status or organization).
--
-- By default, Amazon WorkDocs returns the first 24 active or pending
-- users. If there are more results, the response includes a marker that
-- you can use to request the next set of results.
--
-- This operation returns paginated results.
module Amazonka.WorkDocs.DescribeUsers
  ( -- * Creating a Request
    DescribeUsers (..),
    newDescribeUsers,

    -- * Request Lenses
    describeUsers_include,
    describeUsers_userIds,
    describeUsers_authenticationToken,
    describeUsers_sort,
    describeUsers_marker,
    describeUsers_query,
    describeUsers_limit,
    describeUsers_order,
    describeUsers_organizationId,
    describeUsers_fields,

    -- * Destructuring the Response
    DescribeUsersResponse (..),
    newDescribeUsersResponse,

    -- * Response Lenses
    describeUsersResponse_users,
    describeUsersResponse_totalNumberOfUsers,
    describeUsersResponse_marker,
    describeUsersResponse_httpStatus,
  )
where

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
import Amazonka.WorkDocs.Types

-- | /See:/ 'newDescribeUsers' smart constructor.
data DescribeUsers = DescribeUsers'
  { -- | The state of the users. Specify \"ALL\" to include inactive users.
    DescribeUsers -> Maybe UserFilterType
include :: Prelude.Maybe UserFilterType,
    -- | The IDs of the users.
    DescribeUsers -> Maybe Text
userIds :: Prelude.Maybe Prelude.Text,
    -- | Amazon WorkDocs authentication token. Not required when using AWS
    -- administrator credentials to access the API.
    DescribeUsers -> Maybe (Sensitive Text)
authenticationToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The sorting criteria.
    DescribeUsers -> Maybe UserSortType
sort :: Prelude.Maybe UserSortType,
    -- | The marker for the next set of results. (You received this marker from a
    -- previous call.)
    DescribeUsers -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | A query to filter users by user name.
    DescribeUsers -> Maybe (Sensitive Text)
query :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The maximum number of items to return.
    DescribeUsers -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | The order for the results.
    DescribeUsers -> Maybe OrderType
order :: Prelude.Maybe OrderType,
    -- | The ID of the organization.
    DescribeUsers -> Maybe Text
organizationId :: Prelude.Maybe Prelude.Text,
    -- | A comma-separated list of values. Specify \"STORAGE_METADATA\" to
    -- include the user storage quota and utilization information.
    DescribeUsers -> Maybe Text
fields :: Prelude.Maybe Prelude.Text
  }
  deriving (DescribeUsers -> DescribeUsers -> Bool
(DescribeUsers -> DescribeUsers -> Bool)
-> (DescribeUsers -> DescribeUsers -> Bool) -> Eq DescribeUsers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeUsers -> DescribeUsers -> Bool
$c/= :: DescribeUsers -> DescribeUsers -> Bool
== :: DescribeUsers -> DescribeUsers -> Bool
$c== :: DescribeUsers -> DescribeUsers -> Bool
Prelude.Eq, Int -> DescribeUsers -> ShowS
[DescribeUsers] -> ShowS
DescribeUsers -> String
(Int -> DescribeUsers -> ShowS)
-> (DescribeUsers -> String)
-> ([DescribeUsers] -> ShowS)
-> Show DescribeUsers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeUsers] -> ShowS
$cshowList :: [DescribeUsers] -> ShowS
show :: DescribeUsers -> String
$cshow :: DescribeUsers -> String
showsPrec :: Int -> DescribeUsers -> ShowS
$cshowsPrec :: Int -> DescribeUsers -> ShowS
Prelude.Show, (forall x. DescribeUsers -> Rep DescribeUsers x)
-> (forall x. Rep DescribeUsers x -> DescribeUsers)
-> Generic DescribeUsers
forall x. Rep DescribeUsers x -> DescribeUsers
forall x. DescribeUsers -> Rep DescribeUsers x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeUsers x -> DescribeUsers
$cfrom :: forall x. DescribeUsers -> Rep DescribeUsers x
Prelude.Generic)

-- |
-- Create a value of 'DescribeUsers' 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:
--
-- 'include', 'describeUsers_include' - The state of the users. Specify \"ALL\" to include inactive users.
--
-- 'userIds', 'describeUsers_userIds' - The IDs of the users.
--
-- 'authenticationToken', 'describeUsers_authenticationToken' - Amazon WorkDocs authentication token. Not required when using AWS
-- administrator credentials to access the API.
--
-- 'sort', 'describeUsers_sort' - The sorting criteria.
--
-- 'marker', 'describeUsers_marker' - The marker for the next set of results. (You received this marker from a
-- previous call.)
--
-- 'query', 'describeUsers_query' - A query to filter users by user name.
--
-- 'limit', 'describeUsers_limit' - The maximum number of items to return.
--
-- 'order', 'describeUsers_order' - The order for the results.
--
-- 'organizationId', 'describeUsers_organizationId' - The ID of the organization.
--
-- 'fields', 'describeUsers_fields' - A comma-separated list of values. Specify \"STORAGE_METADATA\" to
-- include the user storage quota and utilization information.
newDescribeUsers ::
  DescribeUsers
newDescribeUsers :: DescribeUsers
newDescribeUsers =
  DescribeUsers' :: Maybe UserFilterType
-> Maybe Text
-> Maybe (Sensitive Text)
-> Maybe UserSortType
-> Maybe Text
-> Maybe (Sensitive Text)
-> Maybe Natural
-> Maybe OrderType
-> Maybe Text
-> Maybe Text
-> DescribeUsers
DescribeUsers'
    { $sel:include:DescribeUsers' :: Maybe UserFilterType
include = Maybe UserFilterType
forall a. Maybe a
Prelude.Nothing,
      $sel:userIds:DescribeUsers' :: Maybe Text
userIds = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:authenticationToken:DescribeUsers' :: Maybe (Sensitive Text)
authenticationToken = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:sort:DescribeUsers' :: Maybe UserSortType
sort = Maybe UserSortType
forall a. Maybe a
Prelude.Nothing,
      $sel:marker:DescribeUsers' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:query:DescribeUsers' :: Maybe (Sensitive Text)
query = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:limit:DescribeUsers' :: Maybe Natural
limit = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:order:DescribeUsers' :: Maybe OrderType
order = Maybe OrderType
forall a. Maybe a
Prelude.Nothing,
      $sel:organizationId:DescribeUsers' :: Maybe Text
organizationId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:fields:DescribeUsers' :: Maybe Text
fields = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The state of the users. Specify \"ALL\" to include inactive users.
describeUsers_include :: Lens.Lens' DescribeUsers (Prelude.Maybe UserFilterType)
describeUsers_include :: (Maybe UserFilterType -> f (Maybe UserFilterType))
-> DescribeUsers -> f DescribeUsers
describeUsers_include = (DescribeUsers -> Maybe UserFilterType)
-> (DescribeUsers -> Maybe UserFilterType -> DescribeUsers)
-> Lens
     DescribeUsers
     DescribeUsers
     (Maybe UserFilterType)
     (Maybe UserFilterType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUsers' {Maybe UserFilterType
include :: Maybe UserFilterType
$sel:include:DescribeUsers' :: DescribeUsers -> Maybe UserFilterType
include} -> Maybe UserFilterType
include) (\s :: DescribeUsers
s@DescribeUsers' {} Maybe UserFilterType
a -> DescribeUsers
s {$sel:include:DescribeUsers' :: Maybe UserFilterType
include = Maybe UserFilterType
a} :: DescribeUsers)

-- | The IDs of the users.
describeUsers_userIds :: Lens.Lens' DescribeUsers (Prelude.Maybe Prelude.Text)
describeUsers_userIds :: (Maybe Text -> f (Maybe Text)) -> DescribeUsers -> f DescribeUsers
describeUsers_userIds = (DescribeUsers -> Maybe Text)
-> (DescribeUsers -> Maybe Text -> DescribeUsers)
-> Lens DescribeUsers DescribeUsers (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUsers' {Maybe Text
userIds :: Maybe Text
$sel:userIds:DescribeUsers' :: DescribeUsers -> Maybe Text
userIds} -> Maybe Text
userIds) (\s :: DescribeUsers
s@DescribeUsers' {} Maybe Text
a -> DescribeUsers
s {$sel:userIds:DescribeUsers' :: Maybe Text
userIds = Maybe Text
a} :: DescribeUsers)

-- | Amazon WorkDocs authentication token. Not required when using AWS
-- administrator credentials to access the API.
describeUsers_authenticationToken :: Lens.Lens' DescribeUsers (Prelude.Maybe Prelude.Text)
describeUsers_authenticationToken :: (Maybe Text -> f (Maybe Text)) -> DescribeUsers -> f DescribeUsers
describeUsers_authenticationToken = (DescribeUsers -> Maybe (Sensitive Text))
-> (DescribeUsers -> Maybe (Sensitive Text) -> DescribeUsers)
-> Lens
     DescribeUsers
     DescribeUsers
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUsers' {Maybe (Sensitive Text)
authenticationToken :: Maybe (Sensitive Text)
$sel:authenticationToken:DescribeUsers' :: DescribeUsers -> Maybe (Sensitive Text)
authenticationToken} -> Maybe (Sensitive Text)
authenticationToken) (\s :: DescribeUsers
s@DescribeUsers' {} Maybe (Sensitive Text)
a -> DescribeUsers
s {$sel:authenticationToken:DescribeUsers' :: Maybe (Sensitive Text)
authenticationToken = Maybe (Sensitive Text)
a} :: DescribeUsers) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> DescribeUsers -> f DescribeUsers)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> DescribeUsers
-> f DescribeUsers
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive 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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The sorting criteria.
describeUsers_sort :: Lens.Lens' DescribeUsers (Prelude.Maybe UserSortType)
describeUsers_sort :: (Maybe UserSortType -> f (Maybe UserSortType))
-> DescribeUsers -> f DescribeUsers
describeUsers_sort = (DescribeUsers -> Maybe UserSortType)
-> (DescribeUsers -> Maybe UserSortType -> DescribeUsers)
-> Lens
     DescribeUsers
     DescribeUsers
     (Maybe UserSortType)
     (Maybe UserSortType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUsers' {Maybe UserSortType
sort :: Maybe UserSortType
$sel:sort:DescribeUsers' :: DescribeUsers -> Maybe UserSortType
sort} -> Maybe UserSortType
sort) (\s :: DescribeUsers
s@DescribeUsers' {} Maybe UserSortType
a -> DescribeUsers
s {$sel:sort:DescribeUsers' :: Maybe UserSortType
sort = Maybe UserSortType
a} :: DescribeUsers)

-- | The marker for the next set of results. (You received this marker from a
-- previous call.)
describeUsers_marker :: Lens.Lens' DescribeUsers (Prelude.Maybe Prelude.Text)
describeUsers_marker :: (Maybe Text -> f (Maybe Text)) -> DescribeUsers -> f DescribeUsers
describeUsers_marker = (DescribeUsers -> Maybe Text)
-> (DescribeUsers -> Maybe Text -> DescribeUsers)
-> Lens DescribeUsers DescribeUsers (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUsers' {Maybe Text
marker :: Maybe Text
$sel:marker:DescribeUsers' :: DescribeUsers -> Maybe Text
marker} -> Maybe Text
marker) (\s :: DescribeUsers
s@DescribeUsers' {} Maybe Text
a -> DescribeUsers
s {$sel:marker:DescribeUsers' :: Maybe Text
marker = Maybe Text
a} :: DescribeUsers)

-- | A query to filter users by user name.
describeUsers_query :: Lens.Lens' DescribeUsers (Prelude.Maybe Prelude.Text)
describeUsers_query :: (Maybe Text -> f (Maybe Text)) -> DescribeUsers -> f DescribeUsers
describeUsers_query = (DescribeUsers -> Maybe (Sensitive Text))
-> (DescribeUsers -> Maybe (Sensitive Text) -> DescribeUsers)
-> Lens
     DescribeUsers
     DescribeUsers
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUsers' {Maybe (Sensitive Text)
query :: Maybe (Sensitive Text)
$sel:query:DescribeUsers' :: DescribeUsers -> Maybe (Sensitive Text)
query} -> Maybe (Sensitive Text)
query) (\s :: DescribeUsers
s@DescribeUsers' {} Maybe (Sensitive Text)
a -> DescribeUsers
s {$sel:query:DescribeUsers' :: Maybe (Sensitive Text)
query = Maybe (Sensitive Text)
a} :: DescribeUsers) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> DescribeUsers -> f DescribeUsers)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> DescribeUsers
-> f DescribeUsers
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive 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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The maximum number of items to return.
describeUsers_limit :: Lens.Lens' DescribeUsers (Prelude.Maybe Prelude.Natural)
describeUsers_limit :: (Maybe Natural -> f (Maybe Natural))
-> DescribeUsers -> f DescribeUsers
describeUsers_limit = (DescribeUsers -> Maybe Natural)
-> (DescribeUsers -> Maybe Natural -> DescribeUsers)
-> Lens DescribeUsers DescribeUsers (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUsers' {Maybe Natural
limit :: Maybe Natural
$sel:limit:DescribeUsers' :: DescribeUsers -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: DescribeUsers
s@DescribeUsers' {} Maybe Natural
a -> DescribeUsers
s {$sel:limit:DescribeUsers' :: Maybe Natural
limit = Maybe Natural
a} :: DescribeUsers)

-- | The order for the results.
describeUsers_order :: Lens.Lens' DescribeUsers (Prelude.Maybe OrderType)
describeUsers_order :: (Maybe OrderType -> f (Maybe OrderType))
-> DescribeUsers -> f DescribeUsers
describeUsers_order = (DescribeUsers -> Maybe OrderType)
-> (DescribeUsers -> Maybe OrderType -> DescribeUsers)
-> Lens
     DescribeUsers DescribeUsers (Maybe OrderType) (Maybe OrderType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUsers' {Maybe OrderType
order :: Maybe OrderType
$sel:order:DescribeUsers' :: DescribeUsers -> Maybe OrderType
order} -> Maybe OrderType
order) (\s :: DescribeUsers
s@DescribeUsers' {} Maybe OrderType
a -> DescribeUsers
s {$sel:order:DescribeUsers' :: Maybe OrderType
order = Maybe OrderType
a} :: DescribeUsers)

-- | The ID of the organization.
describeUsers_organizationId :: Lens.Lens' DescribeUsers (Prelude.Maybe Prelude.Text)
describeUsers_organizationId :: (Maybe Text -> f (Maybe Text)) -> DescribeUsers -> f DescribeUsers
describeUsers_organizationId = (DescribeUsers -> Maybe Text)
-> (DescribeUsers -> Maybe Text -> DescribeUsers)
-> Lens DescribeUsers DescribeUsers (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUsers' {Maybe Text
organizationId :: Maybe Text
$sel:organizationId:DescribeUsers' :: DescribeUsers -> Maybe Text
organizationId} -> Maybe Text
organizationId) (\s :: DescribeUsers
s@DescribeUsers' {} Maybe Text
a -> DescribeUsers
s {$sel:organizationId:DescribeUsers' :: Maybe Text
organizationId = Maybe Text
a} :: DescribeUsers)

-- | A comma-separated list of values. Specify \"STORAGE_METADATA\" to
-- include the user storage quota and utilization information.
describeUsers_fields :: Lens.Lens' DescribeUsers (Prelude.Maybe Prelude.Text)
describeUsers_fields :: (Maybe Text -> f (Maybe Text)) -> DescribeUsers -> f DescribeUsers
describeUsers_fields = (DescribeUsers -> Maybe Text)
-> (DescribeUsers -> Maybe Text -> DescribeUsers)
-> Lens DescribeUsers DescribeUsers (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUsers' {Maybe Text
fields :: Maybe Text
$sel:fields:DescribeUsers' :: DescribeUsers -> Maybe Text
fields} -> Maybe Text
fields) (\s :: DescribeUsers
s@DescribeUsers' {} Maybe Text
a -> DescribeUsers
s {$sel:fields:DescribeUsers' :: Maybe Text
fields = Maybe Text
a} :: DescribeUsers)

instance Core.AWSPager DescribeUsers where
  page :: DescribeUsers -> AWSResponse DescribeUsers -> Maybe DescribeUsers
page DescribeUsers
rq AWSResponse DescribeUsers
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeUsers
DescribeUsersResponse
rs
            DescribeUsersResponse
-> Getting (First Text) DescribeUsersResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeUsersResponse
-> Const (First Text) DescribeUsersResponse
Lens' DescribeUsersResponse (Maybe Text)
describeUsersResponse_marker ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeUsersResponse
 -> Const (First Text) DescribeUsersResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeUsersResponse 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 DescribeUsers
forall a. Maybe a
Prelude.Nothing
    | Maybe [User] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse DescribeUsers
DescribeUsersResponse
rs
            DescribeUsersResponse
-> Getting (First [User]) DescribeUsersResponse [User]
-> Maybe [User]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [User] -> Const (First [User]) (Maybe [User]))
-> DescribeUsersResponse
-> Const (First [User]) DescribeUsersResponse
Lens' DescribeUsersResponse (Maybe [User])
describeUsersResponse_users ((Maybe [User] -> Const (First [User]) (Maybe [User]))
 -> DescribeUsersResponse
 -> Const (First [User]) DescribeUsersResponse)
-> (([User] -> Const (First [User]) [User])
    -> Maybe [User] -> Const (First [User]) (Maybe [User]))
-> Getting (First [User]) DescribeUsersResponse [User]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([User] -> Const (First [User]) [User])
-> Maybe [User] -> Const (First [User]) (Maybe [User])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe DescribeUsers
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      DescribeUsers -> Maybe DescribeUsers
forall a. a -> Maybe a
Prelude.Just (DescribeUsers -> Maybe DescribeUsers)
-> DescribeUsers -> Maybe DescribeUsers
forall a b. (a -> b) -> a -> b
Prelude.$
        DescribeUsers
rq
          DescribeUsers -> (DescribeUsers -> DescribeUsers) -> DescribeUsers
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> DescribeUsers -> Identity DescribeUsers
Lens DescribeUsers DescribeUsers (Maybe Text) (Maybe Text)
describeUsers_marker
          ((Maybe Text -> Identity (Maybe Text))
 -> DescribeUsers -> Identity DescribeUsers)
-> Maybe Text -> DescribeUsers -> DescribeUsers
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse DescribeUsers
DescribeUsersResponse
rs
          DescribeUsersResponse
-> Getting (First Text) DescribeUsersResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> DescribeUsersResponse
-> Const (First Text) DescribeUsersResponse
Lens' DescribeUsersResponse (Maybe Text)
describeUsersResponse_marker ((Maybe Text -> Const (First Text) (Maybe Text))
 -> DescribeUsersResponse
 -> Const (First Text) DescribeUsersResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) DescribeUsersResponse 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 DescribeUsers where
  type
    AWSResponse DescribeUsers =
      DescribeUsersResponse
  request :: DescribeUsers -> Request DescribeUsers
request = Service -> DescribeUsers -> Request DescribeUsers
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeUsers
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeUsers)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeUsers))
-> Logger
-> Service
-> Proxy DescribeUsers
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeUsers)))
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 [User]
-> Maybe Integer -> Maybe Text -> Int -> DescribeUsersResponse
DescribeUsersResponse'
            (Maybe [User]
 -> Maybe Integer -> Maybe Text -> Int -> DescribeUsersResponse)
-> Either String (Maybe [User])
-> Either
     String
     (Maybe Integer -> Maybe Text -> Int -> DescribeUsersResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [User]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Users" Either String (Maybe (Maybe [User]))
-> Maybe [User] -> Either String (Maybe [User])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [User]
forall a. Monoid a => a
Prelude.mempty)
            Either
  String
  (Maybe Integer -> Maybe Text -> Int -> DescribeUsersResponse)
-> Either String (Maybe Integer)
-> Either String (Maybe Text -> Int -> DescribeUsersResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"TotalNumberOfUsers")
            Either String (Maybe Text -> Int -> DescribeUsersResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DescribeUsersResponse)
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
"Marker")
            Either String (Int -> DescribeUsersResponse)
-> Either String Int -> Either String DescribeUsersResponse
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 DescribeUsers

instance Prelude.NFData DescribeUsers

instance Core.ToHeaders DescribeUsers where
  toHeaders :: DescribeUsers -> ResponseHeaders
toHeaders DescribeUsers' {Maybe Natural
Maybe Text
Maybe (Sensitive Text)
Maybe OrderType
Maybe UserFilterType
Maybe UserSortType
fields :: Maybe Text
organizationId :: Maybe Text
order :: Maybe OrderType
limit :: Maybe Natural
query :: Maybe (Sensitive Text)
marker :: Maybe Text
sort :: Maybe UserSortType
authenticationToken :: Maybe (Sensitive Text)
userIds :: Maybe Text
include :: Maybe UserFilterType
$sel:fields:DescribeUsers' :: DescribeUsers -> Maybe Text
$sel:organizationId:DescribeUsers' :: DescribeUsers -> Maybe Text
$sel:order:DescribeUsers' :: DescribeUsers -> Maybe OrderType
$sel:limit:DescribeUsers' :: DescribeUsers -> Maybe Natural
$sel:query:DescribeUsers' :: DescribeUsers -> Maybe (Sensitive Text)
$sel:marker:DescribeUsers' :: DescribeUsers -> Maybe Text
$sel:sort:DescribeUsers' :: DescribeUsers -> Maybe UserSortType
$sel:authenticationToken:DescribeUsers' :: DescribeUsers -> Maybe (Sensitive Text)
$sel:userIds:DescribeUsers' :: DescribeUsers -> Maybe Text
$sel:include:DescribeUsers' :: DescribeUsers -> Maybe UserFilterType
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"Authentication" HeaderName -> Maybe (Sensitive Text) -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe (Sensitive Text)
authenticationToken,
        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.ToPath DescribeUsers where
  toPath :: DescribeUsers -> ByteString
toPath = ByteString -> DescribeUsers -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/api/v1/users"

instance Core.ToQuery DescribeUsers where
  toQuery :: DescribeUsers -> QueryString
toQuery DescribeUsers' {Maybe Natural
Maybe Text
Maybe (Sensitive Text)
Maybe OrderType
Maybe UserFilterType
Maybe UserSortType
fields :: Maybe Text
organizationId :: Maybe Text
order :: Maybe OrderType
limit :: Maybe Natural
query :: Maybe (Sensitive Text)
marker :: Maybe Text
sort :: Maybe UserSortType
authenticationToken :: Maybe (Sensitive Text)
userIds :: Maybe Text
include :: Maybe UserFilterType
$sel:fields:DescribeUsers' :: DescribeUsers -> Maybe Text
$sel:organizationId:DescribeUsers' :: DescribeUsers -> Maybe Text
$sel:order:DescribeUsers' :: DescribeUsers -> Maybe OrderType
$sel:limit:DescribeUsers' :: DescribeUsers -> Maybe Natural
$sel:query:DescribeUsers' :: DescribeUsers -> Maybe (Sensitive Text)
$sel:marker:DescribeUsers' :: DescribeUsers -> Maybe Text
$sel:sort:DescribeUsers' :: DescribeUsers -> Maybe UserSortType
$sel:authenticationToken:DescribeUsers' :: DescribeUsers -> Maybe (Sensitive Text)
$sel:userIds:DescribeUsers' :: DescribeUsers -> Maybe Text
$sel:include:DescribeUsers' :: DescribeUsers -> Maybe UserFilterType
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"include" ByteString -> Maybe UserFilterType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe UserFilterType
include,
        ByteString
"userIds" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
userIds,
        ByteString
"sort" ByteString -> Maybe UserSortType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe UserSortType
sort,
        ByteString
"marker" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
marker,
        ByteString
"query" ByteString -> Maybe (Sensitive Text) -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe (Sensitive Text)
query,
        ByteString
"limit" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
limit,
        ByteString
"order" ByteString -> Maybe OrderType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe OrderType
order,
        ByteString
"organizationId" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
organizationId,
        ByteString
"fields" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
fields
      ]

-- | /See:/ 'newDescribeUsersResponse' smart constructor.
data DescribeUsersResponse = DescribeUsersResponse'
  { -- | The users.
    DescribeUsersResponse -> Maybe [User]
users :: Prelude.Maybe [User],
    -- | The total number of users included in the results.
    DescribeUsersResponse -> Maybe Integer
totalNumberOfUsers :: Prelude.Maybe Prelude.Integer,
    -- | The marker to use when requesting the next set of results. If there are
    -- no additional results, the string is empty.
    DescribeUsersResponse -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeUsersResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeUsersResponse -> DescribeUsersResponse -> Bool
(DescribeUsersResponse -> DescribeUsersResponse -> Bool)
-> (DescribeUsersResponse -> DescribeUsersResponse -> Bool)
-> Eq DescribeUsersResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeUsersResponse -> DescribeUsersResponse -> Bool
$c/= :: DescribeUsersResponse -> DescribeUsersResponse -> Bool
== :: DescribeUsersResponse -> DescribeUsersResponse -> Bool
$c== :: DescribeUsersResponse -> DescribeUsersResponse -> Bool
Prelude.Eq, ReadPrec [DescribeUsersResponse]
ReadPrec DescribeUsersResponse
Int -> ReadS DescribeUsersResponse
ReadS [DescribeUsersResponse]
(Int -> ReadS DescribeUsersResponse)
-> ReadS [DescribeUsersResponse]
-> ReadPrec DescribeUsersResponse
-> ReadPrec [DescribeUsersResponse]
-> Read DescribeUsersResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeUsersResponse]
$creadListPrec :: ReadPrec [DescribeUsersResponse]
readPrec :: ReadPrec DescribeUsersResponse
$creadPrec :: ReadPrec DescribeUsersResponse
readList :: ReadS [DescribeUsersResponse]
$creadList :: ReadS [DescribeUsersResponse]
readsPrec :: Int -> ReadS DescribeUsersResponse
$creadsPrec :: Int -> ReadS DescribeUsersResponse
Prelude.Read, Int -> DescribeUsersResponse -> ShowS
[DescribeUsersResponse] -> ShowS
DescribeUsersResponse -> String
(Int -> DescribeUsersResponse -> ShowS)
-> (DescribeUsersResponse -> String)
-> ([DescribeUsersResponse] -> ShowS)
-> Show DescribeUsersResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeUsersResponse] -> ShowS
$cshowList :: [DescribeUsersResponse] -> ShowS
show :: DescribeUsersResponse -> String
$cshow :: DescribeUsersResponse -> String
showsPrec :: Int -> DescribeUsersResponse -> ShowS
$cshowsPrec :: Int -> DescribeUsersResponse -> ShowS
Prelude.Show, (forall x. DescribeUsersResponse -> Rep DescribeUsersResponse x)
-> (forall x. Rep DescribeUsersResponse x -> DescribeUsersResponse)
-> Generic DescribeUsersResponse
forall x. Rep DescribeUsersResponse x -> DescribeUsersResponse
forall x. DescribeUsersResponse -> Rep DescribeUsersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeUsersResponse x -> DescribeUsersResponse
$cfrom :: forall x. DescribeUsersResponse -> Rep DescribeUsersResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeUsersResponse' 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', 'describeUsersResponse_users' - The users.
--
-- 'totalNumberOfUsers', 'describeUsersResponse_totalNumberOfUsers' - The total number of users included in the results.
--
-- 'marker', 'describeUsersResponse_marker' - The marker to use when requesting the next set of results. If there are
-- no additional results, the string is empty.
--
-- 'httpStatus', 'describeUsersResponse_httpStatus' - The response's http status code.
newDescribeUsersResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeUsersResponse
newDescribeUsersResponse :: Int -> DescribeUsersResponse
newDescribeUsersResponse Int
pHttpStatus_ =
  DescribeUsersResponse' :: Maybe [User]
-> Maybe Integer -> Maybe Text -> Int -> DescribeUsersResponse
DescribeUsersResponse'
    { $sel:users:DescribeUsersResponse' :: Maybe [User]
users = Maybe [User]
forall a. Maybe a
Prelude.Nothing,
      $sel:totalNumberOfUsers:DescribeUsersResponse' :: Maybe Integer
totalNumberOfUsers = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:marker:DescribeUsersResponse' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeUsersResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The users.
describeUsersResponse_users :: Lens.Lens' DescribeUsersResponse (Prelude.Maybe [User])
describeUsersResponse_users :: (Maybe [User] -> f (Maybe [User]))
-> DescribeUsersResponse -> f DescribeUsersResponse
describeUsersResponse_users = (DescribeUsersResponse -> Maybe [User])
-> (DescribeUsersResponse -> Maybe [User] -> DescribeUsersResponse)
-> Lens' DescribeUsersResponse (Maybe [User])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUsersResponse' {Maybe [User]
users :: Maybe [User]
$sel:users:DescribeUsersResponse' :: DescribeUsersResponse -> Maybe [User]
users} -> Maybe [User]
users) (\s :: DescribeUsersResponse
s@DescribeUsersResponse' {} Maybe [User]
a -> DescribeUsersResponse
s {$sel:users:DescribeUsersResponse' :: Maybe [User]
users = Maybe [User]
a} :: DescribeUsersResponse) ((Maybe [User] -> f (Maybe [User]))
 -> DescribeUsersResponse -> f DescribeUsersResponse)
-> ((Maybe [User] -> f (Maybe [User]))
    -> Maybe [User] -> f (Maybe [User]))
-> (Maybe [User] -> f (Maybe [User]))
-> DescribeUsersResponse
-> f DescribeUsersResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [User] [User] [User] [User]
-> Iso (Maybe [User]) (Maybe [User]) (Maybe [User]) (Maybe [User])
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 [User] [User] [User] [User]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The total number of users included in the results.
describeUsersResponse_totalNumberOfUsers :: Lens.Lens' DescribeUsersResponse (Prelude.Maybe Prelude.Integer)
describeUsersResponse_totalNumberOfUsers :: (Maybe Integer -> f (Maybe Integer))
-> DescribeUsersResponse -> f DescribeUsersResponse
describeUsersResponse_totalNumberOfUsers = (DescribeUsersResponse -> Maybe Integer)
-> (DescribeUsersResponse
    -> Maybe Integer -> DescribeUsersResponse)
-> Lens
     DescribeUsersResponse
     DescribeUsersResponse
     (Maybe Integer)
     (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUsersResponse' {Maybe Integer
totalNumberOfUsers :: Maybe Integer
$sel:totalNumberOfUsers:DescribeUsersResponse' :: DescribeUsersResponse -> Maybe Integer
totalNumberOfUsers} -> Maybe Integer
totalNumberOfUsers) (\s :: DescribeUsersResponse
s@DescribeUsersResponse' {} Maybe Integer
a -> DescribeUsersResponse
s {$sel:totalNumberOfUsers:DescribeUsersResponse' :: Maybe Integer
totalNumberOfUsers = Maybe Integer
a} :: DescribeUsersResponse)

-- | The marker to use when requesting the next set of results. If there are
-- no additional results, the string is empty.
describeUsersResponse_marker :: Lens.Lens' DescribeUsersResponse (Prelude.Maybe Prelude.Text)
describeUsersResponse_marker :: (Maybe Text -> f (Maybe Text))
-> DescribeUsersResponse -> f DescribeUsersResponse
describeUsersResponse_marker = (DescribeUsersResponse -> Maybe Text)
-> (DescribeUsersResponse -> Maybe Text -> DescribeUsersResponse)
-> Lens' DescribeUsersResponse (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeUsersResponse' {Maybe Text
marker :: Maybe Text
$sel:marker:DescribeUsersResponse' :: DescribeUsersResponse -> Maybe Text
marker} -> Maybe Text
marker) (\s :: DescribeUsersResponse
s@DescribeUsersResponse' {} Maybe Text
a -> DescribeUsersResponse
s {$sel:marker:DescribeUsersResponse' :: Maybe Text
marker = Maybe Text
a} :: DescribeUsersResponse)

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

instance Prelude.NFData DescribeUsersResponse