{-# 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-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)
--
-- 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.Lens as Lens
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
(ListKeyGroups -> ListKeyGroups -> Bool)
-> (ListKeyGroups -> ListKeyGroups -> Bool) -> Eq ListKeyGroups
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]
(Int -> ReadS ListKeyGroups)
-> ReadS [ListKeyGroups]
-> ReadPrec ListKeyGroups
-> ReadPrec [ListKeyGroups]
-> Read 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
(Int -> ListKeyGroups -> ShowS)
-> (ListKeyGroups -> String)
-> ([ListKeyGroups] -> ShowS)
-> Show ListKeyGroups
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. ListKeyGroups -> Rep ListKeyGroups x)
-> (forall x. Rep ListKeyGroups x -> ListKeyGroups)
-> Generic ListKeyGroups
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' :: Maybe Text -> Maybe Text -> ListKeyGroups
ListKeyGroups'
    { $sel:marker:ListKeyGroups' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxItems:ListKeyGroups' :: Maybe Text
maxItems = Maybe Text
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 :: (Maybe Text -> f (Maybe Text)) -> ListKeyGroups -> f ListKeyGroups
listKeyGroups_marker = (ListKeyGroups -> Maybe Text)
-> (ListKeyGroups -> Maybe Text -> ListKeyGroups)
-> Lens ListKeyGroups ListKeyGroups (Maybe Text) (Maybe Text)
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 :: (Maybe Text -> f (Maybe Text)) -> ListKeyGroups -> f ListKeyGroups
listKeyGroups_maxItems = (ListKeyGroups -> Maybe Text)
-> (ListKeyGroups -> Maybe Text -> ListKeyGroups)
-> Lens ListKeyGroups ListKeyGroups (Maybe Text) (Maybe Text)
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 :: ListKeyGroups -> Request ListKeyGroups
request = Service -> ListKeyGroups -> Request ListKeyGroups
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListKeyGroups
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListKeyGroups)))
response =
    (Int
 -> ResponseHeaders
 -> [Node]
 -> Either String (AWSResponse ListKeyGroups))
-> Logger
-> Service
-> Proxy ListKeyGroups
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListKeyGroups)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe KeyGroupList -> Int -> ListKeyGroupsResponse
ListKeyGroupsResponse'
            (Maybe KeyGroupList -> Int -> ListKeyGroupsResponse)
-> Either String (Maybe KeyGroupList)
-> Either String (Int -> ListKeyGroupsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node] -> Either String (Maybe KeyGroupList)
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)
            Either String (Int -> ListKeyGroupsResponse)
-> Either String Int -> Either String ListKeyGroupsResponse
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 ListKeyGroups

instance Prelude.NFData ListKeyGroups

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

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

instance Core.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
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Marker" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
marker,
        ByteString
"MaxItems" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: 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
(ListKeyGroupsResponse -> ListKeyGroupsResponse -> Bool)
-> (ListKeyGroupsResponse -> ListKeyGroupsResponse -> Bool)
-> Eq ListKeyGroupsResponse
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]
(Int -> ReadS ListKeyGroupsResponse)
-> ReadS [ListKeyGroupsResponse]
-> ReadPrec ListKeyGroupsResponse
-> ReadPrec [ListKeyGroupsResponse]
-> Read 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
(Int -> ListKeyGroupsResponse -> ShowS)
-> (ListKeyGroupsResponse -> String)
-> ([ListKeyGroupsResponse] -> ShowS)
-> Show ListKeyGroupsResponse
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. ListKeyGroupsResponse -> Rep ListKeyGroupsResponse x)
-> (forall x. Rep ListKeyGroupsResponse x -> ListKeyGroupsResponse)
-> Generic ListKeyGroupsResponse
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' :: Maybe KeyGroupList -> Int -> ListKeyGroupsResponse
ListKeyGroupsResponse'
    { $sel:keyGroupList:ListKeyGroupsResponse' :: Maybe KeyGroupList
keyGroupList =
        Maybe 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 :: (Maybe KeyGroupList -> f (Maybe KeyGroupList))
-> ListKeyGroupsResponse -> f ListKeyGroupsResponse
listKeyGroupsResponse_keyGroupList = (ListKeyGroupsResponse -> Maybe KeyGroupList)
-> (ListKeyGroupsResponse
    -> Maybe KeyGroupList -> ListKeyGroupsResponse)
-> Lens
     ListKeyGroupsResponse
     ListKeyGroupsResponse
     (Maybe KeyGroupList)
     (Maybe 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 :: (Int -> f Int) -> ListKeyGroupsResponse -> f ListKeyGroupsResponse
listKeyGroupsResponse_httpStatus = (ListKeyGroupsResponse -> Int)
-> (ListKeyGroupsResponse -> Int -> ListKeyGroupsResponse)
-> Lens ListKeyGroupsResponse ListKeyGroupsResponse Int Int
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