{-# 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.CloudFront.ListKeyGroups
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets a list of key groups.
--
-- You can optionally specify the maximum number of items to receive in the
-- response. If the total number of items in the list exceeds the maximum
-- that you specify, or the default maximum, the response is paginated. To
-- get the next page of items, send a subsequent request that specifies the
-- @NextMarker@ value from the current response as the @Marker@ value in
-- the subsequent request.
module Amazonka.CloudFront.ListKeyGroups
  ( -- * Creating a Request
    ListKeyGroups (..),
    newListKeyGroups,

    -- * Request Lenses
    listKeyGroups_marker,
    listKeyGroups_maxItems,

    -- * Destructuring the Response
    ListKeyGroupsResponse (..),
    newListKeyGroupsResponse,

    -- * Response Lenses
    listKeyGroupsResponse_keyGroupList,
    listKeyGroupsResponse_httpStatus,
  )
where

import Amazonka.CloudFront.Types
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

-- | /See:/ 'newListKeyGroups' smart constructor.
data ListKeyGroups = ListKeyGroups'
  { -- | Use this field when paginating results to indicate where to begin in
    -- your list of key groups. The response includes key groups in the list
    -- that occur after the marker. To get the next page of the list, set this
    -- field\'s value to the value of @NextMarker@ from the current page\'s
    -- response.
    ListKeyGroups -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of key groups that you want in the response.
    ListKeyGroups -> Maybe Text
maxItems :: Prelude.Maybe Prelude.Text
  }
  deriving (ListKeyGroups -> ListKeyGroups -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListKeyGroups -> ListKeyGroups -> Bool
$c/= :: ListKeyGroups -> ListKeyGroups -> Bool
== :: ListKeyGroups -> ListKeyGroups -> Bool
$c== :: ListKeyGroups -> ListKeyGroups -> Bool
Prelude.Eq, ReadPrec [ListKeyGroups]
ReadPrec ListKeyGroups
Int -> ReadS ListKeyGroups
ReadS [ListKeyGroups]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListKeyGroups]
$creadListPrec :: ReadPrec [ListKeyGroups]
readPrec :: ReadPrec ListKeyGroups
$creadPrec :: ReadPrec ListKeyGroups
readList :: ReadS [ListKeyGroups]
$creadList :: ReadS [ListKeyGroups]
readsPrec :: Int -> ReadS ListKeyGroups
$creadsPrec :: Int -> ReadS ListKeyGroups
Prelude.Read, Int -> ListKeyGroups -> ShowS
[ListKeyGroups] -> ShowS
ListKeyGroups -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListKeyGroups] -> ShowS
$cshowList :: [ListKeyGroups] -> ShowS
show :: ListKeyGroups -> String
$cshow :: ListKeyGroups -> String
showsPrec :: Int -> ListKeyGroups -> ShowS
$cshowsPrec :: Int -> ListKeyGroups -> ShowS
Prelude.Show, forall x. Rep ListKeyGroups x -> ListKeyGroups
forall x. ListKeyGroups -> Rep ListKeyGroups x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListKeyGroups x -> ListKeyGroups
$cfrom :: forall x. ListKeyGroups -> Rep ListKeyGroups x
Prelude.Generic)

-- |
-- Create a value of 'ListKeyGroups' 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:
--
-- 'marker', 'listKeyGroups_marker' - Use this field when paginating results to indicate where to begin in
-- your list of key groups. The response includes key groups in the list
-- that occur after the marker. To get the next page of the list, set this
-- field\'s value to the value of @NextMarker@ from the current page\'s
-- response.
--
-- 'maxItems', 'listKeyGroups_maxItems' - The maximum number of key groups that you want in the response.
newListKeyGroups ::
  ListKeyGroups
newListKeyGroups :: ListKeyGroups
newListKeyGroups =
  ListKeyGroups'
    { $sel:marker:ListKeyGroups' :: Maybe Text
marker = forall a. Maybe a
Prelude.Nothing,
      $sel:maxItems:ListKeyGroups' :: Maybe Text
maxItems = forall a. Maybe a
Prelude.Nothing
    }

-- | Use this field when paginating results to indicate where to begin in
-- your list of key groups. The response includes key groups in the list
-- that occur after the marker. To get the next page of the list, set this
-- field\'s value to the value of @NextMarker@ from the current page\'s
-- response.
listKeyGroups_marker :: Lens.Lens' ListKeyGroups (Prelude.Maybe Prelude.Text)
listKeyGroups_marker :: Lens' ListKeyGroups (Maybe Text)
listKeyGroups_marker = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListKeyGroups' {Maybe Text
marker :: Maybe Text
$sel:marker:ListKeyGroups' :: ListKeyGroups -> Maybe Text
marker} -> Maybe Text
marker) (\s :: ListKeyGroups
s@ListKeyGroups' {} Maybe Text
a -> ListKeyGroups
s {$sel:marker:ListKeyGroups' :: Maybe Text
marker = Maybe Text
a} :: ListKeyGroups)

-- | The maximum number of key groups that you want in the response.
listKeyGroups_maxItems :: Lens.Lens' ListKeyGroups (Prelude.Maybe Prelude.Text)
listKeyGroups_maxItems :: Lens' ListKeyGroups (Maybe Text)
listKeyGroups_maxItems = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListKeyGroups' {Maybe Text
maxItems :: Maybe Text
$sel:maxItems:ListKeyGroups' :: ListKeyGroups -> Maybe Text
maxItems} -> Maybe Text
maxItems) (\s :: ListKeyGroups
s@ListKeyGroups' {} Maybe Text
a -> ListKeyGroups
s {$sel:maxItems:ListKeyGroups' :: Maybe Text
maxItems = Maybe Text
a} :: ListKeyGroups)

instance Core.AWSRequest ListKeyGroups where
  type
    AWSResponse ListKeyGroups =
      ListKeyGroupsResponse
  request :: (Service -> Service) -> ListKeyGroups -> Request ListKeyGroups
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 ListKeyGroups
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListKeyGroups)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe KeyGroupList -> Int -> ListKeyGroupsResponse
ListKeyGroupsResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall a. FromXML a => [Node] -> Either String a
Data.parseXML [Node]
x)
            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 ListKeyGroups where
  hashWithSalt :: Int -> ListKeyGroups -> Int
hashWithSalt Int
_salt ListKeyGroups' {Maybe Text
maxItems :: Maybe Text
marker :: Maybe Text
$sel:maxItems:ListKeyGroups' :: ListKeyGroups -> Maybe Text
$sel:marker:ListKeyGroups' :: ListKeyGroups -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
marker
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
maxItems

instance Prelude.NFData ListKeyGroups where
  rnf :: ListKeyGroups -> ()
rnf ListKeyGroups' {Maybe Text
maxItems :: Maybe Text
marker :: Maybe Text
$sel:maxItems:ListKeyGroups' :: ListKeyGroups -> Maybe Text
$sel:marker:ListKeyGroups' :: ListKeyGroups -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
marker
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
maxItems

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

instance Data.ToPath ListKeyGroups where
  toPath :: ListKeyGroups -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/2020-05-31/key-group"

instance Data.ToQuery ListKeyGroups where
  toQuery :: ListKeyGroups -> QueryString
toQuery ListKeyGroups' {Maybe Text
maxItems :: Maybe Text
marker :: Maybe Text
$sel:maxItems:ListKeyGroups' :: ListKeyGroups -> Maybe Text
$sel:marker:ListKeyGroups' :: ListKeyGroups -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Marker" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
marker,
        ByteString
"MaxItems" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
maxItems
      ]

