packages feed

ms-graph-api 0.8.0.0 → 0.9.0.0

raw patch · 7 files changed

+99/−22 lines, 7 filesdep +http-clientPVP ok

version bump matches the API change (PVP)

Dependencies added: http-client

API changes (from Hackage documentation)

+ MSGraphAPI.Files.Drive: Drive :: Text -> Text -> Text -> ZonedTime -> Text -> Drive
+ MSGraphAPI.Files.Drive: [dDescription] :: Drive -> Text
+ MSGraphAPI.Files.Drive: [dDriveType] :: Drive -> Text
+ MSGraphAPI.Files.Drive: [dId] :: Drive -> Text
+ MSGraphAPI.Files.Drive: [dLastModifiedDateTime] :: Drive -> ZonedTime
+ MSGraphAPI.Files.Drive: [dName] :: Drive -> Text
+ MSGraphAPI.Files.Drive: data Drive
+ MSGraphAPI.Files.Drive: instance Data.Aeson.Types.FromJSON.FromJSON MSGraphAPI.Files.Drive.Drive
+ MSGraphAPI.Files.Drive: instance Data.Aeson.Types.ToJSON.ToJSON MSGraphAPI.Files.Drive.Drive
+ MSGraphAPI.Files.Drive: instance GHC.Generics.Generic MSGraphAPI.Files.Drive.Drive
+ MSGraphAPI.Files.Drive: instance GHC.Show.Show MSGraphAPI.Files.Drive.Drive
+ MSGraphAPI.Files.Drive: listDrivesGroup :: Text -> AccessToken -> Req (Collection Drive)
+ MSGraphAPI.Files.Drive: listDrivesMe :: AccessToken -> Req (Collection Drive)
+ MSGraphAPI.Users.User: instance Data.Aeson.Types.ToJSON.ToJSON MSGraphAPI.Users.User.User
- MSGraphAPI: withTLS :: MonadIO m => (HttpConfig -> m b) -> m b
+ MSGraphAPI: withTLS :: MonadIO m => (HttpConfig -> Manager -> m b) -> m b

Files

