{-# 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.ResourceGroups.ListGroups
-- 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)
--
-- Returns a list of existing resource groups in your account.
--
-- __Minimum permissions__
--
-- To run this command, you must have the following permissions:
--
-- -   @resource-groups:ListGroups@
--
-- This operation returns paginated results.
module Amazonka.ResourceGroups.ListGroups
  ( -- * Creating a Request
    ListGroups (..),
    newListGroups,

    -- * Request Lenses
    listGroups_filters,
    listGroups_nextToken,
    listGroups_maxResults,

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

    -- * Response Lenses
    listGroupsResponse_groups,
    listGroupsResponse_nextToken,
    listGroupsResponse_groupIdentifiers,
    listGroupsResponse_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 Amazonka.ResourceGroups.Types
import qualified Amazonka.Response as Response

-- | /See:/ 'newListGroups' smart constructor.
data ListGroups = ListGroups'
  { -- | Filters, formatted as GroupFilter objects, that you want to apply to a
    -- @ListGroups@ operation.
    --
    -- -   @resource-type@ - Filter the results to include only those of the
    --     specified resource types. Specify up to five resource types in the
    --     format @AWS::ServiceCode::ResourceType @. For example,
    --     @AWS::EC2::Instance@, or @AWS::S3::Bucket@.
    --
    -- -   @configuration-type@ - Filter the results to include only those
    --     groups that have the specified configuration types attached. The
    --     current supported values are:
    --
    --     -   @AWS:EC2::CapacityReservationPool@
    --
    --     -   @AWS:EC2::HostManagement@
    ListGroups -> Maybe [GroupFilter]
filters :: Prelude.Maybe [GroupFilter],
    -- | The parameter for receiving additional results if you receive a
    -- @NextToken@ response in a previous request. A @NextToken@ response
    -- indicates that more output is available. Set this parameter to the value
    -- provided by a previous call\'s @NextToken@ response to indicate where
    -- the output should continue from.
    ListGroups -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The total number of results that you want included on each page of the
    -- response. If you do not include this parameter, it defaults to a value
    -- that is specific to the operation. If additional items exist beyond the
    -- maximum you specify, the @NextToken@ response element is present and has
    -- a value (is not null). Include that value as the @NextToken@ request
    -- parameter in the next call to the operation to get the next part of the
    -- results. Note that the service might return fewer results than the
    -- maximum even when there are more results available. You should check
    -- @NextToken@ after every operation to ensure that you receive all of the
    -- results.
    ListGroups -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (ListGroups -> ListGroups -> Bool
(ListGroups -> ListGroups -> Bool)
-> (ListGroups -> ListGroups -> Bool) -> Eq ListGroups
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]
(Int -> ReadS ListGroups)
-> ReadS [ListGroups]
-> ReadPrec ListGroups
-> ReadPrec [ListGroups]
-> Read 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
(Int -> ListGroups -> ShowS)
-> (ListGroups -> String)
-> ([ListGroups] -> ShowS)
-> Show ListGroups
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. ListGroups -> Rep ListGroups x)
-> (forall x. Rep ListGroups x -> ListGroups) -> Generic ListGroups
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:
--
-- 'filters', 'listGroups_filters' - Filters, formatted as GroupFilter objects, that you want to apply to a
-- @ListGroups@ operation.
--
-- -   @resource-type@ - Filter the results to include only those of the
--     specified resource types. Specify up to five resource types in the
--     format @AWS::ServiceCode::ResourceType @. For example,
--     @AWS::EC2::Instance@, or @AWS::S3::Bucket@.
--
-- -   @configuration-type@ - Filter the results to include only those
--     groups that have the specified configuration types attached. The
--     current supported values are:
--
--     -   @AWS:EC2::CapacityReservationPool@
--
--     -   @AWS:EC2::HostManagement@
--
-- 'nextToken', 'listGroups_nextToken' - The parameter for receiving additional results if you receive a
-- @NextToken@ response in a previous request. A @NextToken@ response
-- indicates that more output is available. Set this parameter to the value
-- provided by a previous call\'s @NextToken@ response to indicate where
-- the output should continue from.
--
-- 'maxResults', 'listGroups_maxResults' - The total number of results that you want included on each page of the
-- response. If you do not include this parameter, it defaults to a value
-- that is specific to the operation. If additional items exist beyond the
-- maximum you specify, the @NextToken@ response element is present and has
-- a value (is not null). Include that value as the @NextToken@ request
-- parameter in the next call to the operation to get the next part of the
-- results. Note that the service might return fewer results than the
-- maximum even when there are more results available. You should check
-- @NextToken@ after every operation to ensure that you receive all of the
-- results.
newListGroups ::
  ListGroups
newListGroups :: ListGroups
newListGroups =
  ListGroups' :: Maybe [GroupFilter] -> Maybe Text -> Maybe Natural -> ListGroups
ListGroups'
    { $sel:filters:ListGroups' :: Maybe [GroupFilter]
filters = Maybe [GroupFilter]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListGroups' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:ListGroups' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | Filters, formatted as GroupFilter objects, that you want to apply to a
-- @ListGroups@ operation.
--
-- -   @resource-type@ - Filter the results to include only those of the
--     specified resource types. Specify up to five resource types in the
--     format @AWS::ServiceCode::ResourceType @. For example,
--     @AWS::EC2::Instance@, or @AWS::S3::Bucket@.
--
-- -   @configuration-type@ - Filter the results to include only those
--     groups that have the specified configuration types attached. The
--     current supported values are:
--
--     -   @AWS:EC2::CapacityReservationPool@
--
--     -   @AWS:EC2::HostManagement@
listGroups_filters :: Lens.Lens' ListGroups (Prelude.Maybe [GroupFilter])
listGroups_filters :: (Maybe [GroupFilter] -> f (Maybe [GroupFilter]))
-> ListGroups -> f ListGroups
listGroups_filters = (ListGroups -> Maybe [GroupFilter])
-> (ListGroups -> Maybe [GroupFilter] -> ListGroups)
-> Lens
     ListGroups ListGroups (Maybe [GroupFilter]) (Maybe [GroupFilter])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroups' {Maybe [GroupFilter]
filters :: Maybe [GroupFilter]
$sel:filters:ListGroups' :: ListGroups -> Maybe [GroupFilter]
filters} -> Maybe [GroupFilter]
filters) (\s :: ListGroups
s@ListGroups' {} Maybe [GroupFilter]
a -> ListGroups
s {$sel:filters:ListGroups' :: Maybe [GroupFilter]
filters = Maybe [GroupFilter]
a} :: ListGroups) ((Maybe [GroupFilter] -> f (Maybe [GroupFilter]))
 -> ListGroups -> f ListGroups)
-> ((Maybe [GroupFilter] -> f (Maybe [GroupFilter]))
    -> Maybe [GroupFilter] -> f (Maybe [GroupFilter]))
-> (Maybe [GroupFilter] -> f (Maybe [GroupFilter]))
-> ListGroups
-> f ListGroups
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [GroupFilter] [GroupFilter] [GroupFilter] [GroupFilter]
-> Iso
     (Maybe [GroupFilter])
     (Maybe [GroupFilter])
     (Maybe [GroupFilter])
     (Maybe [GroupFilter])
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 [GroupFilter] [GroupFilter] [GroupFilter] [GroupFilter]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The parameter for receiving additional results if you receive a
-- @NextToken@ response in a previous request. A @NextToken@ response
-- indicates that more output is available. Set this parameter to the value
-- provided by a previous call\'s @NextToken@ response to indicate where
-- the output should continue from.
listGroups_nextToken :: Lens.Lens' ListGroups (Prelude.Maybe Prelude.Text)
listGroups_nextToken :: (Maybe Text -> f (Maybe Text)) -> ListGroups -> f ListGroups
listGroups_nextToken = (ListGroups -> Maybe Text)
-> (ListGroups -> Maybe Text -> ListGroups)
-> Lens ListGroups ListGroups (Maybe Text) (Maybe Text)
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 total number of results that you want included on each page of the
-- response. If you do not include this parameter, it defaults to a value
-- that is specific to the operation. If additional items exist beyond the
-- maximum you specify, the @NextToken@ response element is present and has
-- a value (is not null). Include that value as the @NextToken@ request
-- parameter in the next call to the operation to get the next part of the
-- results. Note that the service might return fewer results than the
-- maximum even when there are more results available. You should check
-- @NextToken@ after every operation to ensure that you receive all of the
-- results.
listGroups_maxResults :: Lens.Lens' ListGroups (Prelude.Maybe Prelude.Natural)
listGroups_maxResults :: (Maybe Natural -> f (Maybe Natural)) -> ListGroups -> f ListGroups
listGroups_maxResults = (ListGroups -> Maybe Natural)
-> (ListGroups -> Maybe Natural -> ListGroups)
-> Lens ListGroups ListGroups (Maybe Natural) (Maybe Natural)
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)

