{-# 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.AdminListDevices
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Lists devices, as an administrator.
--
-- Calling this action requires developer credentials.
module Amazonka.CognitoIdentityProvider.AdminListDevices
  ( -- * Creating a Request
    AdminListDevices (..),
    newAdminListDevices,

    -- * Request Lenses
    adminListDevices_limit,
    adminListDevices_paginationToken,
    adminListDevices_userPoolId,
    adminListDevices_username,

    -- * Destructuring the Response
    AdminListDevicesResponse (..),
    newAdminListDevicesResponse,

    -- * Response Lenses
    adminListDevicesResponse_devices,
    adminListDevicesResponse_paginationToken,
    adminListDevicesResponse_httpStatus,
  )
where

import Amazonka.CognitoIdentityProvider.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Represents the request to list devices, as an administrator.
--
-- /See:/ 'newAdminListDevices' smart constructor.
data AdminListDevices = AdminListDevices'
  { -- | The limit of the devices request.
    AdminListDevices -> Maybe Natural
limit :: Prelude.Maybe Prelude.Natural,
    -- | The pagination token.
    AdminListDevices -> Maybe Text
paginationToken :: Prelude.Maybe Prelude.Text,
    -- | The user pool ID.
    AdminListDevices -> Text
userPoolId :: Prelude.Text,
    -- | The user name.
    AdminListDevices -> Sensitive Text
username :: Data.Sensitive Prelude.Text
  }
  deriving (AdminListDevices -> AdminListDevices -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AdminListDevices -> AdminListDevices -> Bool
$c/= :: AdminListDevices -> AdminListDevices -> Bool
== :: AdminListDevices -> AdminListDevices -> Bool
$c== :: AdminListDevices -> AdminListDevices -> Bool
Prelude.Eq, Int -> AdminListDevices -> ShowS
[AdminListDevices] -> ShowS
AdminListDevices -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AdminListDevices] -> ShowS
$cshowList :: [AdminListDevices] -> ShowS
show :: AdminListDevices -> String
$cshow :: AdminListDevices -> String
showsPrec :: Int -> AdminListDevices -> ShowS
$cshowsPrec :: Int -> AdminListDevices -> ShowS
Prelude.Show, forall x. Rep AdminListDevices x -> AdminListDevices
forall x. AdminListDevices -> Rep AdminListDevices x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AdminListDevices x -> AdminListDevices
$cfrom :: forall x. AdminListDevices -> Rep AdminListDevices x
Prelude.Generic)

-- |
-- Create a value of 'AdminListDevices' 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:
--
-- 'limit', 'adminListDevices_limit' - The limit of the devices request.
--
-- 'paginationToken', 'adminListDevices_paginationToken' - The pagination token.
--
-- 'userPoolId', 'adminListDevices_userPoolId' - The user pool ID.
--
-- 'username', 'adminListDevices_username' - The user name.
newAdminListDevices ::
  -- | 'userPoolId'
  Prelude.Text ->
  -- | 'username'
  Prelude.Text ->
  AdminListDevices
newAdminListDevices :: Text -> Text -> AdminListDevices
newAdminListDevices Text
pUserPoolId_ Text
pUsername_ =
  AdminListDevices'
    { $sel:limit:AdminListDevices' :: Maybe Natural
limit = forall a. Maybe a
Prelude.Nothing,
      $sel:paginationToken:AdminListDevices' :: Maybe Text
paginationToken = forall a. Maybe a
Prelude.Nothing,
      $sel:userPoolId:AdminListDevices' :: Text
userPoolId = Text
pUserPoolId_,
      $sel:username:AdminListDevices' :: Sensitive Text
username = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pUsername_
    }

-- | The limit of the devices request.
adminListDevices_limit :: Lens.Lens' AdminListDevices (Prelude.Maybe Prelude.Natural)
adminListDevices_limit :: Lens' AdminListDevices (Maybe Natural)
adminListDevices_limit = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminListDevices' {Maybe Natural
limit :: Maybe Natural
$sel:limit:AdminListDevices' :: AdminListDevices -> Maybe Natural
limit} -> Maybe Natural
limit) (\s :: AdminListDevices
s@AdminListDevices' {} Maybe Natural
a -> AdminListDevices
s {$sel:limit:AdminListDevices' :: Maybe Natural
limit = Maybe Natural
a} :: AdminListDevices)

-- | The pagination token.
adminListDevices_paginationToken :: Lens.Lens' AdminListDevices (Prelude.Maybe Prelude.Text)
adminListDevices_paginationToken :: Lens' AdminListDevices (Maybe Text)
adminListDevices_paginationToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminListDevices' {Maybe Text
paginationToken :: Maybe Text
$sel:paginationToken:AdminListDevices' :: AdminListDevices -> Maybe Text
paginationToken} -> Maybe Text
paginationToken) (\s :: AdminListDevices
s@AdminListDevices' {} Maybe Text
a -> AdminListDevices
s {$sel:paginationToken:AdminListDevices' :: Maybe Text
paginationToken = Maybe Text
a} :: AdminListDevices)

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

-- | The user name.
adminListDevices_username :: Lens.Lens' AdminListDevices Prelude.Text
adminListDevices_username :: Lens' AdminListDevices Text
adminListDevices_username = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminListDevices' {Sensitive Text
username :: Sensitive Text
$sel:username:AdminListDevices' :: AdminListDevices -> Sensitive Text
username} -> Sensitive Text
username) (\s :: AdminListDevices
s@AdminListDevices' {} Sensitive Text
a -> AdminListDevices
s {$sel:username:AdminListDevices' :: Sensitive Text
username = Sensitive Text
a} :: AdminListDevices) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

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

instance Prelude.Hashable AdminListDevices where
  hashWithSalt :: Int -> AdminListDevices -> Int
hashWithSalt Int
_salt AdminListDevices' {Maybe Natural
Maybe Text
Text
Sensitive Text
username :: Sensitive Text
userPoolId :: Text
paginationToken :: Maybe Text
limit :: Maybe Natural
$sel:username:AdminListDevices' :: AdminListDevices -> Sensitive Text
$sel:userPoolId:AdminListDevices' :: AdminListDevices -> Text
$sel:paginationToken:AdminListDevices' :: AdminListDevices -> Maybe Text
$sel:limit:AdminListDevices' :: AdminListDevices -> Maybe Natural
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
limit
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
paginationToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
userPoolId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
username

instance Prelude.NFData AdminListDevices where
  rnf :: AdminListDevices -> ()
rnf AdminListDevices' {Maybe Natural
Maybe Text
Text
Sensitive Text
username :: Sensitive Text
userPoolId :: Text
paginationToken :: Maybe Text
limit :: Maybe Natural
$sel:username:AdminListDevices' :: AdminListDevices -> Sensitive Text
$sel:userPoolId:AdminListDevices' :: AdminListDevices -> Text
$sel:paginationToken:AdminListDevices' :: AdminListDevices -> Maybe Text
$sel:limit:AdminListDevices' :: AdminListDevices -> Maybe Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
limit
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
paginationToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
userPoolId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
username

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

instance Data.ToJSON AdminListDevices where
  toJSON :: AdminListDevices -> Value
toJSON AdminListDevices' {Maybe Natural
Maybe Text
Text
Sensitive Text
username :: Sensitive Text
userPoolId :: Text
paginationToken :: Maybe Text
limit :: Maybe Natural
$sel:username:AdminListDevices' :: AdminListDevices -> Sensitive Text
$sel:userPoolId:AdminListDevices' :: AdminListDevices -> Text
$sel:paginationToken:AdminListDevices' :: AdminListDevices -> Maybe Text
$sel:limit:AdminListDevices' :: AdminListDevices -> Maybe Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Limit" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
limit,
            (Key
"PaginationToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
paginationToken,
            forall a. a -> Maybe a
Prelude.Just (Key
"UserPoolId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
userPoolId),
            forall a. a -> Maybe a
Prelude.Just (Key
"Username" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
username)
          ]
      )

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

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

