smartsheet-python-sdk 3.1.0__py2.py3-none-any.whl → 3.2.0__py2.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.
@@ -121,3 +121,4 @@ from .webhook_subscope import WebhookSubscope
121
121
  from .widget import Widget
122
122
  from .widget_content import WidgetContent
123
123
  from .workspace import Workspace
124
+ from .user_plan import UserPlan
@@ -52,3 +52,4 @@ from .system_column_type import SystemColumnType
52
52
  from .update_request_status import UpdateRequestStatus
53
53
  from .user_status import UserStatus
54
54
  from .widget_type import WidgetType
55
+ from .seat_type import SeatType, DowngradeSeatType, UpgradeSeatType
@@ -0,0 +1,17 @@
1
+ from enum import Enum
2
+
3
+ class SeatType(str, Enum):
4
+ VIEWER = 'VIEWER'
5
+ GUEST = 'GUEST'
6
+ MEMBER = 'MEMBER'
7
+ PROVISIONAL_MEMBER = 'PROVISIONAL_MEMBER'
8
+
9
+
10
+ class DowngradeSeatType(str, Enum):
11
+ VIEWER = 'VIEWER'
12
+ GUEST = 'GUEST'
13
+
14
+
15
+ class UpgradeSeatType(str, Enum):
16
+ GUEST = 'GUEST'
17
+ MEMBER = 'MEMBER'
@@ -18,7 +18,7 @@
18
18
  from __future__ import absolute_import
19
19
 
20
20
  from typing import TypeVar, Generic, List
21
- from ..types import String, json
21
+ from ..types import String, json, TypedList, importlib
22
22
  from ..util import deserialize, serialize
23
23
 
24
24
  T = TypeVar('T')
@@ -27,13 +27,17 @@ T = TypeVar('T')
27
27
  class TokenPaginatedResult(Generic[T]):
28
28
  """Smartsheet TokenPaginatedResult data model with generic type support."""
29
29
 
30
- def __init__(self, props=None, base_obj=None):
30
+ def __init__(self, props=None, dynamic_data_type=None, base_obj=None):
31
31
  """Initialize the TokenPaginatedResult model."""
32
32
  self._base = None
33
33
  if base_obj is not None:
34
34
  self._base = base_obj
35
35
 
36
- self._data = []
36
+ self._dynamic_data_type = None
37
+ if dynamic_data_type is not None:
38
+ self._dynamic_data_type = dynamic_data_type
39
+
40
+ self._data = TypedList(object)
37
41
  self._last_key = String()
38
42
 
39
43
  if props:
@@ -48,7 +52,14 @@ class TokenPaginatedResult(Generic[T]):
48
52
 
49
53
  @data.setter
50
54
  def data(self, value):
51
- self._data = value
55
+ class_ = getattr(
56
+ importlib.import_module("smartsheet.models"), self._dynamic_data_type
57
+ )
58
+ if isinstance(value, list):
59
+ self._data = [class_(x, self._base) for x in value]
60
+ else:
61
+ self._data = class_(value, self._base)
62
+
52
63
 
53
64
  @property
54
65
  def last_key(self):
@@ -19,6 +19,7 @@ from __future__ import absolute_import
19
19
 
20
20
  from ..types import (Boolean, EnumeratedValue, Number, String, Timestamp,
21
21
  TypedList, TypedObject, json)
22
+ from ..models.enums import SeatType
22
23
  from ..util import deserialize, serialize
23
24
  from .alternate_email import AlternateEmail
24
25
  from .enums import UserStatus
@@ -44,6 +45,7 @@ class UserModel:
44
45
  self._first_name = String()
45
46
  self._group_admin = Boolean()
46
47
  self._id_ = Number()
48
+ self._is_internal = Boolean()
47
49
  self._last_login = Timestamp()
48
50
  self._last_name = String()
49
51
  self._licensed_sheet_creator = Boolean()
@@ -51,6 +53,8 @@ class UserModel:
51
53
  self._profile_image = TypedObject(ProfileImage)
52
54
  self._resource_viewer = Boolean()
53
55
  self._role = String()
56
+ self._seat_type = EnumeratedValue(SeatType)
57
+ self._seat_type_last_changed_at = Timestamp()
54
58
  self._sheet_count = Number()
55
59
  self._status = EnumeratedValue(UserStatus)
56
60
  self._title = String()
@@ -145,6 +149,14 @@ class UserModel:
145
149
  def id_(self, value):
146
150
  self._id_.value = value
147
151
 
152
+ @property
153
+ def is_internal(self):
154
+ return self._is_internal.value
155
+
156
+ @is_internal.setter
157
+ def is_internal(self, value):
158
+ self._is_internal.value = value
159
+
148
160
  @property
149
161
  def last_login(self):
150
162
  return self._last_login.value
@@ -201,6 +213,22 @@ class UserModel:
201
213
  def role(self, value):
202
214
  self._role.value = value
203
215
 
216
+ @property
217
+ def seat_type(self):
218
+ return self._seat_type
219
+
220
+ @seat_type.setter
221
+ def seat_type(self, value):
222
+ self._seat_type.set(value)
223
+
224
+ @property
225
+ def seat_type_last_changed_at(self):
226
+ return self._seat_type_last_changed_at.value
227
+
228
+ @seat_type_last_changed_at.setter
229
+ def seat_type_last_changed_at(self, value):
230
+ self._seat_type_last_changed_at.value = value
231
+
204
232
  @property
205
233
  def sheet_count(self):
206
234
  return self._sheet_count.value
@@ -0,0 +1,68 @@
1
+ from __future__ import absolute_import
2
+
3
+ from ..types import (Boolean, EnumeratedValue, Number, String, Timestamp,
4
+ TypedList, TypedObject, json)
5
+ from ..models.enums import SeatType
6
+ from ..util import deserialize, serialize
7
+
8
+
9
+ class UserPlan:
10
+
11
+ """Smartsheet Plan for a User data model."""
12
+
13
+ def __init__(self, props=None, base_obj=None):
14
+ """Initialize the UserPlan model."""
15
+ self._base = None
16
+ if base_obj is not None:
17
+ self._base = base_obj
18
+
19
+ self._plan_id = Number()
20
+ self._seat_type = EnumeratedValue(SeatType)
21
+ self._seat_type_last_changed_at = Timestamp()
22
+ self._is_internal = Boolean()
23
+
24
+ if props:
25
+ deserialize(self, props)
26
+
27
+ self.__initialized = True
28
+
29
+ @property
30
+ def plan_id(self):
31
+ return self._plan_id.value
32
+
33
+ @plan_id.setter
34
+ def plan_id(self, value):
35
+ self._plan_id.value = value
36
+
37
+ @property
38
+ def seat_type(self):
39
+ return self._seat_type
40
+
41
+ @seat_type.setter
42
+ def seat_type(self, value):
43
+ self._seat_type.set(value)
44
+
45
+ @property
46
+ def seat_type_last_changed_at(self):
47
+ return self._seat_type_last_changed_at.value
48
+
49
+ @seat_type_last_changed_at.setter
50
+ def seat_type_last_changed_at(self, value):
51
+ self._seat_type_last_changed_at.value = value
52
+
53
+ @property
54
+ def is_internal(self):
55
+ return self._is_internal.value
56
+
57
+ @is_internal.setter
58
+ def is_internal(self, value):
59
+ self._is_internal.value = value
60
+
61
+ def to_dict(self):
62
+ return serialize(self)
63
+
64
+ def to_json(self):
65
+ return json.dumps(self.to_dict())
66
+
67
+ def __str__(self):
68
+ return self.to_json()
smartsheet/users.py CHANGED
@@ -21,6 +21,7 @@ import logging
21
21
  from datetime import datetime
22
22
 
23
23
  from . import fresh_operation
24
+ from .models.enums.seat_type import SeatType
24
25
 
25
26
 
26
27
  class Users:
@@ -254,7 +255,8 @@ class Users:
254
255
  return response
255
256
 
256
257
  def list_users(
257
- self, email=None, page_size=None, page=None, include_all=None, include=None
258
+ self, email=None, page_size=None, page=None, include_all=None, include=None,
259
+ plan_id=None, seat_type=None
258
260
  ):
259
261
  """Get the list of Users in the organization.
260
262
 
@@ -268,6 +270,10 @@ class Users:
268
270
  (i.e. do not paginate).
269
271
  include(list[str]): optional include parameter, only current
270
272
  accepted value is 'lastLogin'
273
+ plan_id(int): optional plan_id parameter, returns users
274
+ in the selected plan.
275
+ seat_type(SeatType): optional seat_type parameter, filters users
276
+ by their seat type.
271
277
 
272
278
  Returns:
273
279
  IndexResult
@@ -280,6 +286,8 @@ class Users:
280
286
  _op["query_params"]["pageSize"] = page_size
281
287
  _op["query_params"]["page"] = page
282
288
  _op["query_params"]["includeAll"] = include_all
289
+ _op["query_params"]["planId"] = plan_id
290
+ _op["query_params"]["seatType"] = seat_type
283
291
 
284
292
  expected = ["IndexResult", "User"]
285
293
 
@@ -358,6 +366,91 @@ class Users:
358
366
 
359
367
  return response
360
368
 
369
+ def upgrade_user(self, user_id, plan_id, seat_type):
370
+ """Upgrades a user for a plan.
371
+
372
+ Args:
373
+ user_id (int): User ID
374
+ plan_id (int): Plan ID
375
+ seat_type (UpgradeSeatType): Seat type to upgrade to
376
+
377
+ Returns:
378
+ dict: Result
379
+ """
380
+ _op = fresh_operation("upgrade_user")
381
+ _op["method"] = "POST"
382
+ _op["path"] = f"/users/{user_id}/plans/{plan_id}/upgrade"
383
+ _op["json"] = {"seatType": seat_type}
384
+
385
+ expected = ["Result", None]
386
+
387
+ prepped_request = self._base.prepare_request(_op)
388
+ response = self._base.request(prepped_request, expected, _op)
389
+
390
+ return response
391
+
392
+ def downgrade_user(self, user_id, plan_id, seat_type):
393
+ """Downgrades a user for a plan.
394
+
395
+ Args:
396
+ user_id (int): User ID
397
+ plan_id (int): Plan ID
398
+ seat_type (DowngradeSeatType): Seat type to downgrade to
399
+
400
+ Returns:
401
+ dict: Result
402
+ """
403
+ _op = fresh_operation("downgrade_user")
404
+ _op["method"] = "POST"
405
+ _op["path"] = f"/users/{user_id}/plans/{plan_id}/downgrade"
406
+ _op["json"] = {"seatType": seat_type}
407
+
408
+ expected = ["Result", None]
409
+
410
+ prepped_request = self._base.prepare_request(_op)
411
+ response = self._base.request(prepped_request, expected, _op)
412
+
413
+ return response
414
+
415
+ def list_user_plans(self, user_id, last_key=None, max_items=None):
416
+ """List user's plans.
417
+ Args:
418
+ user_id (int): User ID
419
+ Returns:
420
+ TokenPaginatedResult
421
+ """
422
+ _op = fresh_operation("list_user_plans")
423
+ _op["method"] = "GET"
424
+ _op["path"] = f"/users/{user_id}/plans"
425
+ _op["query_params"]["lastKey"] = last_key
426
+ _op["query_params"]["maxItems"] = max_items
427
+
428
+ expected = ["TokenPaginatedResult", "UserPlan"]
429
+
430
+ prepped_request = self._base.prepare_request(_op)
431
+ response = self._base.request(prepped_request, expected, _op)
432
+
433
+ return response
434
+
435
+ def remove_user_from_plan(self, user_id, plan_id):
436
+ """Remove user from plan.
437
+ Args:
438
+ user_id (int): User ID
439
+ plan_id (int): Plan ID
440
+ Returns:
441
+ Result
442
+ """
443
+ _op = fresh_operation("remove_user_from_plan")
444
+ _op["method"] = "DELETE"
445
+ _op["path"] = f"/users/{user_id}/plans/{plan_id}"
446
+
447
+ expected = ["Result", None]
448
+
449
+ prepped_request = self._base.prepare_request(_op)
450
+ response = self._base.request(prepped_request, expected, _op)
451
+
452
+ return response
453
+
361
454
  def add_profile_image(self, user_id, file, file_type):
362
455
  """Uploads a profile image for the specified user.
363
456
 
smartsheet/version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # file generated by setuptools_scm
2
2
  # don't change, don't track in version control
3
- __version__ = version = '3.1.0'
4
- __version_tuple__ = version_tuple = (3, 1, 0)
3
+ __version__ = version = '3.2.0'
4
+ __version_tuple__ = version_tuple = (3, 2, 0)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smartsheet-python-sdk
3
- Version: 3.1.0
3
+ Version: 3.2.0
4
4
  Summary: Library that uses Python to connect to Smartsheet services (using API 2.0).
5
5
  Home-page: http://smartsheet-platform.github.io/api-docs/
6
6
  Author: Smartsheet
@@ -22,12 +22,12 @@ smartsheet/smartsheet.py,sha256=wOBejFgIh_xQu1KuIlh9ZAsq2OxG8EIWUqtBQpmz1y4,2340
22
22
  smartsheet/templates.py,sha256=z_Tj-4jZsu3RkLNbCAZWM2W05Zbio9T_uyU33rUPxzE,2898
23
23
  smartsheet/token.py,sha256=5uz-IG5adx_zr2-uepH-W8ATv0dq9aZNjYLeZNwldqI,4703
24
24
  smartsheet/types.py,sha256=aIdRJ89jwclmiZ4RH3hnZHJTFWFxgNKW3d8fghm21eM,9126
25
- smartsheet/users.py,sha256=3LyC7BsPLa3dAg5EXaGswgXq0O8s77nsE0sSkjLfRe8,12775
25
+ smartsheet/users.py,sha256=1KnqKJIzJEPMNy26BQY1b9jb3dItbzglrljV1MGD5ic,15887
26
26
  smartsheet/util.py,sha256=12Y6eluecB8k4Ns-at81AEM18ND2TCKa9bF4BlNRrKM,5633
27
- smartsheet/version.py,sha256=PYsCm3eHh5hgAf1b_gyIJMMHI2nMMwbcDKC3cw7zARs,160
27
+ smartsheet/version.py,sha256=jXprrDLc5_o9OzizdGMr92Lmhow65AreA5_ht6m6bmA,160
28
28
  smartsheet/webhooks.py,sha256=7F7g4Ks0GyS3QxsNWm1SFtrOr00jBisCjj7-hcToHM8,4637
29
29
  smartsheet/workspaces.py,sha256=r81xh3HfYsX--ll5pQ-h7kSSJELokYV-bSjuD0WloeU,22651
30
- smartsheet/models/__init__.py,sha256=8Jq9aT_mTbqla7BDuHCiTDB1mhATq0TbNFKQGgaxgcc,4722
30
+ smartsheet/models/__init__.py,sha256=4P6wKY8TpbV_rI5Z5c1ifxiwJEWL5bsvecVcjtUSJ9U,4754
31
31
  smartsheet/models/access_token.py,sha256=sKHL5cFRWPTjymX06ZIXaCDp8ZJQEVpXN8mns1DAvGM,2564
32
32
  smartsheet/models/account.py,sha256=nLg_5O4Vnc7aNf9p1kIcsgdAm23IC2H7cKkxjLxwS9U,1941
33
33
  smartsheet/models/alternate_email.py,sha256=n8zqWkY-uzSw_CVKBvYUc6pGSR0v4yTx8S5PaIiX_AU,2263