instance Core.AWSPager ListGroups where
  page :: ListGroups -> AWSResponse ListGroups -> Maybe ListGroups
page ListGroups
rq AWSResponse ListGroups
rs
    | Maybe Text -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListGroups
ListGroupsResponse
rs
            ListGroupsResponse
-> Getting (First Text) ListGroupsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListGroupsResponse -> Const (First Text) ListGroupsResponse
Lens' ListGroupsResponse (Maybe Text)
listGroupsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListGroupsResponse -> Const (First Text) ListGroupsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListGroupsResponse 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 ListGroups
forall a. Maybe a
Prelude.Nothing
    | Maybe [GroupIdentifier] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListGroups
ListGroupsResponse
rs
            ListGroupsResponse
-> Getting
     (First [GroupIdentifier]) ListGroupsResponse [GroupIdentifier]
-> Maybe [GroupIdentifier]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [GroupIdentifier]
 -> Const (First [GroupIdentifier]) (Maybe [GroupIdentifier]))
-> ListGroupsResponse
-> Const (First [GroupIdentifier]) ListGroupsResponse
Lens' ListGroupsResponse (Maybe [GroupIdentifier])
listGroupsResponse_groupIdentifiers
              ((Maybe [GroupIdentifier]
  -> Const (First [GroupIdentifier]) (Maybe [GroupIdentifier]))
 -> ListGroupsResponse
 -> Const (First [GroupIdentifier]) ListGroupsResponse)
-> (([GroupIdentifier]
     -> Const (First [GroupIdentifier]) [GroupIdentifier])
    -> Maybe [GroupIdentifier]
    -> Const (First [GroupIdentifier]) (Maybe [GroupIdentifier]))
-> Getting
     (First [GroupIdentifier]) ListGroupsResponse [GroupIdentifier]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([GroupIdentifier]
 -> Const (First [GroupIdentifier]) [GroupIdentifier])
-> Maybe [GroupIdentifier]
-> Const (First [GroupIdentifier]) (Maybe [GroupIdentifier])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListGroups
forall a. Maybe a
Prelude.Nothing
    | Maybe [Group] -> Bool
forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListGroups
ListGroupsResponse
rs
            ListGroupsResponse
-> Getting (First [Group]) ListGroupsResponse [Group]
-> Maybe [Group]
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe [Group] -> Const (First [Group]) (Maybe [Group]))
-> ListGroupsResponse -> Const (First [Group]) ListGroupsResponse
Lens' ListGroupsResponse (Maybe [Group])
listGroupsResponse_groups ((Maybe [Group] -> Const (First [Group]) (Maybe [Group]))
 -> ListGroupsResponse -> Const (First [Group]) ListGroupsResponse)
-> (([Group] -> Const (First [Group]) [Group])
    -> Maybe [Group] -> Const (First [Group]) (Maybe [Group]))
-> Getting (First [Group]) ListGroupsResponse [Group]
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Group] -> Const (First [Group]) [Group])
-> Maybe [Group] -> Const (First [Group]) (Maybe [Group])
forall a b. Prism (Maybe a) (Maybe b) a b
Lens._Just
        ) =
      Maybe ListGroups
forall a. Maybe a
Prelude.Nothing
    | Bool
