daytona_api_client 0.105.1__py3-none-any.whl → 0.106.0a2__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.

Potentially problematic release.


This version of daytona_api_client might be problematic. Click here for more details.

@@ -17,11 +17,11 @@ from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
17
17
  from typing import Any, Dict, List, Optional, Tuple, Union
18
18
  from typing_extensions import Annotated
19
19
 
20
- from pydantic import Field, StrictBool, StrictFloat, StrictInt, StrictStr
20
+ from pydantic import Field, StrictBool, StrictStr, field_validator
21
21
  from typing import Optional, Union
22
22
  from typing_extensions import Annotated
23
23
  from daytona_api_client.models.create_snapshot import CreateSnapshot
24
- from daytona_api_client.models.paginated_snapshots_dto import PaginatedSnapshotsDto
24
+ from daytona_api_client.models.paginated_snapshots import PaginatedSnapshots
25
25
  from daytona_api_client.models.set_snapshot_general_status_dto import SetSnapshotGeneralStatusDto
26
26
  from daytona_api_client.models.snapshot_dto import SnapshotDto
27
27
 
@@ -1160,8 +1160,11 @@ class SnapshotsApi:
1160
1160
  def get_all_snapshots(
1161
1161
  self,
1162
1162
  x_daytona_organization_id: Annotated[Optional[StrictStr], Field(description="Use with JWT to specify the organization ID")] = None,
1163
- limit: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Number of items per page")] = None,
1164
- page: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Page number")] = None,
1163
+ page: Annotated[Optional[Union[Annotated[float, Field(strict=True, ge=1)], Annotated[int, Field(strict=True, ge=1)]]], Field(description="Page number of the results")] = None,
1164
+ limit: Annotated[Optional[Union[Annotated[float, Field(le=100, strict=True, ge=1)], Annotated[int, Field(le=100, strict=True, ge=1)]]], Field(description="Number of results per page")] = None,
1165
+ name: Annotated[Optional[StrictStr], Field(description="Filter by partial name match")] = None,
1166
+ sort: Annotated[Optional[StrictStr], Field(description="Field to sort by")] = None,
1167
+ order: Annotated[Optional[StrictStr], Field(description="Direction to sort by")] = None,
1165
1168
  _request_timeout: Union[
1166
1169
  None,
1167
1170
  Annotated[StrictFloat, Field(gt=0)],
@@ -1174,16 +1177,22 @@ class SnapshotsApi:
1174
1177
  _content_type: Optional[StrictStr] = None,
1175
1178
  _headers: Optional[Dict[StrictStr, Any]] = None,
1176
1179
  _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
1177
- ) -> PaginatedSnapshotsDto:
1180
+ ) -> PaginatedSnapshots:
1178
1181
  """List all snapshots
1179
1182
 
1180
1183
 
1181
1184
  :param x_daytona_organization_id: Use with JWT to specify the organization ID
1182
1185
  :type x_daytona_organization_id: str
1183
- :param limit: Number of items per page
1184
- :type limit: float
1185
- :param page: Page number
1186
+ :param page: Page number of the results
1186
1187
  :type page: float
1188
+ :param limit: Number of results per page
1189
+ :type limit: float
1190
+ :param name: Filter by partial name match
1191
+ :type name: str
1192
+ :param sort: Field to sort by
1193
+ :type sort: str
1194
+ :param order: Direction to sort by
1195
+ :type order: str
1187
1196
  :param _request_timeout: timeout setting for this request. If one
1188
1197
  number provided, it will be total request
1189
1198
  timeout. It can also be a pair (tuple) of
@@ -1208,8 +1217,11 @@ class SnapshotsApi:
1208
1217
 
1209
1218
  _param = self._get_all_snapshots_serialize(
1210
1219
  x_daytona_organization_id=x_daytona_organization_id,
1211
- limit=limit,
1212
1220
  page=page,
1221
+ limit=limit,
1222
+ name=name,
1223
+ sort=sort,
1224
+ order=order,
1213
1225
  _request_auth=_request_auth,
1214
1226
  _content_type=_content_type,
1215
1227
  _headers=_headers,
@@ -1217,7 +1229,7 @@ class SnapshotsApi:
1217
1229
  )
1218
1230
 
1219
1231
  _response_types_map: Dict[str, Optional[str]] = {
1220
- '200': "PaginatedSnapshotsDto",
1232
+ '200': "PaginatedSnapshots",
1221
1233
  }
1222
1234
  response_data = self.api_client.call_api(
1223
1235
  *_param,
@@ -1234,8 +1246,11 @@ class SnapshotsApi:
1234
1246
  def get_all_snapshots_with_http_info(
1235
1247
  self,
1236
1248
  x_daytona_organization_id: Annotated[Optional[StrictStr], Field(description="Use with JWT to specify the organization ID")] = None,
1237
- limit: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Number of items per page")] = None,
1238
- page: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Page number")] = None,
1249
+ page: Annotated[Optional[Union[Annotated[float, Field(strict=True, ge=1)], Annotated[int, Field(strict=True, ge=1)]]], Field(description="Page number of the results")] = None,
1250
+ limit: Annotated[Optional[Union[Annotated[float, Field(le=100, strict=True, ge=1)], Annotated[int, Field(le=100, strict=True, ge=1)]]], Field(description="Number of results per page")] = None,
1251
+ name: Annotated[Optional[StrictStr], Field(description="Filter by partial name match")] = None,
1252
+ sort: Annotated[Optional[StrictStr], Field(description="Field to sort by")] = None,
1253
+ order: Annotated[Optional[StrictStr], Field(description="Direction to sort by")] = None,
1239
1254
  _request_timeout: Union[
1240
1255
  None,
1241
1256
  Annotated[StrictFloat, Field(gt=0)],
@@ -1248,16 +1263,22 @@ class SnapshotsApi:
1248
1263
  _content_type: Optional[StrictStr] = None,
1249
1264
  _headers: Optional[Dict[StrictStr, Any]] = None,
1250
1265
  _host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
1251
- ) -> ApiResponse[PaginatedSnapshotsDto]:
1266
+ ) -> ApiResponse[PaginatedSnapshots]:
1252
1267
  """List all snapshots
1253
1268
 
1254
1269
 
1255
1270
  :param x_daytona_organization_id: Use with JWT to specify the organization ID
1256
1271
  :type x_daytona_organization_id: str
1257
- :param limit: Number of items per page
1258
- :type limit: float
1259
- :param page: Page number
1272
+ :param page: Page number of the results
1260
1273
  :type page: float
1274
+ :param limit: Number of results per page
1275
+ :type limit: float
1276
+ :param name: Filter by partial name match
1277
+ :type name: str
1278
+ :param sort: Field to sort by
1279
+ :type sort: str
1280
+ :param order: Direction to sort by
1281
+ :type order: str
1261
1282
  :param _request_timeout: timeout setting for this request. If one
1262
1283
  number provided, it will be total request
1263
1284
  timeout. It can also be a pair (tuple) of
@@ -1282,8 +1303,11 @@ class SnapshotsApi:
1282
1303
 
1283
1304
  _param = self._get_all_snapshots_serialize(
1284
1305
  x_daytona_organization_id=x_daytona_organization_id,
1285
- limit=limit,
1286
1306
  page=page,
1307
+ limit=limit,
1308
+ name=name,
1309
+ sort=sort,
1310
+ order=order,
1287
1311
  _request_auth=_request_auth,
1288
1312
  _content_type=_content_type,
1289
1313
  _headers=_headers,
@@ -1291,7 +1315,7 @@ class SnapshotsApi:
1291
1315
  )
1292
1316
 
1293
1317
  _response_types_map: Dict[str, Optional[str]] = {
1294
- '200': "PaginatedSnapshotsDto",
1318
+ '200': "PaginatedSnapshots",
1295
1319
  }
1296
1320
  response_data = self.api_client.call_api(
1297
1321
  *_param,
@@ -1308,8 +1332,11 @@ class SnapshotsApi:
1308
1332
  def get_all_snapshots_without_preload_content(
1309
1333
  self,
1310
1334
  x_daytona_organization_id: Annotated[Optional[StrictStr], Field(description="Use with JWT to specify the organization ID")] = None,
1311
- limit: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Number of items per page")] = None,
1312
- page: Annotated[Optional[Union[StrictFloat, StrictInt]], Field(description="Page number")] = None,
1335
+ page: Annotated[Optional[Union[Annotated[float, Field(strict=True, ge=1)], Annotated[int, Field(strict=True, ge=1)]]], Field(description="Page number of the results")] = None,
1336
+ limit: Annotated[Optional[Union[Annotated[float, Field(le=100, strict=True, ge=1)], Annotated[int, Field(le=100, strict=True, ge=1)]]], Field(description="Number of results per page")] = None,
1337
+ name: Annotated[Optional[StrictStr], Field(description="Filter by partial name match")] = None,
1338
+ sort: Annotated[Optional[StrictStr], Field(description="Field to sort by")] = None,
1339
+ order: Annotated[Optional[StrictStr], Field(description="Direction to sort by")] = None,
1313
1340
  _request_timeout: Union[
1314
1341
  None,
1315
1342
  Annotated[StrictFloat, Field(gt=0)],
@@ -1328,10 +1355,16 @@ class SnapshotsApi:
1328
1355
 
1329
1356
  :param x_daytona_organization_id: Use with JWT to specify the organization ID
1330
1357
  :type x_daytona_organization_id: str
1331
- :param limit: Number of items per page
1332
- :type limit: float
1333
- :param page: Page number
1358
+ :param page: Page number of the results
1334
1359
  :type page: float
1360
+ :param limit: Number of results per page
1361
+ :type limit: float
1362
+ :param name: Filter by partial name match
1363
+ :type name: str
1364
+ :param sort: Field to sort by
1365
+ :type sort: str
1366
+ :param order: Direction to sort by
1367
+ :type order: str
1335
1368
  :param _request_timeout: timeout setting for this request. If one
1336
1369
  number provided, it will be total request
1337
1370
  timeout. It can also be a pair (tuple) of
@@ -1356,8 +1389,11 @@ class SnapshotsApi:
1356
1389
 
1357
1390
  _param = self._get_all_snapshots_serialize(
1358
1391
  x_daytona_organization_id=x_daytona_organization_id,
1359
- limit=limit,
1360
1392
  page=page,
1393
+ limit=limit,
1394
+ name=name,
1395
+ sort=sort,
1396
+ order=order,
1361
1397
  _request_auth=_request_auth,
1362
1398
  _content_type=_content_type,
1363
1399
  _headers=_headers,
@@ -1365,7 +1401,7 @@ class SnapshotsApi:
1365
1401
  )
1366
1402
 
1367
1403
  _response_types_map: Dict[str, Optional[str]] = {
1368
- '200': "PaginatedSnapshotsDto",
1404
+ '200': "PaginatedSnapshots",
1369
1405
  }
1370
1406
  response_data = self.api_client.call_api(
1371
1407
  *_param,
@@ -1377,8 +1413,11 @@ class SnapshotsApi:
1377
1413
  def _get_all_snapshots_serialize(
1378
1414
  self,
1379
1415
  x_daytona_organization_id,
1380
- limit,
1381
1416
  page,
1417
+ limit,
1418
+ name,
1419
+ sort,
1420
+ order,
1382
1421
  _request_auth,
1383
1422
  _content_type,
1384
1423
  _headers,
@@ -1401,13 +1440,25 @@ class SnapshotsApi:
1401
1440
 
1402
1441
  # process the path parameters
1403
1442
  # process the query parameters
1443
+ if page is not None:
1444
+
1445
+ _query_params.append(('page', page))
1446
+
1404
1447
  if limit is not None:
1405
1448
 
1406
1449
  _query_params.append(('limit', limit))
1407
1450
 
1408
- if page is not None:
1451
+ if name is not None:
1409
1452
 
1410
- _query_params.append(('page', page))
1453
+ _query_params.append(('name', name))
1454
+
1455
+ if sort is not None:
1456
+
1457
+ _query_params.append(('sort', sort))
1458
+
1459
+ if order is not None:
1460
+
1461
+ _query_params.append(('order', order))
1411
1462
 
1412
1463
  # process the header parameters
1413
1464
  if x_daytona_organization_id is not None:
@@ -94,7 +94,8 @@ from daytona_api_client.models.organization_suspension import OrganizationSuspen
94
94
  from daytona_api_client.models.organization_usage_overview import OrganizationUsageOverview
95
95
  from daytona_api_client.models.organization_user import OrganizationUser
96
96
  from daytona_api_client.models.paginated_audit_logs import PaginatedAuditLogs
97
- from daytona_api_client.models.paginated_snapshots_dto import PaginatedSnapshotsDto
97
+ from daytona_api_client.models.paginated_sandboxes import PaginatedSandboxes
98
+ from daytona_api_client.models.paginated_snapshots import PaginatedSnapshots
98
99
  from daytona_api_client.models.port_preview_url import PortPreviewUrl
99
100
  from daytona_api_client.models.position import Position
100
101
  from daytona_api_client.models.posthog_config import PosthogConfig
@@ -104,6 +105,7 @@ from daytona_api_client.models.process_restart_response import ProcessRestartRes
104
105
  from daytona_api_client.models.process_status_response import ProcessStatusResponse
105
106
  from daytona_api_client.models.project_dir_response import ProjectDirResponse
106
107
  from daytona_api_client.models.range import Range
108
+ from daytona_api_client.models.region import Region
107
109
  from daytona_api_client.models.region_screenshot_response import RegionScreenshotResponse
108
110
  from daytona_api_client.models.registry_push_access_dto import RegistryPushAccessDto
109
111
  from daytona_api_client.models.replace_request import ReplaceRequest
@@ -0,0 +1,115 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Daytona
5
+
6
+ Daytona AI platform API Docs
7
+
8
+ The version of the OpenAPI document: 1.0
9
+ Contact: support@daytona.com
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ from __future__ import annotations
17
+ import pprint
18
+ import re # noqa: F401
19
+ import json
20
+
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt
22
+ from typing import Any, ClassVar, Dict, List, Union
23
+ from daytona_api_client.models.sandbox import Sandbox
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class PaginatedSandboxes(BaseModel):
28
+ """
29
+ PaginatedSandboxes
30
+ """ # noqa: E501
31
+ items: List[Sandbox]
32
+ total: Union[StrictFloat, StrictInt]
33
+ page: Union[StrictFloat, StrictInt]
34
+ total_pages: Union[StrictFloat, StrictInt] = Field(alias="totalPages")
35
+ additional_properties: Dict[str, Any] = {}
36
+ __properties: ClassVar[List[str]] = ["items", "total", "page", "totalPages"]
37
+
38
+ model_config = ConfigDict(
39
+ populate_by_name=True,
40
+ validate_assignment=True,
41
+ protected_namespaces=(),
42
+ )
43
+
44
+
45
+ def to_str(self) -> str:
46
+ """Returns the string representation of the model using alias"""
47
+ return pprint.pformat(self.model_dump(by_alias=True))
48
+
49
+ def to_json(self) -> str:
50
+ """Returns the JSON representation of the model using alias"""
51
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
52
+ return json.dumps(self.to_dict())
53
+
54
+ @classmethod
55
+ def from_json(cls, json_str: str) -> Optional[Self]:
56
+ """Create an instance of PaginatedSandboxes from a JSON string"""
57
+ return cls.from_dict(json.loads(json_str))
58
+
59
+ def to_dict(self) -> Dict[str, Any]:
60
+ """Return the dictionary representation of the model using alias.
61
+
62
+ This has the following differences from calling pydantic's
63
+ `self.model_dump(by_alias=True)`:
64
+
65
+ * `None` is only added to the output dict for nullable fields that
66
+ were set at model initialization. Other fields with value `None`
67
+ are ignored.
68
+ * Fields in `self.additional_properties` are added to the output dict.
69
+ """
70
+ excluded_fields: Set[str] = set([
71
+ "additional_properties",
72
+ ])
73
+
74
+ _dict = self.model_dump(
75
+ by_alias=True,
76
+ exclude=excluded_fields,
77
+ exclude_none=True,
78
+ )
79
+ # override the default output from pydantic by calling `to_dict()` of each item in items (list)
80
+ _items = []
81
+ if self.items:
82
+ for _item_items in self.items:
83
+ if _item_items:
84
+ _items.append(_item_items.to_dict())
85
+ _dict['items'] = _items
86
+ # puts key-value pairs in additional_properties in the top level
87
+ if self.additional_properties is not None:
88
+ for _key, _value in self.additional_properties.items():
89
+ _dict[_key] = _value
90
+
91
+ return _dict
92
+
93
+ @classmethod
94
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
95
+ """Create an instance of PaginatedSandboxes from a dict"""
96
+ if obj is None:
97
+ return None
98
+
99
+ if not isinstance(obj, dict):
100
+ return cls.model_validate(obj)
101
+
102
+ _obj = cls.model_validate({
103
+ "items": [Sandbox.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None,
104
+ "total": obj.get("total"),
105
+ "page": obj.get("page"),
106
+ "totalPages": obj.get("totalPages")
107
+ })
108
+ # store additional fields in additional_properties
109
+ for _key in obj.keys():
110
+ if _key not in cls.__properties:
111
+ _obj.additional_properties[_key] = obj.get(_key)
112
+
113
+ return _obj
114
+
115
+
@@ -0,0 +1,115 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Daytona
5
+
6
+ Daytona AI platform API Docs
7
+
8
+ The version of the OpenAPI document: 1.0
9
+ Contact: support@daytona.com
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ from __future__ import annotations
17
+ import pprint
18
+ import re # noqa: F401
19
+ import json
20
+
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt
22
+ from typing import Any, ClassVar, Dict, List, Union
23
+ from daytona_api_client.models.snapshot_dto import SnapshotDto
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class PaginatedSnapshots(BaseModel):
28
+ """
29
+ PaginatedSnapshots
30
+ """ # noqa: E501
31
+ items: List[SnapshotDto]
32
+ total: Union[StrictFloat, StrictInt]
33
+ page: Union[StrictFloat, StrictInt]
34
+ total_pages: Union[StrictFloat, StrictInt] = Field(alias="totalPages")
35
+ additional_properties: Dict[str, Any] = {}
36
+ __properties: ClassVar[List[str]] = ["items", "total", "page", "totalPages"]
37
+
38
+ model_config = ConfigDict(
39
+ populate_by_name=True,
40
+ validate_assignment=True,
41
+ protected_namespaces=(),
42
+ )
43
+
44
+
45
+ def to_str(self) -> str:
46
+ """Returns the string representation of the model using alias"""
47
+ return pprint.pformat(self.model_dump(by_alias=True))
48
+
49
+ def to_json(self) -> str:
50
+ """Returns the JSON representation of the model using alias"""
51
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
52
+ return json.dumps(self.to_dict())
53
+
54
+ @classmethod
55
+ def from_json(cls, json_str: str) -> Optional[Self]:
56
+ """Create an instance of PaginatedSnapshots from a JSON string"""
57
+ return cls.from_dict(json.loads(json_str))
58
+
59
+ def to_dict(self) -> Dict[str, Any]:
60
+ """Return the dictionary representation of the model using alias.
61
+
62
+ This has the following differences from calling pydantic's
63
+ `self.model_dump(by_alias=True)`:
64
+
65
+ * `None` is only added to the output dict for nullable fields that
66
+ were set at model initialization. Other fields with value `None`
67
+ are ignored.
68
+ * Fields in `self.additional_properties` are added to the output dict.
69
+ """
70
+ excluded_fields: Set[str] = set([
71
+ "additional_properties",
72
+ ])
73
+
74
+ _dict = self.model_dump(
75
+ by_alias=True,
76
+ exclude=excluded_fields,
77
+ exclude_none=True,
78
+ )
79
+ # override the default output from pydantic by calling `to_dict()` of each item in items (list)
80
+ _items = []
81
+ if self.items:
82
+ for _item_items in self.items:
83
+ if _item_items:
84
+ _items.append(_item_items.to_dict())
85
+ _dict['items'] = _items
86
+ # puts key-value pairs in additional_properties in the top level
87
+ if self.additional_properties is not None:
88
+ for _key, _value in self.additional_properties.items():
89
+ _dict[_key] = _value
90
+
91
+ return _dict
92
+
93
+ @classmethod
94
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
95
+ """Create an instance of PaginatedSnapshots from a dict"""
96
+ if obj is None:
97
+ return None
98
+
99
+ if not isinstance(obj, dict):
100
+ return cls.model_validate(obj)
101
+
102
+ _obj = cls.model_validate({
103
+ "items": [SnapshotDto.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None,
104
+ "total": obj.get("total"),
105
+ "page": obj.get("page"),
106
+ "totalPages": obj.get("totalPages")
107
+ })
108
+ # store additional fields in additional_properties
109
+ for _key in obj.keys():
110
+ if _key not in cls.__properties:
111
+ _obj.additional_properties[_key] = obj.get(_key)
112
+
113
+ return _obj
114
+
115
+
@@ -0,0 +1,115 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Daytona
5
+
6
+ Daytona AI platform API Docs
7
+
8
+ The version of the OpenAPI document: 1.0
9
+ Contact: support@daytona.com
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
+
12
+ Do not edit the class manually.
13
+ """ # noqa: E501
14
+
15
+
16
+ from __future__ import annotations
17
+ import pprint
18
+ import re # noqa: F401
19
+ import json
20
+
21
+ from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt
22
+ from typing import Any, ClassVar, Dict, List, Union
23
+ from daytona_api_client.models.workspace import Workspace
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class PaginatedWorkspaces(BaseModel):
28
+ """
29
+ PaginatedWorkspaces
30
+ """ # noqa: E501
31
+ items: List[Workspace]
32
+ total: Union[StrictFloat, StrictInt]
33
+ page: Union[StrictFloat, StrictInt]
34
+ total_pages: Union[StrictFloat, StrictInt] = Field(alias="totalPages")
35
+ additional_properties: Dict[str, Any] = {}
36
+ __properties: ClassVar[List[str]] = ["items", "total", "page", "totalPages"]
37
+
38
+ model_config = ConfigDict(
39
+ populate_by_name=True,
40
+ validate_assignment=True,
41
+ protected_namespaces=(),
42
+ )
43
+
44
+
45
+ def to_str(self) -> str:
46
+ """Returns the string representation of the model using alias"""
47
+ return pprint.pformat(self.model_dump(by_alias=True))
48
+
49
+ def to_json(self) -> str:
50
+ """Returns the JSON representation of the model using alias"""
51
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
52
+ return json.dumps(self.to_dict())
53
+
54
+ @classmethod
55
+ def from_json(cls, json_str: str) -> Optional[Self]:
56
+ """Create an instance of PaginatedWorkspaces from a JSON string"""
57
+ return cls.from_dict(json.loads(json_str))
58
+
59
+ def to_dict(self) -> Dict[str, Any]:
60
+ """Return the dictionary representation of the model using alias.
61
+
62
+ This has the following differences from calling pydantic's
63
+ `self.model_dump(by_alias=True)`:
64
+
65
+ * `None` is only added to the output dict for nullable fields that
66
+ were set at model initialization. Other fields with value `None`
67
+ are ignored.
68
+ * Fields in `self.additional_properties` are added to the output dict.
69
+ """
70
+ excluded_fields: Set[str] = set([
71
+ "additional_properties",
72
+ ])
73
+
74
+ _dict = self.model_dump(
75
+ by_alias=True,
76
+ exclude=excluded_fields,
77
+ exclude_none=True,
78
+ )
79
+ # override the default output from pydantic by calling `to_dict()` of each item in items (list)
80
+ _items = []
81
+ if self.items:
82
+ for _item_items in self.items:
83
+ if _item_items:
84
+ _items.append(_item_items.to_dict())
85
+ _dict['items'] = _items
86
+ # puts key-value pairs in additional_properties in the top level
87
+ if self.additional_properties is not None:
88
+ for _key, _value in self.additional_properties.items():
89
+ _dict[_key] = _value
90
+
91
+ return _dict
92
+
93
+ @classmethod
94
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
95
+ """Create an instance of PaginatedWorkspaces from a dict"""
96
+ if obj is None:
97
+ return None
98
+
99
+ if not isinstance(obj, dict):
100
+ return cls.model_validate(obj)
101
+
102
+ _obj = cls.model_validate({
103
+ "items": [Workspace.from_dict(_item) for _item in obj["items"]] if obj.get("items") is not None else None,
104
+ "total": obj.get("total"),
105
+ "page": obj.get("page"),
106
+ "totalPages": obj.get("totalPages")
107
+ })
108
+ # store additional fields in additional_properties
109
+ for _key in obj.keys():
110
+ if _key not in cls.__properties:
111
+ _obj.additional_properties[_key] = obj.get(_key)
112
+
113
+ return _obj
114
+
115
+