@@ -131,10 +131,11 @@ smartsheet/models/string_object_value.py,sha256=GPMIAA1utIefw4VVsHWcT5y5GBK9Z9FC
131
131
  smartsheet/models/summary_field.py,sha256=QdVYD2XleUKkprVAxOJ6dfTbZo8w7sSTj2p_wj2Ue2E,6341
132
132
  smartsheet/models/template.py,sha256=Up5yM3Q02-8QM8j74_WWWN-AwCValM3xnAiOzmmQiDE,4207
133
133
  smartsheet/models/title_rich_text_widget_content.py,sha256=zdHd_RdPPO7flnOmKqIkkqo_CSDtOg0Z4hj0vAK7-ZU,2018
134
- smartsheet/models/token_paginated_result.py,sha256=OHn8mqEiLirKhBn8mWi0QvxwJryVtQtNvGd7-8lqfhc,1841
134
+ smartsheet/models/token_paginated_result.py,sha256=gfdLwahCrG7kTRMVvoXe78jqYdw6TeZEVbnKqUPwCqc,2297
135
135
  smartsheet/models/update_request.py,sha256=5CkaSfhPLUPqtU6O9EuwFsyccpeBB3rnLLtvyxPmrpM,2881
136
136
  smartsheet/models/user.py,sha256=CKMjNusL7_TU0V07vqoxruL6gQbXHctBNItJJIsSQHI,1553
137
- smartsheet/models/user_model.py,sha256=OPwJlCZ7RIB7ghRE6YuvNPw_vRaygKYkYh0zgPH_Mm4,6139
137
+ smartsheet/models/user_model.py,sha256=dVJp2mvtiUH-qi5rQX42S_7kPywyMaMnRkpNTv7-lTw,6910
138
+ smartsheet/models/user_plan.py,sha256=WbZUzvl8GDIaUskqJU6g-ROMgIuFSQN4PjZAqxeOiUg,1696
138
139
  smartsheet/models/user_profile.py,sha256=vKVL2XkFdO9l2RGZRRcpiASjek1q-Ffee7x4z53SLtE,2341
139
140
  smartsheet/models/version.py,sha256=gC8YvEjB-RO9avvz3sG2lDHrDkMi0i-o9SP8h5vLrbY,1540
140
141
  smartsheet/models/web_content_widget_content.py,sha256=N_2HEOsWLI6D3s6vGZV_qCsVEEe3xkxeK9xUAP4SqCI,1719
@@ -146,7 +147,7 @@ smartsheet/models/widget.py,sha256=G5UKR1latGSuXqm-MCRQxn9W7IJgo2FsUWJ9heEW0RA,6
146
147
  smartsheet/models/widget_content.py,sha256=hxv3DJWO8YPe4ND-HUZ59eOVU9LAy02owU-KQVWUsDU,1525
147
148
  smartsheet/models/widget_hyperlink.py,sha256=JPjaSftHFHiFj48tfOckGWzrew_CLKmE2k9lUA_RQSk,2059
148
149
  smartsheet/models/workspace.py,sha256=_YT4i4DEK32kEyqlWixZUQSQyBiZkNtwtSmuhc98H2s,4522
149
- smartsheet/models/enums/__init__.py,sha256=IcAbtVOBw57xrIeuKgQK2pvyZKildMKFko0AG0DqeP8,2254
150
+ smartsheet/models/enums/__init__.py,sha256=i-B6OYkAIRRQZwG8JgX19ZBHwVrBXWHfrLEWMUPXpj4,2322
150
151
  smartsheet/models/enums/access_level.py,sha256=LvKh3Z2LrFeLm-R-dT0qOVinBsA4jEOxM02flg0LFaY,816
151
152
  smartsheet/models/enums/attachment_parent_type.py,sha256=EFcrHg8xpx_ZxrrGb3vkk9Ji8PD74Q8GeWhXZMquVEw,770
152
153
  smartsheet/models/enums/attachment_sub_type.py,sha256=wZEo80LynIFDFZkTHCpQx5T-G5deT9HSRBMRdvHyh7Q,826
