Instantiate a CDP type from a JSON object.
(cls, type_)
| 325 | |
| 326 | @classmethod |
| 327 | def from_json(cls, type_): |
| 328 | """Instantiate a CDP type from a JSON object.""" |
| 329 | return cls( |
| 330 | type_["id"], |
| 331 | type_.get("description"), |
| 332 | type_["type"], |
| 333 | CdpItems.from_json(type_["items"]) if "items" in type_ else None, |
| 334 | type_.get("enum"), |
| 335 | [CdpProperty.from_json(p) for p in type_.get("properties", [])], |
| 336 | ) |
| 337 | |
| 338 | def generate_code(self): |
| 339 | """Generate Python code for this type.""" |