From 000cafa4353fb8547ff7bed8592984341316cd57 Mon Sep 17 00:00:00 2001 From: Marco Zocca Date: Sat, 24 Jun 2023 15:17:58 +0200 Subject: [PATCH] adding AML Jobs --- .../src/MSAzureAPI/MachineLearning/Jobs.hs | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/ms-azure-api/src/MSAzureAPI/MachineLearning/Jobs.hs b/ms-azure-api/src/MSAzureAPI/MachineLearning/Jobs.hs index 3093e63..316798d 100644 --- a/ms-azure-api/src/MSAzureAPI/MachineLearning/Jobs.hs +++ b/ms-azure-api/src/MSAzureAPI/MachineLearning/Jobs.hs @@ -4,9 +4,11 @@ import Control.Applicative (Alternative(..)) import Control.Monad.IO.Class (MonadIO(..)) import Data.Foldable (asum) import Data.Functor (void) -import Data.Maybe (listToMaybe) -import qualified Text.ParserCombinators.ReadP as RP (ReadP, readP_to_S, choice, many, between, char, string, satisfy) +-- import Data.Maybe (listToMaybe) +import GHC.Generics (Generic(..)) +-- aeson +import qualified Data.Aeson as A (ToJSON(..), genericToEncoding, FromJSON(..), genericParseJSON, defaultOptions, Options(..), withObject, withText, (.:), (.:?), object, (.=), Key, Value, camelTo2) -- bytestring import qualified Data.ByteString as BS (ByteString) import qualified Data.ByteString.Char8 as BS8 (pack, unpack) @@ -19,18 +21,19 @@ import Network.HTTP.Req (Req, Url, Option, Scheme(..), header, (=:)) -- text import Data.Text (Text, pack, unpack) import qualified Data.Text.Lazy as TL (Text, pack, unpack, toStrict) --- time -import Data.Time (UTCTime, getCurrentTime) -import Data.Time.Format (FormatTime, formatTime, defaultTimeLocale) -import Data.Time.LocalTime (getZonedTime) --- xeno -import qualified Xeno.DOM.Robust as X (Node, Content(..), name, contents, children) --- xmlbf-xeno -import qualified Xmlbf.Xeno as XB (fromRawXml) +-- -- time +-- import Data.Time (UTCTime, getCurrentTime) +-- import Data.Time.Format (FormatTime, formatTime, defaultTimeLocale) +-- import Data.Time.LocalTime (getZonedTime) +-- -- xeno +-- import qualified Xeno.DOM.Robust as X (Node, Content(..), name, contents, children) +-- -- xmlbf-xeno +-- import qualified Xmlbf.Xeno as XB (fromRawXml) -- xmlbf import qualified Xmlbf as XB (Parser, runParser, pElement, pText) -import MSAzureAPI.Internal.Common (APIPlane(..), (==:), put, get, getBs, post, getLbs) +import qualified MSAzureAPI.Internal.Common as MSA (APIPlane(..), (==:), put, get, getBs, post, getLbs, aesonOptions) + -- | create a job @@ -38,12 +41,22 @@ import MSAzureAPI.Internal.Common (APIPlane(..), (==:), put, get, getBs, post, g -- docs: -- -- @PUT https:\/\/management.azure.com\/subscriptions\/{subscriptionId}\/resourceGroups\/{resourceGroupName}\/providers\/Microsoft.MachineLearningServices\/workspaces\/{workspaceName}\/jobs\/{id}?api-version=2023-04-01@ - +createJob :: (A.FromJSON b) => + Text -- ^ subscription id + -> Text -- ^ res group id + -> Text -- ^ ML workspace id + -> Text -- ^ job id + -> JobBase + -> AccessToken -> Req b createJob sid rgid wsid jid = - put APManagement ["subscriptions", sid, + MSA.put MSA.APManagement ["subscriptions", sid, "resourceGroups", rgid, "providers", "Microsoft.MachineLearningServices", "workspaces", wsid, - "jobs", jid] ("api-version" ==: "2023-04-01") + "jobs", jid] ("api-version" MSA.==: "2023-04-01") -data JobBase = JB +data JobBase = JB { + jbTODO :: Text + } deriving (Eq, Show, Generic) +instance A.ToJSON JobBase where + toEncoding = A.genericToEncoding (MSA.aesonOptions "jb")