{-# 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.ServiceCatalogAppRegistry.ListAttributeGroups
-- 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 attribute groups which you have access to. Results are
-- paginated.
--
-- This operation returns paginated results.
module Amazonka.ServiceCatalogAppRegistry.ListAttributeGroups
  ( -- * Creating a Request
    ListAttributeGroups (..),
    newListAttributeGroups,

    -- * Request Lenses
    listAttributeGroups_maxResults,
    listAttributeGroups_nextToken,

    -- * Destructuring the Response
    ListAttributeGroupsResponse (..),
    newListAttributeGroupsResponse,

    -- * Response Lenses
    listAttributeGroupsResponse_attributeGroups,
    listAttributeGroupsResponse_nextToken,
    listAttributeGroupsResponse_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.ServiceCatalogAppRegistry.Types

-- | /See:/ 'newListAttributeGroups' smart constructor.
data ListAttributeGroups = ListAttributeGroups'
  { -- | The upper bound of the number of results to return (cannot exceed 25).
    -- If this parameter is omitted, it defaults to 25. This value is optional.
    ListAttributeGroups -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural,
    -- | The token to use to get the next page of results after a previous API
    -- call.
    ListAttributeGroups -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text
  }
  deriving (ListAttributeGroups -> ListAttributeGroups -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAttributeGroups -> ListAttributeGroups -> Bool
$c/= :: ListAttributeGroups -> ListAttributeGroups -> Bool
== :: ListAttributeGroups -> ListAttributeGroups -> Bool
$c== :: ListAttributeGroups -> ListAttributeGroups -> Bool
Prelude.Eq, ReadPrec [ListAttributeGroups]
ReadPrec ListAttributeGroups
Int -> ReadS ListAttributeGroups
ReadS [ListAttributeGroups]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAttributeGroups]
$creadListPrec :: ReadPrec [ListAttributeGroups]
readPrec :: ReadPrec ListAttributeGroups
$creadPrec :: ReadPrec ListAttributeGroups
readList :: ReadS [ListAttributeGroups]
$creadList :: ReadS [ListAttributeGroups]
readsPrec :: Int -> ReadS ListAttributeGroups
$creadsPrec :: Int -> ReadS ListAttributeGroups
Prelude.Read, Int -> ListAttributeGroups -> ShowS
[ListAttributeGroups] -> ShowS
ListAttributeGroups -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAttributeGroups] -> ShowS
$cshowList :: [ListAttributeGroups] -> ShowS
show :: ListAttributeGroups -> String
$cshow :: ListAttributeGroups -> String
showsPrec :: Int -> ListAttributeGroups -> ShowS
$cshowsPrec :: Int -> ListAttributeGroups -> ShowS
Prelude.Show, forall x. Rep ListAttributeGroups x -> ListAttributeGroups
forall x. ListAttributeGroups -> Rep ListAttributeGroups x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListAttributeGroups x -> ListAttributeGroups
$cfrom :: forall x. ListAttributeGroups -> Rep ListAttributeGroups x
Prelude.Generic)

-- |
-- Create a value of 'ListAttributeGroups' 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', 'listAttributeGroups_maxResults' - The upper bound of the number of results to return (cannot exceed 25).
-- If this parameter is omitted, it defaults to 25. This value is optional.
--
-- 'nextToken', 'listAttributeGroups_nextToken' - The token to use to get the next page of results after a previous API
-- call.
newListAttributeGroups ::
  ListAttributeGroups
newListAttributeGroups :: ListAttributeGroups
newListAttributeGroups =
  ListAttributeGroups'
    { $sel:maxResults:ListAttributeGroups' :: Maybe Natural
maxResults = forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAttributeGroups' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing
    }

-- | The upper bound of the number of results to return (cannot exceed 25).
-- If this parameter is omitted, it defaults to 25. This value is optional.
listAttributeGroups_maxResults :: Lens.Lens' ListAttributeGroups (Prelude.Maybe Prelude.Natural)
listAttributeGroups_maxResults :: Lens' ListAttributeGroups (Maybe Natural)
listAttributeGroups_maxResults = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttributeGroups' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:ListAttributeGroups' :: ListAttributeGroups -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: ListAttributeGroups
s@ListAttributeGroups' {} Maybe Natural
a -> ListAttributeGroups
s {$sel:maxResults:ListAttributeGroups' :: Maybe Natural
maxResults = Maybe Natural
a} :: ListAttributeGroups)

