-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marco Zocca
committed
Oct 30, 2023
1 parent
6986fd5
commit cd7dc91
Showing
15 changed files
with
205 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
-- | | ||
-- | ||
-- auth: needs @user_impersonation@ scope | ||
module MSAzureAPI.CostManagement where | ||
|
||
import Control.Applicative (Alternative(..)) | ||
import Control.Monad.IO.Class (MonadIO(..)) | ||
import Data.Foldable (asum) | ||
import Data.Functor (void) | ||
-- 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) | ||
import qualified Data.ByteString.Lazy as LBS (ByteString) | ||
-- ms-auth | ||
import MSAuth (AccessToken(..)) | ||
-- req | ||
import Network.HTTP.Req (Req, Url, Option, Scheme(..)) | ||
-- text | ||
import Data.Text (Text, pack, unpack) | ||
import qualified Data.Text.Lazy as TL (Text, pack, unpack, toStrict) | ||
-- time | ||
import Data.Time.Calendar (Day) | ||
import Data.Time (UTCTime, getCurrentTime) | ||
import Data.Time.Format (FormatTime, formatTime, defaultTimeLocale) | ||
import Data.Time.LocalTime (ZonedTime, getZonedTime) | ||
|
||
import qualified MSAzureAPI.Internal.Common as MSA (Collection, APIPlane(..), (==:), put, get, getBs, post, getLbs, aesonOptions) | ||
|
||
|
||
{- generate cost details report https://learn.microsoft.com/en-us/rest/api/cost-management/generate-cost-details-report/create-operation?tabs=HTTP | ||
-} | ||
|
||
-- POST https://management.azure.com/{scope}/providers/Microsoft.CostManagement/generateCostDetailsReport?api-version=2023-08-01 | ||
|
||
generateCostDetailsReport :: (A.FromJSON b) => | ||
Text -> CDROptions -> AccessToken -> Req b | ||
generateCostDetailsReport rid = MSA.post MSA.APManagement [ | ||
rid | ||
, "providers", "Microsoft.CostManagement" | ||
, "generateCostDetailsReport" | ||
] ("api-version" MSA.==: "2023-08-01") | ||
|
||
data CDROptions = CDROptions { | ||
cdrTimePeriod :: CDRTimePeriod | ||
} deriving (Show, Generic) | ||
instance A.FromJSON CDROptions where | ||
parseJSON = A.genericParseJSON (MSA.aesonOptions "cdr") | ||
instance A.ToJSON CDROptions where | ||
toEncoding = A.genericToEncoding (MSA.aesonOptions "cdr") | ||
|
||
data CDRTimePeriod = CDRTimePeriod { | ||
cdrtpStart :: Day | ||
, cdrtpEnd :: Day | ||
} deriving (Show, Generic) | ||
instance A.FromJSON CDRTimePeriod where | ||
parseJSON = A.genericParseJSON (MSA.aesonOptions "cdrtp") | ||
instance A.ToJSON CDRTimePeriod where | ||
toEncoding = A.genericToEncoding (MSA.aesonOptions "cdrtp") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
ms-azure-api/src/MSAzureAPI/MachineLearning/OnlineEndpoints.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
-- | | ||
-- | ||
-- auth: needs @user_impersonation@ scope | ||
module MSAzureAPI.MachineLearning.OnlineEndpoints where | ||
|
||
import Control.Applicative (Alternative(..)) | ||
import Control.Monad.IO.Class (MonadIO(..)) | ||
import Data.Foldable (asum) | ||
import Data.Functor (void) | ||
-- 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) | ||
import qualified Data.ByteString.Lazy as LBS (ByteString) | ||
-- ms-auth | ||
import MSAuth (AccessToken(..)) | ||
-- req | ||
import Network.HTTP.Req (Req, Url, Option, Scheme(..)) | ||
-- 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 (ZonedTime, getZonedTime) | ||
|
||
import qualified MSAzureAPI.Internal.Common as MSA (Collection, APIPlane(..), (==:), put, get, getBs, post, getLbs, aesonOptions) | ||
|
||
-- | list online endpoints | ||
-- | ||
-- docs : https://learn.microsoft.com/en-us/rest/api/azureml/2023-10-01/online-endpoints/list?tabs=HTTP | ||
-- | ||
-- @GET https:\/\/management.azure.com\/subscriptions\/{subscriptionId}\/resourceGroups\/{resourceGroupName}\/providers\/Microsoft.MachineLearningServices\/workspaces\/{workspaceName}\/onlineEndpoints?api-version=2023-10-01@ | ||
listOnlineEndpoints :: Text -- ^ subscription id | ||
-> Text -- ^ res group id | ||
-> Text -- ^ ML workspace id | ||
-> AccessToken -> Req (MSA.Collection OnlineEndpoint) | ||
listOnlineEndpoints sid rgid wsid = MSA.get MSA.APManagement [ | ||
"subscriptions", sid, | ||
"resourceGroups", rgid, | ||
"providers", "Microsoft.MachineLearningServices", | ||
"workspaces", wsid, | ||
"onlineEndpoints" | ||
] ("api-version" MSA.==: "2023-10-01") | ||
|
||
data OnlineEndpoint = OnlineEndpoint { | ||
oeId :: Text | ||
, oeType :: Text | ||
, oeName :: Text | ||
, oeLocation :: Text | ||
, oeProperties :: OnlineEndpointProperties | ||
} deriving (Show, Generic) | ||
instance A.FromJSON OnlineEndpoint where | ||
parseJSON = A.genericParseJSON (MSA.aesonOptions "oe") | ||
instance A.ToJSON OnlineEndpoint where | ||
toEncoding = A.genericToEncoding (MSA.aesonOptions "oe") | ||
|
||
|
||
data OnlineEndpointProperties = OnlineEndpointProperties { | ||
oepProperties :: A.Value | ||
, oepScoringUri :: Text | ||
} deriving (Show, Generic) | ||
instance A.FromJSON OnlineEndpointProperties where | ||
parseJSON = A.genericParseJSON (MSA.aesonOptions "oep") | ||
instance A.ToJSON OnlineEndpointProperties where | ||
toEncoding = A.genericToEncoding (MSA.aesonOptions "oep") |
Oops, something went wrong.