{-# 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.RolesAnywhere.ListProfiles
-- 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 all profiles in the authenticated account and Amazon Web Services
-- Region.
--
-- __Required permissions:__ @rolesanywhere:ListProfiles@.
--
-- This operation returns paginated results.
module Amazonka.RolesAnywhere.ListProfiles
  ( -- * Creating a Request
    ListProfiles (..),
    newListProfiles,

    -- * Request Lenses
    listProfiles_nextToken,
    listProfiles_pageSize,

    -- * Destructuring the Response
    ListProfilesResponse (..),
    newListProfilesResponse,

    -- * Response Lenses
    listProfilesResponse_nextToken,
    listProfilesResponse_profiles,
    listProfilesResponse_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.RolesAnywhere.Types

-- | /See:/ 'newListProfiles' smart constructor.
data ListProfiles = ListProfiles'
  { -- | A token that indicates where the output should continue from, if a
    -- previous operation did not show all results. To get the next results,
    -- call the operation again with this value.
    ListProfiles -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The number of resources in the paginated list.
    ListProfiles -> Maybe Int
pageSize :: Prelude.Maybe Prelude.Int
  }
  deriving (ListProfiles -> ListProfiles -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListProfiles -> ListProfiles -> Bool
$c/= :: ListProfiles -> ListProfiles -> Bool
== :: ListProfiles -> ListProfiles -> Bool
$c== :: ListProfiles -> ListProfiles -> Bool
Prelude.Eq, ReadPrec [ListProfiles]
ReadPrec ListProfiles
Int -> ReadS ListProfiles
ReadS [ListProfiles]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListProfiles]
$creadListPrec :: ReadPrec [ListProfiles]
readPrec :: ReadPrec ListProfiles
$creadPrec :: ReadPrec ListProfiles
readList :: ReadS [ListProfiles]
$creadList :: ReadS [ListProfiles]
readsPrec :: Int -> ReadS ListProfiles
$creadsPrec :: Int -> ReadS ListProfiles
Prelude.Read, Int -> ListProfiles -> ShowS
[ListProfiles] -> ShowS
ListProfiles -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListProfiles] -> ShowS
$cshowList :: [ListProfiles] -> ShowS
show :: ListProfiles -> String
$cshow :: ListProfiles -> String
showsPrec :: Int -> ListProfiles -> ShowS
$cshowsPrec :: Int -> ListProfiles -> ShowS
Prelude.Show, forall x. Rep ListProfiles x -> ListProfiles
forall x. ListProfiles -> Rep ListProfiles x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListProfiles x -> ListProfiles
$cfrom :: forall x. ListProfiles -> Rep ListProfiles x
Prelude.Generic)

-- |
-- Create a value of 'ListProfiles' 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', 'listProfiles_nextToken' - A token that indicates where the output should continue from, if a
-- previous operation did not show all results. To get the next results,
-- call the operation again with this value.
--
-- 'pageSize', 'listProfiles_pageSize' - The number of resources in the paginated list.
newListProfiles ::
  ListProfiles
newListProfiles :: ListProfiles
newListProfiles =
  ListProfiles'
    { $sel:nextToken:ListProfiles' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:pageSize:ListProfiles' :: Maybe Int
pageSize = forall a. Maybe a
Prelude.Nothing
    }

-- | A token that indicates where the output should continue from, if a
-- previous operation did not show all results. To get the next results,
-- call the operation again with this value.
listProfiles_nextToken :: Lens.Lens' ListProfiles (Prelude.Maybe Prelude.Text)
listProfiles_nextToken :: Lens' ListProfiles (Maybe Text)
listProfiles_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListProfiles' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListProfiles' :: ListProfiles -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListProfiles
s@ListProfiles' {} Maybe Text
a -> ListProfiles
s {$sel:nextToken:ListProfiles' :: Maybe Text
nextToken = Maybe Text
a} :: ListProfiles)

-- | The number of resources in the paginated list.
listProfiles_pageSize :: Lens.Lens' ListProfiles (Prelude.Maybe Prelude.Int)
listProfiles_pageSize :: Lens' ListProfiles (Maybe Int)
listProfiles_pageSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListProfiles' {Maybe Int
pageSize :: Maybe Int
$sel:pageSize:ListProfiles' :: ListProfiles -> Maybe Int
pageSize} -> Maybe Int
pageSize) (\s :: ListProfiles
s@ListProfiles' {} Maybe Int
a -> ListProfiles
s {$sel:pageSize:ListProfiles' :: Maybe Int
pageSize = Maybe Int
a} :: ListProfiles)

instance Core.AWSPager ListProfiles where
  page :: ListProfiles -> AWSResponse ListProfiles -> Maybe ListProfiles
page ListProfiles
rq AWSResponse ListProfiles
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListProfiles
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListProfilesResponse (Maybe Text)
listProfilesResponse_nextToken
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListProfiles
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListProfilesResponse (Maybe [ProfileDetail])
listProfilesResponse_profiles
            forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
        forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
        forall a. a -> Maybe a
Prelude.Just
          forall a b. (a -> b) -> a -> b
Prelude.$ ListProfiles
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListProfiles (Maybe Text)
listProfiles_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListProfiles
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListProfilesResponse (Maybe Text)
listProfilesResponse_nextToken
          forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just

instance Core.AWSRequest ListProfiles where
  type AWSResponse ListProfiles = ListProfilesResponse
  request :: (Service -> Service) -> ListProfiles -> Request ListProfiles
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 ListProfiles
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListProfiles)))
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 [ProfileDetail] -> Int -> ListProfilesResponse
ListProfilesResponse'
            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
"profiles" 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 ListProfiles where
  hashWithSalt :: Int -> ListProfiles -> Int
hashWithSalt Int
_salt ListProfiles' {Maybe Int
Maybe Text
pageSize :: Maybe Int
nextToken :: Maybe Text
$sel:pageSize:ListProfiles' :: ListProfiles -> Maybe Int
$sel:nextToken:ListProfiles' :: ListProfiles -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
nextToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
pageSize

instance Prelude.NFData ListProfiles where
  rnf :: ListProfiles -> ()
rnf ListProfiles' {Maybe Int
Maybe Text
pageSize :: Maybe Int
nextToken :: Maybe Text
$sel:pageSize:ListProfiles' :: ListProfiles -> Maybe Int
$sel:nextToken:ListProfiles' :: ListProfiles -> 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 Int
pageSize

instance Data.ToHeaders ListProfiles where
  toHeaders :: ListProfiles -> 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 ListProfiles where
  toPath :: ListProfiles -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/profiles"

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

