{-# 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.IAM.UpdateSigningCertificate
-- 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)
--
-- Changes the status of the specified user signing certificate from active
-- to disabled, or vice versa. This operation can be used to disable an IAM
-- user\'s signing certificate as part of a certificate rotation work flow.
--
-- If the @UserName@ field is not specified, the user name is determined
-- implicitly based on the Amazon Web Services access key ID used to sign
-- the request. This operation works for access keys under the Amazon Web
-- Services account. Consequently, you can use this operation to manage
-- Amazon Web Services account root user credentials even if the Amazon Web
-- Services account has no associated users.
module Amazonka.IAM.UpdateSigningCertificate
  ( -- * Creating a Request
    UpdateSigningCertificate (..),
    newUpdateSigningCertificate,

    -- * Request Lenses
    updateSigningCertificate_userName,
    updateSigningCertificate_certificateId,
    updateSigningCertificate_status,

    -- * Destructuring the Response
    UpdateSigningCertificateResponse (..),
    newUpdateSigningCertificateResponse,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IAM.Types
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:/ 'newUpdateSigningCertificate' smart constructor.
data UpdateSigningCertificate = UpdateSigningCertificate'
  { -- | The name of the IAM user the signing certificate belongs to.
    --
    -- This parameter allows (through its
    -- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
    -- consisting of upper and lowercase alphanumeric characters with no
    -- spaces. You can also include any of the following characters: _+=,.\@-
    UpdateSigningCertificate -> Maybe Text
userName :: Prelude.Maybe Prelude.Text,
    -- | The ID of the signing certificate you want to update.
    --
    -- This parameter allows (through its
    -- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
    -- that can consist of any upper or lowercased letter or digit.
    UpdateSigningCertificate -> Text
certificateId :: Prelude.Text,
    -- | The status you want to assign to the certificate. @Active@ means that
    -- the certificate can be used for programmatic calls to Amazon Web
    -- Services @Inactive@ means that the certificate cannot be used.
    UpdateSigningCertificate -> StatusType
status :: StatusType
  }
  deriving (UpdateSigningCertificate -> UpdateSigningCertificate -> Bool
(UpdateSigningCertificate -> UpdateSigningCertificate -> Bool)
-> (UpdateSigningCertificate -> UpdateSigningCertificate -> Bool)
-> Eq UpdateSigningCertificate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateSigningCertificate -> UpdateSigningCertificate -> Bool
$c/= :: UpdateSigningCertificate -> UpdateSigningCertificate -> Bool
== :: UpdateSigningCertificate -> UpdateSigningCertificate -> Bool
$c== :: UpdateSigningCertificate -> UpdateSigningCertificate -> Bool
Prelude.Eq, ReadPrec [UpdateSigningCertificate]
ReadPrec UpdateSigningCertificate
Int -> ReadS UpdateSigningCertificate
ReadS [UpdateSigningCertificate]
(Int -> ReadS UpdateSigningCertificate)
-> ReadS [UpdateSigningCertificate]
-> ReadPrec UpdateSigningCertificate
-> ReadPrec [UpdateSigningCertificate]
-> Read UpdateSigningCertificate
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateSigningCertificate]
$creadListPrec :: ReadPrec [UpdateSigningCertificate]
readPrec :: ReadPrec UpdateSigningCertificate
$creadPrec :: ReadPrec UpdateSigningCertificate
readList :: ReadS [UpdateSigningCertificate]
$creadList :: ReadS [UpdateSigningCertificate]
readsPrec :: Int -> ReadS UpdateSigningCertificate
$creadsPrec :: Int -> ReadS UpdateSigningCertificate
Prelude.Read, Int -> UpdateSigningCertificate -> ShowS
[UpdateSigningCertificate] -> ShowS
UpdateSigningCertificate -> String
(Int -> UpdateSigningCertificate -> ShowS)
-> (UpdateSigningCertificate -> String)
-> ([UpdateSigningCertificate] -> ShowS)
-> Show UpdateSigningCertificate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateSigningCertificate] -> ShowS
$cshowList :: [UpdateSigningCertificate] -> ShowS
show :: UpdateSigningCertificate -> String
$cshow :: UpdateSigningCertificate -> String
showsPrec :: Int -> UpdateSigningCertificate -> ShowS
$cshowsPrec :: Int -> UpdateSigningCertificate -> ShowS
Prelude.Show, (forall x.
 UpdateSigningCertificate -> Rep UpdateSigningCertificate x)
-> (forall x.
    Rep UpdateSigningCertificate x -> UpdateSigningCertificate)
-> Generic UpdateSigningCertificate
forall x.
Rep UpdateSigningCertificate x -> UpdateSigningCertificate
forall x.
UpdateSigningCertificate -> Rep UpdateSigningCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateSigningCertificate x -> UpdateSigningCertificate
$cfrom :: forall x.
UpdateSigningCertificate -> Rep UpdateSigningCertificate x
Prelude.Generic)

-- |
-- Create a value of 'UpdateSigningCertificate' 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:
--
-- 'userName', 'updateSigningCertificate_userName' - The name of the IAM user the signing certificate belongs to.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of upper and lowercase alphanumeric characters with no
-- spaces. You can also include any of the following characters: _+=,.\@-
--
-- 'certificateId', 'updateSigningCertificate_certificateId' - The ID of the signing certificate you want to update.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- that can consist of any upper or lowercased letter or digit.
--
-- 'status', 'updateSigningCertificate_status' - The status you want to assign to the certificate. @Active@ means that
-- the certificate can be used for programmatic calls to Amazon Web
-- Services @Inactive@ means that the certificate cannot be used.
newUpdateSigningCertificate ::
  -- | 'certificateId'
  Prelude.Text ->
  -- | 'status'
  StatusType ->
  UpdateSigningCertificate
newUpdateSigningCertificate :: Text -> StatusType -> UpdateSigningCertificate
newUpdateSigningCertificate Text
pCertificateId_ StatusType
pStatus_ =
  UpdateSigningCertificate' :: Maybe Text -> Text -> StatusType -> UpdateSigningCertificate
UpdateSigningCertificate'
    { $sel:userName:UpdateSigningCertificate' :: Maybe Text
userName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:certificateId:UpdateSigningCertificate' :: Text
certificateId = Text
pCertificateId_,
      $sel:status:UpdateSigningCertificate' :: StatusType
status = StatusType
pStatus_
    }

-- | The name of the IAM user the signing certificate belongs to.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of upper and lowercase alphanumeric characters with no
-- spaces. You can also include any of the following characters: _+=,.\@-
updateSigningCertificate_userName :: Lens.Lens' UpdateSigningCertificate (Prelude.Maybe Prelude.Text)
updateSigningCertificate_userName :: (Maybe Text -> f (Maybe Text))
-> UpdateSigningCertificate -> f UpdateSigningCertificate
updateSigningCertificate_userName = (UpdateSigningCertificate -> Maybe Text)
-> (UpdateSigningCertificate
    -> Maybe Text -> UpdateSigningCertificate)
-> Lens
     UpdateSigningCertificate
     UpdateSigningCertificate
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSigningCertificate' {Maybe Text
userName :: Maybe Text
$sel:userName:UpdateSigningCertificate' :: UpdateSigningCertificate -> Maybe Text
userName} -> Maybe Text
userName) (\s :: UpdateSigningCertificate
s@UpdateSigningCertificate' {} Maybe Text
a -> UpdateSigningCertificate
s {$sel:userName:UpdateSigningCertificate' :: Maybe Text
userName = Maybe Text
a} :: UpdateSigningCertificate)