-- | The token to use to get the next page of results after a previous API
-- call.
listAttributeGroups_nextToken :: Lens.Lens' ListAttributeGroups (Prelude.Maybe Prelude.Text)
listAttributeGroups_nextToken :: Lens' ListAttributeGroups (Maybe Text)
listAttributeGroups_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttributeGroups' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAttributeGroups' :: ListAttributeGroups -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAttributeGroups
s@ListAttributeGroups' {} Maybe Text
a -> ListAttributeGroups
s {$sel:nextToken:ListAttributeGroups' :: Maybe Text
nextToken = Maybe Text
a} :: ListAttributeGroups)

instance Core.AWSPager ListAttributeGroups where
  page :: ListAttributeGroups
-> AWSResponse ListAttributeGroups -> Maybe ListAttributeGroups
page ListAttributeGroups
rq AWSResponse ListAttributeGroups
rs
    | forall a. AWSTruncated a => a -> Bool
Core.stop
        ( AWSResponse ListAttributeGroups
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListAttributeGroupsResponse (Maybe Text)
listAttributeGroupsResponse_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 ListAttributeGroups
rs
            forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListAttributeGroupsResponse (Maybe [AttributeGroupSummary])
listAttributeGroupsResponse_attributeGroups
            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.$ ListAttributeGroups
rq
          forall a b. a -> (a -> b) -> b
Prelude.& Lens' ListAttributeGroups (Maybe Text)
listAttributeGroups_nextToken
          forall s t a b. ASetter s t a b -> b -> s -> t
Lens..~ AWSResponse ListAttributeGroups
rs
          forall s a. s -> Getting (First a) s a -> Maybe a
Lens.^? Lens' ListAttributeGroupsResponse (Maybe Text)
listAttributeGroupsResponse_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 ListAttributeGroups where
  type
    AWSResponse ListAttributeGroups =
      ListAttributeGroupsResponse
  request :: (Service -> Service)
-> ListAttributeGroups -> Request ListAttributeGroups
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 ListAttributeGroups
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse ListAttributeGroups)))
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 [AttributeGroupSummary]
-> Maybe Text -> Int -> ListAttributeGroupsResponse
ListAttributeGroupsResponse'
            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
"attributeGroups"
                            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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable ListAttributeGroups where
  hashWithSalt :: Int -> ListAttributeGroups -> Int
hashWithSalt Int
_salt ListAttributeGroups' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListAttributeGroups' :: ListAttributeGroups -> Maybe Text
$sel:maxResults:ListAttributeGroups' :: ListAttributeGroups -> 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 ListAttributeGroups where
  rnf :: ListAttributeGroups -> ()
rnf ListAttributeGroups' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListAttributeGroups' :: ListAttributeGroups -> Maybe Text
$sel:maxResults:ListAttributeGroups' :: ListAttributeGroups -> 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 ListAttributeGroups where
  toHeaders :: ListAttributeGroups -> 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 ListAttributeGroups where
  toPath :: ListAttributeGroups -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/attribute-groups"

instance Data.ToQuery ListAttributeGroups where
  toQuery :: ListAttributeGroups -> QueryString
