{-# 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-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 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_newServerCertificateName,
    updateServerCertificate_newPath,
    updateServerCertificate_serverCertificateName,

    -- * Destructuring the Response
    UpdateServerCertificateResponse (..),
    newUpdateServerCertificateResponse,
  )
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:/ 'newUpdateServerCertificate' smart constructor.
data UpdateServerCertificate = 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 -> Maybe Text
newServerCertificateName' :: Prelude.Maybe Prelude.Text,
    -- | 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 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
(UpdateServerCertificate -> UpdateServerCertificate -> Bool)
-> (UpdateServerCertificate -> UpdateServerCertificate -> Bool)
-> Eq UpdateServerCertificate
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]
(Int -> ReadS UpdateServerCertificate)
-> ReadS [UpdateServerCertificate]
-> ReadPrec UpdateServerCertificate
-> ReadPrec [UpdateServerCertificate]
-> Read 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
(Int -> UpdateServerCertificate -> ShowS)
-> (UpdateServerCertificate -> String)
-> ([UpdateServerCertificate] -> ShowS)
-> Show UpdateServerCertificate
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.
 UpdateServerCertificate -> Rep UpdateServerCertificate x)
-> (forall x.
    Rep UpdateServerCertificate x -> UpdateServerCertificate)
-> Generic UpdateServerCertificate
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:
--
-- '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: _+=,.\@-
--
-- '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.
--
-- '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' :: Maybe Text -> Maybe Text -> Text -> UpdateServerCertificate
UpdateServerCertificate'
    { $sel:newServerCertificateName':UpdateServerCertificate' :: Maybe Text
newServerCertificateName' =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:newPath':UpdateServerCertificate' :: Maybe Text
newPath' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:serverCertificateName:UpdateServerCertificate' :: Text
serverCertificateName = Text
pServerCertificateName_
    }

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> UpdateServerCertificate -> f UpdateServerCertificate
updateServerCertificate_newServerCertificateName = (UpdateServerCertificate -> Maybe Text)
-> (UpdateServerCertificate
    -> Maybe Text -> UpdateServerCertificate)
-> Lens
     UpdateServerCertificate
     UpdateServerCertificate
     (Maybe Text)
     (Maybe Text)
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 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 :: (Maybe Text -> f (Maybe Text))
-> UpdateServerCertificate -> f UpdateServerCertificate
updateServerCertificate_newPath = (UpdateServerCertificate -> Maybe Text)
-> (UpdateServerCertificate
    -> Maybe Text -> UpdateServerCertificate)
-> Lens
     UpdateServerCertificate
     UpdateServerCertificate
     (Maybe Text)
     (Maybe Text)
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 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 :: (Text -> f Text)
-> UpdateServerCertificate -> f UpdateServerCertificate
updateServerCertificate_serverCertificateName = (UpdateServerCertificate -> Text)
-> (UpdateServerCertificate -> Text -> UpdateServerCertificate)
-> Lens UpdateServerCertificate UpdateServerCertificate Text Text
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 :: UpdateServerCertificate -> Request UpdateServerCertificate
request = Service
-> UpdateServerCertificate -> Request UpdateServerCertificate
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateServerCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateServerCertificate)))
response =
    AWSResponse UpdateServerCertificate
-> Logger
-> Service
-> Proxy UpdateServerCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateServerCertificate)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull
      AWSResponse UpdateServerCertificate
UpdateServerCertificateResponse
UpdateServerCertificateResponse'

instance Prelude.Hashable UpdateServerCertificate

instance Prelude.NFData UpdateServerCertificate

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

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

instance Core.ToQuery UpdateServerCertificate where
  toQuery :: UpdateServerCertificate -> QueryString
toQuery UpdateServerCertificate' {Maybe Text
Text
serverCertificateName :: Text
newPath' :: Maybe Text
newServerCertificateName' :: Maybe Text
$sel:serverCertificateName:UpdateServerCertificate' :: UpdateServerCertificate -> Text
$sel:newPath':UpdateServerCertificate' :: UpdateServerCertificate -> Maybe Text
$sel:newServerCertificateName':UpdateServerCertificate' :: UpdateServerCertificate -> 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
"UpdateServerCertificate" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"NewServerCertificateName"
          ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
newServerCertificateName',
        ByteString
"NewPath" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
newPath',
        ByteString
"ServerCertificateName"
          ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
serverCertificateName
      ]

-- | /See:/ 'newUpdateServerCertificateResponse' smart constructor.
data UpdateServerCertificateResponse = UpdateServerCertificateResponse'
  {
  }
  deriving (UpdateServerCertificateResponse
-> UpdateServerCertificateResponse -> Bool
(UpdateServerCertificateResponse
 -> UpdateServerCertificateResponse -> Bool)
-> (UpdateServerCertificateResponse
    -> UpdateServerCertificateResponse -> Bool)
-> Eq UpdateServerCertificateResponse
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]
(Int -> ReadS UpdateServerCertificateResponse)
-> ReadS [UpdateServerCertificateResponse]
-> ReadPrec UpdateServerCertificateResponse
-> ReadPrec [UpdateServerCertificateResponse]
-> Read 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
(Int -> UpdateServerCertificateResponse -> ShowS)
-> (UpdateServerCertificateResponse -> String)
-> ([UpdateServerCertificateResponse] -> ShowS)
-> Show UpdateServerCertificateResponse
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.
 UpdateServerCertificateResponse
 -> Rep UpdateServerCertificateResponse x)
-> (forall x.
    Rep UpdateServerCertificateResponse x
    -> UpdateServerCertificateResponse)
-> Generic UpdateServerCertificateResponse
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