{-# 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.QuickSight.ListGroups
-- 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 user groups in Amazon QuickSight.
module Amazonka.QuickSight.ListGroups
  ( -- * Creating a Request
    ListGroups (..),
    newListGroups,

    -- * Request Lenses
    listGroups_maxResults,
    listGroups_nextToken,
    listGroups_awsAccountId,
    listGroups_namespace,

    -- * Destructuring the Response
    ListGroupsResponse (..),
    newListGroupsResponse,

    -- * Response Lenses
    listGroupsResponse_groupList,
    listGroupsResponse_nextToken,
    listGroupsResponse_requestId,
    listGroupsResponse_status,
  )
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 Amazonka.QuickSight.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newListGroups' smart constructor.
data ListGroups = ListGroups'
  { -- | The maximum number of results to return.
    ListGroups -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | A pagination token that can be used in a subsequent request.
    ListGroups -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The ID for the Amazon Web Services account that the group is in.
    -- Currently, you use the ID for the Amazon Web Services account that
    -- contains your Amazon QuickSight account.
    ListGroups -> Text
awsAccountId :: Prelude.Text,
    -- | The namespace that you want a list of groups from.
    ListGroups -> Text
namespace :: Prelude.Text
  }
  deriving (ListGroups -> ListGroups -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListGroups -> ListGroups -> Bool
$c/= :: ListGroups -> ListGroups -> Bool
== :: ListGroups -> ListGroups -> Bool
$c== :: ListGroups -> ListGroups -> Bool
Prelude.Eq, ReadPrec [ListGroups]
ReadPrec ListGroups
Int -> ReadS ListGroups
ReadS [ListGroups]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListGroups]
$creadListPrec :: ReadPrec [ListGroups]
readPrec :: ReadPrec ListGroups
$creadPrec :: ReadPrec ListGroups
readList :: ReadS [ListGroups]
$creadList :: ReadS [ListGroups]
readsPrec :: Int -> ReadS ListGroups
$creadsPrec :: Int -> ReadS ListGroups
Prelude.Read, Int -> ListGroups -> ShowS
[ListGroups] -> ShowS
ListGroups -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListGroups] -> ShowS
$cshowList :: [ListGroups] -> ShowS
show :: ListGroups -> String
$cshow :: ListGroups -> String
showsPrec :: Int -> ListGroups -> ShowS
$cshowsPrec :: Int -> ListGroups -> ShowS
Prelude.Show, forall x. Rep ListGroups x -> ListGroups
forall x. ListGroups -> Rep ListGroups x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListGroups x -> ListGroups
$cfrom :: forall x. ListGroups -> Rep ListGroups x
Prelude.Generic)

-- |
-- Create a value of 'ListGroups' 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', 'listGroups_maxResults' - The maximum number of results to return.
--
-- 'nextToken', 'listGroups_nextToken' - A pagination token that can be used in a subsequent request.
--
-- 'awsAccountId', 'listGroups_awsAccountId' - The ID for the Amazon Web Services account that the group is in.
-- Currently, you use the ID for the Amazon Web Services account that
-- contains your Amazon QuickSight account.
--
-- 'namespace', 'listGroups_namespace' - The namespace that you want a list of groups from.
newListGroups ::
  -- | 'awsAccountId'
  Prelude.Text ->
  -- | 'namespace'
  Prelude.Text ->
  ListGroups
newListGroups :: Text -> Text -> ListGroups
newListGroups Text
pAwsAccountId_ Text
pNamespace_ =
  ListGroups'
    { $sel:maxResults:ListGroups' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListGroups' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:awsAccountId:ListGroups' :: Text
awsAccountId = Text
pAwsAccountId_,
      $sel:namespace:ListGroups' :: Text
namespace = Text
pNamespace_
    }

-- | The maximum number of results to return.
listGroups_maxResults :: Lens.Lens' ListGroups (Prelude.Maybe Prelude.Natural)
listGroups_maxResults :: Lens' ListGroups (Maybe Natural)
listGroups_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroups' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListGroups' :: ListGroups -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListGroups
s@ListGroups' {} Maybe Natural
a -> ListGroups
s {$sel:maxResults:ListGroups' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListGroups)

-- | A pagination token that can be used in a subsequent request.
listGroups_nextToken :: Lens.Lens' ListGroups (Prelude.Maybe Prelude.Text)
listGroups_nextToken :: Lens' ListGroups (Maybe Text)
listGroups_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroups' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListGroups' :: ListGroups -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListGroups
s@ListGroups' {} Maybe Text
a -> ListGroups
s {$sel:nextToken:ListGroups' :: Maybe Text
nextToken = Maybe Text
a} :: ListGroups)

-- | The ID for the Amazon Web Services account that the group is in.
-- Currently, you use the ID for the Amazon Web Services account that
-- contains your Amazon QuickSight account.
listGroups_awsAccountId :: Lens.Lens' ListGroups Prelude.Text
listGroups_awsAccountId :: Lens' ListGroups Text
listGroups_awsAccountId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroups' {Text
awsAccountId :: Text
$sel:awsAccountId:ListGroups' :: ListGroups -> Text
awsAccountId} -> Text
awsAccountId) (\s :: ListGroups
s@ListGroups' {} Text
a -> ListGroups
s {$sel:awsAccountId:ListGroups' :: Text
awsAccountId = Text
a} :: ListGroups)

-- | The namespace that you want a list of groups from.
listGroups_namespace :: Lens.Lens' ListGroups Prelude.Text
listGroups_namespace :: Lens' ListGroups Text
listGroups_namespace = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroups' {Text
namespace :: Text
$sel:namespace:ListGroups' :: ListGroups -> Text
namespace} -> Text
namespace) (\s :: ListGroups
s@ListGroups' {} Text
a -> ListGroups
s {$sel:namespace:ListGroups' :: Text
namespace = Text
a} :: ListGroups)

instance Core.AWSRequest ListGroups where
  type AWSResponse ListGroups = ListGroupsResponse
  request :: (Service -> Service) -> ListGroups -> Request ListGroups
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 ListGroups
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListGroups)))
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 [Group]
-> Maybe Text -> Maybe Text -> Int -> ListGroupsResponse
ListGroupsResponse'
            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
"GroupList" 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
"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
"RequestId")
            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 ListGroups where
  hashWithSalt :: Int -> ListGroups -> Int
hashWithSalt Int
_salt ListGroups' {Maybe Natural
Maybe Text
Text
namespace :: Text
awsAccountId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:namespace:ListGroups' :: ListGroups -> Text
$sel:awsAccountId:ListGroups' :: ListGroups -> Text
$sel:nextToken:ListGroups' :: ListGroups -> Maybe Text
$sel:maxResults:ListGroups' :: ListGroups -> 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
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
awsAccountId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
namespace

instance Prelude.NFData ListGroups where
  rnf :: ListGroups -> ()
rnf ListGroups' {Maybe Natural
Maybe Text
Text
namespace :: Text
awsAccountId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:namespace:ListGroups' :: ListGroups -> Text
$sel:awsAccountId:ListGroups' :: ListGroups -> Text
$sel:nextToken:ListGroups' :: ListGroups -> Maybe Text
$sel:maxResults:ListGroups' :: ListGroups -> 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
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
awsAccountId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
namespace

instance Data.ToHeaders ListGroups where
  toHeaders :: ListGroups -> 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.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath ListGroups where
  toPath :: ListGroups -> ByteString
toPath ListGroups' {Maybe Natural
Maybe Text
Text
namespace :: Text
awsAccountId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:namespace:ListGroups' :: ListGroups -> Text
$sel:awsAccountId:ListGroups' :: ListGroups -> Text
$sel:nextToken:ListGroups' :: ListGroups -> Maybe Text
$sel:maxResults:ListGroups' :: ListGroups -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/accounts/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
awsAccountId,
        ByteString
"/namespaces/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
namespace,
        ByteString
"/groups"
      ]

instance Data.ToQuery ListGroups where
  toQuery :: ListGroups -> QueryString
toQuery ListGroups' {Maybe Natural
Maybe Text
Text
namespace :: Text
awsAccountId :: Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:namespace:ListGroups' :: ListGroups -> Text
$sel:awsAccountId:ListGroups' :: ListGroups -> Text
$sel:nextToken:ListGroups' :: ListGroups -> Maybe Text
$sel:maxResults:ListGroups' :: ListGroups -> Maybe Natural
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"max-results" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Natural
maxResults,
        ByteString
"next-token" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
nextToken
      ]

-- | /See:/ 'newListGroupsResponse' smart constructor.
data ListGroupsResponse = ListGroupsResponse'
  { -- | The list of the groups.
    ListGroupsResponse -> Maybe [Group]
groupList :: Prelude.Maybe [Group],
    -- | A pagination token that can be used in a subsequent request.
    ListGroupsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Web Services request ID for this operation.
    ListGroupsResponse -> Maybe Text
requestId :: Prelude.Maybe Prelude.Text,
    -- | The HTTP status of the request.
    ListGroupsResponse -> Int
status :: Prelude.Int
  }
  deriving (ListGroupsResponse -> ListGroupsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListGroupsResponse -> ListGroupsResponse -> Bool
$c/= :: ListGroupsResponse -> ListGroupsResponse -> Bool
== :: ListGroupsResponse -> ListGroupsResponse -> Bool
$c== :: ListGroupsResponse -> ListGroupsResponse -> Bool
Prelude.Eq, ReadPrec [ListGroupsResponse]
ReadPrec ListGroupsResponse
Int -> ReadS ListGroupsResponse
ReadS [ListGroupsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListGroupsResponse]
$creadListPrec :: ReadPrec [ListGroupsResponse]
readPrec :: ReadPrec ListGroupsResponse
$creadPrec :: ReadPrec ListGroupsResponse
readList :: ReadS [ListGroupsResponse]
$creadList :: ReadS [ListGroupsResponse]
readsPrec :: Int -> ReadS ListGroupsResponse
$creadsPrec :: Int -> ReadS ListGroupsResponse
Prelude.Read, Int -> ListGroupsResponse -> ShowS
[ListGroupsResponse] -> ShowS
ListGroupsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListGroupsResponse] -> ShowS
$cshowList :: [ListGroupsResponse] -> ShowS
show :: ListGroupsResponse -> String
$cshow :: ListGroupsResponse -> String
showsPrec :: Int -> ListGroupsResponse -> ShowS
$cshowsPrec :: Int -> ListGroupsResponse -> ShowS
Prelude.Show, forall x. Rep ListGroupsResponse x -> ListGroupsResponse
forall x. ListGroupsResponse -> Rep ListGroupsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListGroupsResponse x -> ListGroupsResponse
$cfrom :: forall x. ListGroupsResponse -> Rep ListGroupsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListGroupsResponse' 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:
--
-- 'groupList', 'listGroupsResponse_groupList' - The list of the groups.
--
-- 'nextToken', 'listGroupsResponse_nextToken' - A pagination token that can be used in a subsequent request.
--
-- 'requestId', 'listGroupsResponse_requestId' - The Amazon Web Services request ID for this operation.
--
-- 'status', 'listGroupsResponse_status' - The HTTP status of the request.
newListGroupsResponse ::
  -- | 'status'
  Prelude.Int ->
  ListGroupsResponse
newListGroupsResponse :: Int -> ListGroupsResponse
newListGroupsResponse Int
pStatus_ =
  ListGroupsResponse'
    { $sel:groupList:ListGroupsResponse' :: Maybe [Group]
groupList = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListGroupsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:requestId:ListGroupsResponse' :: Maybe Text
requestId = forall a. Maybe a
Prelude.Nothing,
      $sel:status:ListGroupsResponse' :: Int
status = Int
pStatus_
    }

-- | The list of the groups.
listGroupsResponse_groupList :: Lens.Lens' ListGroupsResponse (Prelude.Maybe [Group])
listGroupsResponse_groupList :: Lens' ListGroupsResponse (Maybe [Group])
listGroupsResponse_groupList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroupsResponse' {Maybe [Group]
groupList :: Maybe [Group]
$sel:groupList:ListGroupsResponse' :: ListGroupsResponse -> Maybe [Group]
groupList} -> Maybe [Group]
groupList) (\s :: ListGroupsResponse
s@ListGroupsResponse' {} Maybe [Group]
a -> ListGroupsResponse
s {$sel:groupList:ListGroupsResponse' :: Maybe [Group]
groupList = Maybe [Group]
a} :: ListGroupsResponse) 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

-- | A pagination token that can be used in a subsequent request.
listGroupsResponse_nextToken :: Lens.Lens' ListGroupsResponse (Prelude.Maybe Prelude.Text)
listGroupsResponse_nextToken :: Lens' ListGroupsResponse (Maybe Text)
listGroupsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroupsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListGroupsResponse' :: ListGroupsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListGroupsResponse
s@ListGroupsResponse' {} Maybe Text
a -> ListGroupsResponse
s {$sel:nextToken:ListGroupsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListGroupsResponse)

-- | The Amazon Web Services request ID for this operation.
listGroupsResponse_requestId :: Lens.Lens' ListGroupsResponse (Prelude.Maybe Prelude.Text)
listGroupsResponse_requestId :: Lens' ListGroupsResponse (Maybe Text)
listGroupsResponse_requestId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroupsResponse' {Maybe Text
requestId :: Maybe Text
$sel:requestId:ListGroupsResponse' :: ListGroupsResponse -> Maybe Text
requestId} -> Maybe Text
requestId) (\s :: ListGroupsResponse
s@ListGroupsResponse' {} Maybe Text
a -> ListGroupsResponse
s {$sel:requestId:ListGroupsResponse' :: Maybe Text
requestId = Maybe Text
a} :: ListGroupsResponse)

-- | The HTTP status of the request.
listGroupsResponse_status :: Lens.Lens' ListGroupsResponse Prelude.Int
listGroupsResponse_status :: Lens' ListGroupsResponse Int
listGroupsResponse_status = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroupsResponse' {Int
status :: Int
$sel:status:ListGroupsResponse' :: ListGroupsResponse -> Int
status} -> Int
status) (\s :: ListGroupsResponse
s@ListGroupsResponse' {} Int
a -> ListGroupsResponse
s {$sel:status:ListGroupsResponse' :: Int
status = Int
a} :: ListGroupsResponse)

instance Prelude.NFData ListGroupsResponse where
  rnf :: ListGroupsResponse -> ()
rnf ListGroupsResponse' {Int
Maybe [Group]
Maybe Text
status :: Int
requestId :: Maybe Text
nextToken :: Maybe Text
groupList :: Maybe [Group]
$sel:status:ListGroupsResponse' :: ListGroupsResponse -> Int
$sel:requestId:ListGroupsResponse' :: ListGroupsResponse -> Maybe Text
$sel:nextToken:ListGroupsResponse' :: ListGroupsResponse -> Maybe Text
$sel:groupList:ListGroupsResponse' :: ListGroupsResponse -> Maybe [Group]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Group]
groupList
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 Text
requestId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
status