{-# 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.IoTSiteWise.CreateGateway
(
CreateGateway (..),
newCreateGateway,
createGateway_tags,
createGateway_gatewayName,
createGateway_gatewayPlatform,
CreateGatewayResponse (..),
newCreateGatewayResponse,
createGatewayResponse_httpStatus,
createGatewayResponse_gatewayId,
createGatewayResponse_gatewayArn,
)
where
import qualified Amazonka.Core as Core
import Amazonka.IoTSiteWise.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
data CreateGateway = CreateGateway'
{
CreateGateway -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
CreateGateway -> Text
gatewayName :: Prelude.Text,
CreateGateway -> GatewayPlatform
gatewayPlatform :: GatewayPlatform
}
deriving (CreateGateway -> CreateGateway -> Bool
(CreateGateway -> CreateGateway -> Bool)
-> (CreateGateway -> CreateGateway -> Bool) -> Eq CreateGateway
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateGateway -> CreateGateway -> Bool
$c/= :: CreateGateway -> CreateGateway -> Bool
== :: CreateGateway -> CreateGateway -> Bool
$c== :: CreateGateway -> CreateGateway -> Bool
Prelude.Eq, ReadPrec [CreateGateway]
ReadPrec CreateGateway
Int -> ReadS CreateGateway
ReadS [CreateGateway]
(Int -> ReadS CreateGateway)
-> ReadS [CreateGateway]
-> ReadPrec CreateGateway
-> ReadPrec [CreateGateway]
-> Read CreateGateway
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateGateway]
$creadListPrec :: ReadPrec [CreateGateway]
readPrec :: ReadPrec CreateGateway
$creadPrec :: ReadPrec CreateGateway
readList :: ReadS [CreateGateway]
$creadList :: ReadS [CreateGateway]
readsPrec :: Int -> ReadS CreateGateway
$creadsPrec :: Int -> ReadS CreateGateway
Prelude.Read, Int -> CreateGateway -> ShowS
[CreateGateway] -> ShowS
CreateGateway -> String
(Int -> CreateGateway -> ShowS)
-> (CreateGateway -> String)
-> ([CreateGateway] -> ShowS)
-> Show CreateGateway
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateGateway] -> ShowS
$cshowList :: [CreateGateway] -> ShowS
show :: CreateGateway -> String
$cshow :: CreateGateway -> String
showsPrec :: Int -> CreateGateway -> ShowS
$cshowsPrec :: Int -> CreateGateway -> ShowS
Prelude.Show, (forall x. CreateGateway -> Rep CreateGateway x)
-> (forall x. Rep CreateGateway x -> CreateGateway)
-> Generic CreateGateway
forall x. Rep CreateGateway x -> CreateGateway
forall x. CreateGateway -> Rep CreateGateway x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateGateway x -> CreateGateway
$cfrom :: forall x. CreateGateway -> Rep CreateGateway x
Prelude.Generic)
newCreateGateway ::
Prelude.Text ->
GatewayPlatform ->
CreateGateway
newCreateGateway :: Text -> GatewayPlatform -> CreateGateway
newCreateGateway Text
pGatewayName_ GatewayPlatform
pGatewayPlatform_ =
CreateGateway' :: Maybe (HashMap Text Text)
-> Text -> GatewayPlatform -> CreateGateway
CreateGateway'
{ $sel:tags:CreateGateway' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
$sel:gatewayName:CreateGateway' :: Text
gatewayName = Text
pGatewayName_,
$sel:gatewayPlatform:CreateGateway' :: GatewayPlatform
gatewayPlatform = GatewayPlatform
pGatewayPlatform_
}
createGateway_tags :: Lens.Lens' CreateGateway (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createGateway_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateGateway -> f CreateGateway
createGateway_tags = (CreateGateway -> Maybe (HashMap Text Text))
-> (CreateGateway -> Maybe (HashMap Text Text) -> CreateGateway)
-> Lens
CreateGateway
CreateGateway
(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 (\CreateGateway' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateGateway' :: CreateGateway -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateGateway
s@CreateGateway' {} Maybe (HashMap Text Text)
a -> CreateGateway
s {$sel:tags:CreateGateway' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateGateway) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateGateway -> f CreateGateway)
-> ((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)))
-> CreateGateway
-> f CreateGateway
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
createGateway_gatewayName :: Lens.Lens' CreateGateway Prelude.Text
createGateway_gatewayName :: (Text -> f Text) -> CreateGateway -> f CreateGateway
createGateway_gatewayName = (CreateGateway -> Text)
-> (CreateGateway -> Text -> CreateGateway)
-> Lens CreateGateway CreateGateway Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGateway' {Text
gatewayName :: Text
$sel:gatewayName:CreateGateway' :: CreateGateway -> Text
gatewayName} -> Text
gatewayName) (\s :: CreateGateway
s@CreateGateway' {} Text
a -> CreateGateway
s {$sel:gatewayName:CreateGateway' :: Text
gatewayName = Text
a} :: CreateGateway)
createGateway_gatewayPlatform :: Lens.Lens' CreateGateway GatewayPlatform
createGateway_gatewayPlatform :: (GatewayPlatform -> f GatewayPlatform)
-> CreateGateway -> f CreateGateway
createGateway_gatewayPlatform = (CreateGateway -> GatewayPlatform)
-> (CreateGateway -> GatewayPlatform -> CreateGateway)
-> Lens CreateGateway CreateGateway GatewayPlatform GatewayPlatform
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGateway' {GatewayPlatform
gatewayPlatform :: GatewayPlatform
$sel:gatewayPlatform:CreateGateway' :: CreateGateway -> GatewayPlatform
gatewayPlatform} -> GatewayPlatform
gatewayPlatform) (\s :: CreateGateway
s@CreateGateway' {} GatewayPlatform
a -> CreateGateway
s {$sel:gatewayPlatform:CreateGateway' :: GatewayPlatform
gatewayPlatform = GatewayPlatform
a} :: CreateGateway)
instance Core.AWSRequest CreateGateway where
type
AWSResponse CreateGateway =
CreateGatewayResponse
request :: CreateGateway -> Request CreateGateway
request = Service -> CreateGateway -> Request CreateGateway
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateGateway
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateGateway)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateGateway))
-> Logger
-> Service
-> Proxy CreateGateway
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateGateway)))
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 ->
Int -> Text -> Text -> CreateGatewayResponse
CreateGatewayResponse'
(Int -> Text -> Text -> CreateGatewayResponse)
-> Either String Int
-> Either String (Text -> Text -> CreateGatewayResponse)
forall (f :: * -> *) a b. Functor 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))
Either String (Text -> Text -> CreateGatewayResponse)
-> Either String Text
-> Either String (Text -> CreateGatewayResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"gatewayId")
Either String (Text -> CreateGatewayResponse)
-> Either String Text -> Either String CreateGatewayResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"gatewayArn")
)
instance Prelude.Hashable CreateGateway
instance Prelude.NFData CreateGateway
instance Core.ToHeaders CreateGateway where
toHeaders :: CreateGateway -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateGateway -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Content-Type"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
Prelude.ByteString
)
]
)
instance Core.ToJSON CreateGateway where
toJSON :: CreateGateway -> Value
toJSON CreateGateway' {Maybe (HashMap Text Text)
Text
GatewayPlatform
gatewayPlatform :: GatewayPlatform
gatewayName :: Text
tags :: Maybe (HashMap Text Text)
$sel:gatewayPlatform:CreateGateway' :: CreateGateway -> GatewayPlatform
$sel:gatewayName:CreateGateway' :: CreateGateway -> Text
$sel:tags:CreateGateway' :: CreateGateway -> Maybe (HashMap Text Text)
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (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
"gatewayName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
gatewayName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
(Text
"gatewayPlatform" Text -> GatewayPlatform -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= GatewayPlatform
gatewayPlatform)
]
)
instance Core.ToPath CreateGateway where
toPath :: CreateGateway -> ByteString
toPath = ByteString -> CreateGateway -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/20200301/gateways"
instance Core.ToQuery CreateGateway where
toQuery :: CreateGateway -> QueryString
toQuery = QueryString -> CreateGateway -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateGatewayResponse = CreateGatewayResponse'
{
CreateGatewayResponse -> Int
httpStatus :: Prelude.Int,
CreateGatewayResponse -> Text
gatewayId :: Prelude.Text,
CreateGatewayResponse -> Text
gatewayArn :: Prelude.Text
}
deriving (CreateGatewayResponse -> CreateGatewayResponse -> Bool
(CreateGatewayResponse -> CreateGatewayResponse -> Bool)
-> (CreateGatewayResponse -> CreateGatewayResponse -> Bool)
-> Eq CreateGatewayResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateGatewayResponse -> CreateGatewayResponse -> Bool
$c/= :: CreateGatewayResponse -> CreateGatewayResponse -> Bool
== :: CreateGatewayResponse -> CreateGatewayResponse -> Bool
$c== :: CreateGatewayResponse -> CreateGatewayResponse -> Bool
Prelude.Eq, ReadPrec [CreateGatewayResponse]
ReadPrec CreateGatewayResponse
Int -> ReadS CreateGatewayResponse
ReadS [CreateGatewayResponse]
(Int -> ReadS CreateGatewayResponse)
-> ReadS [CreateGatewayResponse]
-> ReadPrec CreateGatewayResponse
-> ReadPrec [CreateGatewayResponse]
-> Read CreateGatewayResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateGatewayResponse]
$creadListPrec :: ReadPrec [CreateGatewayResponse]
readPrec :: ReadPrec CreateGatewayResponse
$creadPrec :: ReadPrec CreateGatewayResponse
readList :: ReadS [CreateGatewayResponse]
$creadList :: ReadS [CreateGatewayResponse]
readsPrec :: Int -> ReadS CreateGatewayResponse
$creadsPrec :: Int -> ReadS CreateGatewayResponse
Prelude.Read, Int -> CreateGatewayResponse -> ShowS
[CreateGatewayResponse] -> ShowS
CreateGatewayResponse -> String
(Int -> CreateGatewayResponse -> ShowS)
-> (CreateGatewayResponse -> String)
-> ([CreateGatewayResponse] -> ShowS)
-> Show CreateGatewayResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateGatewayResponse] -> ShowS
$cshowList :: [CreateGatewayResponse] -> ShowS
show :: CreateGatewayResponse -> String
$cshow :: CreateGatewayResponse -> String
showsPrec :: Int -> CreateGatewayResponse -> ShowS
$cshowsPrec :: Int -> CreateGatewayResponse -> ShowS
Prelude.Show, (forall x. CreateGatewayResponse -> Rep CreateGatewayResponse x)
-> (forall x. Rep CreateGatewayResponse x -> CreateGatewayResponse)
-> Generic CreateGatewayResponse
forall x. Rep CreateGatewayResponse x -> CreateGatewayResponse
forall x. CreateGatewayResponse -> Rep CreateGatewayResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateGatewayResponse x -> CreateGatewayResponse
$cfrom :: forall x. CreateGatewayResponse -> Rep CreateGatewayResponse x
Prelude.Generic)
newCreateGatewayResponse ::
Prelude.Int ->
Prelude.Text ->
Prelude.Text ->
CreateGatewayResponse
newCreateGatewayResponse :: Int -> Text -> Text -> CreateGatewayResponse
newCreateGatewayResponse
Int
pHttpStatus_
Text
pGatewayId_
Text
pGatewayArn_ =
CreateGatewayResponse' :: Int -> Text -> Text -> CreateGatewayResponse
CreateGatewayResponse'
{ $sel:httpStatus:CreateGatewayResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:gatewayId:CreateGatewayResponse' :: Text
gatewayId = Text
pGatewayId_,
$sel:gatewayArn:CreateGatewayResponse' :: Text
gatewayArn = Text
pGatewayArn_
}
createGatewayResponse_httpStatus :: Lens.Lens' CreateGatewayResponse Prelude.Int
createGatewayResponse_httpStatus :: (Int -> f Int) -> CreateGatewayResponse -> f CreateGatewayResponse
createGatewayResponse_httpStatus = (CreateGatewayResponse -> Int)
-> (CreateGatewayResponse -> Int -> CreateGatewayResponse)
-> Lens CreateGatewayResponse CreateGatewayResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGatewayResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateGatewayResponse' :: CreateGatewayResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateGatewayResponse
s@CreateGatewayResponse' {} Int
a -> CreateGatewayResponse
s {$sel:httpStatus:CreateGatewayResponse' :: Int
httpStatus = Int
a} :: CreateGatewayResponse)
createGatewayResponse_gatewayId :: Lens.Lens' CreateGatewayResponse Prelude.Text
createGatewayResponse_gatewayId :: (Text -> f Text)
-> CreateGatewayResponse -> f CreateGatewayResponse
createGatewayResponse_gatewayId = (CreateGatewayResponse -> Text)
-> (CreateGatewayResponse -> Text -> CreateGatewayResponse)
-> Lens CreateGatewayResponse CreateGatewayResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGatewayResponse' {Text
gatewayId :: Text
$sel:gatewayId:CreateGatewayResponse' :: CreateGatewayResponse -> Text
gatewayId} -> Text
gatewayId) (\s :: CreateGatewayResponse
s@CreateGatewayResponse' {} Text
a -> CreateGatewayResponse
s {$sel:gatewayId:CreateGatewayResponse' :: Text
gatewayId = Text
a} :: CreateGatewayResponse)
createGatewayResponse_gatewayArn :: Lens.Lens' CreateGatewayResponse Prelude.Text
createGatewayResponse_gatewayArn :: (Text -> f Text)
-> CreateGatewayResponse -> f CreateGatewayResponse
createGatewayResponse_gatewayArn = (CreateGatewayResponse -> Text)
-> (CreateGatewayResponse -> Text -> CreateGatewayResponse)
-> Lens CreateGatewayResponse CreateGatewayResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateGatewayResponse' {Text
gatewayArn :: Text
$sel:gatewayArn:CreateGatewayResponse' :: CreateGatewayResponse -> Text
gatewayArn} -> Text
gatewayArn) (\s :: CreateGatewayResponse
s@CreateGatewayResponse' {} Text
a -> CreateGatewayResponse
s {$sel:gatewayArn:CreateGatewayResponse' :: Text
gatewayArn = Text
a} :: CreateGatewayResponse)
instance Prelude.NFData CreateGatewayResponse