{-# 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.ListPublicKeys
-- 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)
--
-- List all public keys that have been added to CloudFront for this
-- account.
module Amazonka.CloudFront.ListPublicKeys
  ( -- * Creating a Request
    ListPublicKeys (..),
    newListPublicKeys,

    -- * Request Lenses
    listPublicKeys_marker,
    listPublicKeys_maxItems,

    -- * Destructuring the Response
    ListPublicKeysResponse (..),
    newListPublicKeysResponse,

    -- * Response Lenses
    listPublicKeysResponse_publicKeyList,
    listPublicKeysResponse_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:/ 'newListPublicKeys' smart constructor.
data ListPublicKeys = ListPublicKeys'
  { -- | Use this when paginating results to indicate where to begin in your list
    -- of public keys. The results include public keys in the list that occur
    -- after the marker. To get the next page of results, set the @Marker@ to
    -- the value of the @NextMarker@ from the current page\'s response (which
    -- is also the ID of the last public key on that page).
    ListPublicKeys -> Maybe Text
marker :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of public keys you want in the response body.
    ListPublicKeys -> Maybe Text
maxItems :: Prelude.Maybe Prelude.Text
  }
  deriving (ListPublicKeys -> ListPublicKeys -> Bool
(ListPublicKeys -> ListPublicKeys -> Bool)
-> (ListPublicKeys -> ListPublicKeys -> Bool) -> Eq ListPublicKeys
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPublicKeys -> ListPublicKeys -> Bool
$c/= :: ListPublicKeys -> ListPublicKeys -> Bool
== :: ListPublicKeys -> ListPublicKeys -> Bool
$c== :: ListPublicKeys -> ListPublicKeys -> Bool
Prelude.Eq, ReadPrec [ListPublicKeys]
ReadPrec ListPublicKeys
Int -> ReadS ListPublicKeys
ReadS [ListPublicKeys]
(Int -> ReadS ListPublicKeys)
-> ReadS [ListPublicKeys]
-> ReadPrec ListPublicKeys
-> ReadPrec [ListPublicKeys]
-> Read ListPublicKeys
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPublicKeys]
$creadListPrec :: ReadPrec [ListPublicKeys]
readPrec :: ReadPrec ListPublicKeys
$creadPrec :: ReadPrec ListPublicKeys
readList :: ReadS [ListPublicKeys]
$creadList :: ReadS [ListPublicKeys]
readsPrec :: Int -> ReadS ListPublicKeys
$creadsPrec :: Int -> ReadS ListPublicKeys
Prelude.Read, Int -> ListPublicKeys -> ShowS
[ListPublicKeys] -> ShowS
ListPublicKeys -> String
(Int -> ListPublicKeys -> ShowS)
-> (ListPublicKeys -> String)
-> ([ListPublicKeys] -> ShowS)
-> Show ListPublicKeys
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPublicKeys] -> ShowS
$cshowList :: [ListPublicKeys] -> ShowS
show :: ListPublicKeys -> String
$cshow :: ListPublicKeys -> String
showsPrec :: Int -> ListPublicKeys -> ShowS
$cshowsPrec :: Int -> ListPublicKeys -> ShowS
Prelude.Show, (forall x. ListPublicKeys -> Rep ListPublicKeys x)
-> (forall x. Rep ListPublicKeys x -> ListPublicKeys)
-> Generic ListPublicKeys
forall x. Rep ListPublicKeys x -> ListPublicKeys
forall x. ListPublicKeys -> Rep ListPublicKeys x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPublicKeys x -> ListPublicKeys
$cfrom :: forall x. ListPublicKeys -> Rep ListPublicKeys x
Prelude.Generic)

-- |
-- Create a value of 'ListPublicKeys' 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', 'listPublicKeys_marker' - Use this when paginating results to indicate where to begin in your list
-- of public keys. The results include public keys in the list that occur
-- after the marker. To get the next page of results, set the @Marker@ to
-- the value of the @NextMarker@ from the current page\'s response (which
-- is also the ID of the last public key on that page).
--
-- 'maxItems', 'listPublicKeys_maxItems' - The maximum number of public keys you want in the response body.
newListPublicKeys ::
  ListPublicKeys
newListPublicKeys :: ListPublicKeys
newListPublicKeys =
  ListPublicKeys' :: Maybe Text -> Maybe Text -> ListPublicKeys
ListPublicKeys'
    { $sel:marker:ListPublicKeys' :: Maybe Text
marker = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxItems:ListPublicKeys' :: Maybe Text
maxItems = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Use this when paginating results to indicate where to begin in your list
-- of public keys. The results include public keys in the list that occur
-- after the marker. To get the next page of results, set the @Marker@ to
-- the value of the @NextMarker@ from the current page\'s response (which
-- is also the ID of the last public key on that page).
listPublicKeys_marker :: Lens.Lens' ListPublicKeys (Prelude.Maybe Prelude.Text)
listPublicKeys_marker :: (Maybe Text -> f (Maybe Text))
-> ListPublicKeys -> f ListPublicKeys
listPublicKeys_marker = (ListPublicKeys -> Maybe Text)
-> (ListPublicKeys -> Maybe Text -> ListPublicKeys)
-> Lens ListPublicKeys ListPublicKeys (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPublicKeys' {Maybe Text
marker :: Maybe Text
$sel:marker:ListPublicKeys' :: ListPublicKeys -> Maybe Text
marker} -> Maybe Text
marker) (\s :: ListPublicKeys
s@ListPublicKeys' {} Maybe Text
a -> ListPublicKeys
s {$sel:marker:ListPublicKeys' :: Maybe Text
marker = Maybe Text
a} :: ListPublicKeys)

-- | The maximum number of public keys you want in the response body.
listPublicKeys_maxItems :: Lens.Lens' ListPublicKeys (Prelude.Maybe Prelude.Text)
listPublicKeys_maxItems :: (Maybe Text -> f (Maybe Text))
-> ListPublicKeys -> f ListPublicKeys
listPublicKeys_maxItems = (ListPublicKeys -> Maybe Text)
-> (ListPublicKeys -> Maybe Text -> ListPublicKeys)
-> Lens ListPublicKeys ListPublicKeys (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPublicKeys' {Maybe Text
maxItems :: Maybe Text
$sel:maxItems:ListPublicKeys' :: ListPublicKeys -> Maybe Text
maxItems} -> Maybe Text
maxItems) (\s :: ListPublicKeys
s@ListPublicKeys' {} Maybe Text
a -> ListPublicKeys
s {$sel:maxItems:ListPublicKeys' :: Maybe Text
maxItems = Maybe Text
a} :: ListPublicKeys)

instance Core.AWSRequest ListPublicKeys where
  type
    AWSResponse ListPublicKeys =
      ListPublicKeysResponse
  request :: ListPublicKeys -> Request ListPublicKeys
request = Service -> ListPublicKeys -> Request ListPublicKeys
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy ListPublicKeys
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListPublicKeys)))
response =
    (Int
 -> ResponseHeaders
 -> [Node]
 -> Either String (AWSResponse ListPublicKeys))
-> Logger
-> Service
-> Proxy ListPublicKeys
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListPublicKeys)))
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 PublicKeyList -> Int -> ListPublicKeysResponse
ListPublicKeysResponse'
            (Maybe PublicKeyList -> Int -> ListPublicKeysResponse)
-> Either String (Maybe PublicKeyList)
-> Either String (Int -> ListPublicKeysResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node] -> Either String (Maybe PublicKeyList)
forall a. FromXML a => [Node] -> Either String a
Core.parseXML [Node]
x)
            Either String (Int -> ListPublicKeysResponse)
-> Either String Int -> Either String ListPublicKeysResponse
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 ListPublicKeys

instance Prelude.NFData ListPublicKeys

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

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

instance Core.ToQuery ListPublicKeys where
  toQuery :: ListPublicKeys -> QueryString
toQuery ListPublicKeys' {Maybe Text
maxItems :: Maybe Text
marker :: Maybe Text
$sel:maxItems:ListPublicKeys' :: ListPublicKeys -> Maybe Text
$sel:marker:ListPublicKeys' :: ListPublicKeys -> 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:/ 'newListPublicKeysResponse' smart constructor.
data ListPublicKeysResponse = ListPublicKeysResponse'
  { -- | Returns a list of all public keys that have been added to CloudFront for
    -- this account.
    ListPublicKeysResponse -> Maybe PublicKeyList
publicKeyList :: Prelude.Maybe PublicKeyList,
    -- | The response's http status code.
    ListPublicKeysResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (ListPublicKeysResponse -> ListPublicKeysResponse -> Bool
(ListPublicKeysResponse -> ListPublicKeysResponse -> Bool)
-> (ListPublicKeysResponse -> ListPublicKeysResponse -> Bool)
-> Eq ListPublicKeysResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ListPublicKeysResponse -> ListPublicKeysResponse -> Bool
$c/= :: ListPublicKeysResponse -> ListPublicKeysResponse -> Bool
== :: ListPublicKeysResponse -> ListPublicKeysResponse -> Bool
$c== :: ListPublicKeysResponse -> ListPublicKeysResponse -> Bool
Prelude.Eq, ReadPrec [ListPublicKeysResponse]
ReadPrec ListPublicKeysResponse
Int -> ReadS ListPublicKeysResponse
ReadS [ListPublicKeysResponse]
(Int -> ReadS ListPublicKeysResponse)
-> ReadS [ListPublicKeysResponse]
-> ReadPrec ListPublicKeysResponse
-> ReadPrec [ListPublicKeysResponse]
-> Read ListPublicKeysResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ListPublicKeysResponse]
$creadListPrec :: ReadPrec [ListPublicKeysResponse]
readPrec :: ReadPrec ListPublicKeysResponse
$creadPrec :: ReadPrec ListPublicKeysResponse
readList :: ReadS [ListPublicKeysResponse]
$creadList :: ReadS [ListPublicKeysResponse]
readsPrec :: Int -> ReadS ListPublicKeysResponse
$creadsPrec :: Int -> ReadS ListPublicKeysResponse
Prelude.Read, Int -> ListPublicKeysResponse -> ShowS
[ListPublicKeysResponse] -> ShowS
ListPublicKeysResponse -> String
(Int -> ListPublicKeysResponse -> ShowS)
-> (ListPublicKeysResponse -> String)
-> ([ListPublicKeysResponse] -> ShowS)
-> Show ListPublicKeysResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ListPublicKeysResponse] -> ShowS
$cshowList :: [ListPublicKeysResponse] -> ShowS
show :: ListPublicKeysResponse -> String
$cshow :: ListPublicKeysResponse -> String
showsPrec :: Int -> ListPublicKeysResponse -> ShowS
$cshowsPrec :: Int -> ListPublicKeysResponse -> ShowS
Prelude.Show, (forall x. ListPublicKeysResponse -> Rep ListPublicKeysResponse x)
-> (forall x.
    Rep ListPublicKeysResponse x -> ListPublicKeysResponse)
-> Generic ListPublicKeysResponse
forall x. Rep ListPublicKeysResponse x -> ListPublicKeysResponse
forall x. ListPublicKeysResponse -> Rep ListPublicKeysResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ListPublicKeysResponse x -> ListPublicKeysResponse
$cfrom :: forall x. ListPublicKeysResponse -> Rep ListPublicKeysResponse x
Prelude.Generic)

-- |
-- Create a value of 'ListPublicKeysResponse' 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:
--
-- 'publicKeyList', 'listPublicKeysResponse_publicKeyList' - Returns a list of all public keys that have been added to CloudFront for
-- this account.
--
-- 'httpStatus', 'listPublicKeysResponse_httpStatus' - The response's http status code.
newListPublicKeysResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  ListPublicKeysResponse
newListPublicKeysResponse :: Int -> ListPublicKeysResponse
newListPublicKeysResponse Int
pHttpStatus_ =
  ListPublicKeysResponse' :: Maybe PublicKeyList -> Int -> ListPublicKeysResponse
ListPublicKeysResponse'
    { $sel:publicKeyList:ListPublicKeysResponse' :: Maybe PublicKeyList
publicKeyList =
        Maybe PublicKeyList
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:ListPublicKeysResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Returns a list of all public keys that have been added to CloudFront for
-- this account.
listPublicKeysResponse_publicKeyList :: Lens.Lens' ListPublicKeysResponse (Prelude.Maybe PublicKeyList)
listPublicKeysResponse_publicKeyList :: (Maybe PublicKeyList -> f (Maybe PublicKeyList))
-> ListPublicKeysResponse -> f ListPublicKeysResponse
listPublicKeysResponse_publicKeyList = (ListPublicKeysResponse -> Maybe PublicKeyList)
-> (ListPublicKeysResponse
    -> Maybe PublicKeyList -> ListPublicKeysResponse)
-> Lens
     ListPublicKeysResponse
     ListPublicKeysResponse
     (Maybe PublicKeyList)
     (Maybe PublicKeyList)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ListPublicKeysResponse' {Maybe PublicKeyList
publicKeyList :: Maybe PublicKeyList
$sel:publicKeyList:ListPublicKeysResponse' :: ListPublicKeysResponse -> Maybe PublicKeyList
publicKeyList} -> Maybe PublicKeyList
publicKeyList) (\s :: ListPublicKeysResponse
s@ListPublicKeysResponse' {} Maybe PublicKeyList
a -> ListPublicKeysResponse
s {$sel:publicKeyList:ListPublicKeysResponse' :: Maybe PublicKeyList
publicKeyList = Maybe PublicKeyList
a} :: ListPublicKeysResponse)

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

instance Prelude.NFData ListPublicKeysResponse