-- | The ID of the signing certificate you want to update.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- that can consist of any upper or lowercased letter or digit.
updateSigningCertificate_certificateId :: Lens.Lens' UpdateSigningCertificate Prelude.Text
updateSigningCertificate_certificateId :: (Text -> f Text)
-> UpdateSigningCertificate -> f UpdateSigningCertificate
updateSigningCertificate_certificateId = (UpdateSigningCertificate -> Text)
-> (UpdateSigningCertificate -> Text -> UpdateSigningCertificate)
-> Lens UpdateSigningCertificate UpdateSigningCertificate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSigningCertificate' {Text
certificateId :: Text
$sel:certificateId:UpdateSigningCertificate' :: UpdateSigningCertificate -> Text
certificateId} -> Text
certificateId) (\s :: UpdateSigningCertificate
s@UpdateSigningCertificate' {} Text
a -> UpdateSigningCertificate
s {$sel:certificateId:UpdateSigningCertificate' :: Text
certificateId = Text
a} :: UpdateSigningCertificate)

-- | The status you want to assign to the certificate. @Active@ means that
-- the certificate can be used for programmatic calls to Amazon Web
-- Services @Inactive@ means that the certificate cannot be used.
updateSigningCertificate_status :: Lens.Lens' UpdateSigningCertificate StatusType
updateSigningCertificate_status :: (StatusType -> f StatusType)
-> UpdateSigningCertificate -> f UpdateSigningCertificate
updateSigningCertificate_status = (UpdateSigningCertificate -> StatusType)
-> (UpdateSigningCertificate
    -> StatusType -> UpdateSigningCertificate)
-> Lens
     UpdateSigningCertificate
     UpdateSigningCertificate
     StatusType
     StatusType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateSigningCertificate' {StatusType
status :: StatusType
$sel:status:UpdateSigningCertificate' :: UpdateSigningCertificate -> StatusType
status} -> StatusType
status) (\s :: UpdateSigningCertificate
s@UpdateSigningCertificate' {} StatusType
a -> UpdateSigningCertificate
s {$sel:status:UpdateSigningCertificate' :: StatusType
status = StatusType
a} :: UpdateSigningCertificate)

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

instance Prelude.Hashable UpdateSigningCertificate

instance Prelude.NFData UpdateSigningCertificate

instance Core.ToHeaders UpdateSigningCertificate where
  toHeaders :: UpdateSigningCertificate -> [Header]
toHeaders = [Header] -> UpdateSigningCertificate -> [Header]
forall a b. a -> b -> a
Prelude.const [Header]
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery UpdateSigningCertificate where
  toQuery :: UpdateSigningCertificate -> QueryString
toQuery UpdateSigningCertificate' {Maybe Text
Text
StatusType
status :: StatusType
certificateId :: Text
userName :: Maybe Text
$sel:status:UpdateSigningCertificate' :: UpdateSigningCertificate -> StatusType
$sel:certificateId:UpdateSigningCertificate' :: UpdateSigningCertificate -> Text
$sel:userName:UpdateSigningCertificate' :: UpdateSigningCertificate -> Maybe Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"UpdateSigningCertificate" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"UserName" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
userName,
        ByteString
"CertificateId" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
certificateId,
        ByteString
"Status" ByteString -> StatusType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: StatusType
status
      ]

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

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

instance
  Prelude.NFData
    UpdateSigningCertificateResponse