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.
Files changed (195) hide show
  1. smartsheet/__init__.py +37 -0
  2. smartsheet/attachments.py +565 -0
  3. smartsheet/cells.py +164 -0
  4. smartsheet/contacts.py +78 -0
  5. smartsheet/discussions.py +411 -0
  6. smartsheet/events.py +79 -0
  7. smartsheet/exceptions.py +130 -0
  8. smartsheet/favorites.py +116 -0
  9. smartsheet/folders.py +438 -0
  10. smartsheet/groups.py +186 -0
  11. smartsheet/home.py +180 -0
  12. smartsheet/images.py +61 -0
  13. smartsheet/models/__init__.py +126 -0
  14. smartsheet/models/access_token.py +95 -0
  15. smartsheet/models/account.py +77 -0
  16. smartsheet/models/alternate_email.py +88 -0
  17. smartsheet/models/asset_share.py +165 -0
  18. smartsheet/models/asset_shares_paginated_result.py +84 -0
  19. smartsheet/models/attachment.py +181 -0
  20. smartsheet/models/auto_number_format.py +81 -0
  21. smartsheet/models/automation_action.py +162 -0
  22. smartsheet/models/automation_rule.py +164 -0
  23. smartsheet/models/boolean_object_value.py +38 -0
  24. smartsheet/models/bulk_item_failure.py +77 -0
  25. smartsheet/models/bulk_item_result.py +111 -0
  26. smartsheet/models/cell.py +193 -0
  27. smartsheet/models/cell_data_item.py +152 -0
  28. smartsheet/models/cell_history.py +67 -0
  29. smartsheet/models/cell_link.py +91 -0
  30. smartsheet/models/cell_link_widget_content.py +101 -0
  31. smartsheet/models/chart_widget_content.py +124 -0
  32. smartsheet/models/column.py +253 -0
  33. smartsheet/models/comment.py +126 -0
  34. smartsheet/models/contact.py +88 -0
  35. smartsheet/models/contact_object_value.py +59 -0
  36. smartsheet/models/container_destination.py +74 -0
  37. smartsheet/models/copy_or_move_row_destination.py +54 -0
  38. smartsheet/models/copy_or_move_row_directive.py +64 -0
  39. smartsheet/models/copy_or_move_row_result.py +67 -0
  40. smartsheet/models/criteria.py +82 -0
  41. smartsheet/models/cross_sheet_reference.py +134 -0
  42. smartsheet/models/currency.py +64 -0
  43. smartsheet/models/date_object_value.py +56 -0
  44. smartsheet/models/datetime_object_value.py +56 -0
  45. smartsheet/models/discussion.py +183 -0
  46. smartsheet/models/downloaded_file.py +106 -0
  47. smartsheet/models/duration.py +112 -0
  48. smartsheet/models/email.py +82 -0
  49. smartsheet/models/enums/__init__.py +56 -0
  50. smartsheet/models/enums/access_level.py +26 -0
  51. smartsheet/models/enums/asset_type.py +10 -0
  52. smartsheet/models/enums/attachment_parent_type.py +23 -0
  53. smartsheet/models/enums/attachment_sub_type.py +26 -0
  54. smartsheet/models/enums/attachment_type.py +29 -0
  55. smartsheet/models/enums/automation_action_frequency.py +24 -0
  56. smartsheet/models/enums/automation_action_type.py +23 -0
  57. smartsheet/models/enums/automation_rule_disabled_reason.py +27 -0
  58. smartsheet/models/enums/cell_link_status.py +28 -0
  59. smartsheet/models/enums/column_type.py +31 -0
  60. smartsheet/models/enums/criteria_target.py +21 -0
  61. smartsheet/models/enums/cross_sheet_reference_status.py +28 -0
  62. smartsheet/models/enums/currency_code.py +43 -0
  63. smartsheet/models/enums/day_descriptors.py +30 -0
  64. smartsheet/models/enums/day_ordinal.py +25 -0
  65. smartsheet/models/enums/event_action.py +76 -0
  66. smartsheet/models/enums/event_obejct_type.py +34 -0
  67. smartsheet/models/enums/event_source.py +27 -0
  68. smartsheet/models/enums/global_template.py +23 -0
  69. smartsheet/models/enums/operator.py +62 -0
  70. smartsheet/models/enums/paper_type.py +29 -0
  71. smartsheet/models/enums/predecessor_type.py +24 -0
  72. smartsheet/models/enums/publish_accessible_by.py +22 -0
  73. smartsheet/models/enums/schedule_type.py +25 -0
  74. smartsheet/models/enums/seat_type.py +17 -0
  75. smartsheet/models/enums/share_scope.py +22 -0
  76. smartsheet/models/enums/share_type.py +22 -0
  77. smartsheet/models/enums/sheet_email_format.py +23 -0
  78. smartsheet/models/enums/sheet_filter_operator.py +22 -0
  79. smartsheet/models/enums/sheet_filter_type.py +23 -0
  80. smartsheet/models/enums/sort_direction.py +22 -0
  81. smartsheet/models/enums/symbol.py +45 -0
  82. smartsheet/models/enums/system_column_type.py +25 -0
  83. smartsheet/models/enums/update_request_status.py +23 -0
  84. smartsheet/models/enums/user_status.py +23 -0
  85. smartsheet/models/enums/widget_type.py +32 -0
  86. smartsheet/models/error.py +74 -0
  87. smartsheet/models/error_result.py +117 -0
  88. smartsheet/models/event.py +153 -0
  89. smartsheet/models/event_result.py +86 -0
  90. smartsheet/models/explicit_null.py +24 -0
  91. smartsheet/models/favorite.py +81 -0
  92. smartsheet/models/folder.py +177 -0
  93. smartsheet/models/font_family.py +63 -0
  94. smartsheet/models/format_details.py +55 -0
  95. smartsheet/models/format_tables.py +191 -0
  96. smartsheet/models/group.py +134 -0
  97. smartsheet/models/group_member.py +104 -0
  98. smartsheet/models/home.py +110 -0
  99. smartsheet/models/hyperlink.py +81 -0
  100. smartsheet/models/image.py +101 -0
  101. smartsheet/models/image_url.py +91 -0
  102. smartsheet/models/image_url_map.py +68 -0
  103. smartsheet/models/image_widget_content.py +117 -0
  104. smartsheet/models/index_result.py +118 -0
  105. smartsheet/models/json_object.py +59 -0
  106. smartsheet/models/multi_contact_object_value.py +49 -0
  107. smartsheet/models/multi_picklist_object_value.py +48 -0
  108. smartsheet/models/multi_row_email.py +60 -0
  109. smartsheet/models/number_object_value.py +38 -0
  110. smartsheet/models/o_auth_error.py +86 -0
  111. smartsheet/models/object_value.py +130 -0
  112. smartsheet/models/paginated_children_result.py +80 -0
  113. smartsheet/models/predecessor.py +102 -0
  114. smartsheet/models/predecessor_list.py +49 -0
  115. smartsheet/models/primitive_object_value.py +59 -0
  116. smartsheet/models/profile_image.py +72 -0
  117. smartsheet/models/project_settings.py +89 -0
  118. smartsheet/models/recipient.py +63 -0
  119. smartsheet/models/report.py +90 -0
  120. smartsheet/models/report_cell.py +59 -0
  121. smartsheet/models/report_column.py +67 -0
  122. smartsheet/models/report_publish.py +95 -0
  123. smartsheet/models/report_row.py +68 -0
  124. smartsheet/models/report_widget_content.py +78 -0
  125. smartsheet/models/result.py +105 -0
  126. smartsheet/models/row.py +336 -0
  127. smartsheet/models/row_email.py +83 -0
  128. smartsheet/models/row_mapping.py +77 -0
  129. smartsheet/models/schedule.py +140 -0
  130. smartsheet/models/scope.py +70 -0
  131. smartsheet/models/search_result.py +67 -0
  132. smartsheet/models/search_result_item.py +150 -0
  133. smartsheet/models/selection_range.py +86 -0
  134. smartsheet/models/sent_update_request.py +172 -0
  135. smartsheet/models/server_info.py +67 -0
  136. smartsheet/models/share.py +183 -0
  137. smartsheet/models/sheet.py +462 -0
  138. smartsheet/models/sheet_email.py +81 -0
  139. smartsheet/models/sheet_filter.py +106 -0
  140. smartsheet/models/sheet_filter_details.py +76 -0
  141. smartsheet/models/sheet_publish.py +184 -0
  142. smartsheet/models/sheet_summary.py +59 -0
  143. smartsheet/models/sheet_user_permissions.py +58 -0
  144. smartsheet/models/sheet_user_settings.py +72 -0
  145. smartsheet/models/shortcut_data_item.py +102 -0
  146. smartsheet/models/shortcut_widget_content.py +61 -0
  147. smartsheet/models/sight.py +175 -0
  148. smartsheet/models/sight_publish.py +77 -0
  149. smartsheet/models/sort_criterion.py +64 -0
  150. smartsheet/models/sort_specifier.py +55 -0
  151. smartsheet/models/source.py +83 -0
  152. smartsheet/models/string_object_value.py +38 -0
  153. smartsheet/models/summary_field.py +256 -0
  154. smartsheet/models/template.py +171 -0
  155. smartsheet/models/title_rich_text_widget_content.py +68 -0
  156. smartsheet/models/token_paginated_result.py +79 -0
  157. smartsheet/models/update_request.py +110 -0
  158. smartsheet/models/user.py +58 -0
  159. smartsheet/models/user_model.py +280 -0
  160. smartsheet/models/user_plan.py +77 -0
  161. smartsheet/models/user_profile.py +89 -0
  162. smartsheet/models/version.py +57 -0
  163. smartsheet/models/web_content_widget_content.py +60 -0
  164. smartsheet/models/webhook.py +219 -0
  165. smartsheet/models/webhook_secret.py +58 -0
  166. smartsheet/models/webhook_stats.py +76 -0
  167. smartsheet/models/webhook_subscope.py +50 -0
  168. smartsheet/models/widget.py +211 -0
  169. smartsheet/models/widget_content.py +52 -0
  170. smartsheet/models/widget_hyperlink.py +74 -0
  171. smartsheet/models/workspace.py +185 -0
  172. smartsheet/object_value.py +72 -0
  173. smartsheet/passthrough.py +127 -0
  174. smartsheet/reports.py +382 -0
  175. smartsheet/search.py +100 -0
  176. smartsheet/server.py +48 -0
  177. smartsheet/session.py +70 -0
  178. smartsheet/sharing.py +163 -0
  179. smartsheet/sheets.py +2062 -0
  180. smartsheet/sights.py +370 -0
  181. smartsheet/smartsheet.py +684 -0
  182. smartsheet/templates.py +87 -0
  183. smartsheet/token.py +128 -0
  184. smartsheet/types.py +323 -0
  185. smartsheet/users.py +490 -0
  186. smartsheet/util.py +199 -0
  187. smartsheet/version.py +34 -0
  188. smartsheet/webhooks.py +161 -0
  189. smartsheet/workspaces.py +647 -0
  190. smartsheet_python_sdk-3.5.5.dist-info/METADATA +120 -0
  191. smartsheet_python_sdk-3.5.5.dist-info/RECORD +195 -0
  192. smartsheet_python_sdk-3.5.5.dist-info/WHEEL +5 -0
  193. smartsheet_python_sdk-3.5.5.dist-info/licenses/LICENSE.md +201 -0
  194. smartsheet_python_sdk-3.5.5.dist-info/licenses/NOTICE +10 -0
  195. smartsheet_python_sdk-3.5.5.dist-info/top_level.txt +1 -0
smartsheet/sheets.py ADDED
@@ -0,0 +1,2062 @@
1
+ # pylint: disable=C0111,R0902,R0913,C0301,R0914
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
+ from datetime import datetime
23
+
24
+ import six
25
+
26
+ from . import fresh_operation
27
+ from .models.column import Column
28
+ from .models.row import Row
29
+ from .models.summary_field import SummaryField
30
+ from .types import TypedList
31
+ from .util import deprecated
32
+
33
+ class Sheets:
34
+
35
+ """Class for handling Sheets operations."""
36
+
37
+ def __init__(self, smartsheet_obj):
38
+ """Init Sheets with base Smartsheet object."""
39
+ self._base = smartsheet_obj
40
+ self._log = logging.getLogger(__name__)
41
+
42
+ def add_columns(self, sheet_id, list_of_columns):
43
+ """Insert one or more Columns into the specified Sheet
44
+
45
+ Args:
46
+ sheet_id (int): Sheet ID
47
+ list_of_columns (list[Column]): One or more
48
+ Column objects
49
+
50
+ Returns:
51
+ Result
52
+ """
53
+
54
+ if isinstance(list_of_columns, (dict, Column)):
55
+ arg_value = list_of_columns
56
+ list_of_columns = TypedList(Column)
57
+ list_of_columns.append(arg_value)
58
+
59
+ _op = fresh_operation("add_columns")
60
+ _op["method"] = "POST"
61
+ _op["path"] = "/sheets/" + str(sheet_id) + "/columns"
62
+ _op["json"] = list_of_columns
63
+
64
+ expected = ["Result", "Column"]
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 add_rows(self, sheet_id, list_of_rows):
72
+ """Insert one or more Rows into the specified Sheet.
73
+
74
+ If multiple rows are specified in the request, all rows
75
+ must be inserted at the same location (i.e. the **toTop**,
76
+ **toBottom**, **parentId**, **siblingId**, and **above** attributes
77
+ must be the same for all rows in the request.)
78
+
79
+ In a parent row, values of the following fields will be
80
+ auto-calculated based upon values in the child rows (and therefore
81
+ cannot be updated using the API): Start Date, End Date, Duration, %
82
+ Complete.
83
+
84
+ Args:
85
+ sheet_id (int): Sheet ID
86
+ row_or_list_of_rows (list[Row]): An array of Row objects with the following attributes:
87
+
88
+ One or more location-specifier attributes (optional)
89
+
90
+ format (optional)
91
+
92
+ expanded (optional)
93
+
94
+ locked (optional)
95
+
96
+ A cells attribute set to an array of Cell objects.
97
+ To insert an empty row, set the cells attribute to empty or null.
98
+ Each Cell object may contain the following attributes:
99
+
100
+ columnId (required)
101
+
102
+ value (required)
103
+
104
+ strict (optional)
105
+
106
+ format (optional)
107
+
108
+ hyperlink (optional)
109
+
110
+ Returns:
111
+ Result
112
+ """
113
+ if isinstance(list_of_rows, (dict, Row)):
114
+ arg_value = list_of_rows
115
+ list_of_rows = TypedList(Row)
116
+ list_of_rows.append(arg_value)
117
+
118
+ _op = fresh_operation("add_rows")
119
+ _op["method"] = "POST"
120
+ _op["path"] = "/sheets/" + str(sheet_id) + "/rows"
121
+ _op["json"] = list_of_rows
122
+
123
+ expected = ["Result", "Row"]
124
+
125
+ prepped_request = self._base.prepare_request(_op)
126
+ response = self._base.request(prepped_request, expected, _op)
127
+
128
+ return response
129
+
130
+ def add_rows_with_partial_success(self, sheet_id, list_of_rows):
131
+ """Insert one or more Rows into the specified Sheet.
132
+
133
+ If multiple rows are specified in the request, all rows
134
+ must be inserted at the same location (i.e. the **toTop**,
135
+ **toBottom**, **parentId**, **siblingId**, and **above** attributes
136
+ must be the same for all rows in the request.)
137
+
138
+ In a parent row, values of the following fields will be
139
+ auto-calculated based upon values in the child rows (and therefore
140
+ cannot be updated using the API): Start Date, End Date, Duration, %
141
+ Complete.
142
+
143
+ Args:
144
+ sheet_id (int): Sheet ID
145
+ list_of_rows (list[Row]): An array of Row objects with the following attributes:
146
+
147
+ One or more location-specifier attributes (optional)
148
+
149
+ format (optional)
150
+
151
+ expanded (optional)
152
+
153
+ locked (optional)
154
+
155
+ A cells attribute set to an array of Cell objects.
156
+ To insert an empty row, set the cells attribute to empty or null.
157
+ Each Cell object may contain the following attributes:
158
+
159
+ columnId (required)
160
+
161
+ value (required)
162
+
163
+ strict (optional)
164
+
165
+ format (optional)
166
+
167
+ hyperlink (optional)
168
+
169
+ Returns:
170
+ Result
171
+ """
172
+ if isinstance(list_of_rows, (dict, Row)):
173
+ arg_value = list_of_rows
174
+ list_of_rows = TypedList(Row)
175
+ list_of_rows.append(arg_value)
176
+
177
+ _op = fresh_operation("add_rows")
178
+ _op["method"] = "POST"
179
+ _op["path"] = "/sheets/" + str(sheet_id) + "/rows"
180
+ _op["json"] = list_of_rows
181
+ _op["query_params"]["allowPartialSuccess"] = "true"
182
+
183
+ expected = ["BulkItemResult", "Row"]
184
+
185
+ prepped_request = self._base.prepare_request(_op)
186
+ response = self._base.request(prepped_request, expected, _op)
187
+
188
+ return response
189
+
190
+ def copy_rows(
191
+ self,
192
+ sheet_id,
193
+ copy_or_move_row_directive_obj,
194
+ include=None,
195
+ ignore_rows_not_found=None,
196
+ ):
197
+ """Copies Row(s) from the specified Sheet to the bottom of another
198
+ Sheet.
199
+
200
+ Args:
201
+ sheet_id (int): Sheet ID
202
+ copy_or_move_row_directive_obj
203
+ (CopyOrMoveRowDirective): CopyOrMoveRowDirective object.
204
+ include (list[str]): A comma-separated list of
205
+ row elements to copy in addition to the cell data. Valid
206
+ list values: attachments, discussions, children, all.
207
+ ignore_rows_not_found (bool): If set to `true`,
208
+ specifying row ids that do not exist within the source sheet
209
+ will not cause an error response. If omitted or set to false
210
+ (the default), specifying row ids that do not exist within
211
+ the source sheet will cause an error response (and no rows
212
+ will be altered).
213
+
214
+ Returns:
215
+ CopyOrMoveRowResult
216
+ """
217
+ _op = fresh_operation("copy_rows")
218
+ _op["method"] = "POST"
219
+ _op["path"] = "/sheets/" + str(sheet_id) + "/rows/copy"
220
+ _op["query_params"]["include"] = include
221
+ _op["query_params"]["ignoreRowsNotFound"] = ignore_rows_not_found
222
+ _op["json"] = copy_or_move_row_directive_obj
223
+
224
+ expected = "CopyOrMoveRowResult"
225
+ prepped_request = self._base.prepare_request(_op)
226
+ response = self._base.request(prepped_request, expected, _op)
227
+
228
+ return response
229
+
230
+ def copy_sheet(
231
+ self, sheet_id, container_destination_obj, include=None, exclude=None
232
+ ):
233
+ """Creates a copy of the specified Sheet
234
+
235
+ Args:
236
+ sheet_id (int): Sheet ID
237
+ container_destination_obj
238
+ (ContainerDestination): Container Destination object.
239
+ include (list[str]): A comma-separated list of
240
+ optional elements to include in the response. Valid list values:
241
+ attachments, cellLinks, data, discussions, filters, forms, ruleRecipients,
242
+ rules, shares, all (deprecated).
243
+ exclude (list[str]): A comma-separated list of optional elements
244
+ to omit. Only current valid value is sheetHyperlinks
245
+
246
+ Returns:
247
+ Result
248
+ """
249
+ _op = fresh_operation("copy_sheet")
250
+ _op["method"] = "POST"
251
+ _op["path"] = "/sheets/" + str(sheet_id) + "/copy"
252
+ _op["query_params"]["include"] = include
253
+ _op["query_params"]["exclude"] = exclude
254
+ _op["json"] = container_destination_obj
255
+
256
+ expected = ["Result", "Sheet"]
257
+
258
+ prepped_request = self._base.prepare_request(_op)
259
+ response = self._base.request(prepped_request, expected, _op)
260
+
261
+ return response
262
+
263
+ def delete_column(self, sheet_id, column_id):
264
+ """Delete the specified Column.
265
+
266
+ Args:
267
+ sheet_id (int): Sheet ID
268
+ column_id (int): Column ID
269
+
270
+ Returns:
271
+ Result
272
+ """
273
+ _op = fresh_operation("delete_column")
274
+ _op["method"] = "DELETE"
275
+ _op["path"] = "/sheets/" + str(sheet_id) + "/columns/" + str(column_id)
276
+
277
+ expected = "Result"
278
+ prepped_request = self._base.prepare_request(_op)
279
+ response = self._base.request(prepped_request, expected, _op)
280
+
281
+ return response
282
+
283
+ def delete_rows(self, sheet_id, ids, ignore_rows_not_found=False):
284
+ """Deletes one or more Row(s) from the specified Sheeet.
285
+
286
+ Args:
287
+ sheet_id (int): Sheet ID
288
+ ids (list[int]): a comma-separated list of
289
+ object IDs representing the items to work on.
290
+ ignore_rows_not_found (bool): If set to `true`,
291
+ specifying row ids that do not exist within the source sheet
292
+ will not cause an error response. If omitted or set to false
293
+ (the default), specifying row ids that do not exist within
294
+ the source sheet will cause an error response (and no rows
295
+ will be altered).
296
+
297
+ Returns:
298
+ Result
299
+ """
300
+ _op = fresh_operation("delete_rows")
301
+ _op["method"] = "DELETE"
302
+ _op["path"] = "/sheets/" + str(sheet_id) + "/rows"
303
+ _op["query_params"]["ids"] = ids
304
+ _op["query_params"]["ignoreRowsNotFound"] = ignore_rows_not_found
305
+
306
+ expected = ["Result", "NumberObjectValue"]
307
+ prepped_request = self._base.prepare_request(_op)
308
+ response = self._base.request(prepped_request, expected, _op)
309
+
310
+ return response
311
+
312
+ @deprecated
313
+ def delete_share(self, sheet_id, share_id):
314
+ """Delete the specified Share.
315
+
316
+ Args:
317
+ sheet_id (int): Sheet ID
318
+ share_id (str): Share ID
319
+
320
+ Returns:
321
+ Result
322
+
323
+ Deprecated:
324
+ Use sharing.delete_share instead with assetType=AssetType.SHEET
325
+ """
326
+ _op = fresh_operation("delete_share")
327
+ _op["method"] = "DELETE"
328
+ _op["path"] = "/sheets/" + str(sheet_id) + "/shares/" + str(share_id)
329
+
330
+ expected = ["Result", None]
331
+ prepped_request = self._base.prepare_request(_op)
332
+ response = self._base.request(prepped_request, expected, _op)
333
+
334
+ return response
335
+
336
+ def delete_sheet(self, sheet_id):
337
+ """Delete the specified Sheet.
338
+
339
+ Args:
340
+ sheet_id (int): Sheet ID
341
+
342
+ Returns:
343
+ Result
344
+ """
345
+ _op = fresh_operation("delete_sheet")
346
+ _op["method"] = "DELETE"
347
+ _op["path"] = "/sheets/" + str(sheet_id)
348
+
349
+ expected = ["Result", None]
350
+ prepped_request = self._base.prepare_request(_op)
351
+ response = self._base.request(prepped_request, expected, _op)
352
+
353
+ return response
354
+
355
+ def get_column(self, sheet_id, column_id, include=None):
356
+ """Get the specified Column.
357
+
358
+ Args:
359
+ sheet_id (int): Sheet ID
360
+ column_id (int): Column ID
361
+ include (str): (future)
362
+
363
+ Returns:
364
+ Column
365
+ """
366
+ _op = fresh_operation("get_column")
367
+ _op["method"] = "GET"
368
+ _op["path"] = "/sheets/" + str(sheet_id) + "/columns/" + str(column_id)
369
+ _op["query_params"]["include"] = include
370
+
371
+ expected = "Column"
372
+ prepped_request = self._base.prepare_request(_op)
373
+ response = self._base.request(prepped_request, expected, _op)
374
+
375
+ return response
376
+
377
+ def get_columns(
378
+ self,
379
+ sheet_id,
380
+ include=None,
381
+ page_size=None,
382
+ page=None,
383
+ include_all=None,
384
+ level=None,
385
+ ):
386
+ """Get all columns belonging to the specified Sheet.
387
+
388
+ Args:
389
+ sheet_id (int): Sheet ID
390
+ include (str): (future)
391
+ page_size (int): The maximum number of items to
392
+ return per page.
393
+ page (int): Which page to return.
394
+ include_all (bool): If true, include all results
395
+ (i.e. do not paginate).
396
+ level (int): compatibility level
397
+
398
+ Returns:
399
+ IndexResult
400
+ """
401
+ _op = fresh_operation("get_columns")
402
+ _op["method"] = "GET"
403
+ _op["path"] = "/sheets/" + str(sheet_id) + "/columns"
404
+ _op["query_params"]["include"] = include
405
+ _op["query_params"]["pageSize"] = page_size
406
+ _op["query_params"]["page"] = page
407
+ _op["query_params"]["includeAll"] = include_all
408
+ _op["query_params"]["level"] = level
409
+
410
+ expected = ["IndexResult", "Column"]
411
+
412
+ prepped_request = self._base.prepare_request(_op)
413
+ response = self._base.request(prepped_request, expected, _op)
414
+
415
+ return response
416
+
417
+ def get_publish_status(self, sheet_id):
418
+ """Get the Publish status of the Sheet.
419
+
420
+ Get the status of the Publish settings of the Sheet,
421
+ including URLs of any enabled publishings.
422
+
423
+ Args:
424
+ sheet_id (int): Sheet ID
425
+
426
+ Returns:
427
+ SheetPublish
428
+ """
429
+ _op = fresh_operation("get_publish_status")
430
+ _op["method"] = "GET"
431
+ _op["path"] = "/sheets/" + str(sheet_id) + "/publish"
432
+
433
+ expected = "SheetPublish"
434
+ prepped_request = self._base.prepare_request(_op)
435
+ response = self._base.request(prepped_request, expected, _op)
436
+
437
+ return response
438
+
439
+ def get_row(self, sheet_id, row_id, include=None, exclude=None, level=None):
440
+ """Get the specified Row of the specified Sheet.
441
+
442
+ Args:
443
+ sheet_id (int): Sheet ID
444
+ row_id (int): Row ID
445
+ include (list[str]): A comma-separated list of
446
+ flags that indicate additional attributes to be included in
447
+ each Row object within the response. Valid list values:
448
+ discussions, attachments, format, filters, columnType,
449
+ rowPermalink, rowWriterInfo.
450
+ exclude (str): Response will not include cells
451
+ that have never contained any data.
452
+ level (int): Indicates compatibility level of data to return.
453
+ Valid options: 0, 1, 2
454
+ Option Descriptors:
455
+
456
+ 0 - Backwards compatible text format
457
+ 1 - multi-contact complex object
458
+ 2 - multi-picklist complex object
459
+
460
+ Returns:
461
+ Row
462
+ """
463
+ _op = fresh_operation("get_row")
464
+ _op["method"] = "GET"
465
+ _op["path"] = "/sheets/" + str(sheet_id) + "/rows/" + str(row_id)
466
+ _op["query_params"]["include"] = include
467
+ _op["query_params"]["exclude"] = exclude
468
+ _op["query_params"]["level"] = level
469
+
470
+ expected = "Row"
471
+ prepped_request = self._base.prepare_request(_op)
472
+ response = self._base.request(prepped_request, expected, _op)
473
+
474
+ return response
475
+
476
+ @deprecated
477
+ def get_share(self, sheet_id, share_id):
478
+ """Get the specified Share.
479
+
480
+ Args:
481
+ sheet_id (int): Sheet ID
482
+ share_id (str): Share ID
483
+
484
+ Returns:
485
+ Share
486
+
487
+ Deprecated:
488
+ Use sharing.get_asset_share instead with assetType=AssetType.SHEET
489
+ """
490
+ _op = fresh_operation("get_share")
491
+ _op["method"] = "GET"
492
+ _op["path"] = "/sheets/" + str(sheet_id) + "/shares/" + str(share_id)
493
+
494
+ expected = "Share"
495
+ prepped_request = self._base.prepare_request(_op)
496
+ response = self._base.request(prepped_request, expected, _op)
497
+
498
+ return response
499
+
500
+ def get_sheet(
501
+ self,
502
+ sheet_id,
503
+ include=None,
504
+ exclude=None,
505
+ row_ids=None,
506
+ row_numbers=None,
507
+ column_ids=None,
508
+ page_size=None,
509
+ page=None,
510
+ if_version_after=None,
511
+ level=None,
512
+ rows_modified_since=None,
513
+ filter_id=None,
514
+ ):
515
+ """Get the specified Sheet.
516
+
517
+ Get the specified Sheet. Returns the Sheet, including Rows,
518
+ and optionally populated with Discussion and Attachment
519
+ objects.
520
+
521
+ Args:
522
+ sheet_id (int): Sheet ID
523
+ include (list[str]): A comma-separated list of
524
+ optional elements to include in the response. Valid list
525
+ values: attachments, columnType, crossSheetReferences, discussions, filters,
526
+ filterDefinitions, format, objectValue, ownerInfo, rowPermalink,
527
+ rowWriterInfo (deprecated - use writerInfo), source, summary, writerInfo.
528
+ exclude (str): Response will not include cells
529
+ that have never contained any data.
530
+ row_ids (list[int]): comma-separated list of Row
531
+ IDs on which to filter the rows included in the result.
532
+ row_numbers (list[int]): comma-separated list of
533
+ Row numbers on which to filter the rows included in the
534
+ result. Non-existent row numbers are ignored.
535
+ column_ids (list[int]): comma-separated list of
536
+ Column IDs. The response will contain only the specified
537
+ columns in the 'columns' array, and individual rows' 'cells'
538
+ array will only contain cells in the specified columns.
539
+ page_size (int): The maximum number of items to
540
+ return per page.
541
+ page (int): Which page to return.
542
+ if_version_after (int): only fetch Sheet if more recent version
543
+ available.
544
+ level (int): compatibility level
545
+ rows_modified_since: Date should be in ISO-8601 format, for example, rowsModifiedSince=2020-01-30T13:25:32-07:00.
546
+ filter_id (int): Applies the given filter (if accessible by the calling user)
547
+ and marks the affected rows as "filteredOut": true
548
+
549
+ Returns:
550
+ Sheet
551
+ """
552
+ _op = fresh_operation("get_sheet")
553
+ _op["method"] = "GET"
554
+ _op["path"] = "/sheets/" + str(sheet_id)
555
+ _op["query_params"]["include"] = include
556
+ _op["query_params"]["exclude"] = exclude
557
+ _op["query_params"]["rowIds"] = row_ids
558
+ _op["query_params"]["rowNumbers"] = row_numbers
559
+ _op["query_params"]["columnIds"] = column_ids
560
+ _op["query_params"]["pageSize"] = page_size
561
+ _op["query_params"]["page"] = page
562
+ _op["query_params"]["ifVersionAfter"] = if_version_after
563
+ _op["query_params"]["level"] = level
564
+ _op["query_params"]["rowsModifiedSince"] = rows_modified_since
565
+ _op["query_params"]["filterId"] = filter_id
566
+
567
+ expected = "Sheet"
568
+ prepped_request = self._base.prepare_request(_op)
569
+ response = self._base.request(prepped_request, expected, _op)
570
+
571
+ return response
572
+
573
+ def get_sheet_as_csv(self, sheet_id, download_path, alternate_file_name=None):
574
+ """Get the specified Sheet as a CSV file.
575
+
576
+ Args:
577
+ sheet_id (int): Sheet ID
578
+ download_path (str): Directory path on local
579
+ machine to save file.
580
+ alternate_file_name (str): Filename to use
581
+ instead of name suggested by Content-Disposition.
582
+
583
+ Returns:
584
+ DownloadedFile
585
+ """
586
+ if not os.path.isdir(download_path):
587
+ raise ValueError("download_path must be a directory.")
588
+
589
+ _op = fresh_operation("get_sheet_as_csv")
590
+ _op["method"] = "GET"
591
+ _op["path"] = "/sheets/" + str(sheet_id)
592
+ _op["header_params"]["Accept"] = "text/csv"
593
+ _op["dl_path"] = download_path
594
+
595
+ expected = "DownloadedFile"
596
+ prepped_request = self._base.prepare_request(_op)
597
+ response = self._base.request(prepped_request, expected, _op)
598
+ if alternate_file_name is not None:
599
+ response.filename = alternate_file_name
600
+
601
+ response.save_to_file()
602
+ return response
603
+
604
+ def get_sheet_as_excel(self, sheet_id, download_path, alternate_file_name=None):
605
+ """Get the specified Sheet as an Excel .xls file.
606
+
607
+ Args:
608
+ sheet_id (int): Sheet ID
609
+ download_path (str): Directory path on local
610
+ machine to save file.
611
+ alternate_file_name (str): Filename to use
612
+ instead of name suggested by Content-Disposition.
613
+
614
+ Returns:
615
+ DownloadedFile
616
+ """
617
+ if not os.path.isdir(download_path):
618
+ raise ValueError("download_path must be a directory.")
619
+
620
+ _op = fresh_operation("get_sheet_as_excel")
621
+ _op["method"] = "GET"
622
+ _op["path"] = "/sheets/" + str(sheet_id)
623
+ _op["header_params"]["Accept"] = "application/vnd.ms-excel"
624
+ _op["dl_path"] = download_path
625
+
626
+ expected = "DownloadedFile"
627
+ prepped_request = self._base.prepare_request(_op)
628
+ response = self._base.request(prepped_request, expected, _op)
629
+ if alternate_file_name is not None:
630
+ response.filename = alternate_file_name
631
+
632
+ response.save_to_file()
633
+ return response
634
+
635
+ def get_sheet_as_pdf(
636
+ self, sheet_id, download_path, paper_size=None, alternate_file_name=None
637
+ ):
638
+ """Get the specified Sheet as a PDF file.
639
+
640
+ Args:
641
+ sheet_id (int): Sheet ID
642
+ download_path (str): Directory path on local
643
+ machine to save file.
644
+ paper_size (str): Applies to PDF only. One of:
645
+ LETTER, LEGAL, WIDE, ARCHD, A4, A3, A2, A1, A0
646
+ alternate_file_name (str): Filename to use
647
+ instead of name suggested by Content-Disposition.
648
+
649
+ Returns:
650
+ DownloadedFile
651
+ """
652
+ if not os.path.isdir(download_path):
653
+ raise ValueError("download_path must be a directory.")
654
+
655
+ _op = fresh_operation("get_sheet_as_pdf")
656
+ _op["method"] = "GET"
657
+ _op["path"] = "/sheets/" + str(sheet_id)
658
+ _op["header_params"]["Accept"] = "application/pdf"
659
+ _op["query_params"]["paperSize"] = paper_size
660
+ _op["dl_path"] = download_path
661
+
662
+ expected = "DownloadedFile"
663
+ prepped_request = self._base.prepare_request(_op)
664
+ response = self._base.request(prepped_request, expected, _op)
665
+ if alternate_file_name is not None:
666
+ response.filename = alternate_file_name
667
+
668
+ response.save_to_file()
669
+ return response
670
+
671
+ def get_sheet_version(self, sheet_id):
672
+ """Get the Sheet version without loading the entire Sheet.
673
+
674
+ Args:
675
+ sheet_id (int): Sheet ID
676
+
677
+ Returns:
678
+ Version
679
+ """
680
+ _op = fresh_operation("get_sheet_version")
681
+ _op["method"] = "GET"
682
+ _op["path"] = "/sheets/" + str(sheet_id) + "/version"
683
+
684
+ expected = "Version"
685
+ prepped_request = self._base.prepare_request(_op)
686
+ response = self._base.request(prepped_request, expected, _op)
687
+
688
+ return response
689
+
690
+ @deprecated
691
+ def list_org_sheets(self):
692
+ """Get a list of all Sheets owned by an organization.
693
+
694
+ Get the list of all Sheets owned by the members of the
695
+ account (organization).
696
+ Returns:
697
+ IndexResult
698
+ """
699
+ _op = fresh_operation("list_org_sheets")
700
+ _op["method"] = "GET"
701
+ _op["path"] = "/users/sheets"
702
+
703
+ expected = ["IndexResult", "Sheet"]
704
+
705
+ prepped_request = self._base.prepare_request(_op)
706
+ response = self._base.request(prepped_request, expected, _op)
707
+
708
+ return response
709
+
710
+ def list_shares(
711
+ self,
712
+ sheet_id,
713
+ page_size=None,
714
+ page=None,
715
+ include_all=None,
716
+ include_workspace_shares=False,
717
+ access_api_level=0,
718
+ ):
719
+ """Get the list of all Users and Groups to whom the specified Sheet is
720
+ shared, and their access level.
721
+
722
+ Args:
723
+ sheet_id (int): Sheet ID
724
+ page_size (int): The maximum number of items to
725
+ return per page.
726
+ page (int): Which page to return.
727
+ include_all (bool): If true, include all results
728
+ (i.e. do not paginate).
729
+ include_workspace_shares(bool): Include Workspace shares
730
+
731
+ Returns:
732
+ IndexResult
733
+ """
734
+ _op = fresh_operation("list_shares")
735
+ _op["method"] = "GET"
736
+ _op["path"] = "/sheets/" + str(sheet_id) + "/shares"
737
+ _op["query_params"]["pageSize"] = page_size
738
+ _op["query_params"]["page"] = page
739
+ _op["query_params"]["includeAll"] = include_all
740
+ _op["query_params"]["accessApiLevel"] = access_api_level
741
+ if include_workspace_shares:
742
+ _op["query_params"]["include"] = "workspaceShares"
743
+
744
+ expected = ["IndexResult", "Share"]
745
+
746
+ prepped_request = self._base.prepare_request(_op)
747
+ response = self._base.request(prepped_request, expected, _op)
748
+
749
+ return response
750
+
751
+ def list_sheets(
752
+ self,
753
+ include=None,
754
+ page_size=None,
755
+ page=None,
756
+ include_all=None,
757
+ modified_since=None,
758
+ ):
759
+ """Get the list of all Sheets the User has access to, in alphabetical
760
+ order, by name.
761
+
762
+ Args:
763
+ include (list[str]): A comma-separated list of
764
+ optional elements to include in the response. Valid list
765
+ values: ownerInfo, sheetVersion, source.
766
+ page_size (int): The maximum number of items to
767
+ return per page.
768
+ page (int): Which page to return.
769
+ include_all (bool): If true, include all results
770
+ (i.e. do not paginate).
771
+ modified_since(datetime): Return sheets modified since provided datetime
772
+
773
+ Returns:
774
+ IndexResult
775
+ """
776
+ _op = fresh_operation("list_sheets")
777
+ _op["method"] = "GET"
778
+ _op["path"] = "/sheets"
779
+ _op["query_params"]["include"] = include
780
+ _op["query_params"]["pageSize"] = page_size
781
+ _op["query_params"]["page"] = page
782
+ _op["query_params"]["includeAll"] = include_all
783
+ if isinstance(modified_since, datetime):
784
+ _op["query_params"]["modifiedSince"] = modified_since.isoformat()
785
+
786
+ expected = ["IndexResult", "Sheet"]
787
+
788
+ prepped_request = self._base.prepare_request(_op)
789
+ response = self._base.request(prepped_request, expected, _op)
790
+
791
+ return response
792
+
793
+ def move_rows(
794
+ self,
795
+ sheet_id,
796
+ copy_or_move_row_directive_obj,
797
+ include=None,
798
+ ignore_rows_not_found=None,
799
+ ):
800
+ """Moves Row(s) to the bottom of another Sheet.
801
+
802
+ Up to 5,000 row IDs can be specified in the request, but if
803
+ the total number of rows in the destination Sheet after the move
804
+ exceeds the Smartsheet row limit, an error response will be
805
+ returned.
806
+
807
+ Any child rows of the rows specified in the request will also be
808
+ moved. Parent-child relationships amongst rows will be preserved
809
+ within the destination Sheet.
810
+
811
+ Args:
812
+ sheet_id (int): Sheet ID
813
+ copy_or_move_row_directive_obj
814
+ (CopyOrMoveRowDirective): CopyOrMoveRowDirective object.
815
+ include (list[str]): A comma-separated list of
816
+ row elements to move in addition to the cell data. Valid
817
+ list values: attachments, discussions.
818
+ ignore_rows_not_found (bool): If set to `true`,
819
+ specifying row ids that do not exist within the source sheet
820
+ will not cause an error response. If omitted or set to false
821
+ (the default), specifying row ids that do not exist within
822
+ the source sheet will cause an error response (and no rows
823
+ will be altered).
824
+
825
+ Returns:
826
+ CopyOrMoveRowResult
827
+ """
828
+ _op = fresh_operation("move_rows")
829
+ _op["method"] = "POST"
830
+ _op["path"] = "/sheets/" + str(sheet_id) + "/rows/move"
831
+ _op["query_params"]["include"] = include
832
+ _op["query_params"]["ignoreRowsNotFound"] = ignore_rows_not_found
833
+ _op["json"] = copy_or_move_row_directive_obj
834
+
835
+ expected = "CopyOrMoveRowResult"
836
+ prepped_request = self._base.prepare_request(_op)
837
+ response = self._base.request(prepped_request, expected, _op)
838
+
839
+ return response
840
+
841
+ def move_sheet(self, sheet_id, container_destination_obj):
842
+ """Move the specified Sheet to a new location.
843
+
844
+ Args:
845
+ sheet_id (int): Sheet ID
846
+ container_destination_obj
847
+ (ContainerDestination): Container Destination object.
848
+
849
+ Returns:
850
+ Result
851
+ """
852
+ _op = fresh_operation("move_sheet")
853
+ _op["method"] = "POST"
854
+ _op["path"] = "/sheets/" + str(sheet_id) + "/move"
855
+ _op["json"] = container_destination_obj
856
+
857
+ expected = ["Result", "Sheet"]
858
+
859
+ prepped_request = self._base.prepare_request(_op)
860
+ response = self._base.request(prepped_request, expected, _op)
861
+
862
+ return response
863
+
864
+ def search_sheet(self, sheet_id, query):
865
+ """Search the specified Sheet for the specified text.
866
+
867
+ Args:
868
+ sheet_id (int): Sheet ID
869
+ query (str): Text with which to perform the
870
+ search.
871
+
872
+ Returns:
873
+ SearchResult
874
+ """
875
+ _op = fresh_operation("search_sheet")
876
+ _op["method"] = "GET"
877
+ _op["path"] = "/search/sheets/" + str(sheet_id)
878
+ _op["query_params"]["query"] = query
879
+
880
+ expected = "SearchResult"
881
+ prepped_request = self._base.prepare_request(_op)
882
+ response = self._base.request(prepped_request, expected, _op)
883
+
884
+ return response
885
+
886
+ def send_rows(self, sheet_id, multi_row_email_obj):
887
+ """Send one or more rows via email
888
+
889
+ Args:
890
+ sheet_id (int): Sheet ID
891
+ multi_row_email_obj (MultiRowEmail):
892
+ MultiRowEmail object.
893
+
894
+ Returns:
895
+ Result
896
+ """
897
+ _op = fresh_operation("send_rows")
898
+ _op["method"] = "POST"
899
+ _op["path"] = "/sheets/" + str(sheet_id) + "/rows/emails"
900
+ _op["json"] = multi_row_email_obj
901
+
902
+ expected = ["Result", None]
903
+ prepped_request = self._base.prepare_request(_op)
904
+ response = self._base.request(prepped_request, expected, _op)
905
+
906
+ return response
907
+
908
+ def send_sheet(self, sheet_id, sheet_email_obj):
909
+ """Sends the sheet as an attachment via email to the designated
910
+ recipients.
911
+
912
+ Args:
913
+ sheet_id (int): Sheet ID
914
+ sheet_email_obj (SheetEmail): SheetEmail object.
915
+
916
+ Returns:
917
+ Result
918
+ """
919
+ _op = fresh_operation("send_sheet")
920
+ _op["method"] = "POST"
921
+ _op["path"] = "/sheets/" + str(sheet_id) + "/emails"
922
+ _op["json"] = sheet_email_obj
923
+
924
+ expected = ["Result", None]
925
+ prepped_request = self._base.prepare_request(_op)
926
+ response = self._base.request(prepped_request, expected, _op)
927
+
928
+ return response
929
+
930
+ @deprecated
931
+ def send_update_request(self, sheet_id, multi_row_email_obj):
932
+ """Create an Update Request for the specified Row(s) within the
933
+ Sheet. An email notification (containing a link to the
934
+ update request) will be asynchronously send to the specified
935
+ recipient(s).
936
+
937
+ Args:
938
+ sheet_id (int): Sheet ID
939
+ multi_row_email_obj (MultiRowEmail):
940
+ MultiRowEmail object.
941
+
942
+ Returns:
943
+ Result
944
+ """
945
+ _op = fresh_operation("send_update_request")
946
+ _op["method"] = "POST"
947
+ _op["path"] = "/sheets/" + str(sheet_id) + "/updaterequests"
948
+ _op["json"] = multi_row_email_obj
949
+
950
+ expected = ["Result", "UpdateRequest"]
951
+
952
+ prepped_request = self._base.prepare_request(_op)
953
+ response = self._base.request(prepped_request, expected, _op)
954
+
955
+ return response
956
+
957
+ def set_publish_status(self, sheet_id, sheet_publish_obj):
958
+ """Set the publish status of the Sheet and returns the new status,
959
+ including the URLs of any enabled publishings.
960
+
961
+ Args:
962
+ sheet_id (int): Sheet ID
963
+ sheet_publish_obj (SheetPublish): SheetPublish
964
+ object.
965
+
966
+ Returns:
967
+ Result
968
+ """
969
+ attributes = [
970
+ "read_only_lite_enabled",
971
+ "read_only_full_enabled",
972
+ "read_write_enabled",
973
+ "ical_enabled",
974
+ ]
975
+
976
+ fetch_first = False
977
+ # check for incompleteness, fill in from current status if necessary
978
+ for attribute in attributes:
979
+ val = getattr(sheet_publish_obj, attribute, None)
980
+ if val is None:
981
+ fetch_first = True
982
+ break
983
+
984
+ if fetch_first:
985
+ current_status = self.get_publish_status(sheet_id).to_dict()
986
+ current_status.update(sheet_publish_obj.to_dict())
987
+ sheet_publish_obj = self._base.models.SheetPublish(current_status)
988
+
989
+ _op = fresh_operation("set_publish_status")
990
+ _op["method"] = "PUT"
991
+ _op["path"] = "/sheets/" + str(sheet_id) + "/publish"
992
+ _op["json"] = sheet_publish_obj
993
+
994
+ expected = ["Result", "SheetPublish"]
995
+
996
+ prepped_request = self._base.prepare_request(_op)
997
+ response = self._base.request(prepped_request, expected, _op)
998
+
999
+ return response
1000
+
1001
+ @deprecated
1002
+ def share_sheet(self, sheet_id, share_obj, send_email=None):
1003
+ """Share the specified Sheet.
1004
+
1005
+ Share the specified Sheet with the specified Users and
1006
+ Groups.
1007
+
1008
+ Args:
1009
+ sheet_id (int): Sheet ID
1010
+ share_obj (Share): Share object.
1011
+ send_email (bool): Either true or false to
1012
+ indicate whether or not to notify the user by email. Default
1013
+ is false.
1014
+
1015
+ Returns:
1016
+ Result
1017
+
1018
+ Deprecated:
1019
+ Use sharing.share_asset instead with assetType=AssetType.SHEET
1020
+ """
1021
+ _op = fresh_operation("share_sheet")
1022
+ _op["method"] = "POST"
1023
+ _op["path"] = "/sheets/" + str(sheet_id) + "/shares"
1024
+ _op["json"] = share_obj
1025
+ _op["query_params"]["sendEmail"] = send_email
1026
+
1027
+ expected = ["Result", "Share"]
1028
+
1029
+ prepped_request = self._base.prepare_request(_op)
1030
+ response = self._base.request(prepped_request, expected, _op)
1031
+
1032
+ return response
1033
+
1034
+ def update_column(self, sheet_id, column_id, column_obj):
1035
+ """Update properties of the specified Column.
1036
+
1037
+ Args:
1038
+ sheet_id (int): Sheet ID
1039
+ column_id (int): Column ID
1040
+ column_obj (Column): A Column object.
1041
+
1042
+ Returns:
1043
+ Result
1044
+ """
1045
+ if not all(val is not None for val in ["sheet_id", "column_id", "column_obj"]):
1046
+ raise ValueError(
1047
+ ("One or more required values are missing from call to " + __name__)
1048
+ )
1049
+
1050
+ if isinstance(column_obj, dict):
1051
+ column_obj = Column(column_obj)
1052
+
1053
+ _op = fresh_operation("update_column")
1054
+ _op["method"] = "PUT"
1055
+ _op["path"] = "/sheets/" + str(sheet_id) + "/columns/" + str(column_id)
1056
+ _op["json"] = column_obj
1057
+
1058
+ expected = ["Result", "Column"]
1059
+
1060
+ prepped_request = self._base.prepare_request(_op)
1061
+ response = self._base.request(prepped_request, expected, _op)
1062
+
1063
+ return response
1064
+
1065
+ def update_rows(self, sheet_id, list_of_rows):
1066
+ """Update properties of the specified Row.
1067
+
1068
+ Updates cell values in the specified row(s),
1069
+ expands/collapses the specified row(s), and/or modifies the
1070
+ position of the specified rows (including indenting/outdenting).
1071
+
1072
+ If a row's position is updated, all child rows are moved with the
1073
+ row.
1074
+
1075
+ In a parent row, values of the following fields are auto-calculated
1076
+ based upon values in the child rows (and therefore cannot be
1077
+ updated using the API): Start Date, End Date, Duration, % Complete.
1078
+
1079
+ Args:
1080
+ sheet_id (int): Sheet ID
1081
+ list_of_rows (list[Row]): Array containing one
1082
+ or more Row objects.
1083
+
1084
+ Returns:
1085
+ Result
1086
+ """
1087
+ _op = fresh_operation("update_rows")
1088
+ _op["method"] = "PUT"
1089
+ _op["path"] = "/sheets/" + str(sheet_id) + "/rows"
1090
+ _op["json"] = list_of_rows
1091
+
1092
+ expected = ["Result", "Row"]
1093
+
1094
+ prepped_request = self._base.prepare_request(_op)
1095
+ response = self._base.request(prepped_request, expected, _op)
1096
+
1097
+ return response
1098
+
1099
+ def update_rows_with_partial_success(self, sheet_id, list_of_rows):
1100
+ """Update properties of the specified Row(s).
1101
+
1102
+ Updates cell values in the specified row(s),
1103
+ expands/collapses the specified row(s), and/or modifies the
1104
+ position of the specified rows (including indenting/outdenting).
1105
+
1106
+ If a row's position is updated, all child rows are moved with the
1107
+ row.
1108
+
1109
+ In a parent row, values of the following fields are auto-calculated
1110
+ based upon values in the child rows (and therefore cannot be
1111
+ updated using the API): Start Date, End Date, Duration, % Complete.
1112
+
1113
+ Args:
1114
+ sheet_id (int): Sheet ID
1115
+ list_of_rows (list[Row]): Array containing one
1116
+ or more Row objects.
1117
+
1118
+ Returns:
1119
+ Result
1120
+ """
1121
+ _op = fresh_operation("update_rows")
1122
+ _op["method"] = "PUT"
1123
+ _op["path"] = "/sheets/" + str(sheet_id) + "/rows"
1124
+ _op["json"] = list_of_rows
1125
+ _op["query_params"]["allowPartialSuccess"] = "true"
1126
+
1127
+ expected = ["BulkItemResult", "Row"]
1128
+
1129
+ prepped_request = self._base.prepare_request(_op)
1130
+ response = self._base.request(prepped_request, expected, _op)
1131
+
1132
+ return response
1133
+
1134
+ @deprecated
1135
+ def update_share(self, sheet_id, share_id, share_obj):
1136
+ """Update the access level of a User or Group for the specified Sheet.
1137
+
1138
+ Args:
1139
+ sheet_id (int): Sheet ID
1140
+ share_id (str): Share ID
1141
+ share_obj (Share): Share object.
1142
+
1143
+ Returns:
1144
+ Result
1145
+
1146
+ Deprecated:
1147
+ Use sharing.update_share instead with assetType=AssetType.SHEET
1148
+ """
1149
+ if not all(val is not None for val in ["sheet_id", "share_id", "share_obj"]):
1150
+ raise ValueError(
1151
+ ("One or more required values are missing from call to " + __name__)
1152
+ )
1153
+
1154
+ _op = fresh_operation("update_share")
1155
+ _op["method"] = "PUT"
1156
+ _op["path"] = "/sheets/" + str(sheet_id) + "/shares/" + str(share_id)
1157
+ _op["json"] = share_obj
1158
+
1159
+ expected = ["Result", "Share"]
1160
+
1161
+ prepped_request = self._base.prepare_request(_op)
1162
+ response = self._base.request(prepped_request, expected, _op)
1163
+
1164
+ return response
1165
+
1166
+ def update_sheet(self, sheet_id, sheet_obj):
1167
+ """Updates the specified Sheet.
1168
+
1169
+ Args:
1170
+ sheet_id (int): Sheet ID
1171
+ sheet_obj (Sheet): Sheet object.
1172
+
1173
+ Returns:
1174
+ Result
1175
+ """
1176
+ _op = fresh_operation("update_sheet")
1177
+ _op["method"] = "PUT"
1178
+ _op["path"] = "/sheets/" + str(sheet_id)
1179
+ _op["json"] = sheet_obj
1180
+
1181
+ expected = ["Result", "Sheet"]
1182
+
1183
+ prepped_request = self._base.prepare_request(_op)
1184
+ response = self._base.request(prepped_request, expected, _op)
1185
+
1186
+ return response
1187
+
1188
+ def list_update_requests(
1189
+ self, sheet_id, page_size=None, page=None, include_all=None
1190
+ ):
1191
+ """Get the list of all Sheet UpdateRequests.
1192
+
1193
+ Args:
1194
+ sheet_id (int): Sheet ID
1195
+ page_size (int): The maximum number of items to
1196
+ return per page.
1197
+ page (int): Which page to return.
1198
+ include_all(bool): If true, include all results
1199
+ (i.e. do not paginate).
1200
+
1201
+ Returns:
1202
+ IndexResult
1203
+ """
1204
+ _op = fresh_operation("list_update_requests")
1205
+ _op["method"] = "GET"
1206
+ _op["path"] = "/sheets/" + str(sheet_id) + "/updaterequests"
1207
+ _op["query_params"]["pageSize"] = page_size
1208
+ _op["query_params"]["page"] = page
1209
+ _op["query_params"]["includeAll"] = include_all
1210
+
1211
+ expected = ["IndexResult", "UpdateRequest"]
1212
+
1213
+ prepped_request = self._base.prepare_request(_op)
1214
+ response = self._base.request(prepped_request, expected, _op)
1215
+
1216
+ return response
1217
+
1218
+ def get_update_request(self, sheet_id, update_request_id):
1219
+ """Get the UpdateRequest for Sheet that has a future schedule.
1220
+
1221
+ Args:
1222
+ sheet_id (int): Sheet ID
1223
+ update_request_id (int): UpdateRequest ID
1224
+
1225
+ Returns:
1226
+ UpdateRequest
1227
+ """
1228
+ _op = fresh_operation("get_update_request")
1229
+ _op["method"] = "GET"
1230
+ _op["path"] = (
1231
+ "/sheets/" + str(sheet_id) + "/updaterequests/" + str(update_request_id)
1232
+ )
1233
+
1234
+ expected = "UpdateRequest"
1235
+ prepped_request = self._base.prepare_request(_op)
1236
+ response = self._base.request(prepped_request, expected, _op)
1237
+
1238
+ return response
1239
+
1240
+ def create_update_request(self, sheet_id, update_request_obj):
1241
+ """Creates an UpdateRequest for the specified Rows(s) within the Sheet.
1242
+
1243
+ Args:
1244
+ sheet_id (int): Sheet ID
1245
+ update_request_obj (UpdateRequest): UpdateRequest object
1246
+
1247
+ Returns:
1248
+ Result
1249
+ """
1250
+ _op = fresh_operation("create_update_request")
1251
+ _op["method"] = "POST"
1252
+ _op["path"] = "/sheets/" + str(sheet_id) + "/updaterequests"
1253
+ _op["json"] = update_request_obj
1254
+
1255
+ expected = ["Result", "UpdateRequest"]
1256
+
1257
+ prepped_request = self._base.prepare_request(_op)
1258
+ response = self._base.request(prepped_request, expected, _op)
1259
+
1260
+ return response
1261
+
1262
+ def delete_update_request(self, sheet_id, update_request_id):
1263
+ """Deletes an UpdateRequest for the specified Sheet.
1264
+
1265
+ Args:
1266
+ sheet_id (int): Sheet ID
1267
+ update_request_id (int): UpdateRequest ID
1268
+
1269
+ Returns:
1270
+ Result
1271
+ """
1272
+ _op = fresh_operation("delete_update_request")
1273
+ _op["method"] = "DELETE"
1274
+ _op["path"] = (
1275
+ "/sheets/" + str(sheet_id) + "/updaterequests/" + str(update_request_id)
1276
+ )
1277
+
1278
+ expected = ["Result", None]
1279
+ prepped_request = self._base.prepare_request(_op)
1280
+ response = self._base.request(prepped_request, expected, _op)
1281
+
1282
+ return response
1283
+
1284
+ def update_update_request(self, sheet_id, update_request_id, update_request_obj):
1285
+ """Updates an UpdateRequest for the specified Rows(s) within the Sheet.
1286
+
1287
+ Args:
1288
+ sheet_id (int): Sheet ID
1289
+ update_request_id: Update request ID
1290
+ update_request_obj (UpdateRequest): UpdateRequest object
1291
+
1292
+ Returns:
1293
+ Result
1294
+ """
1295
+ _op = fresh_operation("update_update_request")
1296
+ _op["method"] = "PUT"
1297
+ _op["path"] = (
1298
+ "/sheets/" + str(sheet_id) + "/updaterequests/" + str(update_request_id)
1299
+ )
1300
+ _op["json"] = update_request_obj
1301
+
1302
+ expected = ["Result", "UpdateRequest"]
1303
+
1304
+ prepped_request = self._base.prepare_request(_op)
1305
+ response = self._base.request(prepped_request, expected, _op)
1306
+
1307
+ return response
1308
+
1309
+ def list_sent_update_requests(
1310
+ self, sheet_id, page_size=None, page=None, include_all=None
1311
+ ):
1312
+ """Get the list of all Sent UpdateRequests.
1313
+
1314
+ Args:
1315
+ sheet_id (int): Sheet ID
1316
+ page_size (int): The maximum number of items to
1317
+ return per page.
1318
+ page (int): Which page to return.
1319
+ include_all (bool): If true, include all results
1320
+ (i.e. do not paginate).
1321
+
1322
+ Returns:
1323
+ IndexResult
1324
+ """
1325
+ _op = fresh_operation("list_update_requests")
1326
+ _op["method"] = "GET"
1327
+ _op["path"] = "/sheets/" + str(sheet_id) + "/sentupdaterequests"
1328
+ _op["query_params"]["pageSize"] = page_size
1329
+ _op["query_params"]["page"] = page
1330
+ _op["query_params"]["includeAll"] = include_all
1331
+
1332
+ expected = ["IndexResult", "SentUpdateRequest"]
1333
+
1334
+ prepped_request = self._base.prepare_request(_op)
1335
+ response = self._base.request(prepped_request, expected, _op)
1336
+
1337
+ return response
1338
+
1339
+ def get_sent_update_request(self, sheet_id, sent_update_request_id):
1340
+ """Get the SentUpdateRequest for Sheet.
1341
+
1342
+ Args:
1343
+ sheet_id (int): Sheet ID
1344
+ sent_update_request_id (int): SentUpdateRequest ID
1345
+
1346
+ Returns:
1347
+ UpdateRequest
1348
+ """
1349
+ _op = fresh_operation("get_sent_update_request")
1350
+ _op["method"] = "GET"
1351
+ _op["path"] = (
1352
+ "/sheets/"
1353
+ + str(sheet_id)
1354
+ + "/sentupdaterequests/"
1355
+ + str(sent_update_request_id)
1356
+ )
1357
+
1358
+ expected = "SentUpdateRequest"
1359
+ prepped_request = self._base.prepare_request(_op)
1360
+ response = self._base.request(prepped_request, expected, _op)
1361
+
1362
+ return response
1363
+
1364
+ def delete_sent_update_request(self, sheet_id, sent_update_request_id):
1365
+ """Deletes a SentUpdateRequest for the specified Sheet.
1366
+
1367
+ Args:
1368
+ sheet_id (int): Sheet ID
1369
+ sent_update_request_id (int): SentUpdateRequest ID
1370
+
1371
+ Returns:
1372
+ Result
1373
+ """
1374
+ _op = fresh_operation("delete_update_request")
1375
+ _op["method"] = "DELETE"
1376
+ _op["path"] = (
1377
+ "/sheets/"
1378
+ + str(sheet_id)
1379
+ + "/sentupdaterequests/"
1380
+ + str(sent_update_request_id)
1381
+ )
1382
+
1383
+ expected = ["Result", None]
1384
+ prepped_request = self._base.prepare_request(_op)
1385
+ response = self._base.request(prepped_request, expected, _op)
1386
+
1387
+ return response
1388
+
1389
+ def list_filters(self, sheet_id, page_size=None, page=None, include_all=None):
1390
+ """Returns a list of all saved sheet filters
1391
+
1392
+ Args:
1393
+ sheet_id (int): Sheet ID
1394
+ page_size (int): The maximum number of items to
1395
+ return per page.
1396
+ page (int): Which page to return.
1397
+ include_all (bool): If true, include all results
1398
+ (i.e. do not paginate).
1399
+
1400
+ Returns:
1401
+ IndexResult
1402
+ """
1403
+ _op = fresh_operation("list_sheet_filters")
1404
+ _op["method"] = "GET"
1405
+ _op["path"] = "/sheets/" + str(sheet_id) + "/filters"
1406
+ _op["query_params"]["pageSize"] = page_size
1407
+ _op["query_params"]["page"] = page
1408
+ _op["query_params"]["includeAll"] = include_all
1409
+
1410
+ expected = ["IndexResult", "SheetFilter"]
1411
+
1412
+ prepped_request = self._base.prepare_request(_op)
1413
+ response = self._base.request(prepped_request, expected, _op)
1414
+
1415
+ return response
1416
+
1417
+ def get_filter(self, sheet_id, filter_id):
1418
+ """Get the Filter.
1419
+
1420
+ Args:
1421
+ sheet_id (int): Sheet ID
1422
+ filter_id (int): Filter ID
1423
+
1424
+ Returns:
1425
+ Filter
1426
+ """
1427
+ _op = fresh_operation("get_sheet_filter")
1428
+ _op["method"] = "GET"
1429
+ _op["path"] = "/sheets/" + str(sheet_id) + "/filters/" + str(filter_id)
1430
+
1431
+ expected = "SheetFilter"
1432
+ prepped_request = self._base.prepare_request(_op)
1433
+ response = self._base.request(prepped_request, expected, _op)
1434
+
1435
+ return response
1436
+
1437
+ def delete_filter(self, sheet_id, filter_id):
1438
+ """Deletes a Filter for the specified Sheet.
1439
+
1440
+ Args:
1441
+ sheet_id (int): Sheet ID
1442
+ filter_id (int): Filter ID
1443
+
1444
+ Returns:
1445
+ Result
1446
+ """
1447
+ _op = fresh_operation("delete_sheet_filter")
1448
+ _op["method"] = "DELETE"
1449
+ _op["path"] = "/sheets/" + str(sheet_id) + "/filters/" + str(filter_id)
1450
+
1451
+ expected = ["Result", None]
1452
+ prepped_request = self._base.prepare_request(_op)
1453
+ response = self._base.request(prepped_request, expected, _op)
1454
+
1455
+ return response
1456
+
1457
+ def list_cross_sheet_references(
1458
+ self, sheet_id, page_size=None, page=None, include_all=None
1459
+ ):
1460
+ """Get the list of all CrossSheetReferences for this Sheet.
1461
+
1462
+ Args:
1463
+ sheet_id (int): Sheet ID
1464
+ page_size (int): The maximum number of items to
1465
+ return per page.
1466
+ page (int): Which page to return.
1467
+ include_all (bool): If true, include all results
1468
+ (i.e. do not paginate).
1469
+
1470
+ Returns:
1471
+ IndexResult
1472
+ """
1473
+ _op = fresh_operation("list_cross_sheet_references")
1474
+ _op["method"] = "GET"
1475
+ _op["path"] = "/sheets/" + str(sheet_id) + "/crosssheetreferences"
1476
+ _op["query_params"]["pageSize"] = page_size
1477
+ _op["query_params"]["page"] = page
1478
+ _op["query_params"]["includeAll"] = include_all
1479
+
1480
+ expected = ["IndexResult", "CrossSheetReference"]
1481
+
1482
+ prepped_request = self._base.prepare_request(_op)
1483
+ response = self._base.request(prepped_request, expected, _op)
1484
+
1485
+ return response
1486
+
1487
+ def get_cross_sheet_reference(self, sheet_id, cross_sheet_reference_id):
1488
+ """Get the CrossSheetReference.
1489
+
1490
+ Args:
1491
+ sheet_id (int): Sheet ID
1492
+ cross_sheet_reference_id (int): CrossSheetReferenceID
1493
+
1494
+ Returns:
1495
+ CrossSheetReference
1496
+ """
1497
+ _op = fresh_operation("get_cross_sheet_reference")
1498
+ _op["method"] = "GET"
1499
+ _op["path"] = (
1500
+ "/sheets/"
1501
+ + str(sheet_id)
1502
+ + "/crosssheetreferences/"
1503
+ + str(cross_sheet_reference_id)
1504
+ )
1505
+
1506
+ expected = "CrossSheetReference"
1507
+ prepped_request = self._base.prepare_request(_op)
1508
+ response = self._base.request(prepped_request, expected, _op)
1509
+
1510
+ return response
1511
+
1512
+ def create_cross_sheet_reference(self, sheet_id, cross_sheet_reference_obj):
1513
+ """Creates a CrossSheetReference for the specified Sheet.
1514
+
1515
+ Args:
1516
+ sheet_id (int): Sheet ID
1517
+ cross_sheet_reference_obj (CrossSheetReference): CrossSheetReference object
1518
+
1519
+ Returns:
1520
+ Result
1521
+ """
1522
+ _op = fresh_operation("create_cross_sheet_reference")
1523
+ _op["method"] = "POST"
1524
+ _op["path"] = "/sheets/" + str(sheet_id) + "/crosssheetreferences"
1525
+ _op["json"] = cross_sheet_reference_obj
1526
+
1527
+ expected = ["Result", "CrossSheetReference"]
1528
+
1529
+ prepped_request = self._base.prepare_request(_op)
1530
+ response = self._base.request(prepped_request, expected, _op)
1531
+
1532
+ return response
1533
+
1534
+ def list_automation_rules(
1535
+ self, sheet_id, page_size=None, page=None, include_all=None
1536
+ ):
1537
+ """Get the list of all AutomationRules for this Sheet.
1538
+
1539
+ Args:
1540
+ sheet_id (int): Sheet ID
1541
+ page_size (int): The maximum number of items to
1542
+ return per page.
1543
+ page (int): Which page to return.
1544
+ include_all (bool): If true, include all results
1545
+ (i.e. do not paginate).
1546
+
1547
+ Returns:
1548
+ IndexResult
1549
+ """
1550
+ _op = fresh_operation("list_automation_rules")
1551
+ _op["method"] = "GET"
1552
+ _op["path"] = "/sheets/" + str(sheet_id) + "/automationrules"
1553
+ _op["query_params"]["pageSize"] = page_size
1554
+ _op["query_params"]["page"] = page
1555
+ _op["query_params"]["includeAll"] = include_all
1556
+
1557
+ expected = ["IndexResult", "AutomationRule"]
1558
+
1559
+ prepped_request = self._base.prepare_request(_op)
1560
+ response = self._base.request(prepped_request, expected, _op)
1561
+
1562
+ return response
1563
+
1564
+ def get_automation_rule(self, sheet_id, automation_rule_id):
1565
+ """Get the AutomationRule.
1566
+
1567
+ Args:
1568
+ sheet_id (int): Sheet ID
1569
+ automation_rule_id (long): AutomationRuleID
1570
+
1571
+ Returns:
1572
+ AutomationRule
1573
+ """
1574
+ _op = fresh_operation("get_automation_rule")
1575
+ _op["method"] = "GET"
1576
+ _op["path"] = (
1577
+ "/sheets/" + str(sheet_id) + "/automationrules/" + str(automation_rule_id)
1578
+ )
1579
+
1580
+ expected = "AutomationRule"
1581
+ prepped_request = self._base.prepare_request(_op)
1582
+ response = self._base.request(prepped_request, expected, _op)
1583
+
1584
+ return response
1585
+
1586
+ def update_automation_rule(self, sheet_id, automation_rule_id, automation_rule_obj):
1587
+ """Updates an AutomationRule for the specified Sheet.
1588
+
1589
+ Args:
1590
+ sheet_id (int): Sheet ID
1591
+ automation_rule_id: AutomationRule ID
1592
+ automation_rule_obj (AutomationRule): AutomationRule object
1593
+
1594
+ Returns:
1595
+ Result
1596
+ """
1597
+ _op = fresh_operation("update_automation_rule")
1598
+ _op["method"] = "PUT"
1599
+ _op["path"] = (
1600
+ "/sheets/" + str(sheet_id) + "/automationrules/" + str(automation_rule_id)
1601
+ )
1602
+ _op["json"] = automation_rule_obj
1603
+
1604
+ expected = ["Result", "AutomationRule"]
1605
+
1606
+ prepped_request = self._base.prepare_request(_op)
1607
+ response = self._base.request(prepped_request, expected, _op)
1608
+
1609
+ return response
1610
+
1611
+ def delete_automation_rule(self, sheet_id, automation_rule_id):
1612
+ """Deletes an AutomationRule for the specified Sheet.
1613
+
1614
+ Args:
1615
+ sheet_id (int): Sheet ID
1616
+ automation_rule_id (int): AutomationRule ID
1617
+
1618
+ Returns:
1619
+ Result
1620
+ """
1621
+ _op = fresh_operation("delete_automation_rule")
1622
+ _op["method"] = "DELETE"
1623
+ _op["path"] = (
1624
+ "/sheets/" + str(sheet_id) + "/automationrules/" + str(automation_rule_id)
1625
+ )
1626
+
1627
+ expected = ["Result", None]
1628
+ prepped_request = self._base.prepare_request(_op)
1629
+ response = self._base.request(prepped_request, expected, _op)
1630
+
1631
+ return response
1632
+
1633
+ def sort_sheet(self, sheet_id, sort_specifier_obj, level=None):
1634
+ """Sort Sheet according to SortSpecifier.
1635
+
1636
+ Args:
1637
+ sheet_id (int): Sheet ID
1638
+ sort_specifier_obj (SortSpecifier): SortSpecifier object
1639
+ level (int): compatibility level
1640
+
1641
+ Returns:
1642
+ Sheet
1643
+ """
1644
+ _op = fresh_operation("sort_sheet")
1645
+ _op["method"] = "POST"
1646
+ _op["path"] = "/sheets/" + str(sheet_id) + "/sort"
1647
+ _op["json"] = sort_specifier_obj
1648
+ _op["query_params"]["level"] = level
1649
+
1650
+ expected = "Sheet"
1651
+
1652
+ prepped_request = self._base.prepare_request(_op)
1653
+ response = self._base.request(prepped_request, expected, _op)
1654
+
1655
+ return response
1656
+
1657
+ def import_csv_sheet(
1658
+ self, file, sheet_name=None, header_row_index=None, primary_column_index=None
1659
+ ):
1660
+ """Imports a sheet.
1661
+
1662
+ Args:
1663
+ file (string): path to CSV file.
1664
+ sheet_name (string): destination sheet name
1665
+ header_row_index (int): index (0 based) of row to be used for column names
1666
+ primary_column_index (int): index (0 based) of primary column
1667
+
1668
+ Returns:
1669
+ Result
1670
+ """
1671
+ if not all(val is not None for val in ["folder_id", "file"]):
1672
+ raise ValueError(
1673
+ ("One or more required values are missing from call to " + __name__)
1674
+ )
1675
+
1676
+ return self._import_sheet(
1677
+ file, "text/csv", sheet_name, header_row_index, primary_column_index
1678
+ )
1679
+
1680
+ def import_xlsx_sheet(
1681
+ self, file, sheet_name=None, header_row_index=None, primary_column_index=None
1682
+ ):
1683
+ """Imports a sheet.
1684
+
1685
+ Args:
1686
+ file (string): path to XLSX file.
1687
+ sheet_name (string): destination sheet name
1688
+ header_row_index (int): index (0 based) of row to be used for column names
1689
+ primary_column_index (int): index (0 based) of primary column
1690
+
1691
+ Returns:
1692
+ Result
1693
+ """
1694
+ if not all(val is not None for val in ["folder_id", "file"]):
1695
+ raise ValueError(
1696
+ ("One or more required values are missing from call to " + __name__)
1697
+ )
1698
+
1699
+ return self._import_sheet(
1700
+ file,
1701
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
1702
+ sheet_name,
1703
+ header_row_index,
1704
+ primary_column_index,
1705
+ )
1706
+
1707
+ def _import_sheet(
1708
+ self, file, file_type, sheet_name, header_row_index, primary_column_index
1709
+ ):
1710
+ """Internal function used to import sheet"""
1711
+
1712
+ if sheet_name is None:
1713
+ head, tail = os.path.split(file)
1714
+ sheet_name = tail or os.path.basename(head)
1715
+
1716
+ _data = open(file, "rb").read()
1717
+ _op = fresh_operation("import_sheet_into_folder")
1718
+ _op["method"] = "POST"
1719
+ _op["path"] = "/sheets/import"
1720
+ _op["headers"] = {
1721
+ "content-type": file_type,
1722
+ "content-disposition": "attachment",
1723
+ }
1724
+ _op["form_data"] = _data
1725
+ _op["query_params"]["sheetName"] = sheet_name
1726
+ _op["query_params"]["headerRowIndex"] = header_row_index
1727
+ _op["query_params"]["primaryColumnIndex"] = primary_column_index
1728
+
1729
+ expected = ["Result", "Sheet"]
1730
+
1731
+ prepped_request = self._base.prepare_request(_op)
1732
+ response = self._base.request(prepped_request, expected, _op)
1733
+
1734
+ return response
1735
+
1736
+ def get_sheet_summary(
1737
+ self,
1738
+ sheet_id,
1739
+ include=None,
1740
+ exclude=None,
1741
+ ):
1742
+ """Get the SheetSummary.
1743
+
1744
+ Args:
1745
+ sheet_id (int): Sheet ID
1746
+ include (list[str]): A comma-separated list of
1747
+ optional elements to include in the response. Valid list
1748
+ values: format, writerInfo
1749
+ exclude (list[str]): A comma-separated list of
1750
+ optional elements to exclude from the response. Valid list
1751
+ values: displayValue, image, imageAltText
1752
+
1753
+ Returns:
1754
+ SheetSummary
1755
+ """
1756
+ _op = fresh_operation("get_sheet_summary")
1757
+ _op["method"] = "GET"
1758
+ _op["path"] = "/sheets/" + str(sheet_id) + "/summary"
1759
+ _op["query_params"]["include"] = include
1760
+ _op["query_params"]["exclude"] = exclude
1761
+
1762
+ expected = "SheetSummary"
1763
+ prepped_request = self._base.prepare_request(_op)
1764
+ response = self._base.request(prepped_request, expected, _op)
1765
+
1766
+ return response
1767
+
1768
+ def get_sheet_summary_fields(
1769
+ self,
1770
+ sheet_id,
1771
+ include=None,
1772
+ exclude=None,
1773
+ page_size=None,
1774
+ page=None,
1775
+ include_all=None,
1776
+ ):
1777
+ """Get the list of summary fields for this Sheet.
1778
+
1779
+ Args:
1780
+ sheet_id (int): Sheet ID
1781
+ include (list[str]): A comma-separated list of
1782
+ optional elements to include in the response. Valid list
1783
+ values: format, writerInfo
1784
+ exclude (list[str]): A comma-separated list of
1785
+ optional elements to exclude from the response. Valid list
1786
+ values: displayValue, image, imageAltText
1787
+ page_size (int): The maximum number of items to
1788
+ return per page.
1789
+ page (int): Which page to return.
1790
+ include_all (bool): If true, include all results
1791
+ (i.e. do not paginate).
1792
+
1793
+ Returns:
1794
+ IndexResult
1795
+ """
1796
+ _op = fresh_operation("list_summary_fields")
1797
+ _op["method"] = "GET"
1798
+ _op["path"] = "/sheets/" + str(sheet_id) + "/summary/fields"
1799
+ _op["query_params"]["include"] = include
1800
+ _op["query_params"]["exclude"] = exclude
1801
+ _op["query_params"]["pageSize"] = page_size
1802
+ _op["query_params"]["page"] = page
1803
+ _op["query_params"]["includeAll"] = include_all
1804
+
1805
+ expected = ["IndexResult", "SummaryField"]
1806
+
1807
+ prepped_request = self._base.prepare_request(_op)
1808
+ response = self._base.request(prepped_request, expected, _op)
1809
+
1810
+ return response
1811
+
1812
+ def add_sheet_summary_fields(
1813
+ self, sheet_id, list_of_fields, rename_if_conflict=None
1814
+ ):
1815
+ """Insert one or more SummaryFields into the specified Sheet
1816
+
1817
+ If an error occurs, the Error object returned will contain a detail attribute set to an object with the
1818
+ following attributes:
1819
+
1820
+ - index: the array index of the summary field that caused the error
1821
+ (0 if a single summary field was passed in)
1822
+
1823
+ If any error occurs, the entire request will fail (no summary fields will be updated), and the Error response
1824
+ returned will describe the first problem that was encountered.
1825
+
1826
+ Args:
1827
+ sheet_id (int): Sheet ID
1828
+ list_of_fields (list[SummaryField]): An array of SummaryField objects.
1829
+ rename_if_conflict(Boolean): Normally, this call will fail if it attempts to create a summary field name
1830
+ that already exists. (summary field names must be unique within a sheet.) If this parameter is set to
1831
+ true, then new summary field names will be adjusted to ensure uniqueness.
1832
+
1833
+ Returns:
1834
+ Result
1835
+ """
1836
+ if isinstance(list_of_fields, (dict, SummaryField)):
1837
+ arg_value = list_of_fields
1838
+ list_of_fields = TypedList(SummaryField)
1839
+ list_of_fields.append(arg_value)
1840
+
1841
+ _op = fresh_operation("add_sheet_summary_fields")
1842
+ _op["method"] = "POST"
1843
+ _op["path"] = "/sheets/" + str(sheet_id) + "/summary/fields"
1844
+ _op["json"] = list_of_fields
1845
+ _op["query_params"]["renameIfConflict"] = rename_if_conflict
1846
+
1847
+ expected = ["Result", "SummaryField"]
1848
+
1849
+ prepped_request = self._base.prepare_request(_op)
1850
+ response = self._base.request(prepped_request, expected, _op)
1851
+
1852
+ return response
1853
+
1854
+ def add_sheet_summary_fields_with_partial_success(
1855
+ self, sheet_id, list_of_fields, rename_if_conflict=None
1856
+ ):
1857
+ """Insert one or more SummaryFields into the specified Sheet
1858
+
1859
+ When partial success is enabled, and one or more of the objects in the request fail to be added/updated/deleted,
1860
+ a standard Result object is returned, but with a message of 'PARTIAL_SUCCESS' (instead of 'SUCCESS'), and a
1861
+ resultCode of 3. The object will contain a failedItems attribute - an array of BulkItemFailure objects that
1862
+ contains an item for each object in the request that failed to be added/updated/deleted.
1863
+
1864
+ Args:
1865
+ sheet_id (int): Sheet ID
1866
+ list_of_fields (list[SummaryField]): An array of SummaryField objects.
1867
+ rename_if_conflict(Boolean): Normally, this call will fail if it attempts to create a summary field name
1868
+ that already exists. (summary field names must be unique within a sheet.) If this parameter is set to
1869
+ true, then new summary field names will be adjusted to ensure uniqueness.
1870
+
1871
+ Returns:
1872
+ Result
1873
+ """
1874
+ if isinstance(list_of_fields, (dict, SummaryField)):
1875
+ arg_value = list_of_fields
1876
+ list_of_fields = TypedList(SummaryField)
1877
+ list_of_fields.append(arg_value)
1878
+
1879
+ _op = fresh_operation("add_sheet_summary_fields")
1880
+ _op["method"] = "POST"
1881
+ _op["path"] = "/sheets/" + str(sheet_id) + "/summary/fields"
1882
+ _op["json"] = list_of_fields
1883
+ _op["query_params"]["renameIfConflict"] = rename_if_conflict
1884
+ _op["query_params"]["allowPartialSuccess"] = "true"
1885
+
1886
+ expected = ["BulkItemResult", "SummaryField"]
1887
+
1888
+ prepped_request = self._base.prepare_request(_op)
1889
+ response = self._base.request(prepped_request, expected, _op)
1890
+
1891
+ return response
1892
+
1893
+ def delete_sheet_summary_fields(
1894
+ self, sheet_id, list_of_ids, ignore_summary_fields_not_found=None
1895
+ ):
1896
+ """Deletes a list of SummaryFields for the specified Sheet.
1897
+
1898
+ Args:
1899
+ sheet_id (int): Sheet ID
1900
+ list_of_ids (list[int]): list of SummaryField ids
1901
+ ignore_summary_fields_not_found (Boolean): By default, any specified fieldId that isn't found in the sheet
1902
+ summary will cause the entire operation to fail with a "not found" error. If true (default is false),
1903
+ then the operation will not be blocked by fieldIds that are not found. Response will indicate which
1904
+ fields were deleted.
1905
+
1906
+ Returns:
1907
+ Result
1908
+ """
1909
+ if isinstance(list_of_ids, six.integer_types):
1910
+ arg_value = list_of_ids
1911
+ list_of_ids = TypedList(six.integer_types)
1912
+ list_of_ids.append(arg_value)
1913
+
1914
+ _op = fresh_operation("delete_sheet_summary_fields")
1915
+ _op["method"] = "DELETE"
1916
+ _op["path"] = "/sheets/" + str(sheet_id) + "/summary/fields"
1917
+ _op["query_params"]["ids"] = list_of_ids
1918
+ _op["query_params"][
1919
+ "ignoreSummaryFieldsNotFound"
1920
+ ] = ignore_summary_fields_not_found
1921
+
1922
+ expected = ["Result", "NumberObjectValue"]
1923
+ prepped_request = self._base.prepare_request(_op)
1924
+ response = self._base.request(prepped_request, expected, _op)
1925
+
1926
+ return response
1927
+
1928
+ def update_sheet_summary_fields(
1929
+ self, sheet_id, list_of_summary_fields, rename_if_conflict=None
1930
+ ):
1931
+ """Updates a list of SummaryFields for the specified Sheet.
1932
+
1933
+ Args:
1934
+ sheet_id (int): Sheet ID
1935
+ list_of_summary_fields (list[SummaryField]): list of SummaryFields
1936
+ rename_if_conflict (Boolean): true to rename if a name conflict occurs
1937
+
1938
+ Returns:
1939
+ Result
1940
+ """
1941
+ if isinstance(list_of_summary_fields, (dict, SummaryField)):
1942
+ arg_value = list_of_summary_fields
1943
+ list_of_summary_fields = TypedList(SummaryField)
1944
+ list_of_summary_fields.append(arg_value)
1945
+
1946
+ _op = fresh_operation("update_sheet_summary_fields")
1947
+ _op["method"] = "PUT"
1948
+ _op["path"] = "/sheets/" + str(sheet_id) + "/summary/fields"
1949
+ _op["json"] = list_of_summary_fields
1950
+ _op["query_params"]["renameIfConflict"] = rename_if_conflict
1951
+
1952
+ expected = ["Result", "SummaryField"]
1953
+
1954
+ prepped_request = self._base.prepare_request(_op)
1955
+ response = self._base.request(prepped_request, expected, _op)
1956
+
1957
+ return response
1958
+
1959
+ def update_sheet_summary_fields_with_partial_success(
1960
+ self, sheet_id, list_of_summary_fields, rename_if_conflict=None
1961
+ ):
1962
+ """Updates a list of SummaryFields for the specified Sheet.
1963
+
1964
+ Args:
1965
+ sheet_id (int): Sheet ID
1966
+ list_of_summary_fields (list[SummaryField]): list of SummaryFields
1967
+ rename_if_conflict (Boolean): true to rename if a name conflict occurs
1968
+
1969
+ Returns:
1970
+ Result
1971
+ """
1972
+ if isinstance(list_of_summary_fields, (dict, SummaryField)):
1973
+ arg_value = list_of_summary_fields
1974
+ list_of_summary_fields = TypedList(SummaryField)
1975
+ list_of_summary_fields.append(arg_value)
1976
+
1977
+ _op = fresh_operation("update_sheet_summary_fields")
1978
+ _op["method"] = "PUT"
1979
+ _op["path"] = "/sheets/" + str(sheet_id) + "/summary/fields"
1980
+ _op["json"] = list_of_summary_fields
1981
+ _op["query_params"]["renameIfConflict"] = rename_if_conflict
1982
+ _op["query_params"]["allowPartialSuccess"] = "true"
1983
+
1984
+ expected = ["BulkItemResult", "SummaryField"]
1985
+
1986
+ prepped_request = self._base.prepare_request(_op)
1987
+ response = self._base.request(prepped_request, expected, _op)
1988
+
1989
+ return response
1990
+
1991
+ def add_sheet_summary_field_image(
1992
+ self, sheet_id, field_id, file, file_type, alt_text=None
1993
+ ):
1994
+
1995
+ _data = open(file, "rb").read()
1996
+ _op = fresh_operation("add_sheet_summary_field_image")
1997
+ _op["method"] = "POST"
1998
+ _op["path"] = (
1999
+ "/sheets/" + str(sheet_id) + "/summary/fields/" + str(field_id) + "/images"
2000
+ )
2001
+ _op["headers"] = {
2002
+ "content-type": file_type,
2003
+ "content-disposition": 'attachment; filename="' + file + '"',
2004
+ }
2005
+ _op["query_params"]["altText"] = alt_text
2006
+ _op["form_data"] = _data
2007
+
2008
+ expected = ["Result", "SummaryField"]
2009
+
2010
+ prepped_request = self._base.prepare_request(_op)
2011
+ response = self._base.request(prepped_request, expected, _op)
2012
+
2013
+ return response
2014
+
2015
+ def get_column_by_title(self, sheet_id, title, include=None):
2016
+ """For those times when you don't know the Column Id.
2017
+
2018
+ Note: returns the first matching title found.
2019
+
2020
+ Args:
2021
+ sheet_id(int): Sheet ID
2022
+ title(str): Title search string
2023
+ include (str): (future).
2024
+ """
2025
+ all_columns = self.get_columns(sheet_id, include_all=True)
2026
+ for _c in all_columns.data:
2027
+ if _c.title == title:
2028
+ return self.get_column(sheet_id, _c.id, include=include)
2029
+ return False
2030
+
2031
+ def get_sheet_by_name(
2032
+ self,
2033
+ name,
2034
+ include=None,
2035
+ exclude=None,
2036
+ row_ids=None,
2037
+ row_numbers=None,
2038
+ column_ids=None,
2039
+ page_size=None,
2040
+ page=None,
2041
+ ):
2042
+ """For those times when you don't know the Sheet Id.
2043
+
2044
+ Note: returns the first matching name found.
2045
+
2046
+ Args:
2047
+ See arguments for get_sheet()
2048
+ """
2049
+ all_sheets = self.list_sheets(include_all=True)
2050
+ for _s in all_sheets.data:
2051
+ if _s.name == name:
2052
+ return self.get_sheet(
2053
+ _s.id,
2054
+ include=include,
2055
+ exclude=exclude,
2056
+ row_ids=row_ids,
2057
+ row_numbers=row_numbers,
2058
+ column_ids=column_ids,
2059
+ page_size=page_size,
2060
+ page=page,
2061
+ )
2062
+ return False