Prelude.otherwise =
      ListGroups -> Maybe ListGroups
forall a. a -> Maybe a
Prelude.Just (ListGroups -> Maybe ListGroups) -> ListGroups -> Maybe ListGroups
forall a b. (a -> b) -> a -> b
Prelude.$
        ListGroups
rq
          ListGroups -> (ListGroups -> ListGroups) -> ListGroups
forall a b. a -> (a -> b) -> b
Prelude.& (Maybe Text -> Identity (Maybe Text))
-> ListGroups -> Identity ListGroups
Lens ListGroups ListGroups (Maybe Text) (Maybe Text)
listGroups_nextToken
          ((Maybe Text -> Identity (Maybe Text))
 -> ListGroups -> Identity ListGroups)
-> Maybe Text -> ListGroups -> ListGroups
forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListGroups
ListGroupsResponse
rs
          ListGroupsResponse
-> Getting (First Text) ListGroupsResponse Text -> Maybe Text
forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? (Maybe Text -> Const (First Text) (Maybe Text))
-> ListGroupsResponse -> Const (First Text) ListGroupsResponse
Lens' ListGroupsResponse (Maybe Text)
listGroupsResponse_nextToken ((Maybe Text -> Const (First Text) (Maybe Text))
 -> ListGroupsResponse -> Const (First Text) ListGroupsResponse)
-> ((Text -> Const (First Text) Text)
    -> Maybe Text -> Const (First Text) (Maybe Text))
-> Getting (First Text) ListGroupsResponse 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 ListGroups where
  type AWSResponse ListGroups = ListGroupsResponse
  request :: ListGroups -> Request ListGroups
request = Service -> ListGroups -> Request ListGroups
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy ListGroups
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListGroups)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse ListGroups))
-> Logger
-> Service
-> Proxy ListGroups
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListGroups)))
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 [Group]
-> Maybe Text
-> Maybe [GroupIdentifier]
-> Int
-> ListGroupsResponse
ListGroupsResponse'
            (Maybe [Group]
 -> Maybe Text
 -> Maybe [GroupIdentifier]
 -> Int
 -> ListGroupsResponse)
-> Either String (Maybe [Group])
-> Either
     String
     (Maybe Text
      -> Maybe [GroupIdentifier] -> Int -> ListGroupsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Group]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Groups" Either String (Maybe (Maybe [Group]))
-> Maybe [Group] -> Either String (Maybe [Group])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Group]
forall a. Monoid a => a
Prelude.mempty)
            Either
  String
  (Maybe Text
   -> Maybe [GroupIdentifier] -> Int -> ListGroupsResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe [GroupIdentifier] -> Int -> ListGroupsResponse)
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
"NextToken")
            Either
  String (Maybe [GroupIdentifier] -> Int -> ListGroupsResponse)