-- | Lists the device\'s response, as an administrator.
--
-- /See:/ 'newAdminListDevicesResponse' smart constructor.
data AdminListDevicesResponse = AdminListDevicesResponse'
  { -- | The devices in the list of devices response.
    AdminListDevicesResponse -> Maybe [DeviceType]
devices :: Prelude.Maybe [DeviceType],
    -- | The pagination token.
    AdminListDevicesResponse -> Maybe Text
paginationToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    AdminListDevicesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (AdminListDevicesResponse -> AdminListDevicesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AdminListDevicesResponse -> AdminListDevicesResponse -> Bool
$c/= :: AdminListDevicesResponse -> AdminListDevicesResponse -> Bool
== :: AdminListDevicesResponse -> AdminListDevicesResponse -> Bool
$c== :: AdminListDevicesResponse -> AdminListDevicesResponse -> Bool
Prelude.Eq, Int -> AdminListDevicesResponse -> ShowS
[AdminListDevicesResponse] -> ShowS
AdminListDevicesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AdminListDevicesResponse] -> ShowS
$cshowList :: [AdminListDevicesResponse] -> ShowS
show :: AdminListDevicesResponse -> String
$cshow :: AdminListDevicesResponse -> String
showsPrec :: Int -> AdminListDevicesResponse -> ShowS
$cshowsPrec :: Int -> AdminListDevicesResponse -> ShowS
Prelude.Show, forall x.
Rep AdminListDevicesResponse x -> AdminListDevicesResponse
forall x.
AdminListDevicesResponse -> Rep AdminListDevicesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AdminListDevicesResponse x -> AdminListDevicesResponse
$cfrom :: forall x.
AdminListDevicesResponse -> Rep AdminListDevicesResponse x
Prelude.Generic)

-- |
-- Create a value of 'AdminListDevicesResponse' 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:
--
-- 'devices', 'adminListDevicesResponse_devices' - The devices in the list of devices response.
--
-- 'paginationToken', 'adminListDevicesResponse_paginationToken' - The pagination token.
--
-- 'httpStatus', 'adminListDevicesResponse_httpStatus' - The response's http status code.
newAdminListDevicesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  AdminListDevicesResponse
newAdminListDevicesResponse :: Int -> AdminListDevicesResponse
newAdminListDevicesResponse Int
pHttpStatus_ =
  AdminListDevicesResponse'
    { $sel:devices:AdminListDevicesResponse' :: Maybe [DeviceType]
devices =
        forall a. Maybe a
Prelude.Nothing,
      $sel:paginationToken:AdminListDevicesResponse' :: Maybe Text
paginationToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:AdminListDevicesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The devices in the list of devices response.
adminListDevicesResponse_devices :: Lens.Lens' AdminListDevicesResponse (Prelude.Maybe [DeviceType])
adminListDevicesResponse_devices :: Lens' AdminListDevicesResponse (Maybe [DeviceType])
adminListDevicesResponse_devices = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminListDevicesResponse' {Maybe [DeviceType]
devices :: Maybe [DeviceType]
$sel:devices:AdminListDevicesResponse' :: AdminListDevicesResponse -> Maybe [DeviceType]
devices} -> Maybe [DeviceType]
devices) (\s :: AdminListDevicesResponse
s@AdminListDevicesResponse' {} Maybe [DeviceType]
a -> AdminListDevicesResponse
s {$sel:devices:AdminListDevicesResponse' :: Maybe [DeviceType]
devices = Maybe [DeviceType]
a} :: AdminListDevicesResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The pagination token.
adminListDevicesResponse_paginationToken :: Lens.Lens' AdminListDevicesResponse (Prelude.Maybe Prelude.Text)
adminListDevicesResponse_paginationToken :: Lens' AdminListDevicesResponse (Maybe Text)
adminListDevicesResponse_paginationToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AdminListDevicesResponse' {Maybe Text
paginationToken :: Maybe Text
$sel:paginationToken:AdminListDevicesResponse' :: AdminListDevicesResponse -> Maybe Text
paginationToken} -> Maybe Text
paginationToken) (\s :: AdminListDevicesResponse
s@AdminListDevicesResponse' {} Maybe Text
a -> AdminListDevicesResponse
s {$sel:paginationToken:AdminListDevicesResponse' :: Maybe Text
paginationToken = Maybe Text
a} :: AdminListDevicesResponse)

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

instance Prelude.NFData AdminListDevicesResponse where
  rnf :: AdminListDevicesResponse -> ()
rnf AdminListDevicesResponse' {Int
Maybe [DeviceType]
Maybe Text
httpStatus :: Int
paginationToken :: Maybe Text
devices :: Maybe [DeviceType]
$sel:httpStatus:AdminListDevicesResponse' :: AdminListDevicesResponse -> Int
$sel:paginationToken:AdminListDevicesResponse' :: AdminListDevicesResponse -> Maybe Text
$sel:devices:AdminListDevicesResponse' :: AdminListDevicesResponse -> Maybe [DeviceType]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DeviceType]
devices
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
paginationToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus