{-# 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.UpdateServerCertificate
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates the name and\/or the path of the specified server certificate
-- stored in IAM.
--
-- For more information about working with server certificates, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_server-certs.html Working with server certificates>
-- in the /IAM User Guide/. This topic also includes a list of Amazon Web
-- Services services that can use the server certificates that you manage
-- with IAM.
--
-- You should understand the implications of changing a server
-- certificate\'s path or name. For more information, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_server-certs_manage.html#RenamingServerCerts Renaming a server certificate>
-- in the /IAM User Guide/.
--
-- The person making the request (the principal), must have permission to
-- change the server certificate with the old name and the new name. For
-- example, to change the certificate named @ProductionCert@ to @ProdCert@,
-- the principal must have a policy that allows them to update both
-- certificates. If the principal has permission to update the
-- @ProductionCert@ group, but not the @ProdCert@ certificate, then the
-- update fails. For more information about permissions, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/access.html Access management>
-- in the /IAM User Guide/.
module Amazonka.IAM.UpdateServerCertificate
  ( -- * Creating a Request
    UpdateServerCertificate (..),
    newUpdateServerCertificate,

    -- * Request Lenses
    updateServerCertificate_newPath,
    updateServerCertificate_newServerCertificateName,
    updateServerCertificate_serverCertificateName,

    -- * Destructuring the Response
    UpdateServerCertificateResponse (..),
    newUpdateServerCertificateResponse,
  )
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:/ 'newUpdateServerCertificate' smart constructor.
data UpdateServerCertificate = UpdateServerCertificate'
  { -- | The new path for the server certificate. Include this only if you are
    -- updating the server certificate\'s path.
    --
    -- This parameter allows (through its
    -- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
    -- consisting of either a forward slash (\/) by itself or a string that
    -- must begin and end with forward slashes. In addition, it can contain any
    -- ASCII character from the ! (@\\u0021@) through the DEL character
    -- (@\\u007F@), including most punctuation characters, digits, and upper
    -- and lowercased letters.
    UpdateServerCertificate -> Maybe Text
newPath' :: Prelude.Maybe Prelude.Text,
    -- | The new name for the server certificate. Include this only if you are
    -- updating the server certificate\'s name. The name of the certificate
    -- cannot contain any spaces.
    --
    -- 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: _+=,.\@-
    UpdateServerCertificate -> Maybe Text
newServerCertificateName' :: Prelude.Maybe Prelude.Text,
    -- | The name of the server certificate that you want to update.
    --
    -- 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: _+=,.\@-
    UpdateServerCertificate -> Text
serverCertificateName :: Prelude.Text
  }
  deriving (UpdateServerCertificate -> UpdateServerCertificate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateServerCertificate -> UpdateServerCertificate -> Bool
$c/= :: UpdateServerCertificate -> UpdateServerCertificate -> Bool
== :: UpdateServerCertificate -> UpdateServerCertificate -> Bool
$c== :: UpdateServerCertificate -> UpdateServerCertificate -> Bool
Prelude.Eq, ReadPrec [UpdateServerCertificate]
ReadPrec UpdateServerCertificate
Int -> ReadS UpdateServerCertificate
ReadS [UpdateServerCertificate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateServerCertificate]
$creadListPrec :: ReadPrec [UpdateServerCertificate]
readPrec :: ReadPrec UpdateServerCertificate
$creadPrec :: ReadPrec UpdateServerCertificate
readList :: ReadS [UpdateServerCertificate]
$creadList :: ReadS [UpdateServerCertificate]
readsPrec :: Int -> ReadS UpdateServerCertificate
$creadsPrec :: Int -> ReadS UpdateServerCertificate
Prelude.Read, Int -> UpdateServerCertificate -> ShowS
[UpdateServerCertificate] -> ShowS
UpdateServerCertificate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateServerCertificate] -> ShowS
$cshowList :: [UpdateServerCertificate] -> ShowS
show :: UpdateServerCertificate -> String
$cshow :: UpdateServerCertificate -> String
showsPrec :: Int -> UpdateServerCertificate -> ShowS
$cshowsPrec :: Int -> UpdateServerCertificate -> ShowS
Prelude.Show, forall x. Rep UpdateServerCertificate x -> UpdateServerCertificate
forall x. UpdateServerCertificate -> Rep UpdateServerCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateServerCertificate x -> UpdateServerCertificate
$cfrom :: forall x. UpdateServerCertificate -> Rep UpdateServerCertificate x
Prelude.Generic)

-- |
-- Create a value of 'UpdateServerCertificate' 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:
--
-- 'newPath'', 'updateServerCertificate_newPath' - The new path for the server certificate. Include this only if you are
-- updating the server certificate\'s path.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of either a forward slash (\/) by itself or a string that
-- must begin and end with forward slashes. In addition, it can contain any
-- ASCII character from the ! (@\\u0021@) through the DEL character
-- (@\\u007F@), including most punctuation characters, digits, and upper
-- and lowercased letters.
--
-- 'newServerCertificateName'', 'updateServerCertificate_newServerCertificateName' - The new name for the server certificate. Include this only if you are
-- updating the server certificate\'s name. The name of the certificate
-- cannot contain any spaces.
--
-- 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: _+=,.\@-
--
-- 'serverCertificateName', 'updateServerCertificate_serverCertificateName' - The name of the server certificate that you want to update.
--
-- 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: _+=,.\@-
newUpdateServerCertificate ::
  -- | 'serverCertificateName'
  Prelude.Text ->
  UpdateServerCertificate
newUpdateServerCertificate :: Text -> UpdateServerCertificate
newUpdateServerCertificate Text
pServerCertificateName_ =
  UpdateServerCertificate'
    { $sel:newPath':UpdateServerCertificate' :: Maybe Text
newPath' =
        forall a. Maybe a
Prelude.Nothing,
      $sel:newServerCertificateName':UpdateServerCertificate' :: Maybe Text
newServerCertificateName' = forall a. Maybe a
Prelude.Nothing,
      $sel:serverCertificateName:UpdateServerCertificate' :: Text
serverCertificateName = Text
pServerCertificateName_
    }

-- | The new path for the server certificate. Include this only if you are
-- updating the server certificate\'s path.
--
-- This parameter allows (through its
-- <http://wikipedia.org/wiki/regex regex pattern>) a string of characters
-- consisting of either a forward slash (\/) by itself or a string that
-- must begin and end with forward slashes. In addition, it can contain any
-- ASCII character from the ! (@\\u0021@) through the DEL character
-- (@\\u007F@), including most punctuation characters, digits, and upper
-- and lowercased letters.
updateServerCertificate_newPath :: Lens.Lens' UpdateServerCertificate (Prelude.Maybe Prelude.Text)
updateServerCertificate_newPath :: Lens' UpdateServerCertificate (Maybe Text)
updateServerCertificate_newPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateServerCertificate' {Maybe Text
newPath' :: Maybe Text
$sel:newPath':UpdateServerCertificate' :: UpdateServerCertificate -> Maybe Text
newPath'} -> Maybe Text
newPath') (\s :: UpdateServerCertificate
s@UpdateServerCertificate' {} Maybe Text
a -> UpdateServerCertificate
s {$sel:newPath':UpdateServerCertificate' :: Maybe Text
newPath' = Maybe Text
a} :: UpdateServerCertificate)

-- | The new name for the server certificate. Include this only if you are
-- updating the server certificate\'s name. The name of the certificate
-- cannot contain any spaces.
--
-- 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: _+=,.\@-
updateServerCertificate_newServerCertificateName :: Lens.Lens' UpdateServerCertificate (Prelude.Maybe Prelude.Text)
updateServerCertificate_newServerCertificateName :: Lens' UpdateServerCertificate (Maybe Text)
updateServerCertificate_newServerCertificateName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateServerCertificate' {Maybe Text
newServerCertificateName' :: Maybe Text
$sel:newServerCertificateName':UpdateServerCertificate' :: UpdateServerCertificate -> Maybe Text
newServerCertificateName'} -> Maybe Text
newServerCertificateName') (\s :: UpdateServerCertificate
s@UpdateServerCertificate' {} Maybe Text
a -> UpdateServerCertificate
s {$sel:newServerCertificateName':UpdateServerCertificate' :: Maybe Text
newServerCertificateName' = Maybe Text
a} :: UpdateServerCertificate)

-- | The name of the server certificate that you want to update.
--
-- 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: _+=,.\@-
updateServerCertificate_serverCertificateName :: Lens.Lens' UpdateServerCertificate Prelude.Text
updateServerCertificate_serverCertificateName :: Lens' UpdateServerCertificate Text
updateServerCertificate_serverCertificateName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateServerCertificate' {Text
serverCertificateName :: Text
$sel:serverCertificateName:UpdateServerCertificate' :: UpdateServerCertificate -> Text
serverCertificateName} -> Text
serverCertificateName) (\s :: UpdateServerCertificate
s@UpdateServerCertificate' {} Text
a -> UpdateServerCertificate
s {$sel:serverCertificateName:UpdateServerCertificate' :: Text
serverCertificateName = Text
a} :: UpdateServerCertificate)

instance Core.AWSRequest UpdateServerCertificate where
  type
    AWSResponse UpdateServerCertificate =
      UpdateServerCertificateResponse
  request :: (Service -> Service)
-> UpdateServerCertificate -> Request UpdateServerCertificate
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 UpdateServerCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateServerCertificate)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      UpdateServerCertificateResponse
UpdateServerCertificateResponse'

instance Prelude.Hashable UpdateServerCertificate where
  hashWithSalt :: Int -> UpdateServerCertificate -> Int
hashWithSalt Int
_salt UpdateServerCertificate' {Maybe Text
Text
serverCertificateName :: Text
newServerCertificateName' :: Maybe Text
newPath' :: Maybe Text
$sel:serverCertificateName:UpdateServerCertificate' :: UpdateServerCertificate -> Text
$sel:newServerCertificateName':UpdateServerCertificate' :: UpdateServerCertificate -> Maybe Text
$sel:newPath':UpdateServerCertificate' :: UpdateServerCertificate -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
newPath'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
newServerCertificateName'
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
serverCertificateName

instance Prelude.NFData UpdateServerCertificate where
  rnf :: UpdateServerCertificate -> ()
rnf UpdateServerCertificate' {Maybe Text
Text
serverCertificateName :: Text
newServerCertificateName' :: Maybe Text
newPath' :: Maybe Text
$sel:serverCertificateName:UpdateServerCertificate' :: UpdateServerCertificate -> Text
$sel:newServerCertificateName':UpdateServerCertificate' :: UpdateServerCertificate -> Maybe Text
$sel:newPath':UpdateServerCertificate' :: UpdateServerCertificate -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
newPath'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
newServerCertificateName'
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
serverCertificateName

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

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

instance Data.ToQuery UpdateServerCertificate where
  toQuery :: UpdateServerCertificate -> QueryString
toQuery UpdateServerCertificate' {Maybe Text
Text
serverCertificateName :: Text
newServerCertificateName' :: Maybe Text
newPath' :: Maybe Text
$sel:serverCertificateName:UpdateServerCertificate' :: UpdateServerCertificate -> Text
$sel:newServerCertificateName':UpdateServerCertificate' :: UpdateServerCertificate -> Maybe Text
$sel:newPath':UpdateServerCertificate' :: UpdateServerCertificate -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"UpdateServerCertificate" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"NewPath" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
newPath',
        ByteString
"NewServerCertificateName"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
newServerCertificateName',
        ByteString
"ServerCertificateName"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
serverCertificateName
      ]

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

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

instance
  Prelude.NFData
    UpdateServerCertificateResponse
  where
  rnf :: UpdateServerCertificateResponse -> ()
rnf UpdateServerCertificateResponse
_ = ()