{-# 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.CertificateManagerPCA.UpdateCertificateAuthority
-- 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)
--
-- Updates the status or configuration of a private certificate authority
-- (CA). Your private CA must be in the @ACTIVE@ or @DISABLED@ state before
-- you can update it. You can disable a private CA that is in the @ACTIVE@
-- state or make a CA that is in the @DISABLED@ state active again.
--
-- Both PCA and the IAM principal must have permission to write to the S3
-- bucket that you specify. If the IAM principal making the call does not
-- have permission to write to the bucket, then an exception is thrown. For
-- more information, see
-- <https://docs.aws.amazon.com/acm-pca/latest/userguide/PcaAuthAccess.html Configure Access to ACM Private CA>.
module Amazonka.CertificateManagerPCA.UpdateCertificateAuthority
  ( -- * Creating a Request
    UpdateCertificateAuthority (..),
    newUpdateCertificateAuthority,

    -- * Request Lenses
    updateCertificateAuthority_status,
    updateCertificateAuthority_revocationConfiguration,
    updateCertificateAuthority_certificateAuthorityArn,

    -- * Destructuring the Response
    UpdateCertificateAuthorityResponse (..),
    newUpdateCertificateAuthorityResponse,
  )
where

import Amazonka.CertificateManagerPCA.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:/ 'newUpdateCertificateAuthority' smart constructor.
data UpdateCertificateAuthority = UpdateCertificateAuthority'
  { -- | Status of your private CA.
    UpdateCertificateAuthority -> Maybe CertificateAuthorityStatus
status :: Prelude.Maybe CertificateAuthorityStatus,
    -- | Contains information to enable Online Certificate Status Protocol (OCSP)
    -- support, to enable a certificate revocation list (CRL), to enable both,
    -- or to enable neither. If this parameter is not supplied, existing
    -- capibilites remain unchanged. For more information, see the
    -- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_OcspConfiguration.html OcspConfiguration>
    -- and
    -- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_CrlConfiguration.html CrlConfiguration>
    -- types.
    UpdateCertificateAuthority -> Maybe RevocationConfiguration
revocationConfiguration :: Prelude.Maybe RevocationConfiguration,
    -- | Amazon Resource Name (ARN) of the private CA that issued the certificate
    -- to be revoked. This must be of the form:
    --
    -- @arn:aws:acm-pca:region:account:certificate-authority\/12345678-1234-1234-1234-123456789012 @
    UpdateCertificateAuthority -> Text
certificateAuthorityArn :: Prelude.Text
  }
  deriving (UpdateCertificateAuthority -> UpdateCertificateAuthority -> Bool
(UpdateCertificateAuthority -> UpdateCertificateAuthority -> Bool)
-> (UpdateCertificateAuthority
    -> UpdateCertificateAuthority -> Bool)
-> Eq UpdateCertificateAuthority
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateCertificateAuthority -> UpdateCertificateAuthority -> Bool
$c/= :: UpdateCertificateAuthority -> UpdateCertificateAuthority -> Bool
== :: UpdateCertificateAuthority -> UpdateCertificateAuthority -> Bool
$c== :: UpdateCertificateAuthority -> UpdateCertificateAuthority -> Bool
Prelude.Eq, ReadPrec [UpdateCertificateAuthority]
ReadPrec UpdateCertificateAuthority
Int -> ReadS UpdateCertificateAuthority
ReadS [UpdateCertificateAuthority]
(Int -> ReadS UpdateCertificateAuthority)
-> ReadS [UpdateCertificateAuthority]
-> ReadPrec UpdateCertificateAuthority
-> ReadPrec [UpdateCertificateAuthority]
-> Read UpdateCertificateAuthority
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateCertificateAuthority]
$creadListPrec :: ReadPrec [UpdateCertificateAuthority]
readPrec :: ReadPrec UpdateCertificateAuthority
$creadPrec :: ReadPrec UpdateCertificateAuthority
readList :: ReadS [UpdateCertificateAuthority]
$creadList :: ReadS [UpdateCertificateAuthority]
readsPrec :: Int -> ReadS UpdateCertificateAuthority
$creadsPrec :: Int -> ReadS UpdateCertificateAuthority
Prelude.Read, Int -> UpdateCertificateAuthority -> ShowS
[UpdateCertificateAuthority] -> ShowS
UpdateCertificateAuthority -> String
(Int -> UpdateCertificateAuthority -> ShowS)
-> (UpdateCertificateAuthority -> String)
-> ([UpdateCertificateAuthority] -> ShowS)
-> Show UpdateCertificateAuthority
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateCertificateAuthority] -> ShowS
$cshowList :: [UpdateCertificateAuthority] -> ShowS
show :: UpdateCertificateAuthority -> String
$cshow :: UpdateCertificateAuthority -> String
showsPrec :: Int -> UpdateCertificateAuthority -> ShowS
$cshowsPrec :: Int -> UpdateCertificateAuthority -> ShowS
Prelude.Show, (forall x.
 UpdateCertificateAuthority -> Rep UpdateCertificateAuthority x)
-> (forall x.
    Rep UpdateCertificateAuthority x -> UpdateCertificateAuthority)
-> Generic UpdateCertificateAuthority
forall x.
Rep UpdateCertificateAuthority x -> UpdateCertificateAuthority
forall x.
UpdateCertificateAuthority -> Rep UpdateCertificateAuthority x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateCertificateAuthority x -> UpdateCertificateAuthority
$cfrom :: forall x.
UpdateCertificateAuthority -> Rep UpdateCertificateAuthority x
Prelude.Generic)

-- |
-- Create a value of 'UpdateCertificateAuthority' 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:
--
-- 'status', 'updateCertificateAuthority_status' - Status of your private CA.
--
-- 'revocationConfiguration', 'updateCertificateAuthority_revocationConfiguration' - Contains information to enable Online Certificate Status Protocol (OCSP)
-- support, to enable a certificate revocation list (CRL), to enable both,
-- or to enable neither. If this parameter is not supplied, existing
-- capibilites remain unchanged. For more information, see the
-- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_OcspConfiguration.html OcspConfiguration>
-- and
-- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_CrlConfiguration.html CrlConfiguration>
-- types.
--
-- 'certificateAuthorityArn', 'updateCertificateAuthority_certificateAuthorityArn' - Amazon Resource Name (ARN) of the private CA that issued the certificate
-- to be revoked. This must be of the form:
--
-- @arn:aws:acm-pca:region:account:certificate-authority\/12345678-1234-1234-1234-123456789012 @
newUpdateCertificateAuthority ::
  -- | 'certificateAuthorityArn'
  Prelude.Text ->
  UpdateCertificateAuthority
newUpdateCertificateAuthority :: Text -> UpdateCertificateAuthority
newUpdateCertificateAuthority
  Text
pCertificateAuthorityArn_ =
    UpdateCertificateAuthority' :: Maybe CertificateAuthorityStatus
-> Maybe RevocationConfiguration
-> Text
-> UpdateCertificateAuthority
UpdateCertificateAuthority'
      { $sel:status:UpdateCertificateAuthority' :: Maybe CertificateAuthorityStatus
status =
          Maybe CertificateAuthorityStatus
forall a. Maybe a
Prelude.Nothing,
        $sel:revocationConfiguration:UpdateCertificateAuthority' :: Maybe RevocationConfiguration
revocationConfiguration = Maybe RevocationConfiguration
forall a. Maybe a
Prelude.Nothing,
        $sel:certificateAuthorityArn:UpdateCertificateAuthority' :: Text
certificateAuthorityArn =
          Text
pCertificateAuthorityArn_
      }

-- | Status of your private CA.
updateCertificateAuthority_status :: Lens.Lens' UpdateCertificateAuthority (Prelude.Maybe CertificateAuthorityStatus)
updateCertificateAuthority_status :: (Maybe CertificateAuthorityStatus
 -> f (Maybe CertificateAuthorityStatus))
-> UpdateCertificateAuthority -> f UpdateCertificateAuthority
updateCertificateAuthority_status = (UpdateCertificateAuthority -> Maybe CertificateAuthorityStatus)
-> (UpdateCertificateAuthority
    -> Maybe CertificateAuthorityStatus -> UpdateCertificateAuthority)
-> Lens
     UpdateCertificateAuthority
     UpdateCertificateAuthority
     (Maybe CertificateAuthorityStatus)
     (Maybe CertificateAuthorityStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCertificateAuthority' {Maybe CertificateAuthorityStatus
status :: Maybe CertificateAuthorityStatus
$sel:status:UpdateCertificateAuthority' :: UpdateCertificateAuthority -> Maybe CertificateAuthorityStatus
status} -> Maybe CertificateAuthorityStatus
status) (\s :: UpdateCertificateAuthority
s@UpdateCertificateAuthority' {} Maybe CertificateAuthorityStatus
a -> UpdateCertificateAuthority
s {$sel:status:UpdateCertificateAuthority' :: Maybe CertificateAuthorityStatus
status = Maybe CertificateAuthorityStatus
a} :: UpdateCertificateAuthority)

-- | Contains information to enable Online Certificate Status Protocol (OCSP)
-- support, to enable a certificate revocation list (CRL), to enable both,
-- or to enable neither. If this parameter is not supplied, existing
-- capibilites remain unchanged. For more information, see the
-- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_OcspConfiguration.html OcspConfiguration>
-- and
-- <https://docs.aws.amazon.com/acm-pca/latest/APIReference/API_CrlConfiguration.html CrlConfiguration>
-- types.
updateCertificateAuthority_revocationConfiguration :: Lens.Lens' UpdateCertificateAuthority (Prelude.Maybe RevocationConfiguration)
updateCertificateAuthority_revocationConfiguration :: (Maybe RevocationConfiguration
 -> f (Maybe RevocationConfiguration))
-> UpdateCertificateAuthority -> f UpdateCertificateAuthority
updateCertificateAuthority_revocationConfiguration = (UpdateCertificateAuthority -> Maybe RevocationConfiguration)
-> (UpdateCertificateAuthority
    -> Maybe RevocationConfiguration -> UpdateCertificateAuthority)
-> Lens
     UpdateCertificateAuthority
     UpdateCertificateAuthority
     (Maybe RevocationConfiguration)
     (Maybe RevocationConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCertificateAuthority' {Maybe RevocationConfiguration
revocationConfiguration :: Maybe RevocationConfiguration
$sel:revocationConfiguration:UpdateCertificateAuthority' :: UpdateCertificateAuthority -> Maybe RevocationConfiguration
revocationConfiguration} -> Maybe RevocationConfiguration
revocationConfiguration) (\s :: UpdateCertificateAuthority
s@UpdateCertificateAuthority' {} Maybe RevocationConfiguration
a -> UpdateCertificateAuthority
s {$sel:revocationConfiguration:UpdateCertificateAuthority' :: Maybe RevocationConfiguration
revocationConfiguration = Maybe RevocationConfiguration
a} :: UpdateCertificateAuthority)

-- | Amazon Resource Name (ARN) of the private CA that issued the certificate
-- to be revoked. This must be of the form:
--
-- @arn:aws:acm-pca:region:account:certificate-authority\/12345678-1234-1234-1234-123456789012 @
updateCertificateAuthority_certificateAuthorityArn :: Lens.Lens' UpdateCertificateAuthority Prelude.Text
updateCertificateAuthority_certificateAuthorityArn :: (Text -> f Text)
-> UpdateCertificateAuthority -> f UpdateCertificateAuthority
updateCertificateAuthority_certificateAuthorityArn = (UpdateCertificateAuthority -> Text)
-> (UpdateCertificateAuthority
    -> Text -> UpdateCertificateAuthority)
-> Lens
     UpdateCertificateAuthority UpdateCertificateAuthority Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateCertificateAuthority' {Text
certificateAuthorityArn :: Text
$sel:certificateAuthorityArn:UpdateCertificateAuthority' :: UpdateCertificateAuthority -> Text
certificateAuthorityArn} -> Text
certificateAuthorityArn) (\s :: UpdateCertificateAuthority
s@UpdateCertificateAuthority' {} Text
a -> UpdateCertificateAuthority
s {$sel:certificateAuthorityArn:UpdateCertificateAuthority' :: Text
certificateAuthorityArn = Text
a} :: UpdateCertificateAuthority)

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

instance Prelude.Hashable UpdateCertificateAuthority

instance Prelude.NFData UpdateCertificateAuthority

instance Core.ToHeaders UpdateCertificateAuthority where
  toHeaders :: UpdateCertificateAuthority -> [Header]
toHeaders =
    [Header] -> UpdateCertificateAuthority -> [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
"ACMPrivateCA.UpdateCertificateAuthority" ::
                          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 UpdateCertificateAuthority where
  toJSON :: UpdateCertificateAuthority -> Value
toJSON UpdateCertificateAuthority' {Maybe CertificateAuthorityStatus
Maybe RevocationConfiguration
Text
certificateAuthorityArn :: Text
revocationConfiguration :: Maybe RevocationConfiguration
status :: Maybe CertificateAuthorityStatus
$sel:certificateAuthorityArn:UpdateCertificateAuthority' :: UpdateCertificateAuthority -> Text
$sel:revocationConfiguration:UpdateCertificateAuthority' :: UpdateCertificateAuthority -> Maybe RevocationConfiguration
$sel:status:UpdateCertificateAuthority' :: UpdateCertificateAuthority -> Maybe CertificateAuthorityStatus
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Status" Text -> CertificateAuthorityStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (CertificateAuthorityStatus -> Pair)
-> Maybe CertificateAuthorityStatus -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe CertificateAuthorityStatus
status,
            (Text
"RevocationConfiguration" Text -> RevocationConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (RevocationConfiguration -> Pair)
-> Maybe RevocationConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RevocationConfiguration
revocationConfiguration,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"CertificateAuthorityArn"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
certificateAuthorityArn
              )
          ]
      )

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

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

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

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

instance
  Prelude.NFData
    UpdateCertificateAuthorityResponse