{-# 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.GetPublicKeyConfig
-- 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 public key configuration.
module Amazonka.CloudFront.GetPublicKeyConfig
  ( -- * Creating a Request
    GetPublicKeyConfig (..),
    newGetPublicKeyConfig,

    -- * Request Lenses
    getPublicKeyConfig_id,

    -- * Destructuring the Response
    GetPublicKeyConfigResponse (..),
    newGetPublicKeyConfigResponse,

    -- * Response Lenses
    getPublicKeyConfigResponse_eTag,
    getPublicKeyConfigResponse_publicKeyConfig,
    getPublicKeyConfigResponse_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:/ 'newGetPublicKeyConfig' smart constructor.
data GetPublicKeyConfig = GetPublicKeyConfig'
  { -- | The identifier of the public key whose configuration you are getting.
    GetPublicKeyConfig -> Text
id :: Prelude.Text
  }
  deriving (GetPublicKeyConfig -> GetPublicKeyConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPublicKeyConfig -> GetPublicKeyConfig -> Bool
$c/= :: GetPublicKeyConfig -> GetPublicKeyConfig -> Bool
== :: GetPublicKeyConfig -> GetPublicKeyConfig -> Bool
$c== :: GetPublicKeyConfig -> GetPublicKeyConfig -> Bool
Prelude.Eq, ReadPrec [GetPublicKeyConfig]
ReadPrec GetPublicKeyConfig
Int -> ReadS GetPublicKeyConfig
ReadS [GetPublicKeyConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetPublicKeyConfig]
$creadListPrec :: ReadPrec [GetPublicKeyConfig]
readPrec :: ReadPrec GetPublicKeyConfig
$creadPrec :: ReadPrec GetPublicKeyConfig
readList :: ReadS [GetPublicKeyConfig]
$creadList :: ReadS [GetPublicKeyConfig]
readsPrec :: Int -> ReadS GetPublicKeyConfig
$creadsPrec :: Int -> ReadS GetPublicKeyConfig
Prelude.Read, Int -> GetPublicKeyConfig -> ShowS
[GetPublicKeyConfig] -> ShowS
GetPublicKeyConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPublicKeyConfig] -> ShowS
$cshowList :: [GetPublicKeyConfig] -> ShowS
show :: GetPublicKeyConfig -> String
$cshow :: GetPublicKeyConfig -> String
showsPrec :: Int -> GetPublicKeyConfig -> ShowS
$cshowsPrec :: Int -> GetPublicKeyConfig -> ShowS
Prelude.Show, forall x. Rep GetPublicKeyConfig x -> GetPublicKeyConfig
forall x. GetPublicKeyConfig -> Rep GetPublicKeyConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetPublicKeyConfig x -> GetPublicKeyConfig
$cfrom :: forall x. GetPublicKeyConfig -> Rep GetPublicKeyConfig x
Prelude.Generic)

-- |
-- Create a value of 'GetPublicKeyConfig' 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:
--
-- 'id', 'getPublicKeyConfig_id' - The identifier of the public key whose configuration you are getting.
newGetPublicKeyConfig ::
  -- | 'id'
  Prelude.Text ->
  GetPublicKeyConfig
newGetPublicKeyConfig :: Text -> GetPublicKeyConfig
newGetPublicKeyConfig Text
pId_ =
  GetPublicKeyConfig' {$sel:id:GetPublicKeyConfig' :: Text
id = Text
pId_}

-- | The identifier of the public key whose configuration you are getting.
getPublicKeyConfig_id :: Lens.Lens' GetPublicKeyConfig Prelude.Text
getPublicKeyConfig_id :: Lens' GetPublicKeyConfig Text
getPublicKeyConfig_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPublicKeyConfig' {Text
id :: Text
$sel:id:GetPublicKeyConfig' :: GetPublicKeyConfig -> Text
id} -> Text
id) (\s :: GetPublicKeyConfig
s@GetPublicKeyConfig' {} Text
a -> GetPublicKeyConfig
s {$sel:id:GetPublicKeyConfig' :: Text
id = Text
a} :: GetPublicKeyConfig)

instance Core.AWSRequest GetPublicKeyConfig where
  type
    AWSResponse GetPublicKeyConfig =
      GetPublicKeyConfigResponse
  request :: (Service -> Service)
-> GetPublicKeyConfig -> Request GetPublicKeyConfig
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 GetPublicKeyConfig
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetPublicKeyConfig)))
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 Text
-> Maybe PublicKeyConfig -> Int -> GetPublicKeyConfigResponse
GetPublicKeyConfigResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (ResponseHeaders
h forall a.
FromText a =>
ResponseHeaders -> HeaderName -> Either String (Maybe a)
Data..#? HeaderName
"ETag")
            forall (f :: * -> *) a b. Applicative f => 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 GetPublicKeyConfig where
  hashWithSalt :: Int -> GetPublicKeyConfig -> Int
hashWithSalt Int
_salt GetPublicKeyConfig' {Text
id :: Text
$sel:id:GetPublicKeyConfig' :: GetPublicKeyConfig -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

instance Prelude.NFData GetPublicKeyConfig where
  rnf :: GetPublicKeyConfig -> ()
rnf GetPublicKeyConfig' {Text
id :: Text
$sel:id:GetPublicKeyConfig' :: GetPublicKeyConfig -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
id

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

instance Data.ToPath GetPublicKeyConfig where
  toPath :: GetPublicKeyConfig -> ByteString
toPath GetPublicKeyConfig' {Text
id :: Text
$sel:id:GetPublicKeyConfig' :: GetPublicKeyConfig -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/2020-05-31/public-key/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
id, ByteString
"/config"]

instance Data.ToQuery GetPublicKeyConfig where
  toQuery :: GetPublicKeyConfig -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newGetPublicKeyConfigResponse' smart constructor.
data GetPublicKeyConfigResponse = GetPublicKeyConfigResponse'
  { -- | The identifier for this version of the public key configuration.
    GetPublicKeyConfigResponse -> Maybe Text
eTag :: Prelude.Maybe Prelude.Text,
    -- | A public key configuration.
    GetPublicKeyConfigResponse -> Maybe PublicKeyConfig
publicKeyConfig :: Prelude.Maybe PublicKeyConfig,
    -- | The response's http status code.
    GetPublicKeyConfigResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetPublicKeyConfigResponse -> GetPublicKeyConfigResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetPublicKeyConfigResponse -> GetPublicKeyConfigResponse -> Bool
$c/= :: GetPublicKeyConfigResponse -> GetPublicKeyConfigResponse -> Bool
== :: GetPublicKeyConfigResponse -> GetPublicKeyConfigResponse -> Bool
$c== :: GetPublicKeyConfigResponse -> GetPublicKeyConfigResponse -> Bool
Prelude.Eq, ReadPrec [GetPublicKeyConfigResponse]
ReadPrec GetPublicKeyConfigResponse
Int -> ReadS GetPublicKeyConfigResponse
ReadS [GetPublicKeyConfigResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetPublicKeyConfigResponse]
$creadListPrec :: ReadPrec [GetPublicKeyConfigResponse]
readPrec :: ReadPrec GetPublicKeyConfigResponse
$creadPrec :: ReadPrec GetPublicKeyConfigResponse
readList :: ReadS [GetPublicKeyConfigResponse]
$creadList :: ReadS [GetPublicKeyConfigResponse]
readsPrec :: Int -> ReadS GetPublicKeyConfigResponse
$creadsPrec :: Int -> ReadS GetPublicKeyConfigResponse
Prelude.Read, Int -> GetPublicKeyConfigResponse -> ShowS
[GetPublicKeyConfigResponse] -> ShowS
GetPublicKeyConfigResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetPublicKeyConfigResponse] -> ShowS
$cshowList :: [GetPublicKeyConfigResponse] -> ShowS
show :: GetPublicKeyConfigResponse -> String
$cshow :: GetPublicKeyConfigResponse -> String
showsPrec :: Int -> GetPublicKeyConfigResponse -> ShowS
$cshowsPrec :: Int -> GetPublicKeyConfigResponse -> ShowS
Prelude.Show, forall x.
Rep GetPublicKeyConfigResponse x -> GetPublicKeyConfigResponse
forall x.
GetPublicKeyConfigResponse -> Rep GetPublicKeyConfigResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetPublicKeyConfigResponse x -> GetPublicKeyConfigResponse
$cfrom :: forall x.
GetPublicKeyConfigResponse -> Rep GetPublicKeyConfigResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetPublicKeyConfigResponse' 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:
--
-- 'eTag', 'getPublicKeyConfigResponse_eTag' - The identifier for this version of the public key configuration.
--
-- 'publicKeyConfig', 'getPublicKeyConfigResponse_publicKeyConfig' - A public key configuration.
--
-- 'httpStatus', 'getPublicKeyConfigResponse_httpStatus' - The response's http status code.
newGetPublicKeyConfigResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetPublicKeyConfigResponse
newGetPublicKeyConfigResponse :: Int -> GetPublicKeyConfigResponse
newGetPublicKeyConfigResponse Int
pHttpStatus_ =
  GetPublicKeyConfigResponse'
    { $sel:eTag:GetPublicKeyConfigResponse' :: Maybe Text
eTag = forall a. Maybe a
Prelude.Nothing,
      $sel:publicKeyConfig:GetPublicKeyConfigResponse' :: Maybe PublicKeyConfig
publicKeyConfig = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetPublicKeyConfigResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The identifier for this version of the public key configuration.
getPublicKeyConfigResponse_eTag :: Lens.Lens' GetPublicKeyConfigResponse (Prelude.Maybe Prelude.Text)
getPublicKeyConfigResponse_eTag :: Lens' GetPublicKeyConfigResponse (Maybe Text)
getPublicKeyConfigResponse_eTag = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPublicKeyConfigResponse' {Maybe Text
eTag :: Maybe Text
$sel:eTag:GetPublicKeyConfigResponse' :: GetPublicKeyConfigResponse -> Maybe Text
eTag} -> Maybe Text
eTag) (\s :: GetPublicKeyConfigResponse
s@GetPublicKeyConfigResponse' {} Maybe Text
a -> GetPublicKeyConfigResponse
s {$sel:eTag:GetPublicKeyConfigResponse' :: Maybe Text
eTag = Maybe Text
a} :: GetPublicKeyConfigResponse)