-- | /See:/ 'newListProfilesResponse' smart constructor.
data ListProfilesResponse = ListProfilesResponse'
  { -- | A token that indicates where the output should continue from, if a
    -- previous operation did not show all results. To get the next results,
    -- call the operation again with this value.
    ListProfilesResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of profiles.
    ListProfilesResponse -> Maybe [ProfileDetail]
profiles :: Prelude.Maybe [ProfileDetail],
    -- | The response's http status code.
    ListProfilesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListProfilesResponse -> ListProfilesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListProfilesResponse -> ListProfilesResponse -> Bool
$c/= :: ListProfilesResponse -> ListProfilesResponse -> Bool
== :: ListProfilesResponse -> ListProfilesResponse -> Bool
$c== :: ListProfilesResponse -> ListProfilesResponse -> Bool
Prelude.Eq, ReadPrec [ListProfilesResponse]
ReadPrec ListProfilesResponse
Int -> ReadS ListProfilesResponse
ReadS [ListProfilesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListProfilesResponse]
$creadListPrec :: ReadPrec [ListProfilesResponse]
readPrec :: ReadPrec ListProfilesResponse
$creadPrec :: ReadPrec ListProfilesResponse
readList :: ReadS [ListProfilesResponse]
$creadList :: ReadS [ListProfilesResponse]
readsPrec :: Int -> ReadS ListProfilesResponse
$creadsPrec :: Int -> ReadS ListProfilesResponse
Prelude.Read, Int -> ListProfilesResponse -> ShowS
[ListProfilesResponse] -> ShowS
ListProfilesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListProfilesResponse] -> ShowS
$cshowList :: [ListProfilesResponse] -> ShowS
show :: ListProfilesResponse -> String
$cshow :: ListProfilesResponse -> String
showsPrec :: Int -> ListProfilesResponse -> ShowS
$cshowsPrec :: Int -> ListProfilesResponse -> ShowS
Prelude.Show, forall x. Rep ListProfilesResponse x -> ListProfilesResponse
forall x. ListProfilesResponse -> Rep ListProfilesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListProfilesResponse x -> ListProfilesResponse
$cfrom :: forall x. ListProfilesResponse -> Rep ListProfilesResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListProfilesResponse' 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', 'listProfilesResponse_nextToken' - A token that indicates where the output should continue from, if a
-- previous operation did not show all results. To get the next results,
-- call the operation again with this value.
--
-- 'profiles', 'listProfilesResponse_profiles' - A list of profiles.
--
-- 'httpStatus', 'listProfilesResponse_httpStatus' - The response's http status code.
newListProfilesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListProfilesResponse
newListProfilesResponse :: Int -> ListProfilesResponse
newListProfilesResponse Int
pHttpStatus_ =
  ListProfilesResponse'
    { $sel:nextToken:ListProfilesResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:profiles:ListProfilesResponse' :: Maybe [ProfileDetail]
profiles = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListProfilesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A token that indicates where the output should continue from, if a
-- previous operation did not show all results. To get the next results,
-- call the operation again with this value.
listProfilesResponse_nextToken :: Lens.Lens' ListProfilesResponse (Prelude.Maybe Prelude.Text)
listProfilesResponse_nextToken :: Lens' ListProfilesResponse (Maybe Text)
listProfilesResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListProfilesResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListProfilesResponse' :: ListProfilesResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListProfilesResponse
s@ListProfilesResponse' {} Maybe Text
a -> ListProfilesResponse
s {$sel:nextToken:ListProfilesResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListProfilesResponse)

-- | A list of profiles.
listProfilesResponse_profiles :: Lens.Lens' ListProfilesResponse (Prelude.Maybe [ProfileDetail])
listProfilesResponse_profiles :: Lens' ListProfilesResponse (Maybe [ProfileDetail])
listProfilesResponse_profiles = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListProfilesResponse' {Maybe [ProfileDetail]
profiles :: Maybe [ProfileDetail]
$sel:profiles:ListProfilesResponse' :: ListProfilesResponse -> Maybe [ProfileDetail]
profiles} -> Maybe [ProfileDetail]
profiles) (\s :: ListProfilesResponse
s@ListProfilesResponse' {} Maybe [ProfileDetail]
a -> ListProfilesResponse
s {$sel:profiles:ListProfilesResponse' :: Maybe [ProfileDetail]
profiles = Maybe [ProfileDetail]
a} :: ListProfilesResponse) 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.
listProfilesResponse_httpStatus :: Lens.Lens' ListProfilesResponse Prelude.Int
listProfilesResponse_httpStatus :: Lens' ListProfilesResponse Int
listProfilesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListProfilesResponse' {Int
httpStatus :: Int
$sel:httpStatus:ListProfilesResponse' :: ListProfilesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: ListProfilesResponse
s@ListProfilesResponse' {} Int
a -> ListProfilesResponse
s {$sel:httpStatus:ListProfilesResponse' :: Int
httpStatus = Int
a} :: ListProfilesResponse)

instance Prelude.NFData ListProfilesResponse where
  rnf :: ListProfilesResponse -> ()
rnf ListProfilesResponse' {Int
Maybe [ProfileDetail]
Maybe Text
httpStatus :: Int
profiles :: Maybe [ProfileDetail]
nextToken :: Maybe Text
$sel:httpStatus:ListProfilesResponse' :: ListProfilesResponse -> Int
$sel:profiles:ListProfilesResponse' :: ListProfilesResponse -> Maybe [ProfileDetail]
$sel:nextToken:ListProfilesResponse' :: ListProfilesResponse -> 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 [ProfileDetail]
profiles
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus