This repository was archived by the owner on Oct 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 191
Expand file tree
/
Copy pathdrive_request.py
More file actions
114 lines (97 loc) · 3.94 KB
/
Copy pathdrive_request.py
File metadata and controls
114 lines (97 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# -*- coding: utf-8 -*-
'''
# Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
#
# This file was generated and any changes will be overwritten.
'''
from ..request_base import RequestBase
from ..model.drive import Drive
import json
import asyncio
class DriveRequest(RequestBase):
"""The type DriveRequest."""
def __init__(self, request_url, client, options):
"""Constructs a new DriveRequest.
Args:
request_url (str): The url to perform the DriveRequest
on
client (:class:`OneDriveClient<onedrivesdk.request.one_drive_client.OneDriveClient>`):
The client which will be used for the request
options (list of :class:`Option<onedrivesdk.options.Option>`):
A list of options to pass into the request
"""
super(DriveRequest, self).__init__(request_url, client, options)
def delete(self):
"""Deletes the specified Drive."""
self.method = "DELETE"
self.send()
@asyncio.coroutine
def delete_async(self):
"""Deletes the specified Drive."""
future = self._client._loop.run_in_executor(None,
self.delete)
yield from future
def get(self):
"""Gets the specified Drive.
Returns:
:class:`Drive<onedrivesdk.model.drive.Drive>`:
The Drive.
"""
self.method = "GET"
entity = Drive(json.loads(self.send().content))
self._initialize_collection_properties(entity)
return entity
@asyncio.coroutine
def get_async(self):
"""Gets the specified Drive in async.
Yields:
:class:`Drive<onedrivesdk.model.drive.Drive>`:
The Drive.
"""
future = self._client._loop.run_in_executor(None,
self.get)
entity = yield from future
return entity
def update(self, drive):
"""Updates the specified Drive.
Args:
drive (:class:`Drive<onedrivesdk.model.drive.Drive>`):
The Drive to update.
Returns:
:class:`Drive<onedrivesdk.model.drive.Drive>`:
The updated Drive.
"""
self.content_type = "application/json"
self.method = "PATCH"
entity = Drive(json.loads(self.send(drive).content))
self._initialize_collection_properties(entity)
return entity
@asyncio.coroutine
def update_async(self, drive):
"""Updates the specified Drive in async
Args:
drive (:class:`Drive<onedrivesdk.model.drive.Drive>`):
The Drive to update.
Yields:
:class:`Drive<onedrivesdk.model.drive.Drive>`:
The updated Drive.
"""
future = self._client._loop.run_in_executor(None,
self.update,
drive)
entity = yield from future
return entity
def _initialize_collection_properties(self, value):
if value and value._prop_dict:
if value.items:
if "items@odata.nextLink" in value._prop_dict:
next_page_link = value._prop_dict["items@odata.nextLink"]
value.items._next_page_link = next_page_link
if value.shared:
if "shared@odata.nextLink" in value._prop_dict:
next_page_link = value._prop_dict["shared@odata.nextLink"]
value.shared._next_page_link = next_page_link
if value.special:
if "special@odata.nextLink" in value._prop_dict:
next_page_link = value._prop_dict["special@odata.nextLink"]
value.special._next_page_link = next_page_link