Skip to content

Commit 4340d6c

Browse files
committed
add remaining drive endpoints
1 parent a1f7639 commit 4340d6c

File tree

3 files changed

+246
-11
lines changed

3 files changed

+246
-11
lines changed

ms_graph/drives.py

Lines changed: 245 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def get_root_drive_delta(self) -> Dict:
7272
Dict:
7373
A List of Drive Resource Object.
7474
"""
75-
75+
7676
content = self.graph_session.make_request(
7777
method='get',
7878
endpoint=self.endpoint + "/root/delta"
@@ -96,6 +96,90 @@ def get_root_drive_followed(self) -> Dict:
9696

9797
return content
9898

99+
def get_recent_files(self) -> Dict:
100+
"""List a set of items that have been recently used by the signed in user.
101+
102+
### Overview:
103+
----
104+
This collection includes items that are in the user's drive
105+
as well as items they have access to from other drives.
106+
107+
### Returns
108+
----
109+
Dict:
110+
A List of DriveItem Resource Objects.
111+
"""
112+
113+
content = self.graph_session.make_request(
114+
method='get',
115+
endpoint="me/drive/recent"
116+
)
117+
118+
return content
119+
120+
def get_shared_files(self) -> Dict:
121+
"""Retrieve a collection of DriveItem resources that have been shared with the owner of the Drive.
122+
123+
### Returns
124+
----
125+
Dict:
126+
A List of DriveItem Resource Objects.
127+
"""
128+
129+
content = self.graph_session.make_request(
130+
method='get',
131+
endpoint="me/drive/sharedWithMe"
132+
)
133+
134+
return content
135+
136+
def get_special_folder_by_name(self, folder_name: str) -> Dict:
137+
"""Use the special collection to access a special folder by name.
138+
139+
### Overview:
140+
----
141+
Special folders provide simple aliases to access well-known folders
142+
in OneDrive without the need to look up the folder by path (which
143+
would require localization), or reference the folder with an ID. If
144+
a special folder is renamed or moved to another location within the
145+
drive, this syntax will continue to find that folder. Special folders
146+
are automatically created the first time an application attempts to write
147+
to one, if it doesn't already exist. If a user deletes one, it is recreated
148+
when written to again. Note: If you have read-only permissions and request
149+
a special folder that doesn't exist, you'll receive a 403 Forbidden error.
150+
151+
### Returns
152+
----
153+
Dict:
154+
A List of DriveItem Resource Objects.
155+
"""
156+
157+
content = self.graph_session.make_request(
158+
method='get',
159+
endpoint="/me/drive/special/{folder_name}".format(
160+
folder_name=folder_name)
161+
)
162+
163+
return content
164+
165+
def get_special_folder_children_by_name(self, folder_name: str) -> Dict:
166+
"""Use the special collection to access a collection of Children belonging to special folder
167+
by name.
168+
169+
### Returns
170+
----
171+
Dict:
172+
A List of DriveItem Resource Objects.
173+
"""
174+
175+
content = self.graph_session.make_request(
176+
method='get',
177+
endpoint="/me/drive/special/{folder_name}/children".format(
178+
folder_name=folder_name)
179+
)
180+
181+
return content
182+
99183
def get_drive_by_id(self, drive_id: str) -> Dict:
100184
"""Grab's a Drive Resource using the Drive ID.
101185
@@ -112,13 +196,47 @@ def get_drive_by_id(self, drive_id: str) -> Dict:
112196

113197
return content
114198

199+
def get_my_drive(self) -> Dict:
200+
"""Get's the User's Current OneDrive.
201+
202+
### Returns
203+
----
204+
Dict:
205+
A Drive Resource Object.
206+
"""
207+
208+
content = self.graph_session.make_request(
209+
method='get',
210+
endpoint=self.endpoint + "/me"
211+
)
212+
213+
return content
214+
215+
def get_my_drive_children(self, item_id: str) -> Dict:
216+
"""Returns a list of DriveItem Resources for the User's Current OneDrive.
217+
218+
### Returns
219+
----
220+
Dict:
221+
A List of DriveChildren Resource Objects.
222+
"""
223+
224+
content = self.graph_session.make_request(
225+
method='get',
226+
endpoint=self.endpoint + "/me/drive/items/{item_id}/children".format(
227+
item_id=item_id
228+
)
229+
)
230+
231+
return content
232+
115233
def get_my_drives(self) -> Dict:
116234
"""List children under the Drive for user's default Drive.
117235
118236
### Returns
119237
----
120238
Dict:
121-
A List of Drive Resource Object.
239+
A List of Drive Resource Objects.
122240
"""
123241

124242
content = self.graph_session.make_request(
@@ -128,28 +246,99 @@ def get_my_drives(self) -> Dict:
128246

129247
return content
130248

249+
def get_user_drive(self, user_id: str) -> Dict:
250+
"""Returns the User's default OneDrive.
251+
252+
### Returns
253+
----
254+
Dict:
255+
A Drive Resource Object.
256+
"""
257+
258+
content = self.graph_session.make_request(
259+
method='get',
260+
endpoint="users/{user_id}/drive".format(user_id=user_id)
261+
)
262+
263+
return content
264+
265+
def get_user_drive_children(self, user_id: str, item_id: str) -> Dict:
266+
"""Returns a list of DriveItem Resources for the Default User Drive.
267+
268+
### Returns
269+
----
270+
Dict:
271+
A List of DriveChildren Resource Objects.
272+
"""
273+
274+
content = self.graph_session.make_request(
275+
method='get',
276+
endpoint="users/{user_id}/drive/items/{item_id}/children".format(
277+
user_id=user_id,
278+
item_id=item_id
279+
)
280+
)
281+
282+
return content
283+
131284
def get_user_drives(self, user_id: str) -> Dict:
132-
"""List children under the Drive for user's default Drive.
285+
"""Returns a List Drive Resource Objects for user's default Drive.
133286
134287
### Returns
135288
----
136289
Dict:
137-
A List of Drive Resource Object.
290+
A List of Drive Resource Objects.
138291
"""
292+
139293
content = self.graph_session.make_request(
140294
method='get',
141295
endpoint="users/{user_id}/drives".format(user_id=user_id)
142296
)
143297

144298
return content
145299

300+
def get_group_drive(self, group_id: str) -> Dict:
301+
"""Returns a Site Group default Drive..
302+
303+
### Returns
304+
----
305+
Dict:
306+
A Drive Resource Object.
307+
"""
308+
309+
content = self.graph_session.make_request(
310+
method='get',
311+
endpoint="groups/{group_id}/drive".format(group_id=group_id)
312+
)
313+
314+
return content
315+
316+
def get_group_drive_children(self, group_id: str, item_id: str) -> Dict:
317+
"""Returns a list of DriveItems for the Specified Drive ID for the Specified Group.
318+
319+
### Returns
320+
----
321+
Dict:
322+
A List of DriveChildren Resource Objects.
323+
"""
324+
325+
content = self.graph_session.make_request(
326+
method='get',
327+
endpoint="groups/{group_id}/drive/items/{item_id}/children".format(
328+
group_id=group_id,
329+
item_id=item_id
330+
)
331+
)
332+
333+
return content
334+
146335
def get_group_drives(self, group_id: str) -> Dict:
147336
"""List children under the Drive for user's default Drive.
148337
149338
### Returns
150339
----
151340
Dict:
152-
A List of Drive Resource Object.
341+
A List of Drive Resource Objects.
153342
"""
154343

155344
content = self.graph_session.make_request(
@@ -158,3 +347,54 @@ def get_group_drives(self, group_id: str) -> Dict:
158347
)
159348

160349
return content
350+
351+
def get_sites_drive(self, site_id: str) -> Dict:
352+
"""Returns the Default Drive Resource For the Specified Site ID.
353+
354+
### Returns
355+
----
356+
Dict:
357+
A Drive Resource Object.
358+
"""
359+
360+
content = self.graph_session.make_request(
361+
method='get',
362+
endpoint="sites/{site_id}/drive".format(site_id=site_id)
363+
)
364+
365+
return content
366+
367+
def get_sites_drive_children(self, site_id: str, item_id: str) -> Dict:
368+
"""Returns a list of DriveItems for the Specified Drive ID on the Specified Site.
369+
370+
### Returns
371+
----
372+
Dict:
373+
A List of DriveChildren Resource Objects.
374+
"""
375+
376+
content = self.graph_session.make_request(
377+
method='get',
378+
endpoint="sites/{site_id}/drive/items/{item_id}/children".format(
379+
site_id=site_id,
380+
item_id=item_id
381+
)
382+
)
383+
384+
return content
385+
386+
def get_sites_drives(self, site_id: str) -> Dict:
387+
"""Returns a List of Drive Resources for the Specified Site ID.
388+
389+
### Returns
390+
----
391+
Dict:
392+
A List of Drive Resource Objects.
393+
"""
394+
395+
content = self.graph_session.make_request(
396+
method='get',
397+
endpoint="sites/{site_id}/drives".format(site_id=site_id)
398+
)
399+
400+
return content

samples/configs/config.ini

Lines changed: 0 additions & 5 deletions
This file was deleted.

samples/configs/write_config_video.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
config.set('graph_api', 'redirect_uri', '')
1313

1414
# Write the file.
15-
with open(file='samples/configs/config_video.ini', mode='w+') as f:
15+
with open(file='samples/configs/config.ini', mode='w+') as f:
1616
config.write(f)

0 commit comments

Comments
 (0)