{-# 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.APIGateway.GetClientCertificate
-- 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 information about the current ClientCertificate resource.
module Amazonka.APIGateway.GetClientCertificate
  ( -- * Creating a Request
    GetClientCertificate (..),
    newGetClientCertificate,

    -- * Request Lenses
    getClientCertificate_clientCertificateId,

    -- * Destructuring the Response
    ClientCertificate (..),
    newClientCertificate,

    -- * Response Lenses
    clientCertificate_pemEncodedCertificate,
    clientCertificate_clientCertificateId,
    clientCertificate_createdDate,
    clientCertificate_expirationDate,
    clientCertificate_description,
    clientCertificate_tags,
  )
where

import Amazonka.APIGateway.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

-- | A request to get information about the current ClientCertificate
-- resource.
--
-- /See:/ 'newGetClientCertificate' smart constructor.
data GetClientCertificate = GetClientCertificate'
  { -- | [Required] The identifier of the ClientCertificate resource to be
    -- described.
    GetClientCertificate -> Text
clientCertificateId :: Prelude.Text
  }
  deriving (GetClientCertificate -> GetClientCertificate -> Bool
(GetClientCertificate -> GetClientCertificate -> Bool)
-> (GetClientCertificate -> GetClientCertificate -> Bool)
-> Eq GetClientCertificate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetClientCertificate -> GetClientCertificate -> Bool
$c/= :: GetClientCertificate -> GetClientCertificate -> Bool
== :: GetClientCertificate -> GetClientCertificate -> Bool
$c== :: GetClientCertificate -> GetClientCertificate -> Bool
Prelude.Eq, ReadPrec [GetClientCertificate]
ReadPrec GetClientCertificate
Int -> ReadS GetClientCertificate
ReadS [GetClientCertificate]
(Int -> ReadS GetClientCertificate)
-> ReadS [GetClientCertificate]
-> ReadPrec GetClientCertificate
-> ReadPrec [GetClientCertificate]
-> Read GetClientCertificate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetClientCertificate]
$creadListPrec :: ReadPrec [GetClientCertificate]
readPrec :: ReadPrec GetClientCertificate
$creadPrec :: ReadPrec GetClientCertificate
readList :: ReadS [GetClientCertificate]
$creadList :: ReadS [GetClientCertificate]
readsPrec :: Int -> ReadS GetClientCertificate
$creadsPrec :: Int -> ReadS GetClientCertificate
Prelude.Read, Int -> GetClientCertificate -> ShowS
[GetClientCertificate] -> ShowS
GetClientCertificate -> String
(Int -> GetClientCertificate -> ShowS)
-> (GetClientCertificate -> String)
-> ([GetClientCertificate] -> ShowS)
-> Show GetClientCertificate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetClientCertificate] -> ShowS
$cshowList :: [GetClientCertificate] -> ShowS
show :: GetClientCertificate -> String
$cshow :: GetClientCertificate -> String
showsPrec :: Int -> GetClientCertificate -> ShowS
$cshowsPrec :: Int -> GetClientCertificate -> ShowS
Prelude.Show, (forall x. GetClientCertificate -> Rep GetClientCertificate x)
-> (forall x. Rep GetClientCertificate x -> GetClientCertificate)
-> Generic GetClientCertificate
forall x. Rep GetClientCertificate x -> GetClientCertificate
forall x. GetClientCertificate -> Rep GetClientCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetClientCertificate x -> GetClientCertificate
$cfrom :: forall x. GetClientCertificate -> Rep GetClientCertificate x
Prelude.Generic)

-- |
-- Create a value of 'GetClientCertificate' 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:
--
-- 'clientCertificateId', 'getClientCertificate_clientCertificateId' - [Required] The identifier of the ClientCertificate resource to be
-- described.
newGetClientCertificate ::
  -- | 'clientCertificateId'
  Prelude.Text ->
  GetClientCertificate
newGetClientCertificate :: Text -> GetClientCertificate
newGetClientCertificate Text
pClientCertificateId_ =
  GetClientCertificate' :: Text -> GetClientCertificate
GetClientCertificate'
    { $sel:clientCertificateId:GetClientCertificate' :: Text
clientCertificateId =
        Text
pClientCertificateId_
    }

-- | [Required] The identifier of the ClientCertificate resource to be
-- described.
getClientCertificate_clientCertificateId :: Lens.Lens' GetClientCertificate Prelude.Text
getClientCertificate_clientCertificateId :: (Text -> f Text) -> GetClientCertificate -> f GetClientCertificate
getClientCertificate_clientCertificateId = (GetClientCertificate -> Text)
-> (GetClientCertificate -> Text -> GetClientCertificate)
-> Lens GetClientCertificate GetClientCertificate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetClientCertificate' {Text
clientCertificateId :: Text
$sel:clientCertificateId:GetClientCertificate' :: GetClientCertificate -> Text
clientCertificateId} -> Text
clientCertificateId) (\s :: GetClientCertificate
s@GetClientCertificate' {} Text
a -> GetClientCertificate
s {$sel:clientCertificateId:GetClientCertificate' :: Text
clientCertificateId = Text
a} :: GetClientCertificate)

instance Core.AWSRequest GetClientCertificate where
  type
    AWSResponse GetClientCertificate =
      ClientCertificate
  request :: GetClientCertificate -> Request GetClientCertificate
request = Service -> GetClientCertificate -> Request GetClientCertificate
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetClientCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetClientCertificate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetClientCertificate))
-> Logger
-> Service
-> Proxy GetClientCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetClientCertificate)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> Object -> Either String ClientCertificate
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable GetClientCertificate

instance Prelude.NFData GetClientCertificate

instance Core.ToHeaders GetClientCertificate where
  toHeaders :: GetClientCertificate -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetClientCertificate -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Accept"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"application/json" :: Prelude.ByteString)
          ]
      )

instance Core.ToPath GetClientCertificate where
  toPath :: GetClientCertificate -> ByteString
toPath GetClientCertificate' {Text
clientCertificateId :: Text
$sel:clientCertificateId:GetClientCertificate' :: GetClientCertificate -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/clientcertificates/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
clientCertificateId
      ]

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