{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.WorkSpacesWeb.ListUserSettings
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves a list of user settings.
module Amazonka.WorkSpacesWeb.ListUserSettings
  ( -- * Creating a Request
    ListUserSettings (..),
    newListUserSettings,

    -- * Request Lenses
    listUserSettings_maxResults,
    listUserSettings_nextToken,

    -- * Destructuring the Response
    ListUserSettingsResponse (..),
    newListUserSettingsResponse,

    -- * Response Lenses
    listUserSettingsResponse_nextToken,
    listUserSettingsResponse_userSettings,
    listUserSettingsResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'ListUserSettings' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'maxResults', 'listUserSettings_maxResults' - The maximum number of results to be included in the next page.
--
-- 'nextToken', 'listUserSettings_nextToken' - The pagination token used to retrieve the next page of results for this
-- operation.
newListUserSettings ::
  ListUserSettings
newListUserSettings :: ListUserSettings
newListUserSettings =
  ListUserSettings'
    { $sel:maxResults:ListUserSettings' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListUserSettings' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

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

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

instance Core.AWSRequest ListUserSettings where
  type
    AWSResponse ListUserSettings =
      ListUserSettingsResponse
  request :: (Service -> Service)
-> ListUserSettings -> Request ListUserSettings
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy ListUserSettings
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListUserSettings)))
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 Text
-> Maybe [UserSettingsSummary] -> Int -> ListUserSettingsResponse
ListUserSettingsResponse'
            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
"nextToken")
            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
"userSettings" 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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

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

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

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

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

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

-- | /See:/ 'newListUserSettingsResponse' smart constructor.
data ListUserSettingsResponse = ListUserSettingsResponse'
  { -- | The pagination token used to retrieve the next page of results for this
    -- operation.
    ListUserSettingsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The user settings.
    ListUserSettingsResponse -> Maybe [UserSettingsSummary]
userSettings :: Prelude.Maybe [UserSettingsSummary],
    -- | The response's http status code.
    ListUserSettingsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListUserSettingsResponse -> ListUserSettingsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListUserSettingsResponse -> ListUserSettingsResponse -> Bool
$c/= :: ListUserSettingsResponse -> ListUserSettingsResponse -> Bool
== :: ListUserSettingsResponse -> ListUserSettingsResponse -> Bool
$c== :: ListUserSettingsResponse -> ListUserSettingsResponse -> Bool
Prelude.Eq, ReadPrec [ListUserSettingsResponse]
ReadPrec ListUserSettingsResponse
Int -> ReadS ListUserSettingsResponse
ReadS [ListUserSettingsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListUserSettingsResponse]
$creadListPrec :: ReadPrec [ListUserSettingsResponse]
readPrec :: ReadPrec ListUserSettingsResponse
$creadPrec :: ReadPrec ListUserSettingsResponse
readList :: ReadS [ListUserSettingsResponse]
$creadList :: ReadS [ListUserSettingsResponse]
readsPrec :: Int -> ReadS ListUserSettingsResponse
$creadsPrec :: Int -> ReadS ListUserSettingsResponse
Prelude.Read, Int -> ListUserSettingsResponse -> ShowS
[ListUserSettingsResponse] -> ShowS
ListUserSettingsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListUserSettingsResponse] -> ShowS
$cshowList :: [ListUserSettingsResponse] -> ShowS
show :: ListUserSettingsResponse -> String
$cshow :: ListUserSettingsResponse -> String
showsPrec :: Int -> ListUserSettingsResponse -> ShowS
$cshowsPrec :: Int -> ListUserSettingsResponse -> ShowS
Prelude.Show, forall x.
Rep ListUserSettingsResponse x -> ListUserSettingsResponse
forall x.
ListUserSettingsResponse -> Rep ListUserSettingsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListUserSettingsResponse x -> ListUserSettingsResponse
$cfrom :: forall x.
ListUserSettingsResponse -> Rep ListUserSettingsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListUserSettingsResponse' 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:
--
-- 'nextToken', 'listUserSettingsResponse_nextToken' - The pagination token used to retrieve the next page of results for this
-- operation.
--
-- 'userSettings', 'listUserSettingsResponse_userSettings' - The user settings.
--
-- 'httpStatus', 'listUserSettingsResponse_httpStatus' - The response's http status code.
newListUserSettingsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListUserSettingsResponse
newListUserSettingsResponse :: Int -> ListUserSettingsResponse
newListUserSettingsResponse Int
pHttpStatus_ =
  ListUserSettingsResponse'
    { $sel:nextToken:ListUserSettingsResponse' :: Maybe Text
nextToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:userSettings:ListUserSettingsResponse' :: Maybe [UserSettingsSummary]
userSettings = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListUserSettingsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

-- | The user settings.
listUserSettingsResponse_userSettings :: Lens.Lens' ListUserSettingsResponse (Prelude.Maybe [UserSettingsSummary])
listUserSettingsResponse_userSettings :: Lens' ListUserSettingsResponse (Maybe [UserSettingsSummary])
listUserSettingsResponse_userSettings = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListUserSettingsResponse' {Maybe [UserSettingsSummary]
userSettings :: Maybe [UserSettingsSummary]
$sel:userSettings:ListUserSettingsResponse' :: ListUserSettingsResponse -> Maybe [UserSettingsSummary]
userSettings} -> Maybe [UserSettingsSummary]
userSettings) (\s :: ListUserSettingsResponse
s@ListUserSettingsResponse' {} Maybe [UserSettingsSummary]
a -> ListUserSettingsResponse
s {$sel:userSettings:ListUserSettingsResponse' :: Maybe [UserSettingsSummary]
userSettings = Maybe [UserSettingsSummary]
a} :: ListUserSettingsResponse) 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 response's http status code.
listUserSettingsResponse_httpStatus :: Lens.Lens' ListUserSettingsResponse Prelude.Int
listUserSettingsResponse_httpStatus :: Lens' ListUserSettingsResponse Int
listUserSettingsResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListUserSettingsResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListUserSettingsResponse' :: ListUserSettingsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListUserSettingsResponse
s@ListUserSettingsResponse' {} Int
a -> ListUserSettingsResponse
s {$sel:httpStatus:ListUserSettingsResponse' :: Int
httpStatus = Int
a} :: ListUserSettingsResponse)

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