{-# 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.RenewCertificate
-- 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)
--
-- Renews an eligible ACM certificate. At this time, only exported private
-- certificates can be renewed with this operation. In order to renew your
-- ACM PCA certificates with ACM, you must first
-- <https://docs.aws.amazon.com/acm-pca/latest/userguide/PcaPermissions.html grant the ACM service principal permission to do so>.
-- For more information, see
-- <https://docs.aws.amazon.com/acm/latest/userguide/manual-renewal.html Testing Managed Renewal>
-- in the ACM User Guide.
module Amazonka.CertificateManager.RenewCertificate
  ( -- * Creating a Request
    RenewCertificate (..),
    newRenewCertificate,

    -- * Request Lenses
    renewCertificate_certificateArn,

    -- * Destructuring the Response
    RenewCertificateResponse (..),
    newRenewCertificateResponse,
  )
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:/ 'newRenewCertificate' smart constructor.
data RenewCertificate = RenewCertificate'
  { -- | String that contains the ARN of the ACM certificate to be renewed. This
    -- must be of the 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)>.
    RenewCertificate -> Text
certificateArn :: Prelude.Text
  }
  deriving (RenewCertificate -> RenewCertificate -> Bool
(RenewCertificate -> RenewCertificate -> Bool)
-> (RenewCertificate -> RenewCertificate -> Bool)
-> Eq RenewCertificate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RenewCertificate -> RenewCertificate -> Bool
$c/= :: RenewCertificate -> RenewCertificate -> Bool
== :: RenewCertificate -> RenewCertificate -> Bool
$c== :: RenewCertificate -> RenewCertificate -> Bool
Prelude.Eq, ReadPrec [RenewCertificate]
ReadPrec RenewCertificate
Int -> ReadS RenewCertificate
ReadS [RenewCertificate]
(Int -> ReadS RenewCertificate)
-> ReadS [RenewCertificate]
-> ReadPrec RenewCertificate
-> ReadPrec [RenewCertificate]
-> Read RenewCertificate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RenewCertificate]
$creadListPrec :: ReadPrec [RenewCertificate]
readPrec :: ReadPrec RenewCertificate
$creadPrec :: ReadPrec RenewCertificate
readList :: ReadS [RenewCertificate]
$creadList :: ReadS [RenewCertificate]
readsPrec :: Int -> ReadS RenewCertificate
$creadsPrec :: Int -> ReadS RenewCertificate
Prelude.Read, Int -> RenewCertificate -> ShowS
[RenewCertificate] -> ShowS
RenewCertificate -> String
(Int -> RenewCertificate -> ShowS)
-> (RenewCertificate -> String)
-> ([RenewCertificate] -> ShowS)
-> Show RenewCertificate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RenewCertificate] -> ShowS
$cshowList :: [RenewCertificate] -> ShowS
show :: RenewCertificate -> String
$cshow :: RenewCertificate -> String
showsPrec :: Int -> RenewCertificate -> ShowS
$cshowsPrec :: Int -> RenewCertificate -> ShowS
Prelude.Show, (forall x. RenewCertificate -> Rep RenewCertificate x)
-> (forall x. Rep RenewCertificate x -> RenewCertificate)
-> Generic RenewCertificate
forall x. Rep RenewCertificate x -> RenewCertificate
forall x. RenewCertificate -> Rep RenewCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RenewCertificate x -> RenewCertificate
$cfrom :: forall x. RenewCertificate -> Rep RenewCertificate x
Prelude.Generic)

-- |
-- Create a value of 'RenewCertificate' 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', 'renewCertificate_certificateArn' - String that contains the ARN of the ACM certificate to be renewed. This
-- must be of the 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)>.
newRenewCertificate ::
  -- | 'certificateArn'
  Prelude.Text ->
  RenewCertificate
newRenewCertificate :: Text -> RenewCertificate
newRenewCertificate Text
pCertificateArn_ =
  RenewCertificate' :: Text -> RenewCertificate
RenewCertificate'
    { $sel:certificateArn:RenewCertificate' :: Text
certificateArn =
        Text
pCertificateArn_
    }

-- | String that contains the ARN of the ACM certificate to be renewed. This
-- must be of the 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)>.
renewCertificate_certificateArn :: Lens.Lens' RenewCertificate Prelude.Text
renewCertificate_certificateArn :: (Text -> f Text) -> RenewCertificate -> f RenewCertificate
renewCertificate_certificateArn = (RenewCertificate -> Text)
-> (RenewCertificate -> Text -> RenewCertificate)
-> Lens RenewCertificate RenewCertificate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RenewCertificate' {Text
certificateArn :: Text
$sel:certificateArn:RenewCertificate' :: RenewCertificate -> Text
certificateArn} -> Text
certificateArn) (\s :: RenewCertificate
s@RenewCertificate' {} Text
a -> RenewCertificate
s {$sel:certificateArn:RenewCertificate' :: Text
certificateArn = Text
a} :: RenewCertificate)

