{-# 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.CreateRestApi
-- 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)
--
-- Creates a new RestApi resource.
module Amazonka.APIGateway.CreateRestApi
  ( -- * Creating a Request
    CreateRestApi (..),
    newCreateRestApi,

    -- * Request Lenses
    createRestApi_minimumCompressionSize,
    createRestApi_disableExecuteApiEndpoint,
    createRestApi_binaryMediaTypes,
    createRestApi_version,
    createRestApi_apiKeySource,
    createRestApi_cloneFrom,
    createRestApi_policy,
    createRestApi_endpointConfiguration,
    createRestApi_description,
    createRestApi_tags,
    createRestApi_name,

    -- * Destructuring the Response
    RestApi (..),
    newRestApi,

    -- * Response Lenses
    restApi_minimumCompressionSize,
    restApi_disableExecuteApiEndpoint,
    restApi_binaryMediaTypes,
    restApi_warnings,
    restApi_createdDate,
    restApi_name,
    restApi_version,
    restApi_apiKeySource,
    restApi_id,
    restApi_policy,
    restApi_endpointConfiguration,
    restApi_description,
    restApi_tags,
  )
where

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

-- | The POST Request to add a new RestApi resource to your collection.
--
-- /See:/ 'newCreateRestApi' smart constructor.
data CreateRestApi = CreateRestApi'
  { -- | A nullable integer that is used to enable compression (with non-negative
    -- between 0 and 10485760 (10M) bytes, inclusive) or disable compression
    -- (with a null value) on an API. When compression is enabled, compression
    -- or decompression is not applied on the payload if the payload size is
    -- smaller than this value. Setting it to zero allows compression for any
    -- payload size.
    CreateRestApi -> Maybe Int
minimumCompressionSize :: Prelude.Maybe Prelude.Int,
    -- | Specifies whether clients can invoke your API by using the default
    -- @execute-api@ endpoint. By default, clients can invoke your API with the
    -- default https:\/\/{api_id}.execute-api.{region}.amazonaws.com endpoint.
    -- To require that clients use a custom domain name to invoke your API,
    -- disable the default endpoint.
    CreateRestApi -> Maybe Bool
disableExecuteApiEndpoint :: Prelude.Maybe Prelude.Bool,
    -- | The list of binary media types supported by the RestApi. By default, the
    -- RestApi supports only UTF-8-encoded text payloads.
    CreateRestApi -> Maybe [Text]
binaryMediaTypes :: Prelude.Maybe [Prelude.Text],
    -- | A version identifier for the API.
    CreateRestApi -> Maybe Text
version :: Prelude.Maybe Prelude.Text,
    -- | The source of the API key for metering requests according to a usage
    -- plan. Valid values are:
    --
    -- -   @HEADER@ to read the API key from the @X-API-Key@ header of a
    --     request.
    -- -   @AUTHORIZER@ to read the API key from the @UsageIdentifierKey@ from
    --     a custom authorizer.
    CreateRestApi -> Maybe ApiKeySourceType
apiKeySource :: Prelude.Maybe ApiKeySourceType,
    -- | The ID of the RestApi that you want to clone from.
    CreateRestApi -> Maybe Text
cloneFrom :: Prelude.Maybe Prelude.Text,
    -- | A stringified JSON policy document that applies to this RestApi
    -- regardless of the caller and Method configuration.
    CreateRestApi -> Maybe Text
policy :: Prelude.Maybe Prelude.Text,
    -- | The endpoint configuration of this RestApi showing the endpoint types of
    -- the API.
    CreateRestApi -> Maybe EndpointConfiguration
endpointConfiguration :: Prelude.Maybe EndpointConfiguration,
    -- | The description of the RestApi.
    CreateRestApi -> 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.
    CreateRestApi -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | [Required] The name of the RestApi.
    CreateRestApi -> Text
name :: Prelude.Text
  }
  deriving (CreateRestApi -> CreateRestApi -> Bool
(CreateRestApi -> CreateRestApi -> Bool)
-> (CreateRestApi -> CreateRestApi -> Bool) -> Eq CreateRestApi
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRestApi -> CreateRestApi -> Bool
$c/= :: CreateRestApi -> CreateRestApi -> Bool
== :: CreateRestApi -> CreateRestApi -> Bool
$c== :: CreateRestApi -> CreateRestApi -> Bool
Prelude.Eq, ReadPrec [CreateRestApi]
ReadPrec CreateRestApi
Int -> ReadS CreateRestApi
ReadS [CreateRestApi]
(Int -> ReadS CreateRestApi)
-> ReadS [CreateRestApi]
-> ReadPrec CreateRestApi
-> ReadPrec [CreateRestApi]
-> Read CreateRestApi
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateRestApi]
$creadListPrec :: ReadPrec [CreateRestApi]
readPrec :: ReadPrec CreateRestApi
$creadPrec :: ReadPrec CreateRestApi
readList :: ReadS [CreateRestApi]
$creadList :: ReadS [CreateRestApi]
readsPrec :: Int -> ReadS CreateRestApi
$creadsPrec :: Int -> ReadS CreateRestApi
Prelude.Read, Int -> CreateRestApi -> ShowS
[CreateRestApi] -> ShowS
CreateRestApi -> String
(Int -> CreateRestApi -> ShowS)
-> (CreateRestApi -> String)
-> ([CreateRestApi] -> ShowS)
-> Show CreateRestApi
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRestApi] -> ShowS
$cshowList :: [CreateRestApi] -> ShowS
show :: CreateRestApi -> String
$cshow :: CreateRestApi -> String
showsPrec :: Int -> CreateRestApi -> ShowS
$cshowsPrec :: Int -> CreateRestApi -> ShowS
Prelude.Show, (forall x. CreateRestApi -> Rep CreateRestApi x)
-> (forall x. Rep CreateRestApi x -> CreateRestApi)
-> Generic CreateRestApi
forall x. Rep CreateRestApi x -> CreateRestApi
forall x. CreateRestApi -> Rep CreateRestApi x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateRestApi x -> CreateRestApi
$cfrom :: forall x. CreateRestApi -> Rep CreateRestApi x
Prelude.Generic)

-- |
-- Create a value of 'CreateRestApi' 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:
--
-- 'minimumCompressionSize', 'createRestApi_minimumCompressionSize' - A nullable integer that is used to enable compression (with non-negative
-- between 0 and 10485760 (10M) bytes, inclusive) or disable compression
-- (with a null value) on an API. When compression is enabled, compression
-- or decompression is not applied on the payload if the payload size is
-- smaller than this value. Setting it to zero allows compression for any
-- payload size.
--
-- 'disableExecuteApiEndpoint', 'createRestApi_disableExecuteApiEndpoint' - Specifies whether clients can invoke your API by using the default
-- @execute-api@ endpoint. By default, clients can invoke your API with the
-- default https:\/\/{api_id}.execute-api.{region}.amazonaws.com endpoint.
-- To require that clients use a custom domain name to invoke your API,
-- disable the default endpoint.
--
-- 'binaryMediaTypes', 'createRestApi_binaryMediaTypes' - The list of binary media types supported by the RestApi. By default, the
-- RestApi supports only UTF-8-encoded text payloads.
--
-- 'version', 'createRestApi_version' - A version identifier for the API.
--
-- 'apiKeySource', 'createRestApi_apiKeySource' - The source of the API key for metering requests according to a usage
-- plan. Valid values are:
--
-- -   @HEADER@ to read the API key from the @X-API-Key@ header of a
--     request.
-- -   @AUTHORIZER@ to read the API key from the @UsageIdentifierKey@ from
--     a custom authorizer.
--
-- 'cloneFrom', 'createRestApi_cloneFrom' - The ID of the RestApi that you want to clone from.
--
-- 'policy', 'createRestApi_policy' - A stringified JSON policy document that applies to this RestApi
-- regardless of the caller and Method configuration.
--
-- 'endpointConfiguration', 'createRestApi_endpointConfiguration' - The endpoint configuration of this RestApi showing the endpoint types of
-- the API.
--
-- 'description', 'createRestApi_description' - The description of the RestApi.
--
-- 'tags', 'createRestApi_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.
--
-- 'name', 'createRestApi_name' - [Required] The name of the RestApi.
newCreateRestApi ::
  -- | 'name'
  Prelude.Text ->
  CreateRestApi
newCreateRestApi :: Text -> CreateRestApi
newCreateRestApi Text
pName_ =
  CreateRestApi' :: Maybe Int
-> Maybe Bool
-> Maybe [Text]
-> Maybe Text
-> Maybe ApiKeySourceType
-> Maybe Text
-> Maybe Text
-> Maybe EndpointConfiguration
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Text
-> CreateRestApi
CreateRestApi'
    { $sel:minimumCompressionSize:CreateRestApi' :: Maybe Int
minimumCompressionSize =
        Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:disableExecuteApiEndpoint:CreateRestApi' :: Maybe Bool
disableExecuteApiEndpoint = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:binaryMediaTypes:CreateRestApi' :: Maybe [Text]
binaryMediaTypes = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:version:CreateRestApi' :: Maybe Text
version = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:apiKeySource:CreateRestApi' :: Maybe ApiKeySourceType
apiKeySource = Maybe ApiKeySourceType
forall a. Maybe a
Prelude.Nothing,
      $sel:cloneFrom:CreateRestApi' :: Maybe Text
cloneFrom = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:policy:CreateRestApi' :: Maybe Text
policy = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endpointConfiguration:CreateRestApi' :: Maybe EndpointConfiguration
endpointConfiguration = Maybe EndpointConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:description:CreateRestApi' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:CreateRestApi' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:name:CreateRestApi' :: Text
name = Text
pName_
    }

-- | A nullable integer that is used to enable compression (with non-negative
-- between 0 and 10485760 (10M) bytes, inclusive) or disable compression
-- (with a null value) on an API. When compression is enabled, compression
-- or decompression is not applied on the payload if the payload size is
-- smaller than this value. Setting it to zero allows compression for any
-- payload size.
createRestApi_minimumCompressionSize :: Lens.Lens' CreateRestApi (Prelude.Maybe Prelude.Int)
createRestApi_minimumCompressionSize :: (Maybe Int -> f (Maybe Int)) -> CreateRestApi -> f CreateRestApi
createRestApi_minimumCompressionSize = (CreateRestApi -> Maybe Int)
-> (CreateRestApi -> Maybe Int -> CreateRestApi)
-> Lens CreateRestApi CreateRestApi (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRestApi' {Maybe Int
minimumCompressionSize :: Maybe Int
$sel:minimumCompressionSize:CreateRestApi' :: CreateRestApi -> Maybe Int
minimumCompressionSize} -> Maybe Int
minimumCompressionSize) (\s :: CreateRestApi
s@CreateRestApi' {} Maybe Int
a -> CreateRestApi
s {$sel:minimumCompressionSize:CreateRestApi' :: Maybe Int
minimumCompressionSize = Maybe Int
a} :: CreateRestApi)

-- | Specifies whether clients can invoke your API by using the default
-- @execute-api@ endpoint. By default, clients can invoke your API with the
-- default https:\/\/{api_id}.execute-api.{region}.amazonaws.com endpoint.
-- To require that clients use a custom domain name to invoke your API,
-- disable the default endpoint.
createRestApi_disableExecuteApiEndpoint :: Lens.Lens' CreateRestApi (Prelude.Maybe Prelude.Bool)
createRestApi_disableExecuteApiEndpoint :: (Maybe Bool -> f (Maybe Bool)) -> CreateRestApi -> f CreateRestApi
createRestApi_disableExecuteApiEndpoint = (CreateRestApi -> Maybe Bool)
-> (CreateRestApi -> Maybe Bool -> CreateRestApi)
-> Lens CreateRestApi CreateRestApi (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRestApi' {Maybe Bool
disableExecuteApiEndpoint :: Maybe Bool
$sel:disableExecuteApiEndpoint:CreateRestApi' :: CreateRestApi -> Maybe Bool
disableExecuteApiEndpoint} -> Maybe Bool
disableExecuteApiEndpoint) (\s :: CreateRestApi
s@CreateRestApi' {} Maybe Bool
a -> CreateRestApi
s {$sel:disableExecuteApiEndpoint:CreateRestApi' :: Maybe Bool
disableExecuteApiEndpoint = Maybe Bool
a} :: CreateRestApi)

-- | The list of binary media types supported by the RestApi. By default, the
-- RestApi supports only UTF-8-encoded text payloads.
createRestApi_binaryMediaTypes :: Lens.Lens' CreateRestApi (Prelude.Maybe [Prelude.Text])
createRestApi_binaryMediaTypes :: (Maybe [Text] -> f (Maybe [Text]))
-> CreateRestApi -> f CreateRestApi
createRestApi_binaryMediaTypes = (CreateRestApi -> Maybe [Text])
-> (CreateRestApi -> Maybe [Text] -> CreateRestApi)
-> Lens CreateRestApi CreateRestApi (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRestApi' {Maybe [Text]
binaryMediaTypes :: Maybe [Text]
$sel:binaryMediaTypes:CreateRestApi' :: CreateRestApi -> Maybe [Text]
binaryMediaTypes} -> Maybe [Text]
binaryMediaTypes) (\s :: CreateRestApi
s@CreateRestApi' {} Maybe [Text]
a -> CreateRestApi
s {$sel:binaryMediaTypes:CreateRestApi' :: Maybe [Text]
binaryMediaTypes = Maybe [Text]
a} :: CreateRestApi) ((Maybe [Text] -> f (Maybe [Text]))
 -> CreateRestApi -> f CreateRestApi)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> CreateRestApi
-> f CreateRestApi
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A version identifier for the API.
createRestApi_version :: Lens.Lens' CreateRestApi (Prelude.Maybe Prelude.Text)
createRestApi_version :: (Maybe Text -> f (Maybe Text)) -> CreateRestApi -> f CreateRestApi
createRestApi_version = (CreateRestApi -> Maybe Text)
-> (CreateRestApi -> Maybe Text -> CreateRestApi)
-> Lens CreateRestApi CreateRestApi (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRestApi' {Maybe Text
version :: Maybe Text
$sel:version:CreateRestApi' :: CreateRestApi -> Maybe Text
version} -> Maybe Text
version) (\s :: CreateRestApi
s@CreateRestApi' {} Maybe Text
a -> CreateRestApi
s {$sel:version:CreateRestApi' :: Maybe Text
version = Maybe Text
a} :: CreateRestApi)

-- | The source of the API key for metering requests according to a usage
-- plan. Valid values are:
--
-- -   @HEADER@ to read the API key from the @X-API-Key@ header of a
--     request.
-- -   @AUTHORIZER@ to read the API key from the @UsageIdentifierKey@ from
--     a custom authorizer.
createRestApi_apiKeySource :: Lens.Lens' CreateRestApi (Prelude.Maybe ApiKeySourceType)
createRestApi_apiKeySource :: (Maybe ApiKeySourceType -> f (Maybe ApiKeySourceType))
-> CreateRestApi -> f CreateRestApi
createRestApi_apiKeySource = (CreateRestApi -> Maybe ApiKeySourceType)
-> (CreateRestApi -> Maybe ApiKeySourceType -> CreateRestApi)
-> Lens
     CreateRestApi
     CreateRestApi
     (Maybe ApiKeySourceType)
     (Maybe ApiKeySourceType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRestApi' {Maybe ApiKeySourceType
apiKeySource :: Maybe ApiKeySourceType
$sel:apiKeySource:CreateRestApi' :: CreateRestApi -> Maybe ApiKeySourceType
apiKeySource} -> Maybe ApiKeySourceType
apiKeySource) (\s :: CreateRestApi
s@CreateRestApi' {} Maybe ApiKeySourceType
a -> CreateRestApi
s {$sel:apiKeySource:CreateRestApi' :: Maybe ApiKeySourceType
apiKeySource = Maybe ApiKeySourceType
a} :: CreateRestApi)