-- | /See:/ 'newListKeyGroupsResponse' smart constructor.
data ListKeyGroupsResponse = ListKeyGroupsResponse'
  { -- | A list of key groups.
    ListKeyGroupsResponse -> Maybe KeyGroupList
keyGroupList :: Prelude.Maybe KeyGroupList,
    -- | The response's http status code.
    ListKeyGroupsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListKeyGroupsResponse -> ListKeyGroupsResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListKeyGroupsResponse -> ListKeyGroupsResponse -> Bool
$c/= :: ListKeyGroupsResponse -> ListKeyGroupsResponse -> Bool
== :: ListKeyGroupsResponse -> ListKeyGroupsResponse -> Bool
$c== :: ListKeyGroupsResponse -> ListKeyGroupsResponse -> Bool
Prelude.Eq, ReadPrec [ListKeyGroupsResponse]
ReadPrec ListKeyGroupsResponse
Int -> ReadS ListKeyGroupsResponse
ReadS [ListKeyGroupsResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListKeyGroupsResponse]
$creadListPrec :: ReadPrec [ListKeyGroupsResponse]
readPrec :: ReadPrec ListKeyGroupsResponse
$creadPrec :: ReadPrec ListKeyGroupsResponse
readList :: ReadS [ListKeyGroupsResponse]
$creadList :: ReadS [ListKeyGroupsResponse]
readsPrec :: Int -> ReadS ListKeyGroupsResponse
$creadsPrec :: Int -> ReadS ListKeyGroupsResponse
Prelude.Read, Int -> ListKeyGroupsResponse -> ShowS
[ListKeyGroupsResponse] -> ShowS
ListKeyGroupsResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListKeyGroupsResponse] -> ShowS
$cshowList :: [ListKeyGroupsResponse] -> ShowS
show :: ListKeyGroupsResponse -> String
$cshow :: ListKeyGroupsResponse -> String
showsPrec :: Int -> ListKeyGroupsResponse -> ShowS
$cshowsPrec :: Int -> ListKeyGroupsResponse -> ShowS
Prelude.Show, forall x. Rep ListKeyGroupsResponse x -> ListKeyGroupsResponse
forall x. ListKeyGroupsResponse -> Rep ListKeyGroupsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListKeyGroupsResponse x -> ListKeyGroupsResponse
$cfrom :: forall x. ListKeyGroupsResponse -> Rep ListKeyGroupsResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListKeyGroupsResponse' 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:
--
-- 'keyGroupList', 'listKeyGroupsResponse_keyGroupList' - A list of key groups.
--
-- 'httpStatus', 'listKeyGroupsResponse_httpStatus' - The response's http status code.
newListKeyGroupsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListKeyGroupsResponse
newListKeyGroupsResponse :: Int -> ListKeyGroupsResponse
newListKeyGroupsResponse Int
pHttpStatus_ =
  ListKeyGroupsResponse'
    { $sel:keyGroupList:ListKeyGroupsResponse' :: Maybe KeyGroupList
keyGroupList =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListKeyGroupsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of key groups.
listKeyGroupsResponse_keyGroupList :: Lens.Lens' ListKeyGroupsResponse (Prelude.Maybe KeyGroupList)
listKeyGroupsResponse_keyGroupList :: Lens' ListKeyGroupsResponse (Maybe KeyGroupList)
listKeyGroupsResponse_keyGroupList = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListKeyGroupsResponse' {Maybe KeyGroupList
keyGroupList :: Maybe KeyGroupList
$sel:keyGroupList:ListKeyGroupsResponse' :: ListKeyGroupsResponse -> Maybe KeyGroupList
keyGroupList} -> Maybe KeyGroupList
keyGroupList) (\s :: ListKeyGroupsResponse
s@ListKeyGroupsResponse' {} Maybe KeyGroupList
a -> ListKeyGroupsResponse
s {$sel:keyGroupList:ListKeyGroupsResponse' :: Maybe KeyGroupList
keyGroupList = Maybe KeyGroupList
a} :: ListKeyGroupsResponse)

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

instance Prelude.NFData ListKeyGroupsResponse where
  rnf :: ListKeyGroupsResponse -> ()
rnf ListKeyGroupsResponse' {Int
Maybe KeyGroupList
httpStatus :: Int
keyGroupList :: Maybe KeyGroupList
$sel:httpStatus:ListKeyGroupsResponse' :: ListKeyGroupsResponse -> Int
$sel:keyGroupList:ListKeyGroupsResponse' :: ListKeyGroupsResponse -> Maybe KeyGroupList
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe KeyGroupList
keyGroupList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus