{-# 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.UploadServerCertificate
-- 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)
--
-- Uploads a server certificate entity for the Amazon Web Services account.
-- The server certificate entity includes a public key certificate, a
-- private key, and an optional certificate chain, which should all be
-- PEM-encoded.
--
-- We recommend that you use
-- <https://docs.aws.amazon.com/acm/ Certificate Manager> to provision,
-- manage, and deploy your server certificates. With ACM you can request a
-- certificate, deploy it to Amazon Web Services resources, and let ACM
-- handle certificate renewals for you. Certificates provided by ACM are
-- free. For more information about using ACM, see the
-- <https://docs.aws.amazon.com/acm/latest/userguide/ Certificate Manager User Guide>.
--
-- 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 includes a list of Amazon Web
-- Services services that can use the server certificates that you manage
-- with IAM.
--
-- For information about the number of server certificates you can upload,
-- see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_iam-quotas.html IAM and STS quotas>
-- in the /IAM User Guide/.
--
-- Because the body of the public key certificate, private key, and the
-- certificate chain can be large, you should use POST rather than GET when
-- calling @UploadServerCertificate@. For information about setting up
-- signatures and authorization through the API, see
-- <https://docs.aws.amazon.com/general/latest/gr/signing_aws_api_requests.html Signing Amazon Web Services API requests>
-- in the /Amazon Web Services General Reference/. For general information
-- about using the Query API with IAM, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/programming.html Calling the API by making HTTP query requests>
-- in the /IAM User Guide/.
module Amazonka.IAM.UploadServerCertificate
  ( -- * Creating a Request
    UploadServerCertificate (..),
    newUploadServerCertificate,

    -- * Request Lenses
    uploadServerCertificate_path,
    uploadServerCertificate_certificateChain,
    uploadServerCertificate_tags,
    uploadServerCertificate_serverCertificateName,
    uploadServerCertificate_certificateBody,
    uploadServerCertificate_privateKey,

    -- * Destructuring the Response
    UploadServerCertificateResponse (..),
    newUploadServerCertificateResponse,

    -- * Response Lenses
    uploadServerCertificateResponse_serverCertificateMetadata,
    uploadServerCertificateResponse_tags,
    uploadServerCertificateResponse_httpStatus,
  )
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:/ 'newUploadServerCertificate' smart constructor.
data UploadServerCertificate = UploadServerCertificate'
  { -- | The path for the server certificate. For more information about paths,
    -- see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html IAM identifiers>
    -- in the /IAM User Guide/.
    --
    -- This parameter is optional. If it is not included, it defaults to a
    -- slash (\/). 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.
    --
    -- If you are uploading a server certificate specifically for use with
    -- Amazon CloudFront distributions, you must specify a path using the
    -- @path@ parameter. The path must begin with @\/cloudfront@ and must
    -- include a trailing slash (for example, @\/cloudfront\/test\/@).
    UploadServerCertificate -> Maybe Text
path :: Prelude.Maybe Prelude.Text,
    -- | The contents of the certificate chain. This is typically a concatenation
    -- of the PEM-encoded public key certificates of the chain.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> used to validate
    -- this parameter is a string of characters consisting of the following:
    --
    -- -   Any printable ASCII character ranging from the space character
    --     (@\\u0020@) through the end of the ASCII character range
    --
    -- -   The printable characters in the Basic Latin and Latin-1 Supplement
    --     character set (through @\\u00FF@)
    --
    -- -   The special characters tab (@\\u0009@), line feed (@\\u000A@), and
    --     carriage return (@\\u000D@)
    UploadServerCertificate -> Maybe Text
certificateChain :: Prelude.Maybe Prelude.Text,
    -- | A list of tags that you want to attach to the new IAM server certificate
    -- resource. Each tag consists of a key name and an associated value. For
    -- more information about tagging, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
    -- in the /IAM User Guide/.
    --
    -- If any one of the tags is invalid or if you exceed the allowed maximum
    -- number of tags, then the entire request fails and the resource is not
    -- created.
    UploadServerCertificate -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The name for the server certificate. Do not include the path in this
    -- value. 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: _+=,.\@-
    UploadServerCertificate -> Text
serverCertificateName :: Prelude.Text,
    -- | The contents of the public key certificate in PEM-encoded format.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> used to validate
    -- this parameter is a string of characters consisting of the following:
    --
    -- -   Any printable ASCII character ranging from the space character
    --     (@\\u0020@) through the end of the ASCII character range
    --
    -- -   The printable characters in the Basic Latin and Latin-1 Supplement
    --     character set (through @\\u00FF@)
    --
    -- -   The special characters tab (@\\u0009@), line feed (@\\u000A@), and
    --     carriage return (@\\u000D@)
    UploadServerCertificate -> Text
certificateBody :: Prelude.Text,
    -- | The contents of the private key in PEM-encoded format.
    --
    -- The <http://wikipedia.org/wiki/regex regex pattern> used to validate
    -- this parameter is a string of characters consisting of the following:
    --
    -- -   Any printable ASCII character ranging from the space character
    --     (@\\u0020@) through the end of the ASCII character range
    --
    -- -   The printable characters in the Basic Latin and Latin-1 Supplement
    --     character set (through @\\u00FF@)
    --
    -- -   The special characters tab (@\\u0009@), line feed (@\\u000A@), and
    --     carriage return (@\\u000D@)
    UploadServerCertificate -> Sensitive Text
privateKey :: Core.Sensitive Prelude.Text
  }
  deriving (UploadServerCertificate -> UploadServerCertificate -> Bool
(UploadServerCertificate -> UploadServerCertificate -> Bool)
-> (UploadServerCertificate -> UploadServerCertificate -> Bool)
-> Eq UploadServerCertificate
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UploadServerCertificate -> UploadServerCertificate -> Bool
$c/= :: UploadServerCertificate -> UploadServerCertificate -> Bool
== :: UploadServerCertificate -> UploadServerCertificate -> Bool
$c== :: UploadServerCertificate -> UploadServerCertificate -> Bool
Prelude.Eq, Int -> UploadServerCertificate -> ShowS
[UploadServerCertificate] -> ShowS
UploadServerCertificate -> String
(Int -> UploadServerCertificate -> ShowS)
-> (UploadServerCertificate -> String)
-> ([UploadServerCertificate] -> ShowS)
-> Show UploadServerCertificate
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UploadServerCertificate] -> ShowS
$cshowList :: [UploadServerCertificate] -> ShowS
show :: UploadServerCertificate -> String
$cshow :: UploadServerCertificate -> String
showsPrec :: Int -> UploadServerCertificate -> ShowS
$cshowsPrec :: Int -> UploadServerCertificate -> ShowS
Prelude.Show, (forall x.
 UploadServerCertificate -> Rep UploadServerCertificate x)
-> (forall x.
    Rep UploadServerCertificate x -> UploadServerCertificate)
-> Generic UploadServerCertificate
forall x. Rep UploadServerCertificate x -> UploadServerCertificate
forall x. UploadServerCertificate -> Rep UploadServerCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UploadServerCertificate x -> UploadServerCertificate
$cfrom :: forall x. UploadServerCertificate -> Rep UploadServerCertificate x
Prelude.Generic)

-- |
-- Create a value of 'UploadServerCertificate' 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:
--
-- 'path', 'uploadServerCertificate_path' - The path for the server certificate. For more information about paths,
-- see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html IAM identifiers>
-- in the /IAM User Guide/.
--
-- This parameter is optional. If it is not included, it defaults to a
-- slash (\/). 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.
--
-- If you are uploading a server certificate specifically for use with
-- Amazon CloudFront distributions, you must specify a path using the
-- @path@ parameter. The path must begin with @\/cloudfront@ and must
-- include a trailing slash (for example, @\/cloudfront\/test\/@).
--
-- 'certificateChain', 'uploadServerCertificate_certificateChain' - The contents of the certificate chain. This is typically a concatenation
-- of the PEM-encoded public key certificates of the chain.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> used to validate
-- this parameter is a string of characters consisting of the following:
--
-- -   Any printable ASCII character ranging from the space character
--     (@\\u0020@) through the end of the ASCII character range
--
-- -   The printable characters in the Basic Latin and Latin-1 Supplement
--     character set (through @\\u00FF@)
--
-- -   The special characters tab (@\\u0009@), line feed (@\\u000A@), and
--     carriage return (@\\u000D@)
--
-- 'tags', 'uploadServerCertificate_tags' - A list of tags that you want to attach to the new IAM server certificate
-- resource. Each tag consists of a key name and an associated value. For
-- more information about tagging, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
-- in the /IAM User Guide/.
--
-- If any one of the tags is invalid or if you exceed the allowed maximum
-- number of tags, then the entire request fails and the resource is not
-- created.
--
-- 'serverCertificateName', 'uploadServerCertificate_serverCertificateName' - The name for the server certificate. Do not include the path in this
-- value. 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: _+=,.\@-
--
-- 'certificateBody', 'uploadServerCertificate_certificateBody' - The contents of the public key certificate in PEM-encoded format.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> used to validate
-- this parameter is a string of characters consisting of the following:
--
-- -   Any printable ASCII character ranging from the space character
--     (@\\u0020@) through the end of the ASCII character range
--
-- -   The printable characters in the Basic Latin and Latin-1 Supplement
--     character set (through @\\u00FF@)
--
-- -   The special characters tab (@\\u0009@), line feed (@\\u000A@), and
--     carriage return (@\\u000D@)
--
-- 'privateKey', 'uploadServerCertificate_privateKey' - The contents of the private key in PEM-encoded format.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> used to validate
-- this parameter is a string of characters consisting of the following:
--
-- -   Any printable ASCII character ranging from the space character
--     (@\\u0020@) through the end of the ASCII character range
--
-- -   The printable characters in the Basic Latin and Latin-1 Supplement
--     character set (through @\\u00FF@)
--
-- -   The special characters tab (@\\u0009@), line feed (@\\u000A@), and
--     carriage return (@\\u000D@)
newUploadServerCertificate ::
  -- | 'serverCertificateName'
  Prelude.Text ->
  -- | 'certificateBody'
  Prelude.Text ->
  -- | 'privateKey'
  Prelude.Text ->
  UploadServerCertificate
newUploadServerCertificate :: Text -> Text -> Text -> UploadServerCertificate
newUploadServerCertificate
  Text
pServerCertificateName_
  Text
pCertificateBody_
  Text
pPrivateKey_ =
    UploadServerCertificate' :: Maybe Text
-> Maybe Text
-> Maybe [Tag]
-> Text
-> Text
-> Sensitive Text
-> UploadServerCertificate
UploadServerCertificate'
      { $sel:path:UploadServerCertificate' :: Maybe Text
path = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:certificateChain:UploadServerCertificate' :: Maybe Text
certificateChain = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:tags:UploadServerCertificate' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
        $sel:serverCertificateName:UploadServerCertificate' :: Text
serverCertificateName = Text
pServerCertificateName_,
        $sel:certificateBody:UploadServerCertificate' :: Text
certificateBody = Text
pCertificateBody_,
        $sel:privateKey:UploadServerCertificate' :: Sensitive Text
privateKey = Tagged Text (Identity Text)
-> Tagged (Sensitive Text) (Identity (Sensitive Text))
forall a. Iso' (Sensitive a) a
Core._Sensitive (Tagged Text (Identity Text)
 -> Tagged (Sensitive Text) (Identity (Sensitive Text)))
-> Text -> Sensitive Text
forall t b. AReview t b -> b -> t
Lens.# Text
pPrivateKey_
      }

-- | The path for the server certificate. For more information about paths,
-- see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/Using_Identifiers.html IAM identifiers>
-- in the /IAM User Guide/.
--
-- This parameter is optional. If it is not included, it defaults to a
-- slash (\/). 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.
--
-- If you are uploading a server certificate specifically for use with
-- Amazon CloudFront distributions, you must specify a path using the
-- @path@ parameter. The path must begin with @\/cloudfront@ and must
-- include a trailing slash (for example, @\/cloudfront\/test\/@).
uploadServerCertificate_path :: Lens.Lens' UploadServerCertificate (Prelude.Maybe Prelude.Text)
uploadServerCertificate_path :: (Maybe Text -> f (Maybe Text))
-> UploadServerCertificate -> f UploadServerCertificate
uploadServerCertificate_path = (UploadServerCertificate -> Maybe Text)
-> (UploadServerCertificate
    -> Maybe Text -> UploadServerCertificate)
