{-# 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 #-}
module Amazonka.APIGateway.CreateApiKey
(
CreateApiKey (..),
newCreateApiKey,
createApiKey_enabled,
createApiKey_value,
createApiKey_customerId,
createApiKey_generateDistinctId,
createApiKey_name,
createApiKey_stageKeys,
createApiKey_description,
createApiKey_tags,
ApiKey (..),
newApiKey,
apiKey_enabled,
apiKey_value,
apiKey_customerId,
apiKey_createdDate,
apiKey_name,
apiKey_id,
apiKey_stageKeys,
apiKey_lastUpdatedDate,
apiKey_description,
apiKey_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
data CreateApiKey = CreateApiKey'
{
CreateApiKey -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
CreateApiKey -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
CreateApiKey -> Maybe Text
customerId :: Prelude.Maybe Prelude.Text,
CreateApiKey -> Maybe Bool
generateDistinctId :: Prelude.Maybe Prelude.Bool,
CreateApiKey -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
CreateApiKey -> Maybe [StageKey]
stageKeys :: Prelude.Maybe [StageKey],
CreateApiKey -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
CreateApiKey -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
}
deriving (CreateApiKey -> CreateApiKey -> Bool
(CreateApiKey -> CreateApiKey -> Bool)
-> (CreateApiKey -> CreateApiKey -> Bool) -> Eq CreateApiKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateApiKey -> CreateApiKey -> Bool
$c/= :: CreateApiKey -> CreateApiKey -> Bool
== :: CreateApiKey -> CreateApiKey -> Bool
$c== :: CreateApiKey -> CreateApiKey -> Bool
Prelude.Eq, ReadPrec [CreateApiKey]
ReadPrec CreateApiKey
Int -> ReadS CreateApiKey
ReadS [CreateApiKey]
(Int -> ReadS CreateApiKey)
-> ReadS [CreateApiKey]
-> ReadPrec CreateApiKey
-> ReadPrec [CreateApiKey]
-> Read CreateApiKey
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateApiKey]
$creadListPrec :: ReadPrec [CreateApiKey]
readPrec :: ReadPrec CreateApiKey
$creadPrec :: ReadPrec CreateApiKey
readList :: ReadS [CreateApiKey]
$creadList :: ReadS [CreateApiKey]
readsPrec :: Int -> ReadS CreateApiKey
$creadsPrec :: Int -> ReadS CreateApiKey
Prelude.Read, Int -> CreateApiKey -> ShowS
[CreateApiKey] -> ShowS
CreateApiKey -> String
(Int -> CreateApiKey -> ShowS)
-> (CreateApiKey -> String)
-> ([CreateApiKey] -> ShowS)
-> Show CreateApiKey
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateApiKey] -> ShowS
$cshowList :: [CreateApiKey] -> ShowS
show :: CreateApiKey -> String
$cshow :: CreateApiKey -> String
showsPrec :: Int -> CreateApiKey -> ShowS
$cshowsPrec :: Int -> CreateApiKey -> ShowS
Prelude.Show, (forall x. CreateApiKey -> Rep CreateApiKey x)
-> (forall x. Rep CreateApiKey x -> CreateApiKey)
-> Generic CreateApiKey
forall x. Rep CreateApiKey x -> CreateApiKey
forall x. CreateApiKey -> Rep CreateApiKey x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateApiKey x -> CreateApiKey
$cfrom :: forall x. CreateApiKey -> Rep CreateApiKey x
Prelude.Generic)
newCreateApiKey ::
CreateApiKey
newCreateApiKey :: CreateApiKey
newCreateApiKey =
CreateApiKey' :: Maybe Bool
-> Maybe Text
-> Maybe Text
-> Maybe Bool
-> Maybe Text
-> Maybe [StageKey]
-> Maybe Text
-> Maybe (HashMap Text Text)
-> CreateApiKey
CreateApiKey'
{ $sel:enabled:CreateApiKey' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:value:CreateApiKey' :: Maybe Text
value = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:customerId:CreateApiKey' :: Maybe Text
customerId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:generateDistinctId:CreateApiKey' :: Maybe Bool
generateDistinctId = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
$sel:name:CreateApiKey' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:stageKeys:CreateApiKey' :: Maybe [StageKey]
stageKeys = Maybe [StageKey]
forall a. Maybe a
Prelude.Nothing,
$sel:description:CreateApiKey' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateApiKey' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
}
createApiKey_enabled :: Lens.Lens' CreateApiKey (Prelude.Maybe Prelude.Bool)
createApiKey_enabled :: (Maybe Bool -> f (Maybe Bool)) -> CreateApiKey -> f CreateApiKey
createApiKey_enabled = (CreateApiKey -> Maybe Bool)
-> (CreateApiKey -> Maybe Bool -> CreateApiKey)
-> Lens CreateApiKey CreateApiKey (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApiKey' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:CreateApiKey' :: CreateApiKey -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: CreateApiKey
s@CreateApiKey' {} Maybe Bool
a -> CreateApiKey
s {$sel:enabled:CreateApiKey' :: Maybe Bool
enabled = Maybe Bool
a} :: CreateApiKey)
createApiKey_value :: Lens.Lens' CreateApiKey (Prelude.Maybe Prelude.Text)
createApiKey_value :: (Maybe Text -> f (Maybe Text)) -> CreateApiKey -> f CreateApiKey
createApiKey_value = (CreateApiKey -> Maybe Text)
-> (CreateApiKey -> Maybe Text -> CreateApiKey)
-> Lens CreateApiKey CreateApiKey (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApiKey' {Maybe Text
value :: Maybe Text
$sel:value:CreateApiKey' :: CreateApiKey -> Maybe Text
value} -> Maybe Text
value) (\s :: CreateApiKey
s@CreateApiKey' {} Maybe Text
a -> CreateApiKey
s {$sel:value:CreateApiKey' :: Maybe Text
value = Maybe Text
a} :: CreateApiKey)
createApiKey_customerId :: Lens.Lens' CreateApiKey (Prelude.Maybe Prelude.Text)
createApiKey_customerId :: (Maybe Text -> f (Maybe Text)) -> CreateApiKey -> f CreateApiKey
createApiKey_customerId = (CreateApiKey -> Maybe Text)
-> (CreateApiKey -> Maybe Text -> CreateApiKey)
-> Lens CreateApiKey CreateApiKey (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApiKey' {Maybe Text
customerId :: Maybe Text
$sel:customerId:CreateApiKey' :: CreateApiKey -> Maybe Text
customerId} -> Maybe Text
customerId) (\s :: CreateApiKey
s@CreateApiKey' {} Maybe Text
a -> CreateApiKey
s {$sel:customerId:CreateApiKey' :: Maybe Text
customerId = Maybe Text
a} :: CreateApiKey)
createApiKey_generateDistinctId :: Lens.Lens' CreateApiKey (Prelude.Maybe Prelude.Bool)
createApiKey_generateDistinctId :: (Maybe Bool -> f (Maybe Bool)) -> CreateApiKey -> f CreateApiKey
createApiKey_generateDistinctId = (CreateApiKey -> Maybe Bool)
-> (CreateApiKey -> Maybe Bool -> CreateApiKey)
-> Lens CreateApiKey CreateApiKey (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApiKey' {Maybe Bool
generateDistinctId :: Maybe Bool
$sel:generateDistinctId:CreateApiKey' :: CreateApiKey -> Maybe Bool
generateDistinctId} -> Maybe Bool
generateDistinctId) (\s :: CreateApiKey
s@CreateApiKey' {} Maybe Bool
a -> CreateApiKey
s {$sel:generateDistinctId:CreateApiKey' :: Maybe Bool
generateDistinctId = Maybe Bool
a} :: CreateApiKey)
createApiKey_name :: Lens.Lens' CreateApiKey (Prelude.Maybe Prelude.Text)
createApiKey_name :: (Maybe Text -> f (Maybe Text)) -> CreateApiKey -> f CreateApiKey
createApiKey_name = (CreateApiKey -> Maybe Text)
-> (CreateApiKey -> Maybe Text -> CreateApiKey)
-> Lens CreateApiKey CreateApiKey (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApiKey' {Maybe Text
name :: Maybe Text
$sel:name:CreateApiKey' :: CreateApiKey -> Maybe Text
name} -> Maybe Text
name) (\s :: CreateApiKey
s@CreateApiKey' {} Maybe Text
a -> CreateApiKey
s {$sel:name:CreateApiKey' :: Maybe Text
name = Maybe Text
a} :: CreateApiKey)
createApiKey_stageKeys :: Lens.Lens' CreateApiKey (Prelude.Maybe [StageKey])
createApiKey_stageKeys :: (Maybe [StageKey] -> f (Maybe [StageKey]))
-> CreateApiKey -> f CreateApiKey
createApiKey_stageKeys = (CreateApiKey -> Maybe [StageKey])
-> (CreateApiKey -> Maybe [StageKey] -> CreateApiKey)
-> Lens
CreateApiKey CreateApiKey (Maybe [StageKey]) (Maybe [StageKey])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApiKey' {Maybe [StageKey]
stageKeys :: Maybe [StageKey]
$sel:stageKeys:CreateApiKey' :: CreateApiKey -> Maybe [StageKey]
stageKeys} -> Maybe [StageKey]
stageKeys) (\s :: CreateApiKey
s@CreateApiKey' {} Maybe [StageKey]
a -> CreateApiKey
s {$sel:stageKeys:CreateApiKey' :: Maybe [StageKey]
stageKeys = Maybe [StageKey]
a} :: CreateApiKey) ((Maybe [StageKey] -> f (Maybe [StageKey]))
-> CreateApiKey -> f CreateApiKey)
-> ((Maybe [StageKey] -> f (Maybe [StageKey]))
-> Maybe [StageKey] -> f (Maybe [StageKey]))
-> (Maybe [StageKey] -> f (Maybe [StageKey]))
-> CreateApiKey
-> f CreateApiKey
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [StageKey] [StageKey] [StageKey] [StageKey]
-> Iso
(Maybe [StageKey])
(Maybe [StageKey])
(Maybe [StageKey])
(Maybe [StageKey])
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 [StageKey] [StageKey] [StageKey] [StageKey]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createApiKey_description :: Lens.Lens' CreateApiKey (Prelude.Maybe Prelude.Text)
createApiKey_description :: (Maybe Text -> f (Maybe Text)) -> CreateApiKey -> f CreateApiKey
createApiKey_description = (CreateApiKey -> Maybe Text)
-> (CreateApiKey -> Maybe Text -> CreateApiKey)
-> Lens CreateApiKey CreateApiKey (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateApiKey' {Maybe Text
description :: Maybe Text
$sel:description:CreateApiKey' :: CreateApiKey -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateApiKey
s@CreateApiKey' {} Maybe Text
a -> CreateApiKey
s {$sel:description:CreateApiKey' :: Maybe Text
description = Maybe Text
a} :: CreateApiKey)
createApiKey_tags :: Lens.Lens' CreateApiKey (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createApiKey_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateApiKey -> f CreateApiKey
createApiKey_tags = (CreateApiKey -> Maybe (HashMap Text Text))
-> (CreateApiKey -> Maybe (HashMap Text Text) -> CreateApiKey)
-> Lens
CreateApiKey
CreateApiKey
(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 (\CreateApiKey' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateApiKey' :: CreateApiKey -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateApiKey
s@CreateApiKey' {} Maybe (HashMap Text Text)
a -> CreateApiKey
s {$sel:tags:CreateApiKey' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateApiKey) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateApiKey -> f CreateApiKey)
-> ((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)))
-> CreateApiKey
-> f CreateApiKey
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
instance Core.AWSRequest CreateApiKey where
type AWSResponse CreateApiKey = ApiKey
request :: CreateApiKey -> Request CreateApiKey
request = Service -> CreateApiKey -> Request CreateApiKey
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateApiKey
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateApiKey)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateApiKey))
-> Logger
-> Service
-> Proxy CreateApiKey
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateApiKey)))
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 ApiKey
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
instance Prelude.Hashable CreateApiKey
instance Prelude.NFData CreateApiKey
instance Core.ToHeaders CreateApiKey where
toHeaders :: CreateApiKey -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateApiKey -> 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 CreateApiKey where
toJSON :: CreateApiKey -> Value
toJSON CreateApiKey' {Maybe Bool
Maybe [StageKey]
Maybe Text
Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
description :: Maybe Text
stageKeys :: Maybe [StageKey]
name :: Maybe Text
generateDistinctId :: Maybe Bool
customerId :: Maybe Text
value :: Maybe Text
enabled :: Maybe Bool
$sel:tags:CreateApiKey' :: CreateApiKey -> Maybe (HashMap Text Text)
$sel:description:CreateApiKey' :: CreateApiKey -> Maybe Text
$sel:stageKeys:CreateApiKey' :: CreateApiKey -> Maybe [StageKey]
$sel:name:CreateApiKey' :: CreateApiKey -> Maybe Text
$sel:generateDistinctId:CreateApiKey' :: CreateApiKey -> Maybe Bool
$sel:customerId:CreateApiKey' :: CreateApiKey -> Maybe Text
$sel:value:CreateApiKey' :: CreateApiKey -> Maybe Text
$sel:enabled:CreateApiKey' :: CreateApiKey -> Maybe Bool
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"enabled" 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
enabled,
(Text
"value" 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
value,
(Text
"customerId" 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
customerId,
(Text
"generateDistinctId" 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
generateDistinctId,
(Text
"name" 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
name,
(Text
"stageKeys" Text -> [StageKey] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([StageKey] -> Pair) -> Maybe [StageKey] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [StageKey]
stageKeys,
(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
]
)
instance Core.ToPath CreateApiKey where
toPath :: CreateApiKey -> ByteString
toPath = ByteString -> CreateApiKey -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/apikeys"
instance Core.ToQuery CreateApiKey where
toQuery :: CreateApiKey -> QueryString
toQuery = QueryString -> CreateApiKey -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty