daytona_api_client 0.25.5__py3-none-any.whl → 0.26.0__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.

Files changed (50) hide show
  1. daytona_api_client/__init__.py +12 -1
  2. daytona_api_client/api/__init__.py +2 -0
  3. daytona_api_client/api/default_api.py +1884 -0
  4. daytona_api_client/api/health_api.py +282 -0
  5. daytona_api_client/api/organizations_api.py +6 -6
  6. daytona_api_client/api/sandbox_api.py +855 -2
  7. daytona_api_client/api/webhooks_api.py +1704 -0
  8. daytona_api_client/models/__init__.py +10 -1
  9. daytona_api_client/models/create_audit_log.py +2 -2
  10. daytona_api_client/models/create_sandbox.py +5 -1
  11. daytona_api_client/models/health_controller_check200_response.py +154 -0
  12. daytona_api_client/models/{account_provider_dto.py → health_controller_check200_response_info_value.py} +23 -23
  13. daytona_api_client/models/health_controller_check503_response.py +154 -0
  14. daytona_api_client/models/{usage_overview.py → organization_usage_overview.py} +14 -8
  15. daytona_api_client/models/sandbox.py +5 -1
  16. daytona_api_client/models/sandbox_created_post_request.py +110 -0
  17. daytona_api_client/models/sandbox_created_post_request_data.py +152 -0
  18. daytona_api_client/models/sandbox_state.py +1 -1
  19. daytona_api_client/models/sandbox_state_updated_post_request.py +110 -0
  20. daytona_api_client/models/sandbox_state_updated_post_request_data.py +129 -0
  21. daytona_api_client/models/sandbox_state_updated_post_request_data_sandbox.py +115 -0
  22. daytona_api_client/models/send_webhook_dto.py +105 -0
  23. daytona_api_client/models/snapshot_created_post_request.py +110 -0
  24. daytona_api_client/models/snapshot_created_post_request_data.py +136 -0
  25. daytona_api_client/models/{get_build_logs400_response.py → snapshot_removed_post_request.py} +31 -26
  26. daytona_api_client/models/snapshot_state_updated_post_request.py +110 -0
  27. daytona_api_client/models/snapshot_state_updated_post_request_data.py +129 -0
  28. daytona_api_client/models/snapshot_state_updated_post_request_data_snapshot.py +115 -0
  29. daytona_api_client/models/ssh_access_dto.py +112 -0
  30. daytona_api_client/models/ssh_access_validation_dto.py +107 -0
  31. daytona_api_client/models/volume_created_post_request.py +110 -0
  32. daytona_api_client/models/{volume.py → volume_created_post_request_data.py} +48 -55
  33. daytona_api_client/models/volume_state_updated_post_request.py +110 -0
  34. daytona_api_client/models/volume_state_updated_post_request_data.py +129 -0
  35. daytona_api_client/models/volume_state_updated_post_request_data_volume.py +115 -0
  36. daytona_api_client/models/{download_files.py → webhook_app_portal_access.py} +7 -7
  37. daytona_api_client/models/{upload_file.py → webhook_controller_get_app_portal_access200_response.py} +26 -26
  38. daytona_api_client/models/webhook_controller_get_initialization_status200_response.py +118 -0
  39. daytona_api_client/models/{toggle_state.py → webhook_controller_get_status200_response.py} +7 -7
  40. daytona_api_client/models/webhook_initialization_status.py +121 -0
  41. daytona_api_client/models/workspace.py +5 -1
  42. {daytona_api_client-0.25.5.dist-info → daytona_api_client-0.26.0.dist-info}/METADATA +1 -1
  43. {daytona_api_client-0.25.5.dist-info → daytona_api_client-0.26.0.dist-info}/RECORD +46 -26
  44. daytona_api_client/models/build_snapshot.py +0 -118
  45. daytona_api_client/models/upload_file_dto.py +0 -101
  46. daytona_api_client/models/upload_file_request_file.py +0 -159
  47. daytona_api_client/models/upload_files_multi_request_files_inner.py +0 -101
  48. {daytona_api_client-0.25.5.dist-info → daytona_api_client-0.26.0.dist-info}/WHEEL +0 -0
  49. {daytona_api_client-0.25.5.dist-info → daytona_api_client-0.26.0.dist-info}/licenses/LICENSE +0 -0
  50. {daytona_api_client-0.25.5.dist-info → daytona_api_client-0.26.0.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,105 @@
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, StrictStr
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class SendWebhookDto(BaseModel):
27
+ """
28
+ SendWebhookDto
29
+ """ # noqa: E501
30
+ event_type: StrictStr = Field(description="The type of event being sent", alias="eventType")
31
+ payload: Dict[str, Any] = Field(description="The payload data to send")
32
+ event_id: Optional[StrictStr] = Field(default=None, description="Optional event ID for idempotency", alias="eventId")
33
+ additional_properties: Dict[str, Any] = {}
34
+ __properties: ClassVar[List[str]] = ["eventType", "payload", "eventId"]
35
+
36
+ model_config = ConfigDict(
37
+ populate_by_name=True,
38
+ validate_assignment=True,
39
+ protected_namespaces=(),
40
+ )
41
+
42
+
43
+ def to_str(self) -> str:
44
+ """Returns the string representation of the model using alias"""
45
+ return pprint.pformat(self.model_dump(by_alias=True))
46
+
47
+ def to_json(self) -> str:
48
+ """Returns the JSON representation of the model using alias"""
49
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
50
+ return json.dumps(self.to_dict())
51
+
52
+ @classmethod
53
+ def from_json(cls, json_str: str) -> Optional[Self]:
54
+ """Create an instance of SendWebhookDto from a JSON string"""
55
+ return cls.from_dict(json.loads(json_str))
56
+
57
+ def to_dict(self) -> Dict[str, Any]:
58
+ """Return the dictionary representation of the model using alias.
59
+
60
+ This has the following differences from calling pydantic's
61
+ `self.model_dump(by_alias=True)`:
62
+
63
+ * `None` is only added to the output dict for nullable fields that
64
+ were set at model initialization. Other fields with value `None`
65
+ are ignored.
66
+ * Fields in `self.additional_properties` are added to the output dict.
67
+ """
68
+ excluded_fields: Set[str] = set([
69
+ "additional_properties",
70
+ ])
71
+
72
+ _dict = self.model_dump(
73
+ by_alias=True,
74
+ exclude=excluded_fields,
75
+ exclude_none=True,
76
+ )
77
+ # puts key-value pairs in additional_properties in the top level
78
+ if self.additional_properties is not None:
79
+ for _key, _value in self.additional_properties.items():
80
+ _dict[_key] = _value
81
+
82
+ return _dict
83
+
84
+ @classmethod
85
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
86
+ """Create an instance of SendWebhookDto from a dict"""
87
+ if obj is None:
88
+ return None
89
+
90
+ if not isinstance(obj, dict):
91
+ return cls.model_validate(obj)
92
+
93
+ _obj = cls.model_validate({
94
+ "eventType": obj.get("eventType"),
95
+ "payload": obj.get("payload"),
96
+ "eventId": obj.get("eventId")
97
+ })
98
+ # store additional fields in additional_properties
99
+ for _key in obj.keys():
100
+ if _key not in cls.__properties:
101
+ _obj.additional_properties[_key] = obj.get(_key)
102
+
103
+ return _obj
104
+
105
+
@@ -0,0 +1,110 @@
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 datetime import datetime
22
+ from pydantic import BaseModel, ConfigDict, StrictStr
23
+ from typing import Any, ClassVar, Dict, List, Optional
24
+ from daytona_api_client.models.snapshot_created_post_request_data import SnapshotCreatedPostRequestData
25
+ from typing import Optional, Set
26
+ from typing_extensions import Self
27
+
28
+ class SnapshotCreatedPostRequest(BaseModel):
29
+ """
30
+ SnapshotCreatedPostRequest
31
+ """ # noqa: E501
32
+ event: Optional[StrictStr] = None
33
+ timestamp: Optional[datetime] = None
34
+ data: Optional[SnapshotCreatedPostRequestData] = None
35
+ additional_properties: Dict[str, Any] = {}
36
+ __properties: ClassVar[List[str]] = ["event", "timestamp", "data"]
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 SnapshotCreatedPostRequest 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 data
80
+ if self.data:
81
+ _dict['data'] = self.data.to_dict()
82
+ # puts key-value pairs in additional_properties in the top level
83
+ if self.additional_properties is not None:
84
+ for _key, _value in self.additional_properties.items():
85
+ _dict[_key] = _value
86
+
87
+ return _dict
88
+
89
+ @classmethod
90
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
91
+ """Create an instance of SnapshotCreatedPostRequest from a dict"""
92
+ if obj is None:
93
+ return None
94
+
95
+ if not isinstance(obj, dict):
96
+ return cls.model_validate(obj)
97
+
98
+ _obj = cls.model_validate({
99
+ "event": obj.get("event"),
100
+ "timestamp": obj.get("timestamp"),
101
+ "data": SnapshotCreatedPostRequestData.from_dict(obj["data"]) if obj.get("data") is not None else None
102
+ })
103
+ # store additional fields in additional_properties
104
+ for _key in obj.keys():
105
+ if _key not in cls.__properties:
106
+ _obj.additional_properties[_key] = obj.get(_key)
107
+
108
+ return _obj
109
+
110
+
@@ -0,0 +1,136 @@
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 datetime import datetime
22
+ from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr, field_validator
23
+ from typing import Any, ClassVar, Dict, List, Optional, Union
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class SnapshotCreatedPostRequestData(BaseModel):
28
+ """
29
+ SnapshotCreatedPostRequestData
30
+ """ # noqa: E501
31
+ id: Optional[StrictStr] = None
32
+ organization_id: Optional[StrictStr] = Field(default=None, alias="organizationId")
33
+ general: Optional[StrictBool] = None
34
+ name: Optional[StrictStr] = None
35
+ image_name: Optional[StrictStr] = Field(default=None, alias="imageName")
36
+ state: Optional[StrictStr] = None
37
+ size: Optional[Union[StrictFloat, StrictInt]] = None
38
+ cpu: Optional[Union[StrictFloat, StrictInt]] = None
39
+ gpu: Optional[Union[StrictFloat, StrictInt]] = None
40
+ mem: Optional[Union[StrictFloat, StrictInt]] = None
41
+ disk: Optional[Union[StrictFloat, StrictInt]] = None
42
+ created_at: Optional[datetime] = Field(default=None, alias="createdAt")
43
+ updated_at: Optional[datetime] = Field(default=None, alias="updatedAt")
44
+ additional_properties: Dict[str, Any] = {}
45
+ __properties: ClassVar[List[str]] = ["id", "organizationId", "general", "name", "imageName", "state", "size", "cpu", "gpu", "mem", "disk", "createdAt", "updatedAt"]
46
+
47
+ @field_validator('state')
48
+ def state_validate_enum(cls, value):
49
+ """Validates the enum"""
50
+ if value is None:
51
+ return value
52
+
53
+ if value not in set(['build_pending', 'building', 'pending', 'pulling', 'pending_validation', 'validating', 'active', 'inactive', 'error', 'build_failed', 'removing']):
54
+ raise ValueError("must be one of enum values ('build_pending', 'building', 'pending', 'pulling', 'pending_validation', 'validating', 'active', 'inactive', 'error', 'build_failed', 'removing')")
55
+ return value
56
+
57
+ model_config = ConfigDict(
58
+ populate_by_name=True,
59
+ validate_assignment=True,
60
+ protected_namespaces=(),
61
+ )
62
+
63
+
64
+ def to_str(self) -> str:
65
+ """Returns the string representation of the model using alias"""
66
+ return pprint.pformat(self.model_dump(by_alias=True))
67
+
68
+ def to_json(self) -> str:
69
+ """Returns the JSON representation of the model using alias"""
70
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
71
+ return json.dumps(self.to_dict())
72
+
73
+ @classmethod
74
+ def from_json(cls, json_str: str) -> Optional[Self]:
75
+ """Create an instance of SnapshotCreatedPostRequestData from a JSON string"""
76
+ return cls.from_dict(json.loads(json_str))
77
+
78
+ def to_dict(self) -> Dict[str, Any]:
79
+ """Return the dictionary representation of the model using alias.
80
+
81
+ This has the following differences from calling pydantic's
82
+ `self.model_dump(by_alias=True)`:
83
+
84
+ * `None` is only added to the output dict for nullable fields that
85
+ were set at model initialization. Other fields with value `None`
86
+ are ignored.
87
+ * Fields in `self.additional_properties` are added to the output dict.
88
+ """
89
+ excluded_fields: Set[str] = set([
90
+ "additional_properties",
91
+ ])
92
+
93
+ _dict = self.model_dump(
94
+ by_alias=True,
95
+ exclude=excluded_fields,
96
+ exclude_none=True,
97
+ )
98
+ # puts key-value pairs in additional_properties in the top level
99
+ if self.additional_properties is not None:
100
+ for _key, _value in self.additional_properties.items():
101
+ _dict[_key] = _value
102
+
103
+ return _dict
104
+
105
+ @classmethod
106
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
107
+ """Create an instance of SnapshotCreatedPostRequestData from a dict"""
108
+ if obj is None:
109
+ return None
110
+
111
+ if not isinstance(obj, dict):
112
+ return cls.model_validate(obj)
113
+
114
+ _obj = cls.model_validate({
115
+ "id": obj.get("id"),
116
+ "organizationId": obj.get("organizationId"),
117
+ "general": obj.get("general"),
118
+ "name": obj.get("name"),
119
+ "imageName": obj.get("imageName"),
120
+ "state": obj.get("state"),
121
+ "size": obj.get("size"),
122
+ "cpu": obj.get("cpu"),
123
+ "gpu": obj.get("gpu"),
124
+ "mem": obj.get("mem"),
125
+ "disk": obj.get("disk"),
126
+ "createdAt": obj.get("createdAt"),
127
+ "updatedAt": obj.get("updatedAt")
128
+ })
129
+ # store additional fields in additional_properties
130
+ for _key in obj.keys():
131
+ if _key not in cls.__properties:
132
+ _obj.additional_properties[_key] = obj.get(_key)
133
+
134
+ return _obj
135
+
136
+
@@ -1,38 +1,38 @@
1
1
  # coding: utf-8
2
2
 
3
3
  """
4
- Daytona
4
+ Daytona
5
5
 
6
- Daytona AI platform API Docs
6
+ Daytona AI platform API Docs
7
7
 
8
- The version of the OpenAPI document: 1.0
9
- Contact: support@daytona.com
10
- Generated by OpenAPI Generator (https://openapi-generator.tech)
8
+ The version of the OpenAPI document: 1.0
9
+ Contact: support@daytona.com
10
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
11
11
 
12
- Do not edit the class manually.
12
+ Do not edit the class manually.
13
13
  """ # noqa: E501
14
14
 
15
15
 
16
16
  from __future__ import annotations
17
-
18
- import json
19
17
  import pprint
20
18
  import re # noqa: F401
21
- from typing import Any, ClassVar, Dict, List, Optional, Set, Union
19
+ import json
22
20
 
23
- from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
21
+ from datetime import datetime
22
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr
23
+ from typing import Any, ClassVar, Dict, List, Optional
24
+ from typing import Optional, Set
24
25
  from typing_extensions import Self
25
26
 
26
-
27
- class GetBuildLogs400Response(BaseModel):
27
+ class SnapshotRemovedPostRequest(BaseModel):
28
28
  """
29
- GetBuildLogs400Response
30
- """ # noqa: E501
31
-
32
- message: Optional[StrictStr] = None
33
- status_code: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="statusCode")
29
+ SnapshotRemovedPostRequest
30
+ """ # noqa: E501
31
+ event: Optional[StrictStr] = None
32
+ timestamp: Optional[datetime] = None
33
+ data: Optional[StrictStr] = Field(default=None, description="The ID of the removed snapshot")
34
34
  additional_properties: Dict[str, Any] = {}
35
- __properties: ClassVar[List[str]] = ["message", "statusCode"]
35
+ __properties: ClassVar[List[str]] = ["event", "timestamp", "data"]
36
36
 
37
37
  model_config = ConfigDict(
38
38
  populate_by_name=True,
@@ -40,6 +40,7 @@ class GetBuildLogs400Response(BaseModel):
40
40
  protected_namespaces=(),
41
41
  )
42
42
 
43
+
43
44
  def to_str(self) -> str:
44
45
  """Returns the string representation of the model using alias"""
45
46
  return pprint.pformat(self.model_dump(by_alias=True))
@@ -51,7 +52,7 @@ class GetBuildLogs400Response(BaseModel):
51
52
 
52
53
  @classmethod
53
54
  def from_json(cls, json_str: str) -> Optional[Self]:
54
- """Create an instance of GetBuildLogs400Response from a JSON string"""
55
+ """Create an instance of SnapshotRemovedPostRequest from a JSON string"""
55
56
  return cls.from_dict(json.loads(json_str))
56
57
 
57
58
  def to_dict(self) -> Dict[str, Any]:
@@ -65,11 +66,9 @@ class GetBuildLogs400Response(BaseModel):
65
66
  are ignored.
66
67
  * Fields in `self.additional_properties` are added to the output dict.
67
68
  """