-> Either String (Maybe [GroupIdentifier])
-> Either String (Int -> ListGroupsResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Either String (Maybe (Maybe [GroupIdentifier]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"GroupIdentifiers"
                            Either String (Maybe (Maybe [GroupIdentifier]))
-> Maybe [GroupIdentifier]
-> Either String (Maybe [GroupIdentifier])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [GroupIdentifier]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either String (Int -> ListGroupsResponse)
-> Either String Int -> Either String ListGroupsResponse
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 ListGroups

instance Prelude.NFData ListGroups

instance Core.ToHeaders ListGroups where
  toHeaders :: ListGroups -> ResponseHeaders
toHeaders = ResponseHeaders -> ListGroups -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON ListGroups where
  toJSON :: ListGroups -> Value
toJSON ListGroups' {Maybe Natural
Maybe [GroupFilter]
Maybe Text
maxResults :: Maybe Natural
nextToken :: Maybe Text
filters :: Maybe [GroupFilter]
$sel:maxResults:ListGroups' :: ListGroups -> Maybe Natural
$sel:nextToken:ListGroups' :: ListGroups -> Maybe Text
$sel:filters:ListGroups' :: ListGroups -> Maybe [GroupFilter]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"Filters" Text -> [GroupFilter] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([GroupFilter] -> Pair) -> Maybe [GroupFilter] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [GroupFilter]
filters]
      )

instance Core.ToPath ListGroups where
  toPath :: ListGroups -> ByteString
toPath = ByteString -> ListGroups -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/groups-list"

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

-- | /See:/ 'newListGroupsResponse' smart constructor.
data ListGroupsResponse = ListGroupsResponse'
  { -- | /__Deprecated - don\'t use this field. Use the @GroupIdentifiers@
    -- response field instead.__/
    ListGroupsResponse -> Maybe [Group]
groups :: Prelude.Maybe [Group],
    -- | If present, indicates that more output is available than is included in
    -- the current response. Use this value in the @NextToken@ request
    -- parameter in a subsequent call to the operation to get the next part of
    -- the output. You should repeat this until the @NextToken@ response
    -- element comes back as @null@.
    ListGroupsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | A list of GroupIdentifier objects. Each identifier is an object that
    -- contains both the @Name@ and the @GroupArn@.
    ListGroupsResponse -> Maybe [GroupIdentifier]
groupIdentifiers :: Prelude.Maybe [GroupIdentifier],
    -- | The response's http status code.
    ListGroupsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListGroupsResponse -> ListGroupsResponse -> Bool
(ListGroupsResponse -> ListGroupsResponse -> Bool)
-> (ListGroupsResponse -> ListGroupsResponse -> Bool)
-> Eq ListGroupsResponse
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]
(Int -> ReadS ListGroupsResponse)
-> ReadS [ListGroupsResponse]
-> ReadPrec ListGroupsResponse
-> ReadPrec [ListGroupsResponse]
-> Read 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
(Int -> ListGroupsResponse -> ShowS)
-> (ListGroupsResponse -> String)
-> ([ListGroupsResponse] -> ShowS)
-> Show ListGroupsResponse
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. ListGroupsResponse -> Rep ListGroupsResponse x)
-> (forall x. Rep ListGroupsResponse x -> ListGroupsResponse)
-> Generic ListGroupsResponse
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:
--
-- 'groups', 'listGroupsResponse_groups' - /__Deprecated - don\'t use this field. Use the @GroupIdentifiers@
-- response field instead.__/
--
-- 'nextToken', 'listGroupsResponse_nextToken' - If present, indicates that more output is available than is included in
-- the current response. Use this value in the @NextToken@ request
-- parameter in a subsequent call to the operation to get the next part of
-- the output. You should repeat this until the @NextToken@ response
-- element comes back as @null@.
--
-- 'groupIdentifiers', 'listGroupsResponse_groupIdentifiers' - A list of GroupIdentifier objects. Each identifier is an object that
-- contains both the @Name@ and the @GroupArn@.
--
-- 'httpStatus', 'listGroupsResponse_httpStatus' - The response's http status code.
newListGroupsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListGroupsResponse
newListGroupsResponse :: Int -> ListGroupsResponse
newListGroupsResponse Int
pHttpStatus_ =
  ListGroupsResponse' :: Maybe [Group]
-> Maybe Text
-> Maybe [GroupIdentifier]
-> Int
-> ListGroupsResponse
ListGroupsResponse'
    { $sel:groups:ListGroupsResponse' :: Maybe [Group]
groups = Maybe [Group]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListGroupsResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:groupIdentifiers:ListGroupsResponse' :: Maybe [GroupIdentifier]
groupIdentifiers = Maybe [GroupIdentifier]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListGroupsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | /__Deprecated - don\'t use this field. Use the @GroupIdentifiers@
-- response field instead.__/
listGroupsResponse_groups :: Lens.Lens' ListGroupsResponse (Prelude.Maybe [Group])
listGroupsResponse_groups :: (Maybe [Group] -> f (Maybe [Group]))
-> ListGroupsResponse -> f ListGroupsResponse
listGroupsResponse_groups = (ListGroupsResponse -> Maybe [Group])
-> (ListGroupsResponse -> Maybe [Group] -> ListGroupsResponse)
-> Lens' ListGroupsResponse (Maybe [Group])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroupsResponse' {Maybe [Group]
groups :: Maybe [Group]
$sel:groups:ListGroupsResponse' :: ListGroupsResponse -> Maybe [Group]
groups} -> Maybe [Group]
groups) (\s :: ListGroupsResponse
s@ListGroupsResponse' {} Maybe [Group]
a -> ListGroupsResponse
s {$sel:groups:ListGroupsResponse' :: Maybe [Group]
groups = Maybe [Group]
a} :: ListGroupsResponse) ((Maybe [Group] -> f (Maybe [Group]))
 -> ListGroupsResponse -> f ListGroupsResponse)
-> ((Maybe [Group] -> f (Maybe [Group]))
    -> Maybe [Group] -> f (Maybe [Group]))
-> (Maybe [Group] -> f (Maybe [Group]))
-> ListGroupsResponse
-> f ListGroupsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Group] [Group] [Group] [Group]
-> Iso
     (Maybe [Group]) (Maybe [Group]) (Maybe [Group]) (Maybe [Group])
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 [Group] [Group] [Group] [Group]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | If present, indicates that more output is available than is included in
-- the current response. Use this value in the @NextToken@ request
-- parameter in a subsequent call to the operation to get the next part of
-- the output. You should repeat this until the @NextToken@ response
-- element comes back as @null@.
listGroupsResponse_nextToken :: Lens.Lens' ListGroupsResponse (Prelude.Maybe Prelude.Text)
listGroupsResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> ListGroupsResponse -> f ListGroupsResponse
listGroupsResponse_nextToken = (ListGroupsResponse -> Maybe Text)
-> (ListGroupsResponse -> Maybe Text -> ListGroupsResponse)
-> Lens' ListGroupsResponse (Maybe Text)
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)

-- | A list of GroupIdentifier objects. Each identifier is an object that
-- contains both the @Name@ and the @GroupArn@.
listGroupsResponse_groupIdentifiers :: Lens.Lens' ListGroupsResponse (Prelude.Maybe [GroupIdentifier])
listGroupsResponse_groupIdentifiers :: (Maybe [GroupIdentifier] -> f (Maybe [GroupIdentifier]))
-> ListGroupsResponse -> f ListGroupsResponse
listGroupsResponse_groupIdentifiers = (ListGroupsResponse -> Maybe [GroupIdentifier])
-> (ListGroupsResponse
    -> Maybe [GroupIdentifier] -> ListGroupsResponse)
-> Lens' ListGroupsResponse (Maybe [GroupIdentifier])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListGroupsResponse' {Maybe [GroupIdentifier]
groupIdentifiers :: Maybe [GroupIdentifier]
$sel:groupIdentifiers:ListGroupsResponse' :: ListGroupsResponse -> Maybe [GroupIdentifier]
groupIdentifiers} -> Maybe [GroupIdentifier]
groupIdentifiers) (\s :: ListGroupsResponse
s@ListGroupsResponse' {} Maybe [GroupIdentifier]
a -> ListGroupsResponse
s {$sel:groupIdentifiers:ListGroupsResponse' :: Maybe [GroupIdentifier]
groupIdentifiers = Maybe [GroupIdentifier]
a} :: ListGroupsResponse) ((Maybe [GroupIdentifier] -> f (Maybe [GroupIdentifier]))
 -> ListGroupsResponse -> f ListGroupsResponse)
-> ((Maybe [GroupIdentifier] -> f (Maybe [GroupIdentifier]))
    -> Maybe [GroupIdentifier] -> f (Maybe [GroupIdentifier]))
-> (Maybe [GroupIdentifier] -> f (Maybe [GroupIdentifier]))
-> ListGroupsResponse
-> f ListGroupsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [GroupIdentifier]
  [GroupIdentifier]
  [GroupIdentifier]
  [GroupIdentifier]
-> Iso
     (Maybe [GroupIdentifier])
     (Maybe [GroupIdentifier])
     (Maybe [GroupIdentifier])
     (Maybe [GroupIdentifier])
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
  [GroupIdentifier]
  [GroupIdentifier]
  [GroupIdentifier]
  [GroupIdentifier]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData ListGroupsResponse