toQuery ListAttributeGroups' {Maybe Natural
Maybe Text
nextToken :: Maybe Text
maxResults :: Maybe Natural
$sel:nextToken:ListAttributeGroups' :: ListAttributeGroups -> Maybe Text
$sel:maxResults:ListAttributeGroups' :: ListAttributeGroups -> 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:/ 'newListAttributeGroupsResponse' smart constructor.
data ListAttributeGroupsResponse = ListAttributeGroupsResponse'
  { -- | This list of attribute groups.
    ListAttributeGroupsResponse -> Maybe [AttributeGroupSummary]
attributeGroups :: Prelude.Maybe [AttributeGroupSummary],
    -- | The token to use to get the next page of results after a previous API
    -- call.
    ListAttributeGroupsResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    ListAttributeGroupsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListAttributeGroupsResponse -> ListAttributeGroupsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListAttributeGroupsResponse -> ListAttributeGroupsResponse -> Bool
$c/= :: ListAttributeGroupsResponse -> ListAttributeGroupsResponse -> Bool
== :: ListAttributeGroupsResponse -> ListAttributeGroupsResponse -> Bool
$c== :: ListAttributeGroupsResponse -> ListAttributeGroupsResponse -> Bool
Prelude.Eq, ReadPrec [ListAttributeGroupsResponse]
ReadPrec ListAttributeGroupsResponse
Int -> ReadS ListAttributeGroupsResponse
ReadS [ListAttributeGroupsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListAttributeGroupsResponse]
$creadListPrec :: ReadPrec [ListAttributeGroupsResponse]
readPrec :: ReadPrec ListAttributeGroupsResponse
$creadPrec :: ReadPrec ListAttributeGroupsResponse
readList :: ReadS [ListAttributeGroupsResponse]
$creadList :: ReadS [ListAttributeGroupsResponse]
readsPrec :: Int -> ReadS ListAttributeGroupsResponse
$creadsPrec :: Int -> ReadS ListAttributeGroupsResponse
Prelude.Read, Int -> ListAttributeGroupsResponse -> ShowS
[ListAttributeGroupsResponse] -> ShowS
ListAttributeGroupsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListAttributeGroupsResponse] -> ShowS
$cshowList :: [ListAttributeGroupsResponse] -> ShowS
show :: ListAttributeGroupsResponse -> String
$cshow :: ListAttributeGroupsResponse -> String
showsPrec :: Int -> ListAttributeGroupsResponse -> ShowS
$cshowsPrec :: Int -> ListAttributeGroupsResponse -> ShowS
Prelude.Show, forall x.
Rep ListAttributeGroupsResponse x -> ListAttributeGroupsResponse
forall x.
ListAttributeGroupsResponse -> Rep ListAttributeGroupsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ListAttributeGroupsResponse x -> ListAttributeGroupsResponse
$cfrom :: forall x.
ListAttributeGroupsResponse -> Rep ListAttributeGroupsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListAttributeGroupsResponse' 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:
--
-- 'attributeGroups', 'listAttributeGroupsResponse_attributeGroups' - This list of attribute groups.
--
-- 'nextToken', 'listAttributeGroupsResponse_nextToken' - The token to use to get the next page of results after a previous API
-- call.
--
-- 'httpStatus', 'listAttributeGroupsResponse_httpStatus' - The response's http status code.
newListAttributeGroupsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListAttributeGroupsResponse
newListAttributeGroupsResponse :: Int -> ListAttributeGroupsResponse
newListAttributeGroupsResponse Int
pHttpStatus_ =
  ListAttributeGroupsResponse'
    { $sel:attributeGroups:ListAttributeGroupsResponse' :: Maybe [AttributeGroupSummary]
attributeGroups =
        forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:ListAttributeGroupsResponse' :: Maybe Text
nextToken = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListAttributeGroupsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | This list of attribute groups.
listAttributeGroupsResponse_attributeGroups :: Lens.Lens' ListAttributeGroupsResponse (Prelude.Maybe [AttributeGroupSummary])
listAttributeGroupsResponse_attributeGroups :: Lens' ListAttributeGroupsResponse (Maybe [AttributeGroupSummary])
listAttributeGroupsResponse_attributeGroups = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttributeGroupsResponse' {Maybe [AttributeGroupSummary]
attributeGroups :: Maybe [AttributeGroupSummary]
$sel:attributeGroups:ListAttributeGroupsResponse' :: ListAttributeGroupsResponse -> Maybe [AttributeGroupSummary]
attributeGroups} -> Maybe [AttributeGroupSummary]
attributeGroups) (\s :: ListAttributeGroupsResponse
s@ListAttributeGroupsResponse' {} Maybe [AttributeGroupSummary]
a -> ListAttributeGroupsResponse
s {$sel:attributeGroups:ListAttributeGroupsResponse' :: Maybe [AttributeGroupSummary]
attributeGroups = Maybe [AttributeGroupSummary]
a} :: ListAttributeGroupsResponse) 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 token to use to get the next page of results after a previous API
-- call.
listAttributeGroupsResponse_nextToken :: Lens.Lens' ListAttributeGroupsResponse (Prelude.Maybe Prelude.Text)
listAttributeGroupsResponse_nextToken :: Lens' ListAttributeGroupsResponse (Maybe Text)
listAttributeGroupsResponse_nextToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListAttributeGroupsResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:ListAttributeGroupsResponse' :: ListAttributeGroupsResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: ListAttributeGroupsResponse
s@ListAttributeGroupsResponse' {} Maybe Text
a -> ListAttributeGroupsResponse
s {$sel:nextToken:ListAttributeGroupsResponse' :: Maybe Text
nextToken = Maybe Text
a} :: ListAttributeGroupsResponse)

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

instance Prelude.NFData ListAttributeGroupsResponse where
  rnf :: ListAttributeGroupsResponse -> ()
rnf ListAttributeGroupsResponse' {Int
Maybe [AttributeGroupSummary]
Maybe Text
httpStatus :: Int
nextToken :: Maybe Text
attributeGroups :: Maybe [AttributeGroupSummary]
$sel:httpStatus:ListAttributeGroupsResponse' :: ListAttributeGroupsResponse -> Int
$sel:nextToken:ListAttributeGroupsResponse' :: ListAttributeGroupsResponse -> Maybe Text
$sel:attributeGroups:ListAttributeGroupsResponse' :: ListAttributeGroupsResponse -> Maybe [AttributeGroupSummary]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [AttributeGroupSummary]
attributeGroups
      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 Int
httpStatus