MCPcopy Create free account
hub / github.com/O365/python-o365 / Drive

Class Drive

O365/drive.py:1380–1828  ·  view source on GitHub ↗

A Drive representation. A Drive is a Container of Folders and Files and act as a root item

Source from the content-addressed store, hash-verified

1378
1379
1380class Drive(ApiComponent):
1381 """ A Drive representation.
1382 A Drive is a Container of Folders and Files and act as a root item """
1383
1384 _endpoints = {
1385 'default_drive': '/drive',
1386 'get_drive': '/drives/{id}',
1387 'get_root_item_default': '/drive/root',
1388 'get_root_item': '/drives/{id}/root',
1389 'list_items_default': '/drive/root/children',
1390 'list_items': '/drives/{id}/root/children',
1391 'get_item_default': '/drive/items/{item_id}',
1392 'get_item': '/drives/{id}/items/{item_id}',
1393 'get_item_by_path_default': '/drive/root:{item_path}',
1394 'get_item_by_path': '/drives/{id}/root:{item_path}',
1395 'recent_default': '/drive/recent',
1396 'recent': '/drives/{id}/recent',
1397 'shared_with_me_default': '/drive/sharedWithMe',
1398 'shared_with_me': '/drives/{id}/sharedWithMe',
1399 'get_special_default': '/drive/special/{name}',
1400 'get_special': '/drives/{id}/special/{name}',
1401 'search_default': "/drive/search(q='{search_text}')",
1402 'search': "/drives/{id}/search(q='{search_text}')",
1403 }
1404
1405 def __init__(self, *, parent=None, con=None, **kwargs):
1406 """ Create a drive representation
1407
1408 :param parent: parent for this operation
1409 :type parent: Drive or Storage
1410 :param Connection con: connection to use if no parent specified
1411 :param Protocol protocol: protocol to use if no parent specified
1412 (kwargs)
1413 :param str main_resource: use this resource instead of parent resource
1414 (kwargs)
1415 """
1416 if parent and con:
1417 raise ValueError('Need a parent or a connection but not both')
1418 self.con = parent.con if parent else con
1419 self.parent = parent if isinstance(parent, Drive) else None
1420
1421 # Choose the main_resource passed in kwargs over parent main_resource
1422 main_resource = kwargs.pop('main_resource', None)
1423 if main_resource is None:
1424 main_resource = getattr(parent, 'main_resource', None) if parent else None
1425 super().__init__(
1426 protocol=parent.protocol if parent else kwargs.get('protocol'),
1427 main_resource=main_resource)
1428
1429 self._update_data(kwargs)
1430
1431 def _update_data(self, data):
1432 cloud_data = data.get(self._cloud_data_key, {})
1433
1434 self.object_id = cloud_data.get(self._cc('id'))
1435 # Fallback to manual drive
1436 self.name = cloud_data.get(self._cc('name'), data.get('name',
1437 ''))

Callers 2

get_driveMethod · 0.85
get_default_driveMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected