Commit a6d7e2b
authored
Fix Platform Details API Pydantic validation failure (#45)
* Fix Platform Details API Pydantic validation failure (#44)
The ArkPCloudPlatformsService.platform() method was failing with Pydantic
validation errors because it tried to validate the Platform Details API
response against the wrong model structure.
Root cause:
- Platform Details API (/platforms/{id}) returns:
{"PlatformID": "X", "Active": true, "Details": {...}}
- List Platforms API (/platforms) returns structured data that fits
ArkPCloudPlatform model with nested sections
Changes:
- Add new ArkPCloudPlatformDetails model matching actual API response format
- Update platform() method to return ArkPCloudPlatformDetails instead of ArkPCloudPlatform
- Update import_platform() method return type for consistency
- Add model exports to __init__.py
This preserves the existing List Platforms functionality while correctly
handling the Platform Details API response structure.
Fixes #44
* Bump version to 2.0.15 for platform details API fix
* Fix import_platform return type to match API response
The Import Platform API only returns {"PlatformID": "{PlatformID}"},
so the method should return the platform ID string rather than trying
to fetch platform details. This removes the type mismatch and correctly
reflects what the API actually provides.
Users can call platform() separately if they need platform details.
* Fix Platform Details API validation with Union approach
Use Union[ArkPCloudPlatform, ArkPCloudPlatformDetails] return type with
try/fallback logic to maintain backward compatibility while fixing
Pydantic validation failures for Details API endpoint.
Addresses reviewer feedback on PR #45.
* Prioritize ArkPCloudPlatform validation for backward compatibility1 parent f723b85 commit a6d7e2b
File tree
4 files changed
+30
-7
lines changed- ark_sdk_python
- models/services/pcloud/platforms
- services/pcloud/platforms
4 files changed
+30
-7
lines changedLines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| 46 | + | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
| |||
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
Lines changed: 12 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| |||
99 | 100 | | |
100 | 101 | | |
101 | 102 | | |
102 | | - | |
| 103 | + | |
103 | 104 | | |
104 | 105 | | |
105 | 106 | | |
| |||
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
114 | | - | |
| 115 | + | |
115 | 116 | | |
116 | 117 | | |
117 | 118 | | |
118 | 119 | | |
119 | 120 | | |
| 121 | + | |
120 | 122 | | |
121 | | - | |
122 | | - | |
123 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
124 | 130 | | |
125 | 131 | | |
126 | 132 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
0 commit comments