@@ -170,6 +171,7 @@ smartsheet/models/enums/paper_type.py,sha256=vh0VrF6G9xB5Kdt979I51wulnTqYl8hMrXo
170
171
  smartsheet/models/enums/predecessor_type.py,sha256=CB2oX7xbjAV8RjzkTCSHTKVWvzvCkwZLa21jBQLjotA,767
171
172
  smartsheet/models/enums/publish_accessible_by.py,sha256=x5z2CCHttwprcyV7XL0AN39E1h7OIUMpe_Fei5HpBGo,751
172
173
  smartsheet/models/enums/schedule_type.py,sha256=KtTpdD3oKlntmk1Nl2i3ymIfGW6CP3I_7mi7vrVTCZc,793
174
+ smartsheet/models/enums/seat_type.py,sha256=5kaFtJPpescgCtnbXg4JM6H35UQKh-eeSWBFlaBkbE4,318
173
175
  smartsheet/models/enums/share_scope.py,sha256=LEZnBQjBGnFIHVHrX_FsG-sndGK-XsfqDhPeY7oZPWs,749
174
176
  smartsheet/models/enums/share_type.py,sha256=89e8ki-mlH3i8qEjFKnqBEK-GUEipFItOE5rhED39bg,744
175
177
  smartsheet/models/enums/sheet_email_format.py,sha256=St0FcwbnnkPQa0ZqlwnkQ44XxineojE-XtZmZd7_B9U,768
@@ -181,9 +183,9 @@ smartsheet/models/enums/system_column_type.py,sha256=UfhNUBGD_0K1Pas7fujGEuax55O
181
183
  smartsheet/models/enums/update_request_status.py,sha256=xYF84x1dTFhJMYVi1q3G1T9u1IGN3szlR1jj5HHC0hE,777
182
184
  smartsheet/models/enums/user_status.py,sha256=SB7qRcA0dhdRimsOKHCGF3CB6fL0XuifxQEWZGNNS8Q,766
183
185
  smartsheet/models/enums/widget_type.py,sha256=VfVq59fLZsT4ks_ZBrtv52u2Cl60iAdlA6mGD_elz-k,1072
184
- smartsheet_python_sdk-3.1.0.dist-info/LICENSE.md,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
185
- smartsheet_python_sdk-3.1.0.dist-info/METADATA,sha256=GZlKD4SFsKPNebCR2JaZHby28GDwJhgVntp1TMQMXyM,4693
186
- smartsheet_python_sdk-3.1.0.dist-info/NOTICE,sha256=mXr2ryVjnCjykeW0J79kFfVXQG_Z9SV4BV_QPNENW1U,420
187
- smartsheet_python_sdk-3.1.0.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
188
- smartsheet_python_sdk-3.1.0.dist-info/top_level.txt,sha256=kozWEYiKjyJmSXzd6p5ugkQ5bhoHS9V3NnvLagUfcNw,11
189
- smartsheet_python_sdk-3.1.0.dist-info/RECORD,,
186
+ smartsheet_python_sdk-3.2.0.dist-info/LICENSE.md,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
187
+ smartsheet_python_sdk-3.2.0.dist-info/METADATA,sha256=MM8LT9xqe55C482AZXjBraonFBh1ofXzLcO2QEspIuI,4693
188
+ smartsheet_python_sdk-3.2.0.dist-info/NOTICE,sha256=mXr2ryVjnCjykeW0J79kFfVXQG_Z9SV4BV_QPNENW1U,420
189
+ smartsheet_python_sdk-3.2.0.dist-info/WHEEL,sha256=Kh9pAotZVRFj97E15yTA4iADqXdQfIVTHcNaZTjxeGM,110
190
+ smartsheet_python_sdk-3.2.0.dist-info/top_level.txt,sha256=kozWEYiKjyJmSXzd6p5ugkQ5bhoHS9V3NnvLagUfcNw,11
191
+ smartsheet_python_sdk-3.2.0.dist-info/RECORD,,