instance Core.AWSRequest RenewCertificate where
  type
    AWSResponse RenewCertificate =
      RenewCertificateResponse
  request :: RenewCertificate -> Request RenewCertificate
request = Service -> RenewCertificate -> Request RenewCertificate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RenewCertificate
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RenewCertificate)))
response =
    AWSResponse RenewCertificate
-> Logger
-> Service
-> Proxy RenewCertificate
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RenewCertificate)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse RenewCertificate
RenewCertificateResponse
RenewCertificateResponse'

instance Prelude.Hashable RenewCertificate

instance Prelude.NFData RenewCertificate

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

instance Core.ToJSON RenewCertificate where
  toJSON :: RenewCertificate -> Value
toJSON RenewCertificate' {Text
certificateArn :: Text
$sel:certificateArn:RenewCertificate' :: RenewCertificate -> 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 RenewCertificate where
  toPath :: RenewCertificate -> ByteString
toPath = ByteString -> RenewCertificate -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newRenewCertificateResponse' smart constructor.
data RenewCertificateResponse = RenewCertificateResponse'
  {
  }
  deriving (RenewCertificateResponse -> RenewCertificateResponse -> Bool
(RenewCertificateResponse -> RenewCertificateResponse -> Bool)
-> (RenewCertificateResponse -> RenewCertificateResponse -> Bool)
-> Eq RenewCertificateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RenewCertificateResponse -> RenewCertificateResponse -> Bool
$c/= :: RenewCertificateResponse -> RenewCertificateResponse -> Bool
== :: RenewCertificateResponse -> RenewCertificateResponse -> Bool
$c== :: RenewCertificateResponse -> RenewCertificateResponse -> Bool
Prelude.Eq, ReadPrec [RenewCertificateResponse]
ReadPrec RenewCertificateResponse
Int -> ReadS RenewCertificateResponse
ReadS [RenewCertificateResponse]
(Int -> ReadS RenewCertificateResponse)
-> ReadS [RenewCertificateResponse]
-> ReadPrec RenewCertificateResponse
-> ReadPrec [RenewCertificateResponse]
-> Read RenewCertificateResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RenewCertificateResponse]
$creadListPrec :: ReadPrec [RenewCertificateResponse]
readPrec :: ReadPrec RenewCertificateResponse
$creadPrec :: ReadPrec RenewCertificateResponse
readList :: ReadS [RenewCertificateResponse]
$creadList :: ReadS [RenewCertificateResponse]
readsPrec :: Int -> ReadS RenewCertificateResponse
$creadsPrec :: Int -> ReadS RenewCertificateResponse
Prelude.Read, Int -> RenewCertificateResponse -> ShowS
[RenewCertificateResponse] -> ShowS
RenewCertificateResponse -> String
(Int -> RenewCertificateResponse -> ShowS)
-> (RenewCertificateResponse -> String)
-> ([RenewCertificateResponse] -> ShowS)
-> Show RenewCertificateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RenewCertificateResponse] -> ShowS
$cshowList :: [RenewCertificateResponse] -> ShowS
show :: RenewCertificateResponse -> String
$cshow :: RenewCertificateResponse -> String
showsPrec :: Int -> RenewCertificateResponse -> ShowS
$cshowsPrec :: Int -> RenewCertificateResponse -> ShowS
Prelude.Show, (forall x.
 RenewCertificateResponse -> Rep RenewCertificateResponse x)
-> (forall x.
    Rep RenewCertificateResponse x -> RenewCertificateResponse)
-> Generic RenewCertificateResponse
forall x.
Rep RenewCertificateResponse x -> RenewCertificateResponse
forall x.
RenewCertificateResponse -> Rep RenewCertificateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RenewCertificateResponse x -> RenewCertificateResponse
$cfrom :: forall x.
RenewCertificateResponse -> Rep RenewCertificateResponse x
Prelude.Generic)

-- |
-- Create a value of 'RenewCertificateResponse' 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.
newRenewCertificateResponse ::
  RenewCertificateResponse
newRenewCertificateResponse :: RenewCertificateResponse
newRenewCertificateResponse =
  RenewCertificateResponse
RenewCertificateResponse'

instance Prelude.NFData RenewCertificateResponse