-- | The ID of the RestApi that you want to clone from.
createRestApi_cloneFrom :: Lens.Lens' CreateRestApi (Prelude.Maybe Prelude.Text)
createRestApi_cloneFrom :: (Maybe Text -> f (Maybe Text)) -> CreateRestApi -> f CreateRestApi
createRestApi_cloneFrom = (CreateRestApi -> Maybe Text)
-> (CreateRestApi -> Maybe Text -> CreateRestApi)
-> Lens CreateRestApi CreateRestApi (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRestApi' {Maybe Text
cloneFrom :: Maybe Text
$sel:cloneFrom:CreateRestApi' :: CreateRestApi -> Maybe Text
cloneFrom} -> Maybe Text
cloneFrom) (\s :: CreateRestApi
s@CreateRestApi' {} Maybe Text
a -> CreateRestApi
s {$sel:cloneFrom:CreateRestApi' :: Maybe Text
cloneFrom = Maybe Text
a} :: CreateRestApi)

-- | A stringified JSON policy document that applies to this RestApi
-- regardless of the caller and Method configuration.
createRestApi_policy :: Lens.Lens' CreateRestApi (Prelude.Maybe Prelude.Text)
createRestApi_policy :: (Maybe Text -> f (Maybe Text)) -> CreateRestApi -> f CreateRestApi
createRestApi_policy = (CreateRestApi -> Maybe Text)
-> (CreateRestApi -> Maybe Text -> CreateRestApi)
-> Lens CreateRestApi CreateRestApi (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRestApi' {Maybe Text
policy :: Maybe Text
$sel:policy:CreateRestApi' :: CreateRestApi -> Maybe Text
policy} -> Maybe Text
policy) (\s :: CreateRestApi
s@CreateRestApi' {} Maybe Text
a -> CreateRestApi
s {$sel:policy:CreateRestApi' :: Maybe Text
policy = Maybe Text
a} :: CreateRestApi)

-- | The endpoint configuration of this RestApi showing the endpoint types of
-- the API.
createRestApi_endpointConfiguration :: Lens.Lens' CreateRestApi (Prelude.Maybe EndpointConfiguration)
createRestApi_endpointConfiguration :: (Maybe EndpointConfiguration -> f (Maybe EndpointConfiguration))
-> CreateRestApi -> f CreateRestApi
createRestApi_endpointConfiguration = (CreateRestApi -> Maybe EndpointConfiguration)
-> (CreateRestApi -> Maybe EndpointConfiguration -> CreateRestApi)
-> Lens
     CreateRestApi
     CreateRestApi
     (Maybe EndpointConfiguration)
     (Maybe EndpointConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRestApi' {Maybe EndpointConfiguration
endpointConfiguration :: Maybe EndpointConfiguration
$sel:endpointConfiguration:CreateRestApi' :: CreateRestApi -> Maybe EndpointConfiguration
endpointConfiguration} -> Maybe EndpointConfiguration
endpointConfiguration) (\s :: CreateRestApi
s@CreateRestApi' {} Maybe EndpointConfiguration
a -> CreateRestApi
s {$sel:endpointConfiguration:CreateRestApi' :: Maybe EndpointConfiguration
endpointConfiguration = Maybe EndpointConfiguration
a} :: CreateRestApi)

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

