platform-api-python-client 4.28.0__py3-none-any.whl → 4.37.1__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 (79) hide show
  1. platform_api_python_client/__init__.py +43 -10
  2. platform_api_python_client/api/external_api.py +6332 -1348
  3. platform_api_python_client/api_client.py +1 -1
  4. platform_api_python_client/configuration.py +1 -1
  5. platform_api_python_client/models/__init__.py +42 -9
  6. platform_api_python_client/models/ccl_dynamo_pools.py +116 -0
  7. platform_api_python_client/models/{create_c_serve_v2_deployment_response.py → ccl_main_pools.py} +12 -13
  8. platform_api_python_client/models/cloud_provider.py +5 -0
  9. platform_api_python_client/models/cluster_credential.py +2 -2
  10. platform_api_python_client/models/create_compute_deployment_request.py +40 -7
  11. platform_api_python_client/models/create_dynamo_deployment_request.py +97 -6
  12. platform_api_python_client/models/create_inference_v3_deployment_request.py +59 -2
  13. platform_api_python_client/models/create_job_deployment_request.py +43 -10
  14. platform_api_python_client/models/create_object_volume_request.py +19 -19
  15. platform_api_python_client/models/deployment_response.py +23 -23
  16. platform_api_python_client/models/deployment_type.py +14 -0
  17. platform_api_python_client/models/{c_serve_recipe_perf.py → dynamo_communications_input.py} +12 -19
  18. platform_api_python_client/models/dynamo_communications_output.py +91 -0
  19. platform_api_python_client/models/dynamo_image.py +105 -0
  20. platform_api_python_client/models/dynamo_kv_transfer_configuration.py +88 -0
  21. platform_api_python_client/models/dynamo_kv_transfer_policy.py +37 -0
  22. platform_api_python_client/models/dynamo_weight_transfer_configuration.py +88 -0
  23. platform_api_python_client/models/dynamo_weight_transfer_policy.py +36 -0
  24. platform_api_python_client/models/dynamo_worker_pool_config.py +37 -17
  25. platform_api_python_client/models/dynamo_worker_pools.py +23 -16
  26. platform_api_python_client/models/env.py +89 -0
  27. platform_api_python_client/models/get_cluster_response.py +4 -2
  28. platform_api_python_client/models/get_compute_deployment_response.py +45 -4
  29. platform_api_python_client/models/get_deployment_response.py +26 -2
  30. platform_api_python_client/models/get_deployment_usage_response.py +19 -4
  31. platform_api_python_client/models/get_dynamo_deployment_response.py +89 -5
  32. platform_api_python_client/models/get_inference_deployment_response.py +25 -1
  33. platform_api_python_client/models/get_inference_v3_deployment_response.py +67 -2
  34. platform_api_python_client/models/get_job_deployment_response.py +52 -11
  35. platform_api_python_client/models/get_object_volume_response.py +2 -16
  36. platform_api_python_client/models/hardware_instance_response.py +6 -4
  37. platform_api_python_client/models/image.py +112 -0
  38. platform_api_python_client/models/ingress.py +103 -0
  39. platform_api_python_client/models/insight_list_item_response.py +108 -0
  40. platform_api_python_client/models/insight_resource.py +97 -0
  41. platform_api_python_client/models/insight_resource_type.py +37 -0
  42. platform_api_python_client/models/insight_response.py +133 -0
  43. platform_api_python_client/models/insight_severity.py +40 -0
  44. platform_api_python_client/models/insight_status.py +39 -0
  45. platform_api_python_client/models/{c_serve_recipe_response.py → insight_status_change_response.py} +28 -24
  46. platform_api_python_client/models/list_insights_response.py +95 -0
  47. platform_api_python_client/models/metric.py +13 -0
  48. platform_api_python_client/models/pool.py +116 -0
  49. platform_api_python_client/models/unified_get_compute_deployment_response.py +177 -0
  50. platform_api_python_client/models/unified_get_deployment_logs_response.py +95 -0
  51. platform_api_python_client/models/{create_c_serve_v3_deployment_response.py → unified_get_deployment_pods_response.py} +8 -13
  52. platform_api_python_client/models/unified_get_deployment_response.py +164 -0
  53. platform_api_python_client/models/unified_get_deployment_revision_response.py +109 -0
  54. platform_api_python_client/models/unified_get_deployment_rollout_response.py +90 -0
  55. platform_api_python_client/models/unified_get_deployment_usage_response.py +110 -0
  56. platform_api_python_client/models/unified_get_dynamo_deployment_response.py +218 -0
  57. platform_api_python_client/models/unified_get_inference_v3_deployment_response.py +228 -0
  58. platform_api_python_client/models/unified_get_job_deployment_response.py +204 -0
  59. platform_api_python_client/models/{list_c_serve_recipe_response.py → unified_list_deployment_revisions_response.py} +7 -7
  60. platform_api_python_client/models/unified_update_deployment_rollout_request.py +87 -0
  61. platform_api_python_client/models/unified_write_compute_deployment_request.py +154 -0
  62. platform_api_python_client/models/unified_write_deployment_request.py +164 -0
  63. platform_api_python_client/models/{c_serve_v2_recipe.py → unified_write_deployment_response.py} +27 -27
  64. platform_api_python_client/models/unified_write_dynamo_deployment_request.py +197 -0
  65. platform_api_python_client/models/unified_write_inference_v3_deployment_request.py +207 -0
  66. platform_api_python_client/models/unified_write_job_deployment_request.py +183 -0
  67. platform_api_python_client/models/update_insight_status_request.py +106 -0
  68. platform_api_python_client/models/upsert_user_vault_item_request.py +1 -1
  69. platform_api_python_client/models/usage_availability.py +40 -0
  70. platform_api_python_client/models/usage_component.py +39 -0
  71. platform_api_python_client/models/validation_error.py +12 -3
  72. platform_api_python_client/models/volume_mount.py +1 -1
  73. {platform_api_python_client-4.28.0.dist-info → platform_api_python_client-4.37.1.dist-info}/METADATA +1 -1
  74. {platform_api_python_client-4.28.0.dist-info → platform_api_python_client-4.37.1.dist-info}/RECORD +76 -43
  75. {platform_api_python_client-4.28.0.dist-info → platform_api_python_client-4.37.1.dist-info}/WHEEL +1 -1
  76. platform_api_python_client/models/create_c_serve_v3_deployment_request.py +0 -182
  77. platform_api_python_client/models/get_c_serve_v2_deployment_response.py +0 -169
  78. platform_api_python_client/models/get_c_serve_v3_deployment_response.py +0 -170
  79. {platform_api_python_client-4.28.0.dist-info → platform_api_python_client-4.37.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,164 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Platform External API
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ from inspect import getfullargspec
17
+ import json
18
+ import pprint
19
+ import re # noqa: F401
20
+ from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
21
+ from typing import Optional
22
+ from platform_api_python_client.models.unified_get_compute_deployment_response import UnifiedGetComputeDeploymentResponse
23
+ from platform_api_python_client.models.unified_get_dynamo_deployment_response import UnifiedGetDynamoDeploymentResponse
24
+ from platform_api_python_client.models.unified_get_inference_v3_deployment_response import UnifiedGetInferenceV3DeploymentResponse
25
+ from platform_api_python_client.models.unified_get_job_deployment_response import UnifiedGetJobDeploymentResponse
26
+ from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict
27
+ from typing_extensions import Literal, Self
28
+ from pydantic import Field
29
+
30
+ UNIFIEDGETDEPLOYMENTRESPONSE_ANY_OF_SCHEMAS = ["UnifiedGetComputeDeploymentResponse", "UnifiedGetDynamoDeploymentResponse", "UnifiedGetInferenceV3DeploymentResponse", "UnifiedGetJobDeploymentResponse"]
31
+
32
+ class UnifiedGetDeploymentResponse(BaseModel):
33
+ """
34
+ UnifiedGetDeploymentResponse
35
+ """
36
+
37
+ # data type: UnifiedGetComputeDeploymentResponse
38
+ anyof_schema_1_validator: Optional[UnifiedGetComputeDeploymentResponse] = None
39
+ # data type: UnifiedGetInferenceV3DeploymentResponse
40
+ anyof_schema_2_validator: Optional[UnifiedGetInferenceV3DeploymentResponse] = None
41
+ # data type: UnifiedGetJobDeploymentResponse
42
+ anyof_schema_3_validator: Optional[UnifiedGetJobDeploymentResponse] = None
43
+ # data type: UnifiedGetDynamoDeploymentResponse
44
+ anyof_schema_4_validator: Optional[UnifiedGetDynamoDeploymentResponse] = None
45
+ if TYPE_CHECKING:
46
+ actual_instance: Optional[Union[UnifiedGetComputeDeploymentResponse, UnifiedGetDynamoDeploymentResponse, UnifiedGetInferenceV3DeploymentResponse, UnifiedGetJobDeploymentResponse]] = None
47
+ else:
48
+ actual_instance: Any = None
49
+ any_of_schemas: Set[str] = { "UnifiedGetComputeDeploymentResponse", "UnifiedGetDynamoDeploymentResponse", "UnifiedGetInferenceV3DeploymentResponse", "UnifiedGetJobDeploymentResponse" }
50
+
51
+ model_config = {
52
+ "validate_assignment": True,
53
+ "protected_namespaces": (),
54
+ }
55
+
56
+ def __init__(self, *args, **kwargs) -> None:
57
+ if args:
58
+ if len(args) > 1:
59
+ raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
60
+ if kwargs:
61
+ raise ValueError("If a position argument is used, keyword arguments cannot be used.")
62
+ super().__init__(actual_instance=args[0])
63
+ else:
64
+ super().__init__(**kwargs)
65
+
66
+ @field_validator('actual_instance')
67
+ def actual_instance_must_validate_anyof(cls, v):
68
+ instance = UnifiedGetDeploymentResponse.model_construct()
69
+ error_messages = []
70
+ # validate data type: UnifiedGetComputeDeploymentResponse
71
+ if not isinstance(v, UnifiedGetComputeDeploymentResponse):
72
+ error_messages.append(f"Error! Input type `{type(v)}` is not `UnifiedGetComputeDeploymentResponse`")
73
+ else:
74
+ return v
75
+
76
+ # validate data type: UnifiedGetInferenceV3DeploymentResponse
77
+ if not isinstance(v, UnifiedGetInferenceV3DeploymentResponse):
78
+ error_messages.append(f"Error! Input type `{type(v)}` is not `UnifiedGetInferenceV3DeploymentResponse`")
79
+ else:
80
+ return v
81
+
82
+ # validate data type: UnifiedGetJobDeploymentResponse
83
+ if not isinstance(v, UnifiedGetJobDeploymentResponse):
84
+ error_messages.append(f"Error! Input type `{type(v)}` is not `UnifiedGetJobDeploymentResponse`")
85
+ else:
86
+ return v
87
+
88
+ # validate data type: UnifiedGetDynamoDeploymentResponse
89
+ if not isinstance(v, UnifiedGetDynamoDeploymentResponse):
90
+ error_messages.append(f"Error! Input type `{type(v)}` is not `UnifiedGetDynamoDeploymentResponse`")
91
+ else:
92
+ return v
93
+
94
+ if error_messages:
95
+ # no match
96
+ raise ValueError("No match found when setting the actual_instance in UnifiedGetDeploymentResponse with anyOf schemas: UnifiedGetComputeDeploymentResponse, UnifiedGetDynamoDeploymentResponse, UnifiedGetInferenceV3DeploymentResponse, UnifiedGetJobDeploymentResponse. Details: " + ", ".join(error_messages))
97
+ else:
98
+ return v
99
+
100
+ @classmethod
101
+ def from_dict(cls, obj: Dict[str, Any]) -> Self:
102
+ return cls.from_json(json.dumps(obj))
103
+
104
+ @classmethod
105
+ def from_json(cls, json_str: str) -> Self:
106
+ """Returns the object represented by the json string"""
107
+ instance = cls.model_construct()
108
+ error_messages = []
109
+ # anyof_schema_1_validator: Optional[UnifiedGetComputeDeploymentResponse] = None
110
+ try:
111
+ instance.actual_instance = UnifiedGetComputeDeploymentResponse.from_json(json_str)
112
+ return instance
113
+ except (ValidationError, ValueError) as e:
114
+ error_messages.append(str(e))
115
+ # anyof_schema_2_validator: Optional[UnifiedGetInferenceV3DeploymentResponse] = None
116
+ try:
117
+ instance.actual_instance = UnifiedGetInferenceV3DeploymentResponse.from_json(json_str)
118
+ return instance
119
+ except (ValidationError, ValueError) as e:
120
+ error_messages.append(str(e))
121
+ # anyof_schema_3_validator: Optional[UnifiedGetJobDeploymentResponse] = None
122
+ try:
123
+ instance.actual_instance = UnifiedGetJobDeploymentResponse.from_json(json_str)
124
+ return instance
125
+ except (ValidationError, ValueError) as e:
126
+ error_messages.append(str(e))
127
+ # anyof_schema_4_validator: Optional[UnifiedGetDynamoDeploymentResponse] = None
128
+ try:
129
+ instance.actual_instance = UnifiedGetDynamoDeploymentResponse.from_json(json_str)
130
+ return instance
131
+ except (ValidationError, ValueError) as e:
132
+ error_messages.append(str(e))
133
+
134
+ if error_messages:
135
+ # no match
136
+ raise ValueError("No match found when deserializing the JSON string into UnifiedGetDeploymentResponse with anyOf schemas: UnifiedGetComputeDeploymentResponse, UnifiedGetDynamoDeploymentResponse, UnifiedGetInferenceV3DeploymentResponse, UnifiedGetJobDeploymentResponse. Details: " + ", ".join(error_messages))
137
+ else:
138
+ return instance
139
+
140
+ def to_json(self) -> str:
141
+ """Returns the JSON representation of the actual instance"""
142
+ if self.actual_instance is None:
143
+ return "null"
144
+
145
+ if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
146
+ return self.actual_instance.to_json()
147
+ else:
148
+ return json.dumps(self.actual_instance)
149
+
150
+ def to_dict(self) -> Optional[Union[Dict[str, Any], UnifiedGetComputeDeploymentResponse, UnifiedGetDynamoDeploymentResponse, UnifiedGetInferenceV3DeploymentResponse, UnifiedGetJobDeploymentResponse]]:
151
+ """Returns the dict representation of the actual instance"""
152
+ if self.actual_instance is None:
153
+ return None
154
+
155
+ if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
156
+ return self.actual_instance.to_dict()
157
+ else:
158
+ return self.actual_instance
159
+
160
+ def to_str(self) -> str:
161
+ """Returns the string representation of the actual instance"""
162
+ return pprint.pformat(self.model_dump())
163
+
164
+
@@ -0,0 +1,109 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Platform External API
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from datetime import datetime
21
+ from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
22
+ from typing import Any, ClassVar, Dict, List, Optional
23
+ from platform_api_python_client.models.unified_get_deployment_response import UnifiedGetDeploymentResponse
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class UnifiedGetDeploymentRevisionResponse(BaseModel):
28
+ """
29
+ UnifiedGetDeploymentRevisionResponse
30
+ """ # noqa: E501
31
+ id: StrictInt
32
+ revision_number: StrictInt
33
+ deployment_id: StrictInt
34
+ deployment_response: UnifiedGetDeploymentResponse
35
+ notes: Optional[StrictStr] = None
36
+ created_at: datetime
37
+ updated_at: datetime
38
+ __properties: ClassVar[List[str]] = ["id", "revision_number", "deployment_id", "deployment_response", "notes", "created_at", "updated_at"]
39
+
40
+ model_config = ConfigDict(
41
+ populate_by_name=True,
42
+ validate_assignment=True,
43
+ protected_namespaces=(),
44
+ )
45
+
46
+
47
+ def to_str(self) -> str:
48
+ """Returns the string representation of the model using alias"""
49
+ return pprint.pformat(self.model_dump(by_alias=True))
50
+
51
+ def to_json(self) -> str:
52
+ """Returns the JSON representation of the model using alias"""
53
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
54
+ return json.dumps(self.to_dict())
55
+
56
+ @classmethod
57
+ def from_json(cls, json_str: str) -> Optional[Self]:
58
+ """Create an instance of UnifiedGetDeploymentRevisionResponse from a JSON string"""
59
+ return cls.from_dict(json.loads(json_str))
60
+
61
+ def to_dict(self) -> Dict[str, Any]:
62
+ """Return the dictionary representation of the model using alias.
63
+
64
+ This has the following differences from calling pydantic's
65
+ `self.model_dump(by_alias=True)`:
66
+
67
+ * `None` is only added to the output dict for nullable fields that
68
+ were set at model initialization. Other fields with value `None`
69
+ are ignored.
70
+ """
71
+ excluded_fields: Set[str] = set([
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 deployment_response
80
+ if self.deployment_response:
81
+ _dict['deployment_response'] = self.deployment_response.to_dict()
82
+ # set to None if notes (nullable) is None
83
+ # and model_fields_set contains the field
84
+ if self.notes is None and "notes" in self.model_fields_set:
85
+ _dict['notes'] = None
86
+
87
+ return _dict
88
+
89
+ @classmethod
90
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
91
+ """Create an instance of UnifiedGetDeploymentRevisionResponse 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
+ "id": obj.get("id"),
100
+ "revision_number": obj.get("revision_number"),
101
+ "deployment_id": obj.get("deployment_id"),
102
+ "deployment_response": UnifiedGetDeploymentResponse.from_dict(obj["deployment_response"]) if obj.get("deployment_response") is not None else None,
103
+ "notes": obj.get("notes"),
104
+ "created_at": obj.get("created_at"),
105
+ "updated_at": obj.get("updated_at")
106
+ })
107
+ return _obj
108
+
109
+
@@ -0,0 +1,90 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Platform External API
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, StrictBool
21
+ from typing import Any, ClassVar, Dict, List
22
+ from platform_api_python_client.models.rollout_status import RolloutStatus
23
+ from typing import Optional, Set
24
+ from typing_extensions import Self
25
+
26
+ class UnifiedGetDeploymentRolloutResponse(BaseModel):
27
+ """
28
+ UnifiedGetDeploymentRolloutResponse
29
+ """ # noqa: E501
30
+ paused: StrictBool
31
+ status: RolloutStatus
32
+ __properties: ClassVar[List[str]] = ["paused", "status"]
33
+
34
+ model_config = ConfigDict(
35
+ populate_by_name=True,
36
+ validate_assignment=True,
37
+ protected_namespaces=(),
38
+ )
39
+
40
+
41
+ def to_str(self) -> str:
42
+ """Returns the string representation of the model using alias"""
43
+ return pprint.pformat(self.model_dump(by_alias=True))
44
+
45
+ def to_json(self) -> str:
46
+ """Returns the JSON representation of the model using alias"""
47
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
48
+ return json.dumps(self.to_dict())
49
+
50
+ @classmethod
51
+ def from_json(cls, json_str: str) -> Optional[Self]:
52
+ """Create an instance of UnifiedGetDeploymentRolloutResponse from a JSON string"""
53
+ return cls.from_dict(json.loads(json_str))
54
+
55
+ def to_dict(self) -> Dict[str, Any]:
56
+ """Return the dictionary representation of the model using alias.
57
+
58
+ This has the following differences from calling pydantic's
59
+ `self.model_dump(by_alias=True)`:
60
+
61
+ * `None` is only added to the output dict for nullable fields that
62
+ were set at model initialization. Other fields with value `None`
63
+ are ignored.
64
+ """
65
+ excluded_fields: Set[str] = set([
66
+ ])
67
+
68
+ _dict = self.model_dump(
69
+ by_alias=True,
70
+ exclude=excluded_fields,
71
+ exclude_none=True,
72
+ )
73
+ return _dict
74
+
75
+ @classmethod
76
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
77
+ """Create an instance of UnifiedGetDeploymentRolloutResponse from a dict"""
78
+ if obj is None:
79
+ return None
80
+
81
+ if not isinstance(obj, dict):
82
+ return cls.model_validate(obj)
83
+
84
+ _obj = cls.model_validate({
85
+ "paused": obj.get("paused"),
86
+ "status": obj.get("status")
87
+ })
88
+ return _obj
89
+
90
+
@@ -0,0 +1,110 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Platform External API
5
+
6
+ No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
7
+
8
+ The version of the OpenAPI document: 0.1.0
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ from __future__ import annotations
16
+ import pprint
17
+ import re # noqa: F401
18
+ import json
19
+
20
+ from pydantic import BaseModel, ConfigDict, StrictInt
21
+ from typing import Any, ClassVar, Dict, List, Optional
22
+ from platform_api_python_client.models.deployment_usage import DeploymentUsage
23
+ from platform_api_python_client.models.usage_availability import UsageAvailability
24
+ from typing import Optional, Set
25
+ from typing_extensions import Self
26
+
27
+ class UnifiedGetDeploymentUsageResponse(BaseModel):
28
+ """
29
+ UnifiedGetDeploymentUsageResponse
30
+ """ # noqa: E501
31
+ values: List[DeploymentUsage]
32
+ availability: Optional[UsageAvailability] = None
33
+ last_sample_at: Optional[StrictInt] = None
34
+ __properties: ClassVar[List[str]] = ["values", "availability", "last_sample_at"]
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 UnifiedGetDeploymentUsageResponse 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
+ """
67
+ excluded_fields: Set[str] = set([
68
+ ])
69
+
70
+ _dict = self.model_dump(
71
+ by_alias=True,
72
+ exclude=excluded_fields,
73
+ exclude_none=True,
74
+ )
75
+ # override the default output from pydantic by calling `to_dict()` of each item in values (list)
76
+ _items = []
77
+ if self.values:
78
+ for _item_values in self.values:
79
+ if _item_values:
80
+ _items.append(_item_values.to_dict())
81
+ _dict['values'] = _items
82
+ # set to None if availability (nullable) is None
83
+ # and model_fields_set contains the field
84
+ if self.availability is None and "availability" in self.model_fields_set:
85
+ _dict['availability'] = None
86
+
87
+ # set to None if last_sample_at (nullable) is None
88
+ # and model_fields_set contains the field
89
+ if self.last_sample_at is None and "last_sample_at" in self.model_fields_set:
90
+ _dict['last_sample_at'] = None
91
+
92
+ return _dict
93
+
94
+ @classmethod
95
+ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
96
+ """Create an instance of UnifiedGetDeploymentUsageResponse from a dict"""
97
+ if obj is None:
98
+ return None
99
+
100
+ if not isinstance(obj, dict):
101
+ return cls.model_validate(obj)
102
+
103
+ _obj = cls.model_validate({
104
+ "values": [DeploymentUsage.from_dict(_item) for _item in obj["values"]] if obj.get("values") is not None else None,
105
+ "availability": obj.get("availability"),
106
+ "last_sample_at": obj.get("last_sample_at")
107
+ })
108
+ return _obj
109
+
110
+