-> Lens
     UploadServerCertificate
     UploadServerCertificate
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadServerCertificate' {Maybe Text
path :: Maybe Text
$sel:path:UploadServerCertificate' :: UploadServerCertificate -> Maybe Text
path} -> Maybe Text
path) (\s :: UploadServerCertificate
s@UploadServerCertificate' {} Maybe Text
a -> UploadServerCertificate
s {$sel:path:UploadServerCertificate' :: Maybe Text
path = Maybe Text
a} :: UploadServerCertificate)

-- | The contents of the certificate chain. This is typically a concatenation
-- of the PEM-encoded public key certificates of the chain.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> used to validate
-- this parameter is a string of characters consisting of the following:
--
-- -   Any printable ASCII character ranging from the space character
--     (@\\u0020@) through the end of the ASCII character range
--
-- -   The printable characters in the Basic Latin and Latin-1 Supplement
--     character set (through @\\u00FF@)
--
-- -   The special characters tab (@\\u0009@), line feed (@\\u000A@), and
--     carriage return (@\\u000D@)
uploadServerCertificate_certificateChain :: Lens.Lens' UploadServerCertificate (Prelude.Maybe Prelude.Text)
uploadServerCertificate_certificateChain :: (Maybe Text -> f (Maybe Text))
-> UploadServerCertificate -> f UploadServerCertificate
uploadServerCertificate_certificateChain = (UploadServerCertificate -> Maybe Text)
-> (UploadServerCertificate
    -> Maybe Text -> UploadServerCertificate)
-> Lens
     UploadServerCertificate
     UploadServerCertificate
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadServerCertificate' {Maybe Text
certificateChain :: Maybe Text
$sel:certificateChain:UploadServerCertificate' :: UploadServerCertificate -> Maybe Text
certificateChain} -> Maybe Text
certificateChain) (\s :: UploadServerCertificate
s@UploadServerCertificate' {} Maybe Text
a -> UploadServerCertificate
s {$sel:certificateChain:UploadServerCertificate' :: Maybe Text
certificateChain = Maybe Text
a} :: UploadServerCertificate)

-- | A list of tags that you want to attach to the new IAM server certificate
-- resource. Each tag consists of a key name and an associated value. For
-- more information about tagging, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
-- in the /IAM User Guide/.
--
-- If any one of the tags is invalid or if you exceed the allowed maximum
-- number of tags, then the entire request fails and the resource is not
-- created.
uploadServerCertificate_tags :: Lens.Lens' UploadServerCertificate (Prelude.Maybe [Tag])
uploadServerCertificate_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> UploadServerCertificate -> f UploadServerCertificate
uploadServerCertificate_tags = (UploadServerCertificate -> Maybe [Tag])
-> (UploadServerCertificate
    -> Maybe [Tag] -> UploadServerCertificate)
-> Lens
     UploadServerCertificate
     UploadServerCertificate
     (Maybe [Tag])
     (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadServerCertificate' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:UploadServerCertificate' :: UploadServerCertificate -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: UploadServerCertificate
s@UploadServerCertificate' {} Maybe [Tag]
a -> UploadServerCertificate
s {$sel:tags:UploadServerCertificate' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: UploadServerCertificate) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> UploadServerCertificate -> f UploadServerCertificate)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> UploadServerCertificate
-> f UploadServerCertificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The name for the server certificate. Do not include the path in this
-- value. 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: _+=,.\@-
uploadServerCertificate_serverCertificateName :: Lens.Lens' UploadServerCertificate Prelude.Text
uploadServerCertificate_serverCertificateName :: (Text -> f Text)
-> UploadServerCertificate -> f UploadServerCertificate
uploadServerCertificate_serverCertificateName = (UploadServerCertificate -> Text)
-> (UploadServerCertificate -> Text -> UploadServerCertificate)
-> Lens UploadServerCertificate UploadServerCertificate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadServerCertificate' {Text
serverCertificateName :: Text
$sel:serverCertificateName:UploadServerCertificate' :: UploadServerCertificate -> Text
serverCertificateName} -> Text
serverCertificateName) (\s :: UploadServerCertificate
s@UploadServerCertificate' {} Text
a -> UploadServerCertificate
s {$sel:serverCertificateName:UploadServerCertificate' :: Text
serverCertificateName = Text
a} :: UploadServerCertificate)