-- | A public key configuration.
getPublicKeyConfigResponse_publicKeyConfig :: Lens.Lens' GetPublicKeyConfigResponse (Prelude.Maybe PublicKeyConfig)
getPublicKeyConfigResponse_publicKeyConfig :: Lens' GetPublicKeyConfigResponse (Maybe PublicKeyConfig)
getPublicKeyConfigResponse_publicKeyConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetPublicKeyConfigResponse' {Maybe PublicKeyConfig
publicKeyConfig :: Maybe PublicKeyConfig
$sel:publicKeyConfig:GetPublicKeyConfigResponse' :: GetPublicKeyConfigResponse -> Maybe PublicKeyConfig
publicKeyConfig} -> Maybe PublicKeyConfig
publicKeyConfig) (\s :: GetPublicKeyConfigResponse
s@GetPublicKeyConfigResponse' {} Maybe PublicKeyConfig
a -> GetPublicKeyConfigResponse
s {$sel:publicKeyConfig:GetPublicKeyConfigResponse' :: Maybe PublicKeyConfig
publicKeyConfig = Maybe PublicKeyConfig
a} :: GetPublicKeyConfigResponse)

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

instance Prelude.NFData GetPublicKeyConfigResponse where
  rnf :: GetPublicKeyConfigResponse -> ()
rnf GetPublicKeyConfigResponse' {Int
Maybe Text
Maybe PublicKeyConfig
httpStatus :: Int
publicKeyConfig :: Maybe PublicKeyConfig
eTag :: Maybe Text
$sel:httpStatus:GetPublicKeyConfigResponse' :: GetPublicKeyConfigResponse -> Int
$sel:publicKeyConfig:GetPublicKeyConfigResponse' :: GetPublicKeyConfigResponse -> Maybe PublicKeyConfig
$sel:eTag:GetPublicKeyConfigResponse' :: GetPublicKeyConfigResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
eTag
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe PublicKeyConfig
publicKeyConfig
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus