SDL-Hercules-390 / hyperion

The SDL Hercules 4.x Hyperion version of the System/370, ESA/390, and z/Architecture Emulator
Other
240 stars 90 forks source link

Adding JSON APIs to the HTTP server #578

Closed mainframed closed 1 year ago

mainframed commented 1 year ago

This change adds JSON APIs to the HTTP server similar to xml/rate but provides a lot more information in different/various API calls.

This request adds the following URLs:

For example (from zzsacard.bin):

http://localhost:8888/cgi-bin/api/v1/devices

{
    "devices": [{
        "devnum": "0009",
        "subchannel": "0000",
        "devclass": "CON",
        "devtype": "3215",
        "status": "open ",
        "assignment": "*syscons cmdpref(/) noprompt IO[0]"
    }, {
        "devnum": "000C",
        "subchannel": "0001",
        "devclass": "RDR",
        "devtype": "3505",
        "status": "",
        "assignment": "./util/zzsacard.bin intrq IO[0]"
    }, {
        "devnum": "000D",
        "subchannel": "0002",
        "devclass": "PCH",
        "devtype": "3525",
        "status": "open ",
        "assignment": "punch00d.txt ascii IO[0]"
    }, {
        "devnum": "000E",
        "subchannel": "0003",
        "devclass": "PRT",
        "devtype": "1403",
        "status": "open ",
        "assignment": "print00e.txt crlf IO[0]"
    }, {
        "devnum": "001F",
        "subchannel": "0004",
        "devclass": "DSP",
        "devtype": "3270",
        "status": "",
        "assignment": "* IO[0]"
    }]
}

http://localhost:8888/cgi-bin/api/v1/devices

{
    "cpus": [{
        "cpuid": "CPU0000",
        "online": true,
        "mode": "ESA/390",
        "percent": 0,
        "PSW": "030A0000800078DC",
        "general_registers": {
            "GR0": "00000000",
            "GR1": "0004FFFF",
            "GR2": "00000000",
            "GR3": "00000000",
            "GR4": "00000000",
            "GR5": "00000000",
            "GR6": "00000000",
            "GR7": "00000000",
            "GR8": "00000000",
            "GR9": "00000000",
            "GR10": "00001000",
            "GR11": "00002000",
            "GR12": "800078DA",
            "GR13": "00000000",
            "GR14": "00000000",
            "GR15": "00000000"
        },
        "control_registers": {
            "CR0": "00000840",
            "CR1": "00000000",
            "CR2": "00000000",
            "CR3": "00000000",
            "CR4": "00000000",
            "CR5": "00000000",
            "CR6": "80000000",
            "CR7": "00000000",
            "CR8": "00000000",
            "CR9": "00000000",
            "CR10": "00000000",
            "CR11": "00000000",
            "CR12": "00000000",
            "CR13": "00000000",
            "CR14": "C2000000",
            "CR15": "00000000"
        },
        "access_registers": {
            "AR0": "00000000",
            "AR1": "00000000",
            "AR2": "00000000",
            "AR3": "00000000",
            "AR4": "00000000",
            "AR5": "00000000",
            "AR6": "00000000",
            "AR7": "00000000",
            "AR8": "00000000",
            "AR9": "00000000",
            "AR10": "00000000",
            "AR11": "00000000",
            "AR12": "00000000",
            "AR13": "00000000",
            "AR14": "00000000",
            "AR15": "00000000"
        }
    }, {
        "cpuid": "CPU0001",
        "online": false,
        "mode": "z/Arch",
        "percent": 0,
        "PSW": "00000000000000000000000000000000",
        "general_registers": {
            "GR0": "0000000000000000",
            "GR1": "0000000000000000",
            "GR2": "0000000000000000",
            "GR3": "0000000000000000",
            "GR4": "0000000000000000",
            "GR5": "0000000000000000",
            "GR6": "0000000000000000",
            "GR7": "0000000000000000",
            "GR8": "0000000000000000",
            "GR9": "0000000000000000",
            "GR10": "0000000000000000",
            "GR11": "0000000000000000",
            "GR12": "0000000000000000",
            "GR13": "0000000000000000",
            "GR14": "0000000000000000",
            "GR15": "0000000000000000"
        },
        "control_registers": {
            "CR0": "0000000000000060",
            "CR1": "0000000000000000",
            "CR2": "0000000000000000",
            "CR3": "0000000000000000",
            "CR4": "0000000000000000",
            "CR5": "0000000000000000",
            "CR6": "0000000000000000",
            "CR7": "0000000000000000",
            "CR8": "0000000000000000",
            "CR9": "0000000000000000",
            "CR10": "0000000000000000",
            "CR11": "0000000000000000",
            "CR12": "0000000000000000",
            "CR13": "0000000000000000",
            "CR14": "00000000C2000000",
            "CR15": "0000000000000000"
        },
        "access_registers": {
            "AR0": "00000000",
            "AR1": "00000000",
            "AR2": "00000000",
            "AR3": "00000000",
            "AR4": "00000000",
            "AR5": "00000000",
            "AR6": "00000000",
            "AR7": "00000000",
            "AR8": "00000000",
            "AR9": "00000000",
            "AR10": "00000000",
            "AR11": "00000000",
            "AR12": "00000000",
            "AR13": "00000000",
            "AR14": "00000000",
            "AR15": "00000000"
        }
    }]
}

http://localhost:8888/cgi-bin/api/v1/syslog?msgcount=15

{
    "command": "",
    "msgcount": 15,
    "syslog": 
                         [
                             "HHC00100I Thread id 00007f76fd8cd640, prio 0, name 'rubato_thread' started", 
                             "HHC01024I Waiting for console connections on port 13270", 
                             "HHC01603I ipl c", 
                             "HHC00811I Processor CP00: architecture mode ESA/390",  
                             "HHC00801I Processor CP00: Operand exception interruption code 0015 ilc 4", 
                             "HHC02324I PSW=00081000800005E4 INST=B2343000     STSCH 0(3)                   store_subchannel", 
                             "HHC02326I R:00007E88:K:06=00000000 00010009 80000080 0000FF80  ................", 
                             "HHC02269I GR00=00000000 GR01=00050000 GR02=00000000 GR03=00007E88", 
                             "HHC02269I GR04=00000148 GR05=00000000 GR06=000005D2 GR07=00000000", 
                             "HHC02269I GR08=000A0000 GR09=DEAD0001 GR10=00001000 GR11=00002000", 
                             "HHC02269I GR12=00000000 GR13=00000000 GR14=80000390 GR15=00000000", 
                             "HHC02271I CR00=00000840 CR01=00000000 CR02=00000000 CR03=00000000", 
                             "HHC02271I CR04=00000000 CR05=00000000 CR06=80000000 CR07=00000000", 
                             "HHC02271I CR08=00000000 CR09=00000000 CR10=00000000 CR11=00000000", 
                             "HHC02271I CR12=00000000 CR13=00000000 CR14=C2000000 CR15=00000000", 
                             ""
                        ]
}

Also included is the addition of the javascript mimetype.