-- | The contents of the public key certificate in PEM-encoded format.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> used to validate
-- this parameter is a string of characters consisting of the following:
--
-- -   Any printable ASCII character ranging from the space character
--     (@\\u0020@) through the end of the ASCII character range
--
-- -   The printable characters in the Basic Latin and Latin-1 Supplement
--     character set (through @\\u00FF@)
--
-- -   The special characters tab (@\\u0009@), line feed (@\\u000A@), and
--     carriage return (@\\u000D@)
uploadServerCertificate_certificateBody :: Lens.Lens' UploadServerCertificate Prelude.Text
uploadServerCertificate_certificateBody :: (Text -> f Text)
-> UploadServerCertificate -> f UploadServerCertificate
uploadServerCertificate_certificateBody = (UploadServerCertificate -> Text)
-> (UploadServerCertificate -> Text -> UploadServerCertificate)
-> Lens UploadServerCertificate UploadServerCertificate Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadServerCertificate' {Text
certificateBody :: Text
$sel:certificateBody:UploadServerCertificate' :: UploadServerCertificate -> Text
certificateBody} -> Text
certificateBody) (\s :: UploadServerCertificate
s@UploadServerCertificate' {} Text
a -> UploadServerCertificate
s {$sel:certificateBody:UploadServerCertificate' :: Text
certificateBody = Text
a} :: UploadServerCertificate)

-- | The contents of the private key in PEM-encoded format.
--
-- The <http://wikipedia.org/wiki/regex regex pattern> used to validate
-- this parameter is a string of characters consisting of the following:
--
-- -   Any printable ASCII character ranging from the space character
--     (@\\u0020@) through the end of the ASCII character range
--
-- -   The printable characters in the Basic Latin and Latin-1 Supplement
--     character set (through @\\u00FF@)
--
-- -   The special characters tab (@\\u0009@), line feed (@\\u000A@), and
--     carriage return (@\\u000D@)
uploadServerCertificate_privateKey :: Lens.Lens' UploadServerCertificate Prelude.Text
uploadServerCertificate_privateKey :: (Text -> f Text)
-> UploadServerCertificate -> f UploadServerCertificate
uploadServerCertificate_privateKey = (UploadServerCertificate -> Sensitive Text)
-> (UploadServerCertificate
    -> Sensitive Text -> UploadServerCertificate)
-> Lens
     UploadServerCertificate
     UploadServerCertificate
     (Sensitive Text)
     (Sensitive Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadServerCertificate' {Sensitive Text
privateKey :: Sensitive Text
$sel:privateKey:UploadServerCertificate' :: UploadServerCertificate -> Sensitive Text
privateKey} -> Sensitive Text
privateKey) (\s :: UploadServerCertificate
s@UploadServerCertificate' {} Sensitive Text
a -> UploadServerCertificate
s {$sel:privateKey:UploadServerCertificate' :: Sensitive Text
privateKey = Sensitive Text
a} :: UploadServerCertificate) ((Sensitive Text -> f (Sensitive Text))
 -> UploadServerCertificate -> f UploadServerCertificate)
-> ((Text -> f Text) -> Sensitive Text -> f (Sensitive Text))
-> (Text -> f Text)
-> UploadServerCertificate
-> f UploadServerCertificate
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (Text -> f Text) -> Sensitive Text -> f (Sensitive Text)
forall a. Iso' (Sensitive a) a
Core._Sensitive

instance Core.AWSRequest UploadServerCertificate where
  type
    AWSResponse UploadServerCertificate =
      UploadServerCertificateResponse
  request :: UploadServerCertificate -> Request UploadServerCertificate
request = Service
-> UploadServerCertificate -> Request UploadServerCertificate
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy UploadServerCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UploadServerCertificate)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse UploadServerCertificate))
-> Logger
-> Service
-> Proxy UploadServerCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UploadServerCertificate)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"UploadServerCertificateResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe ServerCertificateMetadata
-> Maybe [Tag] -> Int -> UploadServerCertificateResponse
UploadServerCertificateResponse'
            (Maybe ServerCertificateMetadata
 -> Maybe [Tag] -> Int -> UploadServerCertificateResponse)
-> Either String (Maybe ServerCertificateMetadata)
-> Either
     String (Maybe [Tag] -> Int -> UploadServerCertificateResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe ServerCertificateMetadata)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ServerCertificateMetadata")
            Either
  String (Maybe [Tag] -> Int -> UploadServerCertificateResponse)
-> Either String (Maybe [Tag])
-> Either String (Int -> UploadServerCertificateResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Tags" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                            Either String [Node]
-> ([Node] -> Either String (Maybe [Tag]))
-> Either String (Maybe [Tag])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Tag])
-> [Node] -> Either String (Maybe [Tag])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Tag]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                        )
            Either String (Int -> UploadServerCertificateResponse)
-> Either String Int
-> Either String UploadServerCertificateResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UploadServerCertificate

instance Prelude.NFData UploadServerCertificate

instance Core.ToHeaders UploadServerCertificate where
  toHeaders :: UploadServerCertificate -> ResponseHeaders
toHeaders = ResponseHeaders -> UploadServerCertificate -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

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

instance Core.ToQuery UploadServerCertificate where
  toQuery :: UploadServerCertificate -> QueryString
toQuery UploadServerCertificate' {Maybe [Tag]
Maybe Text
Text
Sensitive Text
privateKey :: Sensitive Text
certificateBody :: Text
serverCertificateName :: Text
tags :: Maybe [Tag]
certificateChain :: Maybe Text
path :: Maybe Text
$sel:privateKey:UploadServerCertificate' :: UploadServerCertificate -> Sensitive Text
$sel:certificateBody:UploadServerCertificate' :: UploadServerCertificate -> Text
$sel:serverCertificateName:UploadServerCertificate' :: UploadServerCertificate -> Text
$sel:tags:UploadServerCertificate' :: UploadServerCertificate -> Maybe [Tag]
$sel:certificateChain:UploadServerCertificate' :: UploadServerCertificate -> Maybe Text
$sel:path:UploadServerCertificate' :: UploadServerCertificate -> 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
"UploadServerCertificate" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-05-08" :: Prelude.ByteString),
        ByteString
"Path" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
path,
        ByteString
"CertificateChain" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
certificateChain,
        ByteString
"Tags"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
            (ByteString -> [Tag] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Tag] -> QueryString) -> Maybe [Tag] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags),
        ByteString
"ServerCertificateName"
          ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
serverCertificateName,
        ByteString
"CertificateBody" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
certificateBody,
        ByteString
"PrivateKey" ByteString -> Sensitive Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Sensitive Text
privateKey
      ]

-- | Contains the response to a successful UploadServerCertificate request.
--
-- /See:/ 'newUploadServerCertificateResponse' smart constructor.
data UploadServerCertificateResponse = UploadServerCertificateResponse'
  { -- | The meta information of the uploaded server certificate without its
    -- certificate body, certificate chain, and private key.
    UploadServerCertificateResponse -> Maybe ServerCertificateMetadata
serverCertificateMetadata :: Prelude.Maybe ServerCertificateMetadata,
    -- | A list of tags that are attached to the new IAM server certificate. The
    -- returned list of tags is sorted by tag key. For more information about
    -- tagging, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
    -- in the /IAM User Guide/.
    UploadServerCertificateResponse -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
    -- | The response's http status code.
    UploadServerCertificateResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UploadServerCertificateResponse
-> UploadServerCertificateResponse -> Bool
(UploadServerCertificateResponse
 -> UploadServerCertificateResponse -> Bool)
-> (UploadServerCertificateResponse
    -> UploadServerCertificateResponse -> Bool)
-> Eq UploadServerCertificateResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UploadServerCertificateResponse
-> UploadServerCertificateResponse -> Bool
$c/= :: UploadServerCertificateResponse
-> UploadServerCertificateResponse -> Bool
== :: UploadServerCertificateResponse
-> UploadServerCertificateResponse -> Bool
$c== :: UploadServerCertificateResponse
-> UploadServerCertificateResponse -> Bool
Prelude.Eq, ReadPrec [UploadServerCertificateResponse]
ReadPrec UploadServerCertificateResponse
Int -> ReadS UploadServerCertificateResponse
ReadS [UploadServerCertificateResponse]
(Int -> ReadS UploadServerCertificateResponse)
-> ReadS [UploadServerCertificateResponse]
-> ReadPrec UploadServerCertificateResponse
-> ReadPrec [UploadServerCertificateResponse]
-> Read UploadServerCertificateResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UploadServerCertificateResponse]
$creadListPrec :: ReadPrec [UploadServerCertificateResponse]
readPrec :: ReadPrec UploadServerCertificateResponse
$creadPrec :: ReadPrec UploadServerCertificateResponse
readList :: ReadS [UploadServerCertificateResponse]
$creadList :: ReadS [UploadServerCertificateResponse]
readsPrec :: Int -> ReadS UploadServerCertificateResponse
$creadsPrec :: Int -> ReadS UploadServerCertificateResponse
Prelude.Read, Int -> UploadServerCertificateResponse -> ShowS
[UploadServerCertificateResponse] -> ShowS
UploadServerCertificateResponse -> String
(Int -> UploadServerCertificateResponse -> ShowS)
-> (UploadServerCertificateResponse -> String)
-> ([UploadServerCertificateResponse] -> ShowS)
-> Show UploadServerCertificateResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UploadServerCertificateResponse] -> ShowS
$cshowList :: [UploadServerCertificateResponse] -> ShowS
show :: UploadServerCertificateResponse -> String
$cshow :: UploadServerCertificateResponse -> String
showsPrec :: Int -> UploadServerCertificateResponse -> ShowS
$cshowsPrec :: Int -> UploadServerCertificateResponse -> ShowS
Prelude.Show, (forall x.
 UploadServerCertificateResponse
 -> Rep UploadServerCertificateResponse x)
-> (forall x.
    Rep UploadServerCertificateResponse x
    -> UploadServerCertificateResponse)
-> Generic UploadServerCertificateResponse
forall x.
Rep UploadServerCertificateResponse x
-> UploadServerCertificateResponse
forall x.
UploadServerCertificateResponse
-> Rep UploadServerCertificateResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UploadServerCertificateResponse x
-> UploadServerCertificateResponse
$cfrom :: forall x.
UploadServerCertificateResponse
-> Rep UploadServerCertificateResponse x
Prelude.Generic)

-- |
-- Create a value of 'UploadServerCertificateResponse' 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:
--
-- 'serverCertificateMetadata', 'uploadServerCertificateResponse_serverCertificateMetadata' - The meta information of the uploaded server certificate without its
-- certificate body, certificate chain, and private key.
--
-- 'tags', 'uploadServerCertificateResponse_tags' - A list of tags that are attached to the new IAM server certificate. The
-- returned list of tags is sorted by tag key. For more information about
-- tagging, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
-- in the /IAM User Guide/.
--
-- 'httpStatus', 'uploadServerCertificateResponse_httpStatus' - The response's http status code.
newUploadServerCertificateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UploadServerCertificateResponse
newUploadServerCertificateResponse :: Int -> UploadServerCertificateResponse
newUploadServerCertificateResponse Int
pHttpStatus_ =
  UploadServerCertificateResponse' :: Maybe ServerCertificateMetadata
-> Maybe [Tag] -> Int -> UploadServerCertificateResponse
UploadServerCertificateResponse'
    { $sel:serverCertificateMetadata:UploadServerCertificateResponse' :: Maybe ServerCertificateMetadata
serverCertificateMetadata =
        Maybe ServerCertificateMetadata
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:UploadServerCertificateResponse' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UploadServerCertificateResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The meta information of the uploaded server certificate without its
-- certificate body, certificate chain, and private key.
uploadServerCertificateResponse_serverCertificateMetadata :: Lens.Lens' UploadServerCertificateResponse (Prelude.Maybe ServerCertificateMetadata)
uploadServerCertificateResponse_serverCertificateMetadata :: (Maybe ServerCertificateMetadata
 -> f (Maybe ServerCertificateMetadata))
-> UploadServerCertificateResponse
-> f UploadServerCertificateResponse
uploadServerCertificateResponse_serverCertificateMetadata = (UploadServerCertificateResponse
 -> Maybe ServerCertificateMetadata)
-> (UploadServerCertificateResponse
    -> Maybe ServerCertificateMetadata
    -> UploadServerCertificateResponse)
-> Lens
     UploadServerCertificateResponse
     UploadServerCertificateResponse
     (Maybe ServerCertificateMetadata)
     (Maybe ServerCertificateMetadata)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadServerCertificateResponse' {Maybe ServerCertificateMetadata
serverCertificateMetadata :: Maybe ServerCertificateMetadata
$sel:serverCertificateMetadata:UploadServerCertificateResponse' :: UploadServerCertificateResponse -> Maybe ServerCertificateMetadata
serverCertificateMetadata} -> Maybe ServerCertificateMetadata
serverCertificateMetadata) (\s :: UploadServerCertificateResponse
s@UploadServerCertificateResponse' {} Maybe ServerCertificateMetadata
a -> UploadServerCertificateResponse
s {$sel:serverCertificateMetadata:UploadServerCertificateResponse' :: Maybe ServerCertificateMetadata
serverCertificateMetadata = Maybe ServerCertificateMetadata
a} :: UploadServerCertificateResponse)

-- | A list of tags that are attached to the new IAM server certificate. The
-- returned list of tags is sorted by tag key. For more information about
-- tagging, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/id_tags.html Tagging IAM resources>
-- in the /IAM User Guide/.
uploadServerCertificateResponse_tags :: Lens.Lens' UploadServerCertificateResponse (Prelude.Maybe [Tag])
uploadServerCertificateResponse_tags :: (Maybe [Tag] -> f (Maybe [Tag]))
-> UploadServerCertificateResponse
-> f UploadServerCertificateResponse
uploadServerCertificateResponse_tags = (UploadServerCertificateResponse -> Maybe [Tag])
-> (UploadServerCertificateResponse
    -> Maybe [Tag] -> UploadServerCertificateResponse)
-> Lens
     UploadServerCertificateResponse
     UploadServerCertificateResponse
     (Maybe [Tag])
     (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadServerCertificateResponse' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:UploadServerCertificateResponse' :: UploadServerCertificateResponse -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: UploadServerCertificateResponse
s@UploadServerCertificateResponse' {} Maybe [Tag]
a -> UploadServerCertificateResponse
s {$sel:tags:UploadServerCertificateResponse' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: UploadServerCertificateResponse) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> UploadServerCertificateResponse
 -> f UploadServerCertificateResponse)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> UploadServerCertificateResponse
-> f UploadServerCertificateResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
uploadServerCertificateResponse_httpStatus :: Lens.Lens' UploadServerCertificateResponse Prelude.Int
uploadServerCertificateResponse_httpStatus :: (Int -> f Int)
-> UploadServerCertificateResponse
-> f UploadServerCertificateResponse
uploadServerCertificateResponse_httpStatus = (UploadServerCertificateResponse -> Int)
-> (UploadServerCertificateResponse
    -> Int -> UploadServerCertificateResponse)
-> Lens
     UploadServerCertificateResponse
     UploadServerCertificateResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UploadServerCertificateResponse' {Int
httpStatus :: Int
$sel:httpStatus:UploadServerCertificateResponse' :: UploadServerCertificateResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UploadServerCertificateResponse
s@UploadServerCertificateResponse' {} Int
a -> UploadServerCertificateResponse
s {$sel:httpStatus:UploadServerCertificateResponse' :: Int
httpStatus = Int
a} :: UploadServerCertificateResponse)

instance
  Prelude.NFData
    UploadServerCertificateResponse