{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns detailed metadata about the specified ACM certificate.
--
-- If you have just created a certificate using the @RequestCertificate@
-- action, there is a delay of several seconds before you can retrieve
-- information about it.
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.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:/ '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
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]
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
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. 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'
    { $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 :: Lens' DescribeCertificate Text
describeCertificate_certificateArn = 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 :: (Service -> Service)
-> DescribeCertificate -> Request DescribeCertificate
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeCertificate)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe CertificateDetail -> Int -> DescribeCertificateResponse
DescribeCertificateResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Certificate")
            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 DescribeCertificate where
  hashWithSalt :: Int -> DescribeCertificate -> Int
hashWithSalt Int
_salt DescribeCertificate' {Text
certificateArn :: Text
$sel:certificateArn:DescribeCertificate' :: DescribeCertificate -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
certificateArn

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

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

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

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

instance Data.ToQuery DescribeCertificate where
  toQuery :: DescribeCertificate -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
    { $sel:certificate:DescribeCertificateResponse' :: Maybe CertificateDetail
certificate =
        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 :: Lens' DescribeCertificateResponse (Maybe CertificateDetail)
describeCertificateResponse_certificate = 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 :: Lens' DescribeCertificateResponse Int
describeCertificateResponse_httpStatus = 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 where
  rnf :: DescribeCertificateResponse -> ()
rnf DescribeCertificateResponse' {Int
Maybe CertificateDetail
httpStatus :: Int
certificate :: Maybe CertificateDetail
$sel:httpStatus:DescribeCertificateResponse' :: DescribeCertificateResponse -> Int
$sel:certificate:DescribeCertificateResponse' :: DescribeCertificateResponse -> Maybe CertificateDetail
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe CertificateDetail
certificate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus