-
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
Jul 2, 2023
1 parent
ce63e16
commit ec85173
Showing
4 changed files
with
66 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(..), Value, genericParseJSON, (.:), (.:?), Object, withObject, Key) | ||
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, pack, unpack) | ||
-- time | ||
import Data.Time (ZonedTime) | ||
|
||
import qualified MSGraphAPI.Internal.Common as MSG (get, getLbs, post, 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"] |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
-- | Files.DriveItem | ||
module MSGraphAPI.Files.DriveItem ( | ||
-- * list items | ||
listRootChildrenMe | ||
|