amazonka-apigateway-2.0: gen/Amazonka/APIGateway/CreateApiKey.hs
{-# 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.CreateApiKey
-- Copyright : (c) 2013-2023 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Create an ApiKey resource.
module Amazonka.APIGateway.CreateApiKey
( -- * Creating a Request
CreateApiKey (..),
newCreateApiKey,
-- * Request Lenses
createApiKey_customerId,
createApiKey_description,
createApiKey_enabled,
createApiKey_generateDistinctId,
createApiKey_name,
createApiKey_stageKeys,
createApiKey_tags,
createApiKey_value,
-- * Destructuring the Response
ApiKey (..),
newApiKey,
-- * Response Lenses
apiKey_createdDate,
apiKey_customerId,
apiKey_description,
apiKey_enabled,
apiKey_id,
apiKey_lastUpdatedDate,
apiKey_name,
apiKey_stageKeys,
apiKey_tags,
apiKey_value,
)
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
-- | Request to create an ApiKey resource.
--
-- /See:/ 'newCreateApiKey' smart constructor.
data CreateApiKey = CreateApiKey'
{ -- | An AWS Marketplace customer identifier , when integrating with the AWS
-- SaaS Marketplace.
customerId :: Prelude.Maybe Prelude.Text,
-- | The description of the ApiKey.
description :: Prelude.Maybe Prelude.Text,
-- | Specifies whether the ApiKey can be used by callers.
enabled :: Prelude.Maybe Prelude.Bool,
-- | Specifies whether (@true@) or not (@false@) the key identifier is
-- distinct from the created API key value. This parameter is deprecated
-- and should not be used.
generateDistinctId :: Prelude.Maybe Prelude.Bool,
-- | The name of the ApiKey.
name :: Prelude.Maybe Prelude.Text,
-- | DEPRECATED FOR USAGE PLANS - Specifies stages associated with the API
-- key.
stageKeys :: Prelude.Maybe [StageKey],
-- | 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.
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
-- | Specifies a value of the API key.
value :: Prelude.Maybe Prelude.Text
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'CreateApiKey' 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:
--
-- 'customerId', 'createApiKey_customerId' - An AWS Marketplace customer identifier , when integrating with the AWS
-- SaaS Marketplace.
--
-- 'description', 'createApiKey_description' - The description of the ApiKey.
--
-- 'enabled', 'createApiKey_enabled' - Specifies whether the ApiKey can be used by callers.
--
-- 'generateDistinctId', 'createApiKey_generateDistinctId' - Specifies whether (@true@) or not (@false@) the key identifier is
-- distinct from the created API key value. This parameter is deprecated
-- and should not be used.
--
-- 'name', 'createApiKey_name' - The name of the ApiKey.
--
-- 'stageKeys', 'createApiKey_stageKeys' - DEPRECATED FOR USAGE PLANS - Specifies stages associated with the API
-- key.
--
-- 'tags', 'createApiKey_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.
--
-- 'value', 'createApiKey_value' - Specifies a value of the API key.
newCreateApiKey ::
CreateApiKey
newCreateApiKey =
CreateApiKey'
{ customerId = Prelude.Nothing,
description = Prelude.Nothing,
enabled = Prelude.Nothing,
generateDistinctId = Prelude.Nothing,
name = Prelude.Nothing,
stageKeys = Prelude.Nothing,
tags = Prelude.Nothing,
value = Prelude.Nothing
}
-- | An AWS Marketplace customer identifier , when integrating with the AWS
-- SaaS Marketplace.
createApiKey_customerId :: Lens.Lens' CreateApiKey (Prelude.Maybe Prelude.Text)
createApiKey_customerId = Lens.lens (\CreateApiKey' {customerId} -> customerId) (\s@CreateApiKey' {} a -> s {customerId = a} :: CreateApiKey)
-- | The description of the ApiKey.
createApiKey_description :: Lens.Lens' CreateApiKey (Prelude.Maybe Prelude.Text)
createApiKey_description = Lens.lens (\CreateApiKey' {description} -> description) (\s@CreateApiKey' {} a -> s {description = a} :: CreateApiKey)
-- | Specifies whether the ApiKey can be used by callers.
createApiKey_enabled :: Lens.Lens' CreateApiKey (Prelude.Maybe Prelude.Bool)
createApiKey_enabled = Lens.lens (\CreateApiKey' {enabled} -> enabled) (\s@CreateApiKey' {} a -> s {enabled = a} :: CreateApiKey)
-- | Specifies whether (@true@) or not (@false@) the key identifier is
-- distinct from the created API key value. This parameter is deprecated
-- and should not be used.
createApiKey_generateDistinctId :: Lens.Lens' CreateApiKey (Prelude.Maybe Prelude.Bool)
createApiKey_generateDistinctId = Lens.lens (\CreateApiKey' {generateDistinctId} -> generateDistinctId) (\s@CreateApiKey' {} a -> s {generateDistinctId = a} :: CreateApiKey)
-- | The name of the ApiKey.
createApiKey_name :: Lens.Lens' CreateApiKey (Prelude.Maybe Prelude.Text)
createApiKey_name = Lens.lens (\CreateApiKey' {name} -> name) (\s@CreateApiKey' {} a -> s {name = a} :: CreateApiKey)
-- | DEPRECATED FOR USAGE PLANS - Specifies stages associated with the API
-- key.
createApiKey_stageKeys :: Lens.Lens' CreateApiKey (Prelude.Maybe [StageKey])
createApiKey_stageKeys = Lens.lens (\CreateApiKey' {stageKeys} -> stageKeys) (\s@CreateApiKey' {} a -> s {stageKeys = a} :: CreateApiKey) Prelude.. Lens.mapping Lens.coerced
-- | 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.
createApiKey_tags :: Lens.Lens' CreateApiKey (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createApiKey_tags = Lens.lens (\CreateApiKey' {tags} -> tags) (\s@CreateApiKey' {} a -> s {tags = a} :: CreateApiKey) Prelude.. Lens.mapping Lens.coerced
-- | Specifies a value of the API key.
createApiKey_value :: Lens.Lens' CreateApiKey (Prelude.Maybe Prelude.Text)
createApiKey_value = Lens.lens (\CreateApiKey' {value} -> value) (\s@CreateApiKey' {} a -> s {value = a} :: CreateApiKey)
instance Core.AWSRequest CreateApiKey where
type AWSResponse CreateApiKey = ApiKey
request overrides =
Request.postJSON (overrides defaultService)
response =
Response.receiveJSON
(\s h x -> Data.eitherParseJSON x)
instance Prelude.Hashable CreateApiKey where
hashWithSalt _salt CreateApiKey' {..} =
_salt
`Prelude.hashWithSalt` customerId
`Prelude.hashWithSalt` description
`Prelude.hashWithSalt` enabled
`Prelude.hashWithSalt` generateDistinctId
`Prelude.hashWithSalt` name
`Prelude.hashWithSalt` stageKeys
`Prelude.hashWithSalt` tags
`Prelude.hashWithSalt` value
instance Prelude.NFData CreateApiKey where
rnf CreateApiKey' {..} =
Prelude.rnf customerId
`Prelude.seq` Prelude.rnf description
`Prelude.seq` Prelude.rnf enabled
`Prelude.seq` Prelude.rnf generateDistinctId
`Prelude.seq` Prelude.rnf name
`Prelude.seq` Prelude.rnf stageKeys
`Prelude.seq` Prelude.rnf tags
`Prelude.seq` Prelude.rnf value
instance Data.ToHeaders CreateApiKey where
toHeaders =
Prelude.const
( Prelude.mconcat
[ "Accept"
Data.=# ("application/json" :: Prelude.ByteString)
]
)
instance Data.ToJSON CreateApiKey where
toJSON CreateApiKey' {..} =
Data.object
( Prelude.catMaybes
[ ("customerId" Data..=) Prelude.<$> customerId,
("description" Data..=) Prelude.<$> description,
("enabled" Data..=) Prelude.<$> enabled,
("generateDistinctId" Data..=)
Prelude.<$> generateDistinctId,
("name" Data..=) Prelude.<$> name,
("stageKeys" Data..=) Prelude.<$> stageKeys,
("tags" Data..=) Prelude.<$> tags,
("value" Data..=) Prelude.<$> value
]
)
instance Data.ToPath CreateApiKey where
toPath = Prelude.const "/apikeys"
instance Data.ToQuery CreateApiKey where
toQuery = Prelude.const Prelude.mempty