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