Instantiate a CDP domain from a JSON object.
(cls, domain: dict)
| 794 | |
| 795 | @classmethod |
| 796 | def from_json(cls, domain: dict): |
| 797 | """Instantiate a CDP domain from a JSON object.""" |
| 798 | types = domain.get("types", []) |
| 799 | commands = domain.get("commands", []) |
| 800 | events = domain.get("events", []) |
| 801 | domain_name = domain["domain"] |
| 802 | |
| 803 | return cls( |
| 804 | domain_name, |
| 805 | domain.get("description"), |
| 806 | domain.get("experimental", False), |
| 807 | domain.get("dependencies", []), |
| 808 | [CdpType.from_json(type) for type in types], |
| 809 | [CdpCommand.from_json(command, domain_name) for command in commands], |
| 810 | [CdpEvent.from_json(event, domain_name) for event in events], |
| 811 | ) |
| 812 | |
| 813 | def generate_code(self): |
| 814 | """Generate the Python module code for a given CDP domain.""" |