{-# 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.APIGateway.GenerateClientCertificate
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Generates a ClientCertificate resource.
module Amazonka.APIGateway.GenerateClientCertificate
  ( -- * Creating a Request
    GenerateClientCertificate (..),
    newGenerateClientCertificate,

    -- * Request Lenses
    generateClientCertificate_description,
    generateClientCertificate_tags,

    -- * Destructuring the Response
    ClientCertificate (..),
    newClientCertificate,

    -- * Response Lenses
    clientCertificate_clientCertificateId,
    clientCertificate_createdDate,
    clientCertificate_description,
    clientCertificate_expirationDate,
    clientCertificate_pemEncodedCertificate,
    clientCertificate_tags,
  )
where

import Amazonka.APIGateway.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | A request to generate a ClientCertificate resource.
--
-- /See:/ 'newGenerateClientCertificate' smart constructor.
data GenerateClientCertificate = GenerateClientCertificate'
  { -- | The description of the ClientCertificate.
    GenerateClientCertificate -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The key-value map of strings. The valid character set is
    -- [a-zA-Z+-=._:\/]. The tag key can be up to 128 characters and must not
    -- start with @aws:@. The tag value can be up to 256 characters.
    GenerateClientCertificate -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (GenerateClientCertificate -> GenerateClientCertificate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GenerateClientCertificate -> GenerateClientCertificate -> Bool
$c/= :: GenerateClientCertificate -> GenerateClientCertificate -> Bool
== :: GenerateClientCertificate -> GenerateClientCertificate -> Bool
$c== :: GenerateClientCertificate -> GenerateClientCertificate -> Bool
Prelude.Eq, ReadPrec [GenerateClientCertificate]
ReadPrec GenerateClientCertificate
Int -> ReadS GenerateClientCertificate
ReadS [GenerateClientCertificate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GenerateClientCertificate]
$creadListPrec :: ReadPrec [GenerateClientCertificate]
readPrec :: ReadPrec GenerateClientCertificate
$creadPrec :: ReadPrec GenerateClientCertificate
readList :: ReadS [GenerateClientCertificate]
$creadList :: ReadS [GenerateClientCertificate]
readsPrec :: Int -> ReadS GenerateClientCertificate
$creadsPrec :: Int -> ReadS GenerateClientCertificate
Prelude.Read, Int -> GenerateClientCertificate -> ShowS
[GenerateClientCertificate] -> ShowS
GenerateClientCertificate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GenerateClientCertificate] -> ShowS
$cshowList :: [GenerateClientCertificate] -> ShowS
show :: GenerateClientCertificate -> String
$cshow :: GenerateClientCertificate -> String
showsPrec :: Int -> GenerateClientCertificate -> ShowS
$cshowsPrec :: Int -> GenerateClientCertificate -> ShowS
Prelude.Show, forall x.
Rep GenerateClientCertificate x -> GenerateClientCertificate
forall x.
GenerateClientCertificate -> Rep GenerateClientCertificate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GenerateClientCertificate x -> GenerateClientCertificate
$cfrom :: forall x.
GenerateClientCertificate -> Rep GenerateClientCertificate x
Prelude.Generic)

-- |
-- Create a value of 'GenerateClientCertificate' 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:
--
-- 'description', 'generateClientCertificate_description' - The description of the ClientCertificate.
--
-- 'tags', 'generateClientCertificate_tags' - The key-value map of strings. The valid character set is
-- [a-zA-Z+-=._:\/]. The tag key can be up to 128 characters and must not
-- start with @aws:@. The tag value can be up to 256 characters.
newGenerateClientCertificate ::
  GenerateClientCertificate
newGenerateClientCertificate :: GenerateClientCertificate
newGenerateClientCertificate =
  GenerateClientCertificate'
    { $sel:description:GenerateClientCertificate' :: Maybe Text
description =
        forall a. Maybe a
Prelude.Nothing,
      $sel:tags:GenerateClientCertificate' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing
    }

-- | The description of the ClientCertificate.
generateClientCertificate_description :: Lens.Lens' GenerateClientCertificate (Prelude.Maybe Prelude.Text)
generateClientCertificate_description :: Lens' GenerateClientCertificate (Maybe Text)
generateClientCertificate_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenerateClientCertificate' {Maybe Text
description :: Maybe Text
$sel:description:GenerateClientCertificate' :: GenerateClientCertificate -> Maybe Text
description} -> Maybe Text
description) (\s :: GenerateClientCertificate
s@GenerateClientCertificate' {} Maybe Text
a -> GenerateClientCertificate
s {$sel:description:GenerateClientCertificate' :: Maybe Text
description = Maybe Text
a} :: GenerateClientCertificate)

-- | The key-value map of strings. The valid character set is
-- [a-zA-Z+-=._:\/]. The tag key can be up to 128 characters and must not
-- start with @aws:@. The tag value can be up to 256 characters.
generateClientCertificate_tags :: Lens.Lens' GenerateClientCertificate (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
generateClientCertificate_tags :: Lens' GenerateClientCertificate (Maybe (HashMap Text Text))
generateClientCertificate_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GenerateClientCertificate' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:GenerateClientCertificate' :: GenerateClientCertificate -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: GenerateClientCertificate
s@GenerateClientCertificate' {} Maybe (HashMap Text Text)
a -> GenerateClientCertificate
s {$sel:tags:GenerateClientCertificate' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: GenerateClientCertificate) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest GenerateClientCertificate where
  type
    AWSResponse GenerateClientCertificate =
      ClientCertificate
  request :: (Service -> Service)
-> GenerateClientCertificate -> Request GenerateClientCertificate
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GenerateClientCertificate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GenerateClientCertificate)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

instance Prelude.Hashable GenerateClientCertificate where
  hashWithSalt :: Int -> GenerateClientCertificate -> Int
hashWithSalt Int
_salt GenerateClientCertificate' {Maybe Text
Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
$sel:tags:GenerateClientCertificate' :: GenerateClientCertificate -> Maybe (HashMap Text Text)
$sel:description:GenerateClientCertificate' :: GenerateClientCertificate -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
tags

instance Prelude.NFData GenerateClientCertificate where
  rnf :: GenerateClientCertificate -> ()
rnf GenerateClientCertificate' {Maybe Text
Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
$sel:tags:GenerateClientCertificate' :: GenerateClientCertificate -> Maybe (HashMap Text Text)
$sel:description:GenerateClientCertificate' :: GenerateClientCertificate -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags

instance Data.ToHeaders GenerateClientCertificate where
  toHeaders :: GenerateClientCertificate -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Accept"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/json" :: Prelude.ByteString)
          ]
      )

instance Data.ToJSON GenerateClientCertificate where
  toJSON :: GenerateClientCertificate -> Value
toJSON GenerateClientCertificate' {Maybe Text
Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
$sel:tags:GenerateClientCertificate' :: GenerateClientCertificate -> Maybe (HashMap Text Text)
$sel:description:GenerateClientCertificate' :: GenerateClientCertificate -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"description" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Key
"tags" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags
          ]
      )

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

instance Data.ToQuery GenerateClientCertificate where
  toQuery :: GenerateClientCertificate -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty