{-# 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.LookoutVision.CreateModel
(
CreateModel (..),
newCreateModel,
createModel_clientToken,
createModel_kmsKeyId,
createModel_description,
createModel_tags,
createModel_projectName,
createModel_outputConfig,
CreateModelResponse (..),
newCreateModelResponse,
createModelResponse_modelMetadata,
createModelResponse_httpStatus,
)
where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.LookoutVision.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
data CreateModel = CreateModel'
{
CreateModel -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
CreateModel -> Maybe Text
kmsKeyId :: Prelude.Maybe Prelude.Text,
CreateModel -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
CreateModel -> Maybe [Tag]
tags :: Prelude.Maybe [Tag],
CreateModel -> Text
projectName :: Prelude.Text,
CreateModel -> OutputConfig
outputConfig :: OutputConfig
}
deriving (CreateModel -> CreateModel -> Bool
(CreateModel -> CreateModel -> Bool)
-> (CreateModel -> CreateModel -> Bool) -> Eq CreateModel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateModel -> CreateModel -> Bool
$c/= :: CreateModel -> CreateModel -> Bool
== :: CreateModel -> CreateModel -> Bool
$c== :: CreateModel -> CreateModel -> Bool
Prelude.Eq, ReadPrec [CreateModel]
ReadPrec CreateModel
Int -> ReadS CreateModel
ReadS [CreateModel]
(Int -> ReadS CreateModel)
-> ReadS [CreateModel]
-> ReadPrec CreateModel
-> ReadPrec [CreateModel]
-> Read CreateModel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateModel]
$creadListPrec :: ReadPrec [CreateModel]
readPrec :: ReadPrec CreateModel
$creadPrec :: ReadPrec CreateModel
readList :: ReadS [CreateModel]
$creadList :: ReadS [CreateModel]
readsPrec :: Int -> ReadS CreateModel
$creadsPrec :: Int -> ReadS CreateModel
Prelude.Read, Int -> CreateModel -> ShowS
[CreateModel] -> ShowS
CreateModel -> String
(Int -> CreateModel -> ShowS)
-> (CreateModel -> String)
-> ([CreateModel] -> ShowS)
-> Show CreateModel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateModel] -> ShowS
$cshowList :: [CreateModel] -> ShowS
show :: CreateModel -> String
$cshow :: CreateModel -> String
showsPrec :: Int -> CreateModel -> ShowS
$cshowsPrec :: Int -> CreateModel -> ShowS
Prelude.Show, (forall x. CreateModel -> Rep CreateModel x)
-> (forall x. Rep CreateModel x -> CreateModel)
-> Generic CreateModel
forall x. Rep CreateModel x -> CreateModel
forall x. CreateModel -> Rep CreateModel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateModel x -> CreateModel
$cfrom :: forall x. CreateModel -> Rep CreateModel x
Prelude.Generic)
newCreateModel ::
Prelude.Text ->
OutputConfig ->
CreateModel
newCreateModel :: Text -> OutputConfig -> CreateModel
newCreateModel Text
pProjectName_ OutputConfig
pOutputConfig_ =
CreateModel' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Tag]
-> Text
-> OutputConfig
-> CreateModel
CreateModel'
{ $sel:clientToken:CreateModel' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:kmsKeyId:CreateModel' :: Maybe Text
kmsKeyId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:description:CreateModel' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:tags:CreateModel' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing,
$sel:projectName:CreateModel' :: Text
projectName = Text
pProjectName_,
$sel:outputConfig:CreateModel' :: OutputConfig
outputConfig = OutputConfig
pOutputConfig_
}
createModel_clientToken :: Lens.Lens' CreateModel (Prelude.Maybe Prelude.Text)
createModel_clientToken :: (Maybe Text -> f (Maybe Text)) -> CreateModel -> f CreateModel
createModel_clientToken = (CreateModel -> Maybe Text)
-> (CreateModel -> Maybe Text -> CreateModel)
-> Lens CreateModel CreateModel (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateModel' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:CreateModel' :: CreateModel -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: CreateModel
s@CreateModel' {} Maybe Text
a -> CreateModel
s {$sel:clientToken:CreateModel' :: Maybe Text
clientToken = Maybe Text
a} :: CreateModel)
createModel_kmsKeyId :: Lens.Lens' CreateModel (Prelude.Maybe Prelude.Text)
createModel_kmsKeyId :: (Maybe Text -> f (Maybe Text)) -> CreateModel -> f CreateModel
createModel_kmsKeyId = (CreateModel -> Maybe Text)
-> (CreateModel -> Maybe Text -> CreateModel)
-> Lens CreateModel CreateModel (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateModel' {Maybe Text
kmsKeyId :: Maybe Text
$sel:kmsKeyId:CreateModel' :: CreateModel -> Maybe Text
kmsKeyId} -> Maybe Text
kmsKeyId) (\s :: CreateModel
s@CreateModel' {} Maybe Text
a -> CreateModel
s {$sel:kmsKeyId:CreateModel' :: Maybe Text
kmsKeyId = Maybe Text
a} :: CreateModel)
createModel_description :: Lens.Lens' CreateModel (Prelude.Maybe Prelude.Text)
createModel_description :: (Maybe Text -> f (Maybe Text)) -> CreateModel -> f CreateModel
createModel_description = (CreateModel -> Maybe Text)
-> (CreateModel -> Maybe Text -> CreateModel)
-> Lens CreateModel CreateModel (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateModel' {Maybe Text
description :: Maybe Text
$sel:description:CreateModel' :: CreateModel -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateModel
s@CreateModel' {} Maybe Text
a -> CreateModel
s {$sel:description:CreateModel' :: Maybe Text
description = Maybe Text
a} :: CreateModel)
createModel_tags :: Lens.Lens' CreateModel (Prelude.Maybe [Tag])
createModel_tags :: (Maybe [Tag] -> f (Maybe [Tag])) -> CreateModel -> f CreateModel
createModel_tags = (CreateModel -> Maybe [Tag])
-> (CreateModel -> Maybe [Tag] -> CreateModel)
-> Lens CreateModel CreateModel (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateModel' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:CreateModel' :: CreateModel -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: CreateModel
s@CreateModel' {} Maybe [Tag]
a -> CreateModel
s {$sel:tags:CreateModel' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: CreateModel) ((Maybe [Tag] -> f (Maybe [Tag])) -> CreateModel -> f CreateModel)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
-> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> CreateModel
-> f CreateModel
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
createModel_projectName :: Lens.Lens' CreateModel Prelude.Text
createModel_projectName :: (Text -> f Text) -> CreateModel -> f CreateModel
createModel_projectName = (CreateModel -> Text)
-> (CreateModel -> Text -> CreateModel)
-> Lens CreateModel CreateModel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateModel' {Text
projectName :: Text
$sel:projectName:CreateModel' :: CreateModel -> Text
projectName} -> Text
projectName) (\s :: CreateModel
s@CreateModel' {} Text
a -> CreateModel
s {$sel:projectName:CreateModel' :: Text
projectName = Text
a} :: CreateModel)
createModel_outputConfig :: Lens.Lens' CreateModel OutputConfig
createModel_outputConfig :: (OutputConfig -> f OutputConfig) -> CreateModel -> f CreateModel
createModel_outputConfig = (CreateModel -> OutputConfig)
-> (CreateModel -> OutputConfig -> CreateModel)
-> Lens CreateModel CreateModel OutputConfig OutputConfig
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateModel' {OutputConfig
outputConfig :: OutputConfig
$sel:outputConfig:CreateModel' :: CreateModel -> OutputConfig
outputConfig} -> OutputConfig
outputConfig) (\s :: CreateModel
s@CreateModel' {} OutputConfig
a -> CreateModel
s {$sel:outputConfig:CreateModel' :: OutputConfig
outputConfig = OutputConfig
a} :: CreateModel)
instance Core.AWSRequest CreateModel where
type AWSResponse CreateModel = CreateModelResponse
request :: CreateModel -> Request CreateModel
request = Service -> CreateModel -> Request CreateModel
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
response :: Logger
-> Service
-> Proxy CreateModel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateModel)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse CreateModel))
-> Logger
-> Service
-> Proxy CreateModel
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateModel)))
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 ->
Maybe ModelMetadata -> Int -> CreateModelResponse
CreateModelResponse'
(Maybe ModelMetadata -> Int -> CreateModelResponse)
-> Either String (Maybe ModelMetadata)
-> Either String (Int -> CreateModelResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ModelMetadata)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ModelMetadata")
Either String (Int -> CreateModelResponse)
-> Either String Int -> Either String CreateModelResponse
forall (f :: * -> *) a b. Applicative f => 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))
)
instance Prelude.Hashable CreateModel
instance Prelude.NFData CreateModel
instance Core.ToHeaders CreateModel where
toHeaders :: CreateModel -> ResponseHeaders
toHeaders CreateModel' {Maybe [Tag]
Maybe Text
Text
OutputConfig
outputConfig :: OutputConfig
projectName :: Text
tags :: Maybe [Tag]
description :: Maybe Text
kmsKeyId :: Maybe Text
clientToken :: Maybe Text
$sel:outputConfig:CreateModel' :: CreateModel -> OutputConfig
$sel:projectName:CreateModel' :: CreateModel -> Text
$sel:tags:CreateModel' :: CreateModel -> Maybe [Tag]
$sel:description:CreateModel' :: CreateModel -> Maybe Text
$sel:kmsKeyId:CreateModel' :: CreateModel -> Maybe Text
$sel:clientToken:CreateModel' :: CreateModel -> Maybe Text
..} =
[ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"X-Amzn-Client-Token" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
clientToken,
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 CreateModel where
toJSON :: CreateModel -> Value
toJSON CreateModel' {Maybe [Tag]
Maybe Text
Text
OutputConfig
outputConfig :: OutputConfig
projectName :: Text
tags :: Maybe [Tag]
description :: Maybe Text
kmsKeyId :: Maybe Text
clientToken :: Maybe Text
$sel:outputConfig:CreateModel' :: CreateModel -> OutputConfig
$sel:projectName:CreateModel' :: CreateModel -> Text
$sel:tags:CreateModel' :: CreateModel -> Maybe [Tag]
$sel:description:CreateModel' :: CreateModel -> Maybe Text
$sel:kmsKeyId:CreateModel' :: CreateModel -> Maybe Text
$sel:clientToken:CreateModel' :: CreateModel -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"KmsKeyId" 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
kmsKeyId,
(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 -> [Tag] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([Tag] -> Pair) -> Maybe [Tag] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Tag]
tags,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"OutputConfig" Text -> OutputConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= OutputConfig
outputConfig)
]
)
instance Core.ToPath CreateModel where
toPath :: CreateModel -> ByteString
toPath CreateModel' {Maybe [Tag]
Maybe Text
Text
OutputConfig
outputConfig :: OutputConfig
projectName :: Text
tags :: Maybe [Tag]
description :: Maybe Text
kmsKeyId :: Maybe Text
clientToken :: Maybe Text
$sel:outputConfig:CreateModel' :: CreateModel -> OutputConfig
$sel:projectName:CreateModel' :: CreateModel -> Text
$sel:tags:CreateModel' :: CreateModel -> Maybe [Tag]
$sel:description:CreateModel' :: CreateModel -> Maybe Text
$sel:kmsKeyId:CreateModel' :: CreateModel -> Maybe Text
$sel:clientToken:CreateModel' :: CreateModel -> Maybe Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/2020-11-20/projects/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
projectName,
ByteString
"/models"
]
instance Core.ToQuery CreateModel where
toQuery :: CreateModel -> QueryString
toQuery = QueryString -> CreateModel -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty
data CreateModelResponse = CreateModelResponse'
{
CreateModelResponse -> Maybe ModelMetadata
modelMetadata :: Prelude.Maybe ModelMetadata,
CreateModelResponse -> Int
httpStatus :: Prelude.Int
}
deriving (CreateModelResponse -> CreateModelResponse -> Bool
(CreateModelResponse -> CreateModelResponse -> Bool)
-> (CreateModelResponse -> CreateModelResponse -> Bool)
-> Eq CreateModelResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateModelResponse -> CreateModelResponse -> Bool
$c/= :: CreateModelResponse -> CreateModelResponse -> Bool
== :: CreateModelResponse -> CreateModelResponse -> Bool
$c== :: CreateModelResponse -> CreateModelResponse -> Bool
Prelude.Eq, ReadPrec [CreateModelResponse]
ReadPrec CreateModelResponse
Int -> ReadS CreateModelResponse
ReadS [CreateModelResponse]
(Int -> ReadS CreateModelResponse)
-> ReadS [CreateModelResponse]
-> ReadPrec CreateModelResponse
-> ReadPrec [CreateModelResponse]
-> Read CreateModelResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateModelResponse]
$creadListPrec :: ReadPrec [CreateModelResponse]
readPrec :: ReadPrec CreateModelResponse
$creadPrec :: ReadPrec CreateModelResponse
readList :: ReadS [CreateModelResponse]
$creadList :: ReadS [CreateModelResponse]
readsPrec :: Int -> ReadS CreateModelResponse
$creadsPrec :: Int -> ReadS CreateModelResponse
Prelude.Read, Int -> CreateModelResponse -> ShowS
[CreateModelResponse] -> ShowS
CreateModelResponse -> String
(Int -> CreateModelResponse -> ShowS)
-> (CreateModelResponse -> String)
-> ([CreateModelResponse] -> ShowS)
-> Show CreateModelResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateModelResponse] -> ShowS
$cshowList :: [CreateModelResponse] -> ShowS
show :: CreateModelResponse -> String
$cshow :: CreateModelResponse -> String
showsPrec :: Int -> CreateModelResponse -> ShowS
$cshowsPrec :: Int -> CreateModelResponse -> ShowS
Prelude.Show, (forall x. CreateModelResponse -> Rep CreateModelResponse x)
-> (forall x. Rep CreateModelResponse x -> CreateModelResponse)
-> Generic CreateModelResponse
forall x. Rep CreateModelResponse x -> CreateModelResponse
forall x. CreateModelResponse -> Rep CreateModelResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateModelResponse x -> CreateModelResponse
$cfrom :: forall x. CreateModelResponse -> Rep CreateModelResponse x
Prelude.Generic)
newCreateModelResponse ::
Prelude.Int ->
CreateModelResponse
newCreateModelResponse :: Int -> CreateModelResponse
newCreateModelResponse Int
pHttpStatus_ =
CreateModelResponse' :: Maybe ModelMetadata -> Int -> CreateModelResponse
CreateModelResponse'
{ $sel:modelMetadata:CreateModelResponse' :: Maybe ModelMetadata
modelMetadata =
Maybe ModelMetadata
forall a. Maybe a
Prelude.Nothing,
$sel:httpStatus:CreateModelResponse' :: Int
httpStatus = Int
pHttpStatus_
}
createModelResponse_modelMetadata :: Lens.Lens' CreateModelResponse (Prelude.Maybe ModelMetadata)
createModelResponse_modelMetadata :: (Maybe ModelMetadata -> f (Maybe ModelMetadata))
-> CreateModelResponse -> f CreateModelResponse
createModelResponse_modelMetadata = (CreateModelResponse -> Maybe ModelMetadata)
-> (CreateModelResponse
-> Maybe ModelMetadata -> CreateModelResponse)
-> Lens
CreateModelResponse
CreateModelResponse
(Maybe ModelMetadata)
(Maybe ModelMetadata)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateModelResponse' {Maybe ModelMetadata
modelMetadata :: Maybe ModelMetadata
$sel:modelMetadata:CreateModelResponse' :: CreateModelResponse -> Maybe ModelMetadata
modelMetadata} -> Maybe ModelMetadata
modelMetadata) (\s :: CreateModelResponse
s@CreateModelResponse' {} Maybe ModelMetadata
a -> CreateModelResponse
s {$sel:modelMetadata:CreateModelResponse' :: Maybe ModelMetadata
modelMetadata = Maybe ModelMetadata
a} :: CreateModelResponse)
createModelResponse_httpStatus :: Lens.Lens' CreateModelResponse Prelude.Int
createModelResponse_httpStatus :: (Int -> f Int) -> CreateModelResponse -> f CreateModelResponse
createModelResponse_httpStatus = (CreateModelResponse -> Int)
-> (CreateModelResponse -> Int -> CreateModelResponse)
-> Lens CreateModelResponse CreateModelResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateModelResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateModelResponse' :: CreateModelResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateModelResponse
s@CreateModelResponse' {} Int
a -> CreateModelResponse
s {$sel:httpStatus:CreateModelResponse' :: Int
httpStatus = Int
a} :: CreateModelResponse)
instance Prelude.NFData CreateModelResponse