{-# 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.CertificateManager.DescribeCertificate
-- 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)
--
-- Returns detailed metadata about the specified ACM certificate.
module Amazonka.CertificateManager.DescribeCertificate
  ( -- * Creating a Request
    DescribeCertificate (..),
    newDescribeCertificate,

    -- * Request Lenses
    describeCertificate_certificateArn,

    -- * Destructuring the Response
    DescribeCertificateResponse (..),
    newDescribeCertificateResponse,

    -- * Response Lenses
    describeCertificateResponse_certificate,
    describeCertificateResponse_httpStatus,
  )
where

import Amazonka.CertificateManager.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:/ 'newDescribeCertificate' smart constructor.
data DescribeCertificate = DescribeCertificate'
  { -- | The Amazon Resource Name (ARN) of the ACM certificate. The ARN must have
    -- the following form:
    --
    -- @arn:aws:acm:region:123456789012:certificate\/12345678-1234-1234-1234-123456789012@
    --
    -- For more information about ARNs, see
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>.
    DescribeCertificate -> Text
certificateArn :: Prelude.Text
  }
  deriving (DescribeCertificate -> DescribeCertificate -> Bool
(DescribeCertificate -> DescribeCertificate -> Bool)
-> (DescribeCertificate -> DescribeCertificate -> Bool)
-> Eq DescribeCertificate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeCertificate -> DescribeCertificate -> Bool
$c/= :: DescribeCertificate -> DescribeCertificate -> Bool
== :: DescribeCertificate -> DescribeCertificate -> Bool
$c== :: DescribeCertificate -> DescribeCertificate -> Bool
Prelude.Eq, ReadPrec [DescribeCertificate]
ReadPrec DescribeCertificate
Int -> ReadS DescribeCertificate
ReadS [DescribeCertificate]
(Int -> ReadS DescribeCertificate)
-> ReadS [DescribeCertificate]
-> ReadPrec DescribeCertificate
-> ReadPrec [DescribeCertificate]
-> Read DescribeCertificate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeCertificate]
$creadListPrec :: ReadPrec [DescribeCertificate]
readPrec :: ReadPrec DescribeCertificate
$creadPrec :: ReadPrec DescribeCertificate
readList :: ReadS [DescribeCertificate]
$creadList :: ReadS [DescribeCertificate]
readsPrec :: Int -> ReadS DescribeCertificate
$creadsPrec :: Int -> ReadS DescribeCertificate
Prelude.Read, Int -> DescribeCertificate -> ShowS
[DescribeCertificate] -> ShowS
DescribeCertificate -> String
(Int -> DescribeCertificate -> ShowS)
-> (DescribeCertificate -> String)
-> ([DescribeCertificate] -> ShowS)
-> Show DescribeCertificate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeCertificate] -> ShowS
$cshowList :: [DescribeCertificate] -> ShowS
show :: DescribeCertificate -> String
$cshow :: DescribeCertificate -> String
showsPrec :: Int -> DescribeCertificate -> ShowS
$cshowsPrec :: Int -> DescribeCertificate -> ShowS
Prelude.Show, (forall x. DescribeCertificate -> Rep DescribeCertificate x)
-> (forall x. Rep DescribeCertificate x -> DescribeCertificate)
-> Generic DescribeCertificate
forall x. Rep DescribeCertificate x -> DescribeCertificate
forall x. DescribeCertificate -> Rep DescribeCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeCertificate x -> DescribeCertificate
$cfrom :: forall x. DescribeCertificate -> Rep DescribeCertificate x
Prelude.Generic)

-- |
-- Create a value of 'DescribeCertificate' 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:
--
-- 'certificateArn', 'describeCertificate_certificateArn' - The Amazon Resource Name (ARN) of the ACM certificate. The ARN must have
-- the following form:
--
-- @arn:aws:acm:region:123456789012:certificate\/12345678-1234-1234-1234-123456789012@
--
-- For more information about ARNs, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>.
newDescribeCertificate ::
  -- | 'certificateArn'
  Prelude.Text ->
  DescribeCertificate
newDescribeCertificate :: Text -> DescribeCertificate
newDescribeCertificate Text
pCertificateArn_ =
  DescribeCertificate' :: Text -> DescribeCertificate
DescribeCertificate'
    { $sel:certificateArn:DescribeCertificate' :: Text
certificateArn =
        Text
pCertificateArn_
    }

-- | The Amazon Resource Name (ARN) of the ACM certificate. The ARN must have
-- the following form:
--
-- @arn:aws:acm:region:123456789012:certificate\/12345678-1234-1234-1234-123456789012@
--
-- For more information about ARNs, see
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon Resource Names (ARNs)>.
describeCertificate_certificateArn :: Lens.Lens' DescribeCertificate Prelude.Text
describeCertificate_certificateArn :: (Text -> f Text) -> DescribeCertificate -> f DescribeCertificate
describeCertificate_certificateArn = (DescribeCertificate -> Text)
-> (DescribeCertificate -> Text -> DescribeCertificate)
-> Lens DescribeCertificate DescribeCertificate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCertificate' {Text
certificateArn :: Text
$sel:certificateArn:DescribeCertificate' :: DescribeCertificate -> Text
certificateArn} -> Text
certificateArn) (\s :: DescribeCertificate
s@DescribeCertificate' {} Text
a -> DescribeCertificate
s {$sel:certificateArn:DescribeCertificate' :: Text
certificateArn = Text
a} :: DescribeCertificate)

instance Core.AWSRequest DescribeCertificate where
  type
    AWSResponse DescribeCertificate =
      DescribeCertificateResponse
  request :: DescribeCertificate -> Request DescribeCertificate
request = Service -> DescribeCertificate -> Request DescribeCertificate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeCertificate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeCertificate))
-> Logger
-> Service
-> Proxy DescribeCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeCertificate)))
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 ->
          Maybe CertificateDetail -> Int -> DescribeCertificateResponse
DescribeCertificateResponse'
            (Maybe CertificateDetail -> Int -> DescribeCertificateResponse)
-> Either String (Maybe CertificateDetail)
-> Either String (Int -> DescribeCertificateResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe CertificateDetail)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Certificate")
            Either String (Int -> DescribeCertificateResponse)
-> Either String Int -> Either String DescribeCertificateResponse
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 DescribeCertificate

instance Prelude.NFData DescribeCertificate

instance Core.ToHeaders DescribeCertificate where
  toHeaders :: DescribeCertificate -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeCertificate -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"CertificateManager.DescribeCertificate" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON DescribeCertificate where
  toJSON :: DescribeCertificate -> Value
toJSON DescribeCertificate' {Text
certificateArn :: Text
$sel:certificateArn:DescribeCertificate' :: DescribeCertificate -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"CertificateArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
certificateArn)
          ]
      )

instance Core.ToPath DescribeCertificate where
  toPath :: DescribeCertificate -> ByteString
toPath = ByteString -> DescribeCertificate -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newDescribeCertificateResponse' smart constructor.
data DescribeCertificateResponse = DescribeCertificateResponse'
  { -- | Metadata about an ACM certificate.
    DescribeCertificateResponse -> Maybe CertificateDetail
certificate :: Prelude.Maybe CertificateDetail,
    -- | The response's http status code.
    DescribeCertificateResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeCertificateResponse -> DescribeCertificateResponse -> Bool
(DescribeCertificateResponse
 -> DescribeCertificateResponse -> Bool)
-> (DescribeCertificateResponse
    -> DescribeCertificateResponse -> Bool)
-> Eq DescribeCertificateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeCertificateResponse -> DescribeCertificateResponse -> Bool
$c/= :: DescribeCertificateResponse -> DescribeCertificateResponse -> Bool
== :: DescribeCertificateResponse -> DescribeCertificateResponse -> Bool
$c== :: DescribeCertificateResponse -> DescribeCertificateResponse -> Bool
Prelude.Eq, ReadPrec [DescribeCertificateResponse]
ReadPrec DescribeCertificateResponse
Int -> ReadS DescribeCertificateResponse
ReadS [DescribeCertificateResponse]
(Int -> ReadS DescribeCertificateResponse)
-> ReadS [DescribeCertificateResponse]
-> ReadPrec DescribeCertificateResponse
-> ReadPrec [DescribeCertificateResponse]
-> Read DescribeCertificateResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeCertificateResponse]
$creadListPrec :: ReadPrec [DescribeCertificateResponse]
readPrec :: ReadPrec DescribeCertificateResponse
$creadPrec :: ReadPrec DescribeCertificateResponse
readList :: ReadS [DescribeCertificateResponse]
$creadList :: ReadS [DescribeCertificateResponse]
readsPrec :: Int -> ReadS DescribeCertificateResponse
$creadsPrec :: Int -> ReadS DescribeCertificateResponse
Prelude.Read, Int -> DescribeCertificateResponse -> ShowS
[DescribeCertificateResponse] -> ShowS
DescribeCertificateResponse -> String
(Int -> DescribeCertificateResponse -> ShowS)
-> (DescribeCertificateResponse -> String)
-> ([DescribeCertificateResponse] -> ShowS)
-> Show DescribeCertificateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeCertificateResponse] -> ShowS
$cshowList :: [DescribeCertificateResponse] -> ShowS
show :: DescribeCertificateResponse -> String
$cshow :: DescribeCertificateResponse -> String
showsPrec :: Int -> DescribeCertificateResponse -> ShowS
$cshowsPrec :: Int -> DescribeCertificateResponse -> ShowS
Prelude.Show, (forall x.
 DescribeCertificateResponse -> Rep DescribeCertificateResponse x)
-> (forall x.
    Rep DescribeCertificateResponse x -> DescribeCertificateResponse)
-> Generic DescribeCertificateResponse
forall x.
Rep DescribeCertificateResponse x -> DescribeCertificateResponse
forall x.
DescribeCertificateResponse -> Rep DescribeCertificateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeCertificateResponse x -> DescribeCertificateResponse
$cfrom :: forall x.
DescribeCertificateResponse -> Rep DescribeCertificateResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeCertificateResponse' 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:
--
-- 'certificate', 'describeCertificateResponse_certificate' - Metadata about an ACM certificate.
--
-- 'httpStatus', 'describeCertificateResponse_httpStatus' - The response's http status code.
newDescribeCertificateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeCertificateResponse
newDescribeCertificateResponse :: Int -> DescribeCertificateResponse
newDescribeCertificateResponse Int
pHttpStatus_ =
  DescribeCertificateResponse' :: Maybe CertificateDetail -> Int -> DescribeCertificateResponse
DescribeCertificateResponse'
    { $sel:certificate:DescribeCertificateResponse' :: Maybe CertificateDetail
certificate =
        Maybe CertificateDetail
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeCertificateResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Metadata about an ACM certificate.
describeCertificateResponse_certificate :: Lens.Lens' DescribeCertificateResponse (Prelude.Maybe CertificateDetail)
describeCertificateResponse_certificate :: (Maybe CertificateDetail -> f (Maybe CertificateDetail))
-> DescribeCertificateResponse -> f DescribeCertificateResponse
describeCertificateResponse_certificate = (DescribeCertificateResponse -> Maybe CertificateDetail)
-> (DescribeCertificateResponse
    -> Maybe CertificateDetail -> DescribeCertificateResponse)
-> Lens
     DescribeCertificateResponse
     DescribeCertificateResponse
     (Maybe CertificateDetail)
     (Maybe CertificateDetail)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeCertificateResponse' {Maybe CertificateDetail
certificate :: Maybe CertificateDetail
$sel:certificate:DescribeCertificateResponse' :: DescribeCertificateResponse -> Maybe CertificateDetail
certificate} -> Maybe CertificateDetail
certificate) (\s :: DescribeCertificateResponse
s@DescribeCertificateResponse' {} Maybe CertificateDetail
a -> DescribeCertificateResponse
s {$sel:certificate:DescribeCertificateResponse' :: Maybe CertificateDetail
certificate = Maybe CertificateDetail
a} :: DescribeCertificateResponse)

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

instance Prelude.NFData DescribeCertificateResponse