-- | 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.
createRestApi_tags :: Lens.Lens' CreateRestApi (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createRestApi_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateRestApi -> f CreateRestApi
createRestApi_tags = (CreateRestApi -> Maybe (HashMap Text Text))
-> (CreateRestApi -> Maybe (HashMap Text Text) -> CreateRestApi)
-> Lens
     CreateRestApi
     CreateRestApi
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRestApi' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateRestApi' :: CreateRestApi -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateRestApi
s@CreateRestApi' {} Maybe (HashMap Text Text)
a -> CreateRestApi
s {$sel:tags:CreateRestApi' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateRestApi) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> CreateRestApi -> f CreateRestApi)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateRestApi
-> f CreateRestApi
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | [Required] The name of the RestApi.
createRestApi_name :: Lens.Lens' CreateRestApi Prelude.Text
createRestApi_name :: (Text -> f Text) -> CreateRestApi -> f CreateRestApi
createRestApi_name = (CreateRestApi -> Text)
-> (CreateRestApi -> Text -> CreateRestApi)
-> Lens CreateRestApi CreateRestApi Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRestApi' {Text
name :: Text
$sel:name:CreateRestApi' :: CreateRestApi -> Text
name} -> Text
name) (\s :: CreateRestApi
s@CreateRestApi' {} Text
a -> CreateRestApi
s {$sel:name:CreateRestApi' :: Text
name = Text
a} :: CreateRestApi)

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

instance Prelude.Hashable CreateRestApi

instance Prelude.NFData CreateRestApi

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

instance Core.ToJSON CreateRestApi where
  toJSON :: CreateRestApi -> Value
toJSON CreateRestApi' {Maybe Bool
Maybe Int
Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
Maybe ApiKeySourceType
Maybe EndpointConfiguration
Text
name :: Text
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
endpointConfiguration :: Maybe EndpointConfiguration
policy :: Maybe Text
cloneFrom :: Maybe Text
apiKeySource :: Maybe ApiKeySourceType
version :: Maybe Text
binaryMediaTypes :: Maybe [Text]
disableExecuteApiEndpoint :: Maybe Bool
minimumCompressionSize :: Maybe Int
$sel:name:CreateRestApi' :: CreateRestApi -> Text
$sel:tags:CreateRestApi' :: CreateRestApi -> Maybe (HashMap Text Text)
$sel:description:CreateRestApi' :: CreateRestApi -> Maybe Text
$sel:endpointConfiguration:CreateRestApi' :: CreateRestApi -> Maybe EndpointConfiguration
$sel:policy:CreateRestApi' :: CreateRestApi -> Maybe Text
$sel:cloneFrom:CreateRestApi' :: CreateRestApi -> Maybe Text
$sel:apiKeySource:CreateRestApi' :: CreateRestApi -> Maybe ApiKeySourceType
$sel:version:CreateRestApi' :: CreateRestApi -> Maybe Text
$sel:binaryMediaTypes:CreateRestApi' :: CreateRestApi -> Maybe [Text]
$sel:disableExecuteApiEndpoint:CreateRestApi' :: CreateRestApi -> Maybe Bool
$sel:minimumCompressionSize:CreateRestApi' :: CreateRestApi -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"minimumCompressionSize" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
minimumCompressionSize,
            (Text
"disableExecuteApiEndpoint" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
disableExecuteApiEndpoint,
            (Text
"binaryMediaTypes" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
binaryMediaTypes,
            (Text
"version" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
version,
            (Text
"apiKeySource" Text -> ApiKeySourceType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (ApiKeySourceType -> Pair) -> Maybe ApiKeySourceType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ApiKeySourceType
apiKeySource,
            (Text
"cloneFrom" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
cloneFrom,
            (Text
"policy" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
policy,
            (Text
"endpointConfiguration" Text -> EndpointConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (EndpointConfiguration -> Pair)
-> Maybe EndpointConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe EndpointConfiguration
endpointConfiguration,
            (Text
"description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            (Text
"tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)
          ]
      )

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

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