{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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 qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.IAM.Types
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
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]
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
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.
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'
    { $sel:userName:UpdateSigningCertificate' :: Maybe Text
userName =
        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 :: Lens' UpdateSigningCertificate (Maybe Text)
updateSigningCertificate_userName = 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 :: Lens' UpdateSigningCertificate Text
updateSigningCertificate_certificateId = 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 :: Lens' UpdateSigningCertificate StatusType
updateSigningCertificate_status = 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 :: (Service -> Service)
-> UpdateSigningCertificate -> Request UpdateSigningCertificate
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateSigningCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateSigningCertificate)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      UpdateSigningCertificateResponse
UpdateSigningCertificateResponse'

instance Prelude.Hashable UpdateSigningCertificate where
  hashWithSalt :: Int -> UpdateSigningCertificate -> Int
hashWithSalt Int
_salt 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
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
userName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
certificateId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` StatusType
status

instance Prelude.NFData UpdateSigningCertificate where
  rnf :: UpdateSigningCertificate -> ()
rnf 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
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
userName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
certificateId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf StatusType
status

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

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

instance Data.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
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"UpdateSigningCertificate" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"UserName" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
userName,
        ByteString
"CertificateId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
certificateId,
        ByteString
"Status" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: StatusType
status
      ]

-- | /See:/ 'newUpdateSigningCertificateResponse' smart constructor.
data UpdateSigningCertificateResponse = UpdateSigningCertificateResponse'
  {
  }
  deriving (UpdateSigningCertificateResponse
-> UpdateSigningCertificateResponse -> Bool
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]
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
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.
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
  where
  rnf :: UpdateSigningCertificateResponse -> ()
rnf UpdateSigningCertificateResponse
_ = ()