{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.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:/ '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
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]
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
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. 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'
    { $sel:marker:ListPublicKeys' :: Maybe Text
marker = forall a. Maybe a
Prelude.Nothing,
      $sel:maxItems:ListPublicKeys' :: Maybe Text
maxItems = 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 :: Lens' ListPublicKeys (Maybe Text)
listPublicKeys_marker = 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 :: Lens' ListPublicKeys (Maybe Text)
listPublicKeys_maxItems = 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 :: (Service -> Service) -> ListPublicKeys -> Request ListPublicKeys
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 ListPublicKeys
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ListPublicKeys)))
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 PublicKeyList -> Int -> ListPublicKeysResponse
ListPublicKeysResponse'
            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 ListPublicKeys where
  hashWithSalt :: Int -> ListPublicKeys -> Int
hashWithSalt Int
_salt ListPublicKeys' {Maybe Text
maxItems :: Maybe Text
marker :: Maybe Text
$sel:maxItems:ListPublicKeys' :: ListPublicKeys -> Maybe Text
$sel:marker:ListPublicKeys' :: ListPublicKeys -> 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 ListPublicKeys where
  rnf :: ListPublicKeys -> ()
rnf ListPublicKeys' {Maybe Text
maxItems :: Maybe Text
marker :: Maybe Text
$sel:maxItems:ListPublicKeys' :: ListPublicKeys -> Maybe Text
$sel:marker:ListPublicKeys' :: ListPublicKeys -> 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 ListPublicKeys where
  toHeaders :: ListPublicKeys -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.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
..} =
    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:/ '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
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]
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
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. 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'
    { $sel:publicKeyList:ListPublicKeysResponse' :: Maybe PublicKeyList
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 :: Lens' ListPublicKeysResponse (Maybe PublicKeyList)
listPublicKeysResponse_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 :: Lens' ListPublicKeysResponse Int
listPublicKeysResponse_httpStatus = 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 where
  rnf :: ListPublicKeysResponse -> ()
rnf ListPublicKeysResponse' {Int
Maybe PublicKeyList
httpStatus :: Int
publicKeyList :: Maybe PublicKeyList
$sel:httpStatus:ListPublicKeysResponse' :: ListPublicKeysResponse -> Int
$sel:publicKeyList:ListPublicKeysResponse' :: ListPublicKeysResponse -> Maybe PublicKeyList
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe PublicKeyList
publicKeyList
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus