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 pathshared_collection.py
More file actions
150 lines (121 loc) · 5.95 KB
/
Copy pathshared_collection.py
File metadata and controls
150 lines (121 loc) · 5.95 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
# -*- 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 __future__ import unicode_literals
from ..collection_base import CollectionRequestBase, CollectionResponseBase
from ..request_builder_base import RequestBuilderBase
from ..model.shared_collection_page import SharedCollectionPage
import json
import asyncio
class SharedCollectionRequest(CollectionRequestBase):
def __init__(self, request_url, client, options):
"""Initialize the SharedCollectionRequest
Args:
request_url (str): The url to perform the SharedCollectionRequest
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(SharedCollectionRequest, self).__init__(request_url, client, options)
def get(self):
"""Gets the SharedCollectionPage
Returns:
:class:`SharedCollectionPage<onedrivesdk.model.shared_collection_page.SharedCollectionPage>`:
The SharedCollectionPage
"""
self.method = "GET"
collection_response = SharedCollectionResponse(json.loads(self.send().content))
return self._page_from_response(collection_response)
@asyncio.coroutine
def get_async(self):
"""Gets the SharedCollectionPage in async
Yields:
:class:`SharedCollectionPage<onedrivesdk.model.shared_collection_page.SharedCollectionPage>`:
The SharedCollectionPage
"""
future = self._client._loop.run_in_executor(None,
self.get)
collection_page = yield from future
return collection_page
@staticmethod
def get_next_page_request(collection_page, client, options=None):
"""Gets the SharedCollectionRequest for the next page. Returns None if there is no next page
Args:
collection_page (:class:`SharedCollectionPage<onedrivesdk.model.shared_collection_page.SharedCollectionPage>`):
The collection to get the next page for
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. Defaults to None.
Yields:
:class:`SharedCollectionRequest<onedrivesdk.request.shared_collection.SharedCollectionRequest>`:
The SharedCollectionRequest
"""
if collection_page._next_page_link:
return SharedCollectionRequest(collection_page._next_page_link, client, options)
else:
return None
class SharedCollectionRequestBuilder(RequestBuilderBase):
def __getitem__(self, key):
"""Get the ItemRequestBuilder with the specified key
Args:
key (str): The key to get a ItemRequestBuilder for
Returns:
:class:`ItemRequestBuilder<onedrivesdk.request.item_request_builder.ItemRequestBuilder>`:
A ItemRequestBuilder for that key
"""
return ItemRequestBuilder(self.append_to_request_url(str(key)), self._client)
def request(self, expand=None, select=None, top=None, order_by=None, options=None):
"""Builds the SharedCollectionRequest
Args:
expand (str): Default None, comma-seperated list of relationships
to expand in the response.
select (str): Default None, comma-seperated list of properties to
include in the response.
top (int): Default None, the number of items to return in a result.
order_by (str): Default None, comma-seperated list of properties
that are used to sort the order of items in the response.
options (list of :class:`Option<onedrivesdk.options.Option>`):
A list of options to pass into the request. Defaults to None.
Returns:
:class:`SharedCollectionRequest<onedrivesdk.request.shared_collection.SharedCollectionRequest>`:
The SharedCollectionRequest
"""
req = SharedCollectionRequest(self._request_url, self._client, options)
req._set_query_options(expand=expand, select=select, top=top, order_by=order_by)
return req
def get(self):
"""Gets the SharedCollectionPage
Returns:
:class:`SharedCollectionPage<onedrivesdk.model.shared_collection_page.SharedCollectionPage>`:
The SharedCollectionPage
"""
return self.request().get()
@asyncio.coroutine
def get_async(self):
"""Gets the SharedCollectionPage in async
Yields:
:class:`SharedCollectionPage<onedrivesdk.model.shared_collection_page.SharedCollectionPage>`:
The SharedCollectionPage
"""
collection_page = yield from self.request().get_async()
return collection_page
class SharedCollectionResponse(CollectionResponseBase):
@property
def collection_page(self):
"""The collection page stored in the response JSON
Returns:
:class:`SharedCollectionPage<onedrivesdk.model.shared_collection_page.SharedCollectionPage>`:
The collection page
"""
if self._collection_page:
self._collection_page._prop_list = self._prop_dict["value"]
else:
self._collection_page = SharedCollectionPage(self._prop_dict["value"])
return self._collection_page
from ..request.item_request_builder import ItemRequestBuilder