CHANGELOG.md view
@@ -9,22 +9,29 @@ ## Unreleased  +## 0.9.0.0 -## 0.8.0.0+MSGraphAPI.Files.Drive -MSGraphAPI.Files.DriveItem+*Breaking changes*+- withTLS changed signature: the inner continuation has an additional Manager parameter  +## 0.8.0.0 +MSGraphAPI.Files.DriveItem :+- custom FromJSON instance using a sum type for the various types of drive item. Makes it convenient for users to pattern match on type. So far only File, Folder and Package drive item types are parsed further. +New MSGraphAPI module to re-expose internals++ ## 0.7.0.0  MSGraphAPI.ChangeNotifications.Subscription: - add createSubscription  *Breaking changes*--Moved the Network/* module hierarchy to the `ms-auth` package shared with `ms-azure-api`.+- Moved the Network/* module hierarchy to the `ms-auth` package shared with `ms-azure-api`.  ## 0.6.0.0 
ms-graph-api.cabal view
@@ -1,5 +1,5 @@ name:                ms-graph-api-version:             0.8.0.0+version:             0.9.0.0 synopsis:            Microsoft Graph API description:         Bindings to the Microsoft Graph API homepage:            https://github.com/unfoldml/ms-graph-api@@ -24,13 +24,15 @@                        MSGraphAPI.Users.User                        MSGraphAPI.Users.Group                        MSGraphAPI.Drive+                       MSGraphAPI.Files.Drive                        MSGraphAPI.Files.DriveItem   other-modules:       MSGraphAPI.Internal.Common-  build-depends:       base >= 4.7 && < 5-                     , aeson+  build-depends:       aeson+                     , base >= 4.7 && < 5                      , bytestring                      , containers                      , hoauth2 == 2.6.0+                     , http-client >= 0.7.13.1                      , http-client-tls >= 0.3                      , http-types                      , modern-uri
+ src/MSGraphAPI/Files/Drive.hs view
@@ -0,0 +1,56 @@+module MSGraphAPI.Files.Drive (+  listDrivesMe+  , listDrivesGroup+  -- * types+  , Drive(..)+                              ) where++-- import Control.Applicative (Alternative(..))+-- import Data.Int (Int32)+import GHC.Generics (Generic(..))++-- aeson+import qualified Data.Aeson as A (ToJSON(..), FromJSON(..), genericParseJSON)+-- import qualified Data.Aeson.Types as A (Parser)+-- bytestring+-- import qualified Data.ByteString.Lazy as LBS (ByteString)+-- hoauth+import Network.OAuth.OAuth2.Internal (AccessToken(..))+-- req+import Network.HTTP.Req (Req)+-- text+import Data.Text (Text)+-- time+import Data.Time (ZonedTime)++import qualified MSGraphAPI.Internal.Common as MSG (get, Collection, aesonOptions)++-- | The top-level object that represents a user's OneDrive or a document library in SharePoint.+--+-- OneDrive users will always have at least one drive available, their default drive. Users without a OneDrive license may not have a default drive available.+--+-- https://learn.microsoft.com/en-us/graph/api/resources/drive?view=graph-rest-1.0+data Drive = Drive {+  dId :: Text+  , dName :: Text+  , dDescription :: Text+  , dLastModifiedDateTime :: ZonedTime -- 2022-11-28T09:18:45Z+  , dDriveType :: Text+                           } deriving (Show, Generic)+instance A.FromJSON Drive where+  parseJSON = A.genericParseJSON (MSG.aesonOptions "d")+instance A.ToJSON Drive++-- | List the current user's drives+--+-- @GET \/me\/drives@+listDrivesMe :: AccessToken -> Req (MSG.Collection Drive)+listDrivesMe = MSG.get ["me", "drives"] mempty+++-- | To list the document libraries for a group, your app requests the drives relationship on the Group.+--+-- @GET \/groups\/{groupId}\/drives@+listDrivesGroup :: Text -- ^ group ID+                -> AccessToken -> Req (MSG.Collection Drive)+listDrivesGroup gid = MSG.get ["groups", gid, "drives"] mempty
src/MSGraphAPI/Files/DriveItem.hs view
@@ -1,3 +1,4 @@+-- | Files.DriveItem module MSGraphAPI.Files.DriveItem (   -- * list items   listRootChildrenMe@@ -17,7 +18,7 @@ import GHC.Generics (Generic(..))  -- aeson-import qualified Data.Aeson as A (ToJSON(..), FromJSON(..), Value, genericParseJSON, (.:), (.:?), Object, withObject, Key)+import qualified Data.Aeson as A (ToJSON(..), FromJSON(..), genericParseJSON, (.:), Object, withObject, Key) import qualified Data.Aeson.Types as A (Parser) -- bytestring import qualified Data.ByteString.Lazy as LBS (ByteString)@@ -26,11 +27,11 @@ -- req import Network.HTTP.Req (Req) -- text-import Data.Text (Text, pack, unpack)+import Data.Text (Text) -- time-import Data.Time (LocalTime, ZonedTime)+import Data.Time (ZonedTime) -import qualified MSGraphAPI.Internal.Common as MSG (get, getLbs, post, Collection, aesonOptions)+import qualified MSGraphAPI.Internal.Common as MSG (get, getLbs, Collection, aesonOptions)  -- | The 'DriveItem' resource represents a file, folder, or other item stored in a drive. --
src/MSGraphAPI/Internal/Common.hs view
@@ -45,6 +45,8 @@ -- hoauth2 import Network.OAuth.OAuth2 (OAuth2Token(..)) import Network.OAuth.OAuth2.Internal (AccessToken(..), ExchangeToken(..), RefreshToken(..), OAuth2Error, IdToken(..))+-- http-client+import Network.HTTP.Client (Manager) -- http-client-tls import Network.HTTP.Client.TLS (newTlsManager) -- modern-uri@@ -68,13 +70,13 @@  -- | Create a new TLS manager, which should be reused throughout the program withTLS :: MonadIO m =>-           (HttpConfig -> m b) -- ^ user program+           (HttpConfig -> Manager -> m b) -- ^ user program         -> m b withTLS act = do   mgr <- newTlsManager   let     hc = defaultHttpConfig { httpConfigAltManager = Just mgr }-  act hc+  act hc mgr  -- | Run a 'Req' computation run :: MonadIO m =>
src/MSGraphAPI/Users/Group.hs view
@@ -12,15 +12,15 @@ import GHC.Generics (Generic(..))  -- aeson-import qualified Data.Aeson as A (ToJSON(..), FromJSON(..), eitherDecode, genericParseJSON, defaultOptions, Options(..), withObject, withText, (.:), (.:?), object, (.=))+import qualified Data.Aeson as A (ToJSON(..), FromJSON(..), genericParseJSON) -- hoauth import Network.OAuth.OAuth2.Internal (AccessToken(..)) -- req import Network.HTTP.Req (Req) -- text-import Data.Text (Text, pack, unpack)+import Data.Text (Text) -import qualified MSGraphAPI.Internal.Common as MSG (Collection(..), get, post, aesonOptions)+import qualified MSGraphAPI.Internal.Common as MSG (Collection(..), get, aesonOptions) import MSGraphAPI.Files.DriveItem (DriveItem)  -- | Groups are collections of principals with shared access to resources in Microsoft services or in your app. Different principals such as users, other groups, devices, and applications can be part of groups. @@ -33,7 +33,7 @@                    } deriving (Eq, Ord, Show, Generic) instance A.FromJSON Group where   parseJSON = A.genericParseJSON (MSG.aesonOptions "g")-instance A.ToJSON Group  +instance A.ToJSON Group  -- | Get the teams in Microsoft Teams that the given user is a direct member of. --@@ -57,6 +57,8 @@ -- @GET \/groups\/{group-id}\/drive\/root\/children@ -- -- https://learn.microsoft.com/en-us/graph/api/driveitem-list-children?view=graph-rest-1.0&tabs=http+--+-- NB : requires @Files.Read.All@, since it tries to access all files a user has access to. getGroupsDriveItems :: Text -- ^ Group ID                     -> AccessToken -> Req (MSG.Collection DriveItem) getGroupsDriveItems gid = MSG.get ["groups", gid, "drive", "root", "children"] mempty
src/MSGraphAPI/Users/User.hs view
@@ -1,20 +1,26 @@ -- | Users.User-module MSGraphAPI.Users.User where+module MSGraphAPI.Users.User (+  get+  , getMe+  -- * types+  , User(..)) where  import GHC.Generics (Generic(..))  -- aeson-import qualified Data.Aeson as A (ToJSON(..), FromJSON(..), genericParseJSON, defaultOptions, Options(..), withObject, withText, (.:), (.:?), object, (.=))+import qualified Data.Aeson as A (ToJSON(..), FromJSON(..), genericParseJSON) -- hoauth import Network.OAuth.OAuth2.Internal (AccessToken(..)) -- req import Network.HTTP.Req (Req) -- text-import Data.Text (Text, pack, unpack)--import qualified MSGraphAPI.Internal.Common as MSG (get, post, aesonOptions)+import Data.Text (Text) +import qualified MSGraphAPI.Internal.Common as MSG (get, aesonOptions) +-- | Representation of a user in the MS Graph API+--+-- https://learn.microsoft.com/en-us/graph/api/resources/users?view=graph-rest-1.0 data User = User {   uId :: Text   , uUserPrincipalName :: Text@@ -22,6 +28,7 @@                  } deriving (Eq, Ord, Show, Generic) instance A.FromJSON User where   parseJSON = A.genericParseJSON (MSG.aesonOptions "u")+instance A.ToJSON User   -- | Get user information