68
- excluded_fields: Set[str] = set(
69
- [
70
- "additional_properties",
71
- ]
72
- )
69
+ excluded_fields: Set[str] = set([
70
+ "additional_properties",
71
+ ])
73
72
 
74
73
  _dict = self.model_dump(
75
74
  by_alias=True,
@@ -85,17 +84,23 @@ class GetBuildLogs400Response(BaseModel):
85
84
 
86
85
  @classmethod
87
86
  def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
88
- """Create an instance of GetBuildLogs400Response from a dict"""
87
+ """Create an instance of SnapshotRemovedPostRequest from a dict"""
89
88
  if obj is None:
90
89
  return None
91
90
 
92
91
  if not isinstance(obj, dict):
93
92
  return cls.model_validate(obj)
94
93
 
95
- _obj = cls.model_validate({"message": obj.get("message"), "statusCode": obj.get("statusCode")})
94
+ _obj = cls.model_validate({
95
+ "event": obj.get("event"),
96
+ "timestamp": obj.get("timestamp"),
97
+ "data": obj.get("data")
98
+ })
96
99
  # store additional fields in additional_properties
97
100
  for _key in obj.keys():
98
101
  if _key not in cls.__properties:
99
102
  _obj.additional_properties[_key] = obj.get(_key)
100
103
 
101
104
  return _obj
105
+
106
+
@@ -0,0 +1,110 @@
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 datetime import datetime
22
+ from pydantic import BaseModel, ConfigDict, StrictStr
23
+ from typing import Any, ClassVar, Dict, List, Optional
24
+ from daytona_api_client.models.snapshot_state_updated_post_request_data import SnapshotStateUpdatedPostRequestData
25
+ from typing import Optional, Set
26
+ from typing_extensions import Self
27
+
28
+ class SnapshotStateUpdatedPostRequest(BaseModel):
29
+ """
30
+ SnapshotStateUpdatedPostRequest
31
+ """ # noqa: E501
32
+ event: Optional[StrictStr] = None
33
+ timestamp: Optional[datetime] = None
34
+ data: Optional[SnapshotStateUpdatedPostRequestData] = None
35
+ additional_properties: Dict[str, Any] = {}
36
+ __properties: ClassVar[List[str]] = ["event", "timestamp", "data"]
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 SnapshotStateUpdatedPostRequest 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 data
80
+ if self.data:
81
+ _dict['data'] = self.data.to_dict()
82
+ # puts key-value pairs in additional_properties in the top level
83
+ if self.additional_properties is not None:
84
+ for _key, _value in self.additional_properties.items():
85
+ _dict[_key] = _value
86
+
87
+ return _dict
88
+
89
+ @classmethod
90
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
91
+ """Create an instance of SnapshotStateUpdatedPostRequest from a dict"""
92
+ if obj is None:
93
+ return None
94
+
95
+ if not isinstance(obj, dict):
96
+ return cls.model_validate(obj)
97
+
98
+ _obj = cls.model_validate({
99
+ "event": obj.get("event"),
100
+ "timestamp": obj.get("timestamp"),
101
+ "data": SnapshotStateUpdatedPostRequestData.from_dict(obj["data"]) if obj.get("data") is not None else None
102
+ })
103
+ # store additional fields in additional_properties
104
+ for _key in obj.keys():
105
+ if _key not in cls.__properties:
106
+ _obj.additional_properties[_key] = obj.get(_key)
107
+
108
+ return _obj
109
+
110
+