{-# 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.CreateAsset
(
CreateAsset (..),
newCreateAsset,
createAsset_clientToken,
createAsset_tags,
createAsset_assetName,
createAsset_assetModelId,
CreateAssetResponse (..),
newCreateAssetResponse,
createAssetResponse_httpStatus,
createAssetResponse_assetId,
createAssetResponse_assetArn,
createAssetResponse_assetStatus,
)
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 CreateAsset = CreateAsset'
{
CreateAsset -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
CreateAsset -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
CreateAsset -> Text
assetName :: Prelude.Text,
CreateAsset -> Text
assetModelId :: Prelude.Text
}
deriving (CreateAsset -> CreateAsset -> Bool
(CreateAsset -> CreateAsset -> Bool)
-> (CreateAsset -> CreateAsset -> Bool) -> Eq CreateAsset
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAsset -> CreateAsset -> Bool
$c/= :: CreateAsset -> CreateAsset -> Bool
== :: CreateAsset -> CreateAsset -> Bool
$c== :: CreateAsset -> CreateAsset -> Bool
Prelude.Eq, ReadPrec [CreateAsset]
ReadPrec CreateAsset
Int -> ReadS CreateAsset
ReadS [CreateAsset]
(Int -> ReadS CreateAsset)
-> ReadS [CreateAsset]
-> ReadPrec CreateAsset
-> ReadPrec [CreateAsset]
-> Read CreateAsset
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateAsset]
$creadListPrec :: ReadPrec [CreateAsset]
readPrec :: ReadPrec CreateAsset
$creadPrec :: ReadPrec CreateAsset
readList :: ReadS [CreateAsset]
$creadList :: ReadS [CreateAsset]
readsPrec :: Int -> ReadS CreateAsset
$creadsPrec :: Int -> ReadS CreateAsset
Prelude.Read, Int -> CreateAsset -> ShowS
[CreateAsset] -> ShowS
CreateAsset -> String
(Int -> CreateAsset -> ShowS)
-> (CreateAsset -> String)
-> ([CreateAsset] -> ShowS)
-> Show CreateAsset
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAsset] -> ShowS
$cshowList :: [CreateAsset] -> ShowS
show :: CreateAsset -> String
$cshow :: CreateAsset -> String
showsPrec :: Int -> CreateAsset -> ShowS
$cshowsPrec :: Int -> CreateAsset -> ShowS
Prelude.Show, (forall x. CreateAsset -> Rep CreateAsset x)
-> (forall x. Rep CreateAsset x -> CreateAsset)
-> Generic CreateAsset
forall x. Rep CreateAsset x -> CreateAsset
forall x. CreateAsset -> Rep CreateAsset x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAsset x -> CreateAsset
$cfrom :: forall x. CreateAsset -> Rep CreateAsset x
Prelude.Generic)
newCreateAsset ::
Prelude.Text ->
Prelude.Text ->
CreateAsset
newCreateAsset :: Text -> Text -> CreateAsset
newCreateAsset Text
pAssetName_ Text
pAssetModelId_ =
CreateAsset' :: Maybe Text
-> Maybe (HashMap Text Text) -> Text -> Text -> CreateAsset
CreateAsset'
{ $sel:clientToken:CreateAsset' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateAsset' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
$sel:assetName:CreateAsset' :: Text
assetName = Text
pAssetName_,
$sel:assetModelId:CreateAsset' :: Text
assetModelId = Text
pAssetModelId_
}
createAsset_clientToken :: Lens.Lens' CreateAsset (Prelude.Maybe Prelude.Text)
createAsset_clientToken :: (Maybe Text -> f (Maybe Text)) -> CreateAsset -> f CreateAsset
createAsset_clientToken = (CreateAsset -> Maybe Text)
-> (CreateAsset -> Maybe Text -> CreateAsset)
-> Lens CreateAsset CreateAsset (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAsset' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:CreateAsset' :: CreateAsset -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: CreateAsset
s@CreateAsset' {} Maybe Text
a -> CreateAsset
s {$sel:clientToken:CreateAsset' :: Maybe Text
clientToken = Maybe Text
a} :: CreateAsset)
createAsset_tags :: Lens.Lens' CreateAsset (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
createAsset_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateAsset -> f CreateAsset
createAsset_tags = (CreateAsset -> Maybe (HashMap Text Text))
-> (CreateAsset -> Maybe (HashMap Text Text) -> CreateAsset)
-> Lens
CreateAsset
CreateAsset
(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 (\CreateAsset' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:CreateAsset' :: CreateAsset -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: CreateAsset
s@CreateAsset' {} Maybe (HashMap Text Text)
a -> CreateAsset
s {$sel:tags:CreateAsset' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: CreateAsset) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> CreateAsset -> f CreateAsset)
-> ((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)))
-> CreateAsset
-> f CreateAsset
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
createAsset_assetName :: Lens.Lens' CreateAsset Prelude.Text
createAsset_assetName :: (Text -> f Text) -> CreateAsset -> f CreateAsset
createAsset_assetName = (CreateAsset -> Text)
-> (CreateAsset -> Text -> CreateAsset)
-> Lens CreateAsset CreateAsset Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAsset' {Text
assetName :: Text
$sel:assetName:CreateAsset' :: CreateAsset -> Text
assetName} -> Text
assetName) (\s :: CreateAsset
s@CreateAsset' {} Text
a -> CreateAsset
s {$sel:assetName:CreateAsset' :: Text
assetName = Text
a} :: CreateAsset)
createAsset_assetModelId :: Lens.Lens' CreateAsset Prelude.Text
createAsset_assetModelId :: (Text -> f Text) -> CreateAsset -> f CreateAsset
createAsset_assetModelId = (CreateAsset -> Text)
-> (CreateAsset -> Text -> CreateAsset)
-> Lens CreateAsset CreateAsset Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAsset' {Text
assetModelId :: Text
$sel:assetModelId:CreateAsset' :: CreateAsset -> Text
assetModelId} -> Text
assetModelId) (\s :: CreateAsset
s@CreateAsset' {} Text
a -> CreateAsset
s {$sel:assetModelId:CreateAsset' :: Text
assetModelId = Text
a} :: CreateAsset)
instance Core.AWSRequest CreateAsset where
type AWSResponse CreateAsset = CreateAssetResponse
request :: CreateAsset -> Request CreateAsset
request = Service -> CreateAsset -> Request CreateAsset
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateAsset
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateAsset)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateAsset))
-> Logger
-> Service
-> Proxy CreateAsset
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateAsset)))
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 -> AssetStatus -> CreateAssetResponse
CreateAssetResponse'
(Int -> Text -> Text -> AssetStatus -> CreateAssetResponse)
-> Either String Int
-> Either
String (Text -> Text -> AssetStatus -> CreateAssetResponse)
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 -> AssetStatus -> CreateAssetResponse)
-> Either String Text
-> Either String (Text -> AssetStatus -> CreateAssetResponse)
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
"assetId")
Either String (Text -> AssetStatus -> CreateAssetResponse)
-> Either String Text
-> Either String (AssetStatus -> CreateAssetResponse)
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
"assetArn")
Either String (AssetStatus -> CreateAssetResponse)
-> Either String AssetStatus -> Either String CreateAssetResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String AssetStatus
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"assetStatus")
)
instance Prelude.Hashable CreateAsset
instance Prelude.NFData CreateAsset
instance Core.ToHeaders CreateAsset where
toHeaders :: CreateAsset -> ResponseHeaders
toHeaders =
ResponseHeaders -> CreateAsset -> 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 CreateAsset where
toJSON :: CreateAsset -> Value
toJSON CreateAsset' {Maybe Text
Maybe (HashMap Text Text)
Text
assetModelId :: Text
assetName :: Text
tags :: Maybe (HashMap Text Text)
clientToken :: Maybe Text
$sel:assetModelId:CreateAsset' :: CreateAsset -> Text
$sel:assetName:CreateAsset' :: CreateAsset -> Text
$sel:tags:CreateAsset' :: CreateAsset -> Maybe (HashMap Text Text)
$sel:clientToken:CreateAsset' :: CreateAsset -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"clientToken" 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
clientToken,
(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
"assetName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
assetName),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"assetModelId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
assetModelId)
]
)
instance Core.ToPath CreateAsset where
toPath :: CreateAsset -> ByteString
toPath = ByteString -> CreateAsset -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/assets"
instance Core.ToQuery CreateAsset where
toQuery :: CreateAsset -> QueryString
toQuery = QueryString -> CreateAsset -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateAssetResponse = CreateAssetResponse'
{
CreateAssetResponse -> Int
httpStatus :: Prelude.Int,
CreateAssetResponse -> Text
assetId :: Prelude.Text,
CreateAssetResponse -> Text
assetArn :: Prelude.Text,
CreateAssetResponse -> AssetStatus
assetStatus :: AssetStatus
}
deriving (CreateAssetResponse -> CreateAssetResponse -> Bool
(CreateAssetResponse -> CreateAssetResponse -> Bool)
-> (CreateAssetResponse -> CreateAssetResponse -> Bool)
-> Eq CreateAssetResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateAssetResponse -> CreateAssetResponse -> Bool
$c/= :: CreateAssetResponse -> CreateAssetResponse -> Bool
== :: CreateAssetResponse -> CreateAssetResponse -> Bool
$c== :: CreateAssetResponse -> CreateAssetResponse -> Bool
Prelude.Eq, ReadPrec [CreateAssetResponse]
ReadPrec CreateAssetResponse
Int -> ReadS CreateAssetResponse
ReadS [CreateAssetResponse]
(Int -> ReadS CreateAssetResponse)
-> ReadS [CreateAssetResponse]
-> ReadPrec CreateAssetResponse
-> ReadPrec [CreateAssetResponse]
-> Read CreateAssetResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateAssetResponse]
$creadListPrec :: ReadPrec [CreateAssetResponse]
readPrec :: ReadPrec CreateAssetResponse
$creadPrec :: ReadPrec CreateAssetResponse
readList :: ReadS [CreateAssetResponse]
$creadList :: ReadS [CreateAssetResponse]
readsPrec :: Int -> ReadS CreateAssetResponse
$creadsPrec :: Int -> ReadS CreateAssetResponse
Prelude.Read, Int -> CreateAssetResponse -> ShowS
[CreateAssetResponse] -> ShowS
CreateAssetResponse -> String
(Int -> CreateAssetResponse -> ShowS)
-> (CreateAssetResponse -> String)
-> ([CreateAssetResponse] -> ShowS)
-> Show CreateAssetResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateAssetResponse] -> ShowS
$cshowList :: [CreateAssetResponse] -> ShowS
show :: CreateAssetResponse -> String
$cshow :: CreateAssetResponse -> String
showsPrec :: Int -> CreateAssetResponse -> ShowS
$cshowsPrec :: Int -> CreateAssetResponse -> ShowS
Prelude.Show, (forall x. CreateAssetResponse -> Rep CreateAssetResponse x)
-> (forall x. Rep CreateAssetResponse x -> CreateAssetResponse)
-> Generic CreateAssetResponse
forall x. Rep CreateAssetResponse x -> CreateAssetResponse
forall x. CreateAssetResponse -> Rep CreateAssetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateAssetResponse x -> CreateAssetResponse
$cfrom :: forall x. CreateAssetResponse -> Rep CreateAssetResponse x
Prelude.Generic)
newCreateAssetResponse ::
Prelude.Int ->
Prelude.Text ->
Prelude.Text ->
AssetStatus ->
CreateAssetResponse
newCreateAssetResponse :: Int -> Text -> Text -> AssetStatus -> CreateAssetResponse
newCreateAssetResponse
Int
pHttpStatus_
Text
pAssetId_
Text
pAssetArn_
AssetStatus
pAssetStatus_ =
CreateAssetResponse' :: Int -> Text -> Text -> AssetStatus -> CreateAssetResponse
CreateAssetResponse'
{ $sel:httpStatus:CreateAssetResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:assetId:CreateAssetResponse' :: Text
assetId = Text
pAssetId_,
$sel:assetArn:CreateAssetResponse' :: Text
assetArn = Text
pAssetArn_,
$sel:assetStatus:CreateAssetResponse' :: AssetStatus
assetStatus = AssetStatus
pAssetStatus_
}
createAssetResponse_httpStatus :: Lens.Lens' CreateAssetResponse Prelude.Int
createAssetResponse_httpStatus :: (Int -> f Int) -> CreateAssetResponse -> f CreateAssetResponse
createAssetResponse_httpStatus = (CreateAssetResponse -> Int)
-> (CreateAssetResponse -> Int -> CreateAssetResponse)
-> Lens CreateAssetResponse CreateAssetResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssetResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateAssetResponse' :: CreateAssetResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateAssetResponse
s@CreateAssetResponse' {} Int
a -> CreateAssetResponse
s {$sel:httpStatus:CreateAssetResponse' :: Int
httpStatus = Int
a} :: CreateAssetResponse)
createAssetResponse_assetId :: Lens.Lens' CreateAssetResponse Prelude.Text
createAssetResponse_assetId :: (Text -> f Text) -> CreateAssetResponse -> f CreateAssetResponse
createAssetResponse_assetId = (CreateAssetResponse -> Text)
-> (CreateAssetResponse -> Text -> CreateAssetResponse)
-> Lens CreateAssetResponse CreateAssetResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssetResponse' {Text
assetId :: Text
$sel:assetId:CreateAssetResponse' :: CreateAssetResponse -> Text
assetId} -> Text
assetId) (\s :: CreateAssetResponse
s@CreateAssetResponse' {} Text
a -> CreateAssetResponse
s {$sel:assetId:CreateAssetResponse' :: Text
assetId = Text
a} :: CreateAssetResponse)
createAssetResponse_assetArn :: Lens.Lens' CreateAssetResponse Prelude.Text
createAssetResponse_assetArn :: (Text -> f Text) -> CreateAssetResponse -> f CreateAssetResponse
createAssetResponse_assetArn = (CreateAssetResponse -> Text)
-> (CreateAssetResponse -> Text -> CreateAssetResponse)
-> Lens CreateAssetResponse CreateAssetResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssetResponse' {Text
assetArn :: Text
$sel:assetArn:CreateAssetResponse' :: CreateAssetResponse -> Text
assetArn} -> Text
assetArn) (\s :: CreateAssetResponse
s@CreateAssetResponse' {} Text
a -> CreateAssetResponse
s {$sel:assetArn:CreateAssetResponse' :: Text
assetArn = Text
a} :: CreateAssetResponse)
createAssetResponse_assetStatus :: Lens.Lens' CreateAssetResponse AssetStatus
createAssetResponse_assetStatus :: (AssetStatus -> f AssetStatus)
-> CreateAssetResponse -> f CreateAssetResponse
createAssetResponse_assetStatus = (CreateAssetResponse -> AssetStatus)
-> (CreateAssetResponse -> AssetStatus -> CreateAssetResponse)
-> Lens
CreateAssetResponse CreateAssetResponse AssetStatus AssetStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateAssetResponse' {AssetStatus
assetStatus :: AssetStatus
$sel:assetStatus:CreateAssetResponse' :: CreateAssetResponse -> AssetStatus
assetStatus} -> AssetStatus
assetStatus) (\s :: CreateAssetResponse
s@CreateAssetResponse' {} AssetStatus
a -> CreateAssetResponse
s {$sel:assetStatus:CreateAssetResponse' :: AssetStatus
assetStatus = AssetStatus
a} :: CreateAssetResponse)
instance Prelude.NFData CreateAssetResponse