smartsheet-python-sdk 3.5.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- smartsheet/__init__.py +37 -0
- smartsheet/attachments.py +565 -0
- smartsheet/cells.py +164 -0
- smartsheet/contacts.py +78 -0
- smartsheet/discussions.py +411 -0
- smartsheet/events.py +79 -0
- smartsheet/exceptions.py +130 -0
- smartsheet/favorites.py +116 -0
- smartsheet/folders.py +438 -0
- smartsheet/groups.py +186 -0
- smartsheet/home.py +180 -0
- smartsheet/images.py +61 -0
- smartsheet/models/__init__.py +126 -0
- smartsheet/models/access_token.py +95 -0
- smartsheet/models/account.py +77 -0
- smartsheet/models/alternate_email.py +88 -0
- smartsheet/models/asset_share.py +165 -0
- smartsheet/models/asset_shares_paginated_result.py +84 -0
- smartsheet/models/attachment.py +181 -0
- smartsheet/models/auto_number_format.py +81 -0
- smartsheet/models/automation_action.py +162 -0
- smartsheet/models/automation_rule.py +164 -0
- smartsheet/models/boolean_object_value.py +38 -0
- smartsheet/models/bulk_item_failure.py +77 -0
- smartsheet/models/bulk_item_result.py +111 -0
- smartsheet/models/cell.py +193 -0
- smartsheet/models/cell_data_item.py +152 -0
- smartsheet/models/cell_history.py +67 -0
- smartsheet/models/cell_link.py +91 -0
- smartsheet/models/cell_link_widget_content.py +101 -0
- smartsheet/models/chart_widget_content.py +124 -0
- smartsheet/models/column.py +253 -0
- smartsheet/models/comment.py +126 -0
- smartsheet/models/contact.py +88 -0
- smartsheet/models/contact_object_value.py +59 -0
- smartsheet/models/container_destination.py +74 -0
- smartsheet/models/copy_or_move_row_destination.py +54 -0
- smartsheet/models/copy_or_move_row_directive.py +64 -0
- smartsheet/models/copy_or_move_row_result.py +67 -0
- smartsheet/models/criteria.py +82 -0
- smartsheet/models/cross_sheet_reference.py +134 -0
- smartsheet/models/currency.py +64 -0
- smartsheet/models/date_object_value.py +56 -0
- smartsheet/models/datetime_object_value.py +56 -0
- smartsheet/models/discussion.py +183 -0
- smartsheet/models/downloaded_file.py +106 -0
- smartsheet/models/duration.py +112 -0
- smartsheet/models/email.py +82 -0
- smartsheet/models/enums/__init__.py +56 -0
- smartsheet/models/enums/access_level.py +26 -0
- smartsheet/models/enums/asset_type.py +10 -0
- smartsheet/models/enums/attachment_parent_type.py +23 -0
- smartsheet/models/enums/attachment_sub_type.py +26 -0
- smartsheet/models/enums/attachment_type.py +29 -0
- smartsheet/models/enums/automation_action_frequency.py +24 -0
- smartsheet/models/enums/automation_action_type.py +23 -0
- smartsheet/models/enums/automation_rule_disabled_reason.py +27 -0
- smartsheet/models/enums/cell_link_status.py +28 -0
- smartsheet/models/enums/column_type.py +31 -0
- smartsheet/models/enums/criteria_target.py +21 -0
- smartsheet/models/enums/cross_sheet_reference_status.py +28 -0
- smartsheet/models/enums/currency_code.py +43 -0
- smartsheet/models/enums/day_descriptors.py +30 -0
- smartsheet/models/enums/day_ordinal.py +25 -0
- smartsheet/models/enums/event_action.py +76 -0
- smartsheet/models/enums/event_obejct_type.py +34 -0
- smartsheet/models/enums/event_source.py +27 -0
- smartsheet/models/enums/global_template.py +23 -0
- smartsheet/models/enums/operator.py +62 -0
- smartsheet/models/enums/paper_type.py +29 -0
- smartsheet/models/enums/predecessor_type.py +24 -0
- smartsheet/models/enums/publish_accessible_by.py +22 -0
- smartsheet/models/enums/schedule_type.py +25 -0
- smartsheet/models/enums/seat_type.py +17 -0
- smartsheet/models/enums/share_scope.py +22 -0
- smartsheet/models/enums/share_type.py +22 -0
- smartsheet/models/enums/sheet_email_format.py +23 -0
- smartsheet/models/enums/sheet_filter_operator.py +22 -0
- smartsheet/models/enums/sheet_filter_type.py +23 -0
- smartsheet/models/enums/sort_direction.py +22 -0
- smartsheet/models/enums/symbol.py +45 -0
- smartsheet/models/enums/system_column_type.py +25 -0
- smartsheet/models/enums/update_request_status.py +23 -0
- smartsheet/models/enums/user_status.py +23 -0
- smartsheet/models/enums/widget_type.py +32 -0
- smartsheet/models/error.py +74 -0
- smartsheet/models/error_result.py +117 -0
- smartsheet/models/event.py +153 -0
- smartsheet/models/event_result.py +86 -0
- smartsheet/models/explicit_null.py +24 -0
- smartsheet/models/favorite.py +81 -0
- smartsheet/models/folder.py +177 -0
- smartsheet/models/font_family.py +63 -0
- smartsheet/models/format_details.py +55 -0
- smartsheet/models/format_tables.py +191 -0
- smartsheet/models/group.py +134 -0
- smartsheet/models/group_member.py +104 -0
- smartsheet/models/home.py +110 -0
- smartsheet/models/hyperlink.py +81 -0
- smartsheet/models/image.py +101 -0
- smartsheet/models/image_url.py +91 -0
- smartsheet/models/image_url_map.py +68 -0
- smartsheet/models/image_widget_content.py +117 -0
- smartsheet/models/index_result.py +118 -0
- smartsheet/models/json_object.py +59 -0
- smartsheet/models/multi_contact_object_value.py +49 -0
- smartsheet/models/multi_picklist_object_value.py +48 -0
- smartsheet/models/multi_row_email.py +60 -0
- smartsheet/models/number_object_value.py +38 -0
- smartsheet/models/o_auth_error.py +86 -0
- smartsheet/models/object_value.py +130 -0
- smartsheet/models/paginated_children_result.py +80 -0
- smartsheet/models/predecessor.py +102 -0
- smartsheet/models/predecessor_list.py +49 -0
- smartsheet/models/primitive_object_value.py +59 -0
- smartsheet/models/profile_image.py +72 -0
- smartsheet/models/project_settings.py +89 -0
- smartsheet/models/recipient.py +63 -0
- smartsheet/models/report.py +90 -0
- smartsheet/models/report_cell.py +59 -0
- smartsheet/models/report_column.py +67 -0
- smartsheet/models/report_publish.py +95 -0
- smartsheet/models/report_row.py +68 -0
- smartsheet/models/report_widget_content.py +78 -0
- smartsheet/models/result.py +105 -0
- smartsheet/models/row.py +336 -0
- smartsheet/models/row_email.py +83 -0
- smartsheet/models/row_mapping.py +77 -0
- smartsheet/models/schedule.py +140 -0
- smartsheet/models/scope.py +70 -0
- smartsheet/models/search_result.py +67 -0
- smartsheet/models/search_result_item.py +150 -0
- smartsheet/models/selection_range.py +86 -0
- smartsheet/models/sent_update_request.py +172 -0
- smartsheet/models/server_info.py +67 -0
- smartsheet/models/share.py +183 -0
- smartsheet/models/sheet.py +462 -0
- smartsheet/models/sheet_email.py +81 -0
- smartsheet/models/sheet_filter.py +106 -0
- smartsheet/models/sheet_filter_details.py +76 -0
- smartsheet/models/sheet_publish.py +184 -0
- smartsheet/models/sheet_summary.py +59 -0
- smartsheet/models/sheet_user_permissions.py +58 -0
- smartsheet/models/sheet_user_settings.py +72 -0
- smartsheet/models/shortcut_data_item.py +102 -0
- smartsheet/models/shortcut_widget_content.py +61 -0
- smartsheet/models/sight.py +175 -0
- smartsheet/models/sight_publish.py +77 -0
- smartsheet/models/sort_criterion.py +64 -0
- smartsheet/models/sort_specifier.py +55 -0
- smartsheet/models/source.py +83 -0
- smartsheet/models/string_object_value.py +38 -0
- smartsheet/models/summary_field.py +256 -0
- smartsheet/models/template.py +171 -0
- smartsheet/models/title_rich_text_widget_content.py +68 -0
- smartsheet/models/token_paginated_result.py +79 -0
- smartsheet/models/update_request.py +110 -0
- smartsheet/models/user.py +58 -0
- smartsheet/models/user_model.py +280 -0
- smartsheet/models/user_plan.py +77 -0
- smartsheet/models/user_profile.py +89 -0
- smartsheet/models/version.py +57 -0
- smartsheet/models/web_content_widget_content.py +60 -0
- smartsheet/models/webhook.py +219 -0
- smartsheet/models/webhook_secret.py +58 -0
- smartsheet/models/webhook_stats.py +76 -0
- smartsheet/models/webhook_subscope.py +50 -0
- smartsheet/models/widget.py +211 -0
- smartsheet/models/widget_content.py +52 -0
- smartsheet/models/widget_hyperlink.py +74 -0
- smartsheet/models/workspace.py +185 -0
- smartsheet/object_value.py +72 -0
- smartsheet/passthrough.py +127 -0
- smartsheet/reports.py +382 -0
- smartsheet/search.py +100 -0
- smartsheet/server.py +48 -0
- smartsheet/session.py +70 -0
- smartsheet/sharing.py +163 -0
- smartsheet/sheets.py +2062 -0
- smartsheet/sights.py +370 -0
- smartsheet/smartsheet.py +684 -0
- smartsheet/templates.py +87 -0
- smartsheet/token.py +128 -0
- smartsheet/types.py +323 -0
- smartsheet/users.py +490 -0
- smartsheet/util.py +199 -0
- smartsheet/version.py +34 -0
- smartsheet/webhooks.py +161 -0
- smartsheet/workspaces.py +647 -0
- smartsheet_python_sdk-3.5.5.dist-info/METADATA +120 -0
- smartsheet_python_sdk-3.5.5.dist-info/RECORD +195 -0
- smartsheet_python_sdk-3.5.5.dist-info/WHEEL +5 -0
- smartsheet_python_sdk-3.5.5.dist-info/licenses/LICENSE.md +201 -0
- smartsheet_python_sdk-3.5.5.dist-info/licenses/NOTICE +10 -0
- smartsheet_python_sdk-3.5.5.dist-info/top_level.txt +1 -0
smartsheet/workspaces.py
ADDED
|
@@ -0,0 +1,647 @@
|
|
|
1
|
+
# pylint: disable=C0111,R0902,R0913
|
|
2
|
+
# Smartsheet Python SDK.
|
|
3
|
+
#
|
|
4
|
+
# Copyright 2018 Smartsheet.com, Inc.
|
|
5
|
+
#
|
|
6
|
+
# Licensed under the Apache License, Version 2.0 (the "License"): you may
|
|
7
|
+
# not use this file except in compliance with the License. You may obtain
|
|
8
|
+
# a copy of the License at
|
|
9
|
+
#
|
|
10
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
#
|
|
12
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
14
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
15
|
+
# License for the specific language governing permissions and limitations
|
|
16
|
+
# under the License.
|
|
17
|
+
|
|
18
|
+
from __future__ import absolute_import
|
|
19
|
+
|
|
20
|
+
import logging
|
|
21
|
+
import os.path
|
|
22
|
+
import warnings
|
|
23
|
+
from typing import Optional, Union
|
|
24
|
+
|
|
25
|
+
from . import fresh_operation
|
|
26
|
+
from .models.folder import Folder
|
|
27
|
+
from .util import deprecated
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class Workspaces:
|
|
31
|
+
|
|
32
|
+
"""Class for handling Workspaces operations."""
|
|
33
|
+
|
|
34
|
+
def __init__(self, smartsheet_obj):
|
|
35
|
+
"""Init Workspaces with base Smartsheet object."""
|
|
36
|
+
self._base = smartsheet_obj
|
|
37
|
+
self._log = logging.getLogger(__name__)
|
|
38
|
+
|
|
39
|
+
def copy_workspace(
|
|
40
|
+
self, workspace_id, container_destination_obj, include=None, skip_remap=None
|
|
41
|
+
):
|
|
42
|
+
"""Create a copy of the specified Workspace.
|
|
43
|
+
|
|
44
|
+
Args:
|
|
45
|
+
workspace_id (int): Workspace ID
|
|
46
|
+
container_destination_obj (ContainerDestination): Container Destination object.
|
|
47
|
+
include (list[str]): A comma-separated list of optional elements to copy.
|
|
48
|
+
Valid list values: attachments, cellLinks, data, discussions, filters, forms,
|
|
49
|
+
ruleRecipients, rules, shares, all (deprecated). Cell history will not be copied,
|
|
50
|
+
regardless of which **include** parameter values are specified.
|
|
51
|
+
skip_remap (list[str]): A comma separated list of references to NOT re-map for
|
|
52
|
+
the newly created resource.
|
|
53
|
+
Valid list items: cellLinks, reports, sheetHyperlinks, sights
|
|
54
|
+
Returns:
|
|
55
|
+
Result
|
|
56
|
+
"""
|
|
57
|
+
_op = fresh_operation("copy_workspace")
|
|
58
|
+
_op["method"] = "POST"
|
|
59
|
+
_op["path"] = "/workspaces/" + str(workspace_id) + "/copy"
|
|
60
|
+
_op["query_params"]["include"] = include
|
|
61
|
+
_op["query_params"]["skipRemap"] = skip_remap
|
|
62
|
+
_op["json"] = container_destination_obj
|
|
63
|
+
|
|
64
|
+
expected = ["Result", "Workspace"]
|
|
65
|
+
|
|
66
|
+
prepped_request = self._base.prepare_request(_op)
|
|
67
|
+
response = self._base.request(prepped_request, expected, _op)
|
|
68
|
+
|
|
69
|
+
return response
|
|
70
|
+
|
|
71
|
+
def create_folder_in_workspace(self, workspace_id, folder_obj):
|
|
72
|
+
"""Creates a Folder in the specified Workspace
|
|
73
|
+
|
|
74
|
+
Args:
|
|
75
|
+
workspace_id (int): Workspace ID
|
|
76
|
+
folder_obj (Folder): Folder object.
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
Result
|
|
80
|
+
"""
|
|
81
|
+
if isinstance(folder_obj, str):
|
|
82
|
+
folder_obj = Folder({"name": folder_obj})
|
|
83
|
+
|
|
84
|
+
_op = fresh_operation("create_folder_in_workspace")
|
|
85
|
+
_op["method"] = "POST"
|
|
86
|
+
_op["path"] = "/workspaces/" + str(workspace_id) + "/folders"
|
|
87
|
+
_op["json"] = folder_obj
|
|
88
|
+
|
|
89
|
+
expected = ["Result", "Folder"]
|
|
90
|
+
|
|
91
|
+
prepped_request = self._base.prepare_request(_op)
|
|
92
|
+
response = self._base.request(prepped_request, expected, _op)
|
|
93
|
+
|
|
94
|
+
return response
|
|
95
|
+
|
|
96
|
+
def create_sheet_in_workspace(self, workspace_id, sheet_obj):
|
|
97
|
+
"""Create a Sheet from scratch at the top-level of the specified
|
|
98
|
+
Workspace.
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
workspace_id (int): Workspace ID
|
|
102
|
+
sheet_obj (Sheet): Sheet object.
|
|
103
|
+
|
|
104
|
+
Returns:
|
|
105
|
+
Result
|
|
106
|
+
"""
|
|
107
|
+
_op = fresh_operation("create_sheet_in_workspace")
|
|
108
|
+
_op["method"] = "POST"
|
|
109
|
+
_op["path"] = "/workspaces/" + str(workspace_id) + "/sheets"
|
|
110
|
+
_op["json"] = sheet_obj
|
|
111
|
+
|
|
112
|
+
expected = ["Result", "Sheet"]
|
|
113
|
+
|
|
114
|
+
prepped_request = self._base.prepare_request(_op)
|
|
115
|
+
response = self._base.request(prepped_request, expected, _op)
|
|
116
|
+
|
|
117
|
+
return response
|
|
118
|
+
|
|
119
|
+
# pylint: disable=invalid-name
|
|
120
|
+
def create_sheet_in_workspace_from_template(
|
|
121
|
+
self, workspace_id, sheet_obj, include=None
|
|
122
|
+
):
|
|
123
|
+
"""Create a Sheet in the specified Workspace from the specified Template.
|
|
124
|
+
|
|
125
|
+
The Sheet object should be limited to the following
|
|
126
|
+
attributes:
|
|
127
|
+
|
|
128
|
+
name (required): need not be unique.
|
|
129
|
+
fromId (required): the ID of the Template to use in creating the
|
|
130
|
+
Sheet.
|
|
131
|
+
|
|
132
|
+
The optional Include parameter is a list of elements to copy from
|
|
133
|
+
the Template. It may include: data, attachments, discussions,
|
|
134
|
+
cellLinks, forms
|
|
135
|
+
|
|
136
|
+
Args:
|
|
137
|
+
workspace_id (int): Workspace ID
|
|
138
|
+
sheet_obj (Sheet): Sheet object.
|
|
139
|
+
include (list[str]): A list of optional elements
|
|
140
|
+
to include from the source Template. Valid list values:
|
|
141
|
+
data, attachments, discussions, cellLinks, forms.
|
|
142
|
+
|
|
143
|
+
Returns:
|
|
144
|
+
Result
|
|
145
|
+
"""
|
|
146
|
+
_op = fresh_operation("create_sheet_in_workspace_from_template")
|
|
147
|
+
_op["method"] = "POST"
|
|
148
|
+
_op["path"] = "/workspaces/" + str(workspace_id) + "/sheets"
|
|
149
|
+
_op["query_params"]["include"] = include
|
|
150
|
+
_op["json"] = sheet_obj
|
|
151
|
+
|
|
152
|
+
expected = ["Result", "Sheet"]
|
|
153
|
+
|
|
154
|
+
prepped_request = self._base.prepare_request(_op)
|
|
155
|
+
response = self._base.request(prepped_request, expected, _op)
|
|
156
|
+
|
|
157
|
+
return response
|
|
158
|
+
|
|
159
|
+
# pylint: enable=invalid-name
|
|
160
|
+
|
|
161
|
+
def create_workspace(self, workspace_obj):
|
|
162
|
+
"""Create a Workspace.
|
|
163
|
+
|
|
164
|
+
Args:
|
|
165
|
+
workspace_obj (Workspace): A Workspace object.
|
|
166
|
+
|
|
167
|
+
Returns:
|
|
168
|
+
Result
|
|
169
|
+
"""
|
|
170
|
+
_op = fresh_operation("create_workspace")
|
|
171
|
+
_op["method"] = "POST"
|
|
172
|
+
_op["path"] = "/workspaces"
|
|
173
|
+
_op["json"] = workspace_obj
|
|
174
|
+
|
|
175
|
+
expected = ["Result", "Workspace"]
|
|
176
|
+
|
|
177
|
+
prepped_request = self._base.prepare_request(_op)
|
|
178
|
+
response = self._base.request(prepped_request, expected, _op)
|
|
179
|
+
|
|
180
|
+
return response
|
|
181
|
+
|
|
182
|
+
def delete_share(self, workspace_id, share_id):
|
|
183
|
+
"""Delete the Share specified.
|
|
184
|
+
|
|
185
|
+
Args:
|
|
186
|
+
workspace_id (int): Workspace ID
|
|
187
|
+
share_id (str): Share ID
|
|
188
|
+
|
|
189
|
+
Returns:
|
|
190
|
+
Result
|
|
191
|
+
"""
|
|
192
|
+
_op = fresh_operation("delete_share")
|
|
193
|
+
_op["method"] = "DELETE"
|
|
194
|
+
_op["path"] = "/workspaces/" + str(workspace_id) + "/shares/" + str(share_id)
|
|
195
|
+
|
|
196
|
+
expected = ["Result", None]
|
|
197
|
+
prepped_request = self._base.prepare_request(_op)
|
|
198
|
+
response = self._base.request(prepped_request, expected, _op)
|
|
199
|
+
|
|
200
|
+
return response
|
|
201
|
+
|
|
202
|
+
def delete_workspace(self, workspace_id):
|
|
203
|
+
"""Delete the specified Workspace and its contents.
|
|
204
|
+
|
|
205
|
+
Args:
|
|
206
|
+
workspace_id (int): Workspace ID
|
|
207
|
+
|
|
208
|
+
Returns:
|
|
209
|
+
Result
|
|
210
|
+
"""
|
|
211
|
+
_op = fresh_operation("delete_workspace")
|
|
212
|
+
_op["method"] = "DELETE"
|
|
213
|
+
_op["path"] = "/workspaces/" + str(workspace_id)
|
|
214
|
+
|
|
215
|
+
expected = ["Result", None]
|
|
216
|
+
prepped_request = self._base.prepare_request(_op)
|
|
217
|
+
response = self._base.request(prepped_request, expected, _op)
|
|
218
|
+
|
|
219
|
+
return response
|
|
220
|
+
|
|
221
|
+
def get_share(self, workspace_id, share_id):
|
|
222
|
+
"""Get the specified Share.
|
|
223
|
+
|
|
224
|
+
Args:
|
|
225
|
+
workspace_id (int): Workspace ID
|
|
226
|
+
share_id (str): Share ID
|
|
227
|
+
|
|
228
|
+
Returns:
|
|
229
|
+
Share
|
|
230
|
+
"""
|
|
231
|
+
_op = fresh_operation("get_share")
|
|
232
|
+
_op["method"] = "GET"
|
|
233
|
+
_op["path"] = "/workspaces/" + str(workspace_id) + "/shares/" + str(share_id)
|
|
234
|
+
|
|
235
|
+
expected = "Share"
|
|
236
|
+
prepped_request = self._base.prepare_request(_op)
|
|
237
|
+
response = self._base.request(prepped_request, expected, _op)
|
|
238
|
+
|
|
239
|
+
return response
|
|
240
|
+
|
|
241
|
+
@deprecated
|
|
242
|
+
def get_workspace(self, workspace_id, load_all=False, include=None):
|
|
243
|
+
"""Get the specified Workspace and list its contents.
|
|
244
|
+
|
|
245
|
+
Deprecated: 3.1.0
|
|
246
|
+
Use `get_workspace_metadata` and `get_workspace_children` instead.
|
|
247
|
+
|
|
248
|
+
Get the specified Workspace and list its contents. By
|
|
249
|
+
default, this operation only returns top-level items in the
|
|
250
|
+
Workspace. To load all of the contents, including nested Folders,
|
|
251
|
+
include the **loadAll** parameter with a value of `true`.
|
|
252
|
+
|
|
253
|
+
Args:
|
|
254
|
+
workspace_id (int): Workspace ID
|
|
255
|
+
load_all (bool): Load all contents, including
|
|
256
|
+
nested items.
|
|
257
|
+
include (list[str]): A comma-separated list of
|
|
258
|
+
optional elements to include in the response. Valid list
|
|
259
|
+
values: ownerInfo, sheetVersion, source.
|
|
260
|
+
|
|
261
|
+
Returns:
|
|
262
|
+
Workspace
|
|
263
|
+
"""
|
|
264
|
+
_op = fresh_operation("get_workspace")
|
|
265
|
+
_op["method"] = "GET"
|
|
266
|
+
_op["path"] = "/workspaces/" + str(workspace_id)
|
|
267
|
+
_op["query_params"]["loadAll"] = load_all
|
|
268
|
+
_op["query_params"]["include"] = include
|
|
269
|
+
|
|
270
|
+
expected = "Workspace"
|
|
271
|
+
prepped_request = self._base.prepare_request(_op)
|
|
272
|
+
response = self._base.request(prepped_request, expected, _op)
|
|
273
|
+
|
|
274
|
+
return response
|
|
275
|
+
|
|
276
|
+
@deprecated
|
|
277
|
+
def list_folders(self, workspace_id, page_size=None, page=None, include_all=None):
|
|
278
|
+
"""Get a list of top-level child Folders within the specified
|
|
279
|
+
Workspace.
|
|
280
|
+
|
|
281
|
+
Deprecated: 3.1.0
|
|
282
|
+
Use `get_workspace_children` with children_resource_types=['folders'] instead.
|
|
283
|
+
|
|
284
|
+
Args:
|
|
285
|
+
workspace_id (int): Workspace ID
|
|
286
|
+
page_size (int): The maximum number of items to
|
|
287
|
+
return per page.
|
|
288
|
+
page (int): Which page to return.
|
|
289
|
+
include_all (bool): If true, include all results
|
|
290
|
+
(i.e. do not paginate).
|
|
291
|
+
|
|
292
|
+
Returns:
|
|
293
|
+
IndexResult
|
|
294
|
+
"""
|
|
295
|
+
_op = fresh_operation("list_folders")
|
|
296
|
+
_op["method"] = "GET"
|
|
297
|
+
_op["path"] = "/workspaces/" + str(workspace_id) + "/folders"
|
|
298
|
+
_op["query_params"]["pageSize"] = page_size
|
|
299
|
+
_op["query_params"]["page"] = page
|
|
300
|
+
_op["query_params"]["includeAll"] = include_all
|
|
301
|
+
|
|
302
|
+
expected = ["IndexResult", "Folder"]
|
|
303
|
+
|
|
304
|
+
prepped_request = self._base.prepare_request(_op)
|
|
305
|
+
response = self._base.request(prepped_request, expected, _op)
|
|
306
|
+
|
|
307
|
+
return response
|
|
308
|
+
|
|
309
|
+
def list_shares(self, workspace_id, page_size=None, page=None, include_all=None):
|
|
310
|
+
"""Get a list of all Users and Groups to whom the specified Workspace
|
|
311
|
+
is shared, and their access level.
|
|
312
|
+
|
|
313
|
+
Args:
|
|
314
|
+
workspace_id (int): Workspace ID
|
|
315
|
+
page_size (int): The maximum number of items to
|
|
316
|
+
return per page.
|
|
317
|
+
page (int): Which page to return.
|
|
318
|
+
include_all (bool): If true, include all results
|
|
319
|
+
(i.e. do not paginate).
|
|
320
|
+
|
|
321
|
+
Returns:
|
|
322
|
+
IndexResult
|
|
323
|
+
"""
|
|
324
|
+
_op = fresh_operation("list_shares")
|
|
325
|
+
_op["method"] = "GET"
|
|
326
|
+
_op["path"] = "/workspaces/" + str(workspace_id) + "/shares"
|
|
327
|
+
_op["query_params"]["pageSize"] = page_size
|
|
328
|
+
_op["query_params"]["page"] = page
|
|
329
|
+
_op["query_params"]["includeAll"] = include_all
|
|
330
|
+
expected = ["IndexResult", "Share"]
|
|
331
|
+
|
|
332
|
+
prepped_request = self._base.prepare_request(_op)
|
|
333
|
+
response = self._base.request(prepped_request, expected, _op)
|
|
334
|
+
|
|
335
|
+
return response
|
|
336
|
+
|
|
337
|
+
def list_workspaces(
|
|
338
|
+
self,
|
|
339
|
+
page_size: Optional[int] = None,
|
|
340
|
+
page: Optional[int] = None,
|
|
341
|
+
include_all: Optional[bool] = None,
|
|
342
|
+
last_key: Optional[str] = None,
|
|
343
|
+
max_items: Optional[int] = None,
|
|
344
|
+
pagination_type: Optional[str] = None
|
|
345
|
+
):
|
|
346
|
+
"""Get the list of Workspaces the authenticated User may access.
|
|
347
|
+
Args:
|
|
348
|
+
page_size (int, optional): [DEPRECATED] The maximum number of items to
|
|
349
|
+
return per page. Use pagination_type='token' with max_items instead.
|
|
350
|
+
page (int, optional): [DEPRECATED] Which page to return.
|
|
351
|
+
Use pagination_type='token' with last_key instead.
|
|
352
|
+
include_all (bool, optional): [DEPRECATED] If true, include all results
|
|
353
|
+
(i.e. do not paginate). Use pagination_type='token' instead.
|
|
354
|
+
last_key (str, optional): Pagination cursor for next page (token pagination only).
|
|
355
|
+
max_items (int, optional): Maximum items per page (token pagination only).
|
|
356
|
+
Must be a positive integer.
|
|
357
|
+
pagination_type (str, optional): Use 'token' for efficient cursor-based pagination.
|
|
358
|
+
Defaults to legacy offset-based pagination if not specified.
|
|
359
|
+
|
|
360
|
+
Returns:
|
|
361
|
+
IndexResult: When pagination_type='token', contains 'data' and 'last_key' attributes.
|
|
362
|
+
When using legacy pagination, contains paginated results with
|
|
363
|
+
total_count, total_pages, etc.
|
|
364
|
+
|
|
365
|
+
Raises:
|
|
366
|
+
ValueError: If pagination_type is not 'token' or None, or if max_items <= 0
|
|
367
|
+
when using token pagination.
|
|
368
|
+
"""
|
|
369
|
+
# Parameter validation
|
|
370
|
+
if pagination_type is not None and pagination_type not in ['token']:
|
|
371
|
+
raise ValueError("pagination_type must be 'token' or None")
|
|
372
|
+
if pagination_type == 'token' and max_items is not None and max_items <= 0:
|
|
373
|
+
raise ValueError("max_items must be a positive integer")
|
|
374
|
+
_op = fresh_operation("list_workspaces")
|
|
375
|
+
_op["method"] = "GET"
|
|
376
|
+
_op["path"] = "/workspaces"
|
|
377
|
+
|
|
378
|
+
# Issue deprecation warnings for old parameters when used
|
|
379
|
+
if page_size is not None:
|
|
380
|
+
warnings.warn(
|
|
381
|
+
"page_size parameter is deprecated. Use pagination_type='token' with max_items instead.",
|
|
382
|
+
DeprecationWarning,
|
|
383
|
+
stacklevel=2
|
|
384
|
+
)
|
|
385
|
+
if page is not None:
|
|
386
|
+
warnings.warn(
|
|
387
|
+
"page parameter is deprecated. Use pagination_type='token' with last_key instead.",
|
|
388
|
+
DeprecationWarning,
|
|
389
|
+
stacklevel=2
|
|
390
|
+
)
|
|
391
|
+
if include_all is not None:
|
|
392
|
+
warnings.warn(
|
|
393
|
+
"include_all parameter is deprecated. Use pagination_type='token' instead.",
|
|
394
|
+
DeprecationWarning,
|
|
395
|
+
stacklevel=2
|
|
396
|
+
)
|
|
397
|
+
|
|
398
|
+
if pagination_type == "token":
|
|
399
|
+
_op["query_params"]["lastKey"] = last_key
|
|
400
|
+
_op["query_params"]["maxItems"] = max_items
|
|
401
|
+
_op["query_params"]["paginationType"] = pagination_type
|
|
402
|
+
else:
|
|
403
|
+
_op["query_params"]["pageSize"] = page_size
|
|
404
|
+
_op["query_params"]["page"] = page
|
|
405
|
+
_op["query_params"]["includeAll"] = include_all
|
|
406
|
+
|
|
407
|
+
expected = ["IndexResult", "Workspace"]
|
|
408
|
+
|
|
409
|
+
prepped_request = self._base.prepare_request(_op)
|
|
410
|
+
response = self._base.request(prepped_request, expected, _op)
|
|
411
|
+
|
|
412
|
+
return response
|
|
413
|
+
|
|
414
|
+
def share_workspace(self, workspace_id, share_obj, send_email=False):
|
|
415
|
+
"""Share a Workspace with the specified Users and Groups.
|
|
416
|
+
|
|
417
|
+
Args:
|
|
418
|
+
workspace_id (int): Workspace ID
|
|
419
|
+
share_obj (Share): Share object.
|
|
420
|
+
send_email (bool): Either true or false to
|
|
421
|
+
indicate whether or not to notify the user by email. Default
|
|
422
|
+
is false.
|
|
423
|
+
|
|
424
|
+
Returns:
|
|
425
|
+
Result
|
|
426
|
+
"""
|
|
427
|
+
_op = fresh_operation("share_workspace")
|
|
428
|
+
_op["method"] = "POST"
|
|
429
|
+
_op["path"] = "/workspaces/" + str(workspace_id) + "/shares"
|
|
430
|
+
_op["query_params"]["sendEmail"] = send_email
|
|
431
|
+
_op["json"] = share_obj
|
|
432
|
+
|
|
433
|
+
expected = ["Result", "Share"]
|
|
434
|
+
|
|
435
|
+
prepped_request = self._base.prepare_request(_op)
|
|
436
|
+
response = self._base.request(prepped_request, expected, _op)
|
|
437
|
+
|
|
438
|
+
return response
|
|
439
|
+
|
|
440
|
+
def update_share(self, workspace_id, share_id, share_obj):
|
|
441
|
+
"""Update the access level of a User or Group for the specified
|
|
442
|
+
Workspace.
|
|
443
|
+
|
|
444
|
+
Args:
|
|
445
|
+
workspace_id (int): Workspace ID
|
|
446
|
+
share_id (str): Share ID
|
|
447
|
+
share_obj (Share): Share object.
|
|
448
|
+
|
|
449
|
+
Returns:
|
|
450
|
+
Result
|
|
451
|
+
"""
|
|
452
|
+
if not all(
|
|
453
|
+
val is not None for val in ["workspace_id", "share_id", "share_obj"]
|
|
454
|
+
):
|
|
455
|
+
raise ValueError(
|
|
456
|
+
("One or more required values are missing from call to " + __name__)
|
|
457
|
+
)
|
|
458
|
+
|
|
459
|
+
_op = fresh_operation("update_share")
|
|
460
|
+
_op["method"] = "PUT"
|
|
461
|
+
_op["path"] = "/workspaces/" + str(workspace_id) + "/shares/" + str(share_id)
|
|
462
|
+
_op["json"] = share_obj
|
|
463
|
+
|
|
464
|
+
expected = ["Result", "Share"]
|
|
465
|
+
|
|
466
|
+
prepped_request = self._base.prepare_request(_op)
|
|
467
|
+
response = self._base.request(prepped_request, expected, _op)
|
|
468
|
+
|
|
469
|
+
return response
|
|
470
|
+
|
|
471
|
+
def update_workspace(self, workspace_id, workspace_obj):
|
|
472
|
+
"""Update the specified Workspace.
|
|
473
|
+
|
|
474
|
+
Args:
|
|
475
|
+
workspace_id (int): Workspace ID
|
|
476
|
+
workspace_obj (Workspace): A Workspace object.
|
|
477
|
+
|
|
478
|
+
Returns:
|
|
479
|
+
Result
|
|
480
|
+
"""
|
|
481
|
+
_op = fresh_operation("update_workspace")
|
|
482
|
+
_op["method"] = "PUT"
|
|
483
|
+
_op["path"] = "/workspaces/" + str(workspace_id)
|
|
484
|
+
_op["json"] = workspace_obj
|
|
485
|
+
|
|
486
|
+
expected = ["Result", "Workspace"]
|
|
487
|
+
|
|
488
|
+
prepped_request = self._base.prepare_request(_op)
|
|
489
|
+
response = self._base.request(prepped_request, expected, _op)
|
|
490
|
+
|
|
491
|
+
return response
|
|
492
|
+
|
|
493
|
+
def get_workspace_metadata(self, workspace_id, include=None):
|
|
494
|
+
"""Get metadata of a workspace.
|
|
495
|
+
|
|
496
|
+
Args:
|
|
497
|
+
workspace_id (int): Workspace ID
|
|
498
|
+
include (list[str]): A list of optional elements to include
|
|
499
|
+
in the response. Valid list values: source
|
|
500
|
+
|
|
501
|
+
Returns:
|
|
502
|
+
Workspace
|
|
503
|
+
"""
|
|
504
|
+
_op = fresh_operation("get_workspace_metadata")
|
|
505
|
+
_op["method"] = "GET"
|
|
506
|
+
_op["path"] = "/workspaces/" + str(workspace_id) + "/metadata"
|
|
507
|
+
_op["query_params"]["include"] = include
|
|
508
|
+
|
|
509
|
+
expected = "Workspace"
|
|
510
|
+
prepped_request = self._base.prepare_request(_op)
|
|
511
|
+
response = self._base.request(prepped_request, expected, _op)
|
|
512
|
+
|
|
513
|
+
return response
|
|
514
|
+
|
|
515
|
+
def get_workspace_children(self, workspace_id, children_resource_types=None, include=None, last_key=None, max_items=None):
|
|
516
|
+
"""Get children of a workspace.
|
|
517
|
+
|
|
518
|
+
Args:
|
|
519
|
+
workspace_id (int): Workspace ID
|
|
520
|
+
children_resource_types (list[str]): The types of the children resources.
|
|
521
|
+
If not provided, returns children of all types.
|
|
522
|
+
Valid list values: sheets, reports, sights, folders.
|
|
523
|
+
include (list[str]): A list of optional elements to include in the response.
|
|
524
|
+
Valid list values: source, ownerInfo.
|
|
525
|
+
last_key (str): The token from a previous request that will allow this one
|
|
526
|
+
to fetch the next page of results.
|
|
527
|
+
max_items (int): The maximum number of items to return in the response.
|
|
528
|
+
|
|
529
|
+
Returns:
|
|
530
|
+
PaginatedChildrenResult
|
|
531
|
+
"""
|
|
532
|
+
_op = fresh_operation("get_workspace_children")
|
|
533
|
+
_op["method"] = "GET"
|
|
534
|
+
_op["path"] = "/workspaces/" + str(workspace_id) + "/children"
|
|
535
|
+
_op["query_params"]["childrenResourceTypes"] = children_resource_types
|
|
536
|
+
_op["query_params"]["include"] = include
|
|
537
|
+
_op["query_params"]["lastKey"] = last_key
|
|
538
|
+
_op["query_params"]["maxItems"] = max_items
|
|
539
|
+
|
|
540
|
+
expected = "PaginatedChildrenResult"
|
|
541
|
+
prepped_request = self._base.prepare_request(_op)
|
|
542
|
+
response = self._base.request(prepped_request, expected, _op)
|
|
543
|
+
|
|
544
|
+
return response
|
|
545
|
+
|
|
546
|
+
def import_csv_sheet(
|
|
547
|
+
self,
|
|
548
|
+
workspace_id,
|
|
549
|
+
file,
|
|
550
|
+
sheet_name=None,
|
|
551
|
+
header_row_index=None,
|
|
552
|
+
primary_column_index=None,
|
|
553
|
+
):
|
|
554
|
+
"""Imports a sheet in the specified workspace.
|
|
555
|
+
|
|
556
|
+
Args:
|
|
557
|
+
workspace_id (int): workspace ID
|
|
558
|
+
file (string): path to CSV file.
|
|
559
|
+
sheet_name (string): destination sheet name
|
|
560
|
+
header_row_index (int): index (0 based) of row to be used for column names
|
|
561
|
+
primary_column_index (int): index (0 based) of primary column
|
|
562
|
+
|
|
563
|
+
Returns:
|
|
564
|
+
Result
|
|
565
|
+
"""
|
|
566
|
+
if not all(val is not None for val in ["folder_id", "file"]):
|
|
567
|
+
raise ValueError(
|
|
568
|
+
("One or more required values are missing from call to " + __name__)
|
|
569
|
+
)
|
|
570
|
+
|
|
571
|
+
return self._import_sheet(
|
|
572
|
+
workspace_id,
|
|
573
|
+
file,
|
|
574
|
+
"text/csv",
|
|
575
|
+
sheet_name,
|
|
576
|
+
header_row_index,
|
|
577
|
+
primary_column_index,
|
|
578
|
+
)
|
|
579
|
+
|
|
580
|
+
def import_xlsx_sheet(
|
|
581
|
+
self,
|
|
582
|
+
workspace_id,
|
|
583
|
+
file,
|
|
584
|
+
sheet_name=None,
|
|
585
|
+
header_row_index=None,
|
|
586
|
+
primary_column_index=None,
|
|
587
|
+
):
|
|
588
|
+
"""Imports a sheet in the specified workspace.
|
|
589
|
+
|
|
590
|
+
Args:
|
|
591
|
+
workspace_id (int): workspace ID
|
|
592
|
+
file (string): path to XLSX file.
|
|
593
|
+
sheet_name (string): destination sheet name
|
|
594
|
+
header_row_index (int): index (0 based) of row to be used for column names
|
|
595
|
+
primary_column_index (int): index (0 based) of primary column
|
|
596
|
+
|
|
597
|
+
Returns:
|
|
598
|
+
Result
|
|
599
|
+
"""
|
|
600
|
+
if not all(val is not None for val in ["folder_id", "file"]):
|
|
601
|
+
raise ValueError(
|
|
602
|
+
("One or more required values are missing from call to " + __name__)
|
|
603
|
+
)
|
|
604
|
+
|
|
605
|
+
return self._import_sheet(
|
|
606
|
+
workspace_id,
|
|
607
|
+
file,
|
|
608
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
609
|
+
sheet_name,
|
|
610
|
+
header_row_index,
|
|
611
|
+
primary_column_index,
|
|
612
|
+
)
|
|
613
|
+
|
|
614
|
+
def _import_sheet(
|
|
615
|
+
self,
|
|
616
|
+
workspace_id,
|
|
617
|
+
file,
|
|
618
|
+
file_type,
|
|
619
|
+
sheet_name,
|
|
620
|
+
header_row_index,
|
|
621
|
+
primary_column_index,
|
|
622
|
+
):
|
|
623
|
+
"""Internal function used to import sheet"""
|
|
624
|
+
|
|
625
|
+
if sheet_name is None:
|
|
626
|
+
head, tail = os.path.split(file)
|
|
627
|
+
sheet_name = tail or os.path.basename(head)
|
|
628
|
+
|
|
629
|
+
_data = open(file, "rb").read()
|
|
630
|
+
_op = fresh_operation("import_sheet_into_folder")
|
|
631
|
+
_op["method"] = "POST"
|
|
632
|
+
_op["path"] = "/workspaces/" + str(workspace_id) + "/sheets/import"
|
|
633
|
+
_op["headers"] = {
|
|
634
|
+
"content-type": file_type,
|
|
635
|
+
"content-disposition": "attachment",
|
|
636
|
+
}
|
|
637
|
+
_op["form_data"] = _data
|
|
638
|
+
_op["query_params"]["sheetName"] = sheet_name
|
|
639
|
+
_op["query_params"]["headerRowIndex"] = header_row_index
|
|
640
|
+
_op["query_params"]["primaryColumnIndex"] = primary_column_index
|
|
641
|
+
|
|
642
|
+
expected = ["Result", "Sheet"]
|
|
643
|
+
|
|
644
|
+
prepped_request = self._base.prepare_request(_op)
|
|
645
|
+
response = self._base.request(prepped_request, expected, _op)
|
|
646
|
+
|
|
647
|
+
return response
|