byxorna / nycmesh-tool

nycmesh-tool CLI
Apache License 2.0
1 stars 0 forks source link

UISP codegen refactor #13

Closed byxorna closed 2 years ago

byxorna commented 2 years ago

Refactor the UISP codegen to be touch-free, making it easier to patch the spec (to fix the litany of vendor-supplied bugs) and make a working library.

I found this useful while debugging why the uisp outages getOutages command failed to deserialize. See changes in patch-3-1644868976-outage.patch and patch-8-1644878967-conflicting-model-names-outages.patch. Before these patches were appled, the following command would fail:

❱ bin/nycmesh-tool uisp outages getOutages --count=1 --page=1 --inProgress|jq
2022/02/14 18:10:45 config file: /home/gabe/.nycmesh-tool.yaml
2022/02/14 18:10:45 binary release v0.4.2-3-ge965c9d, built Mon Feb 14 11:10:40 PM UTC 2022
Error: json: cannot unmarshal object into Go value of type models.Outages
2022/02/14 18:10:50 Error: json: cannot unmarshal object into Go value of type models.Outages

After building this branch, the following command will work correctly:

❱ bin/nycmesh-tool uisp outages getOutages --count=1 --page=1 --inProgress|jq
2022/02/14 18:10:05 config file: /home/gabe/.nycmesh-tool.yaml
2022/02/14 18:10:05 binary release v0.4.2-19-g52482c3, built Mon Feb 14 11:07:22 PM UTC 2022
{
  "aggregation": {
    "allCount": 108,
    "outageCount": 108
  },
  "items": [
    {
      "aggregatedTime": 17060406,
      "device": {
        "authorized": true,
        "category": null,
        "displayName": "nycmesh-...-omni",
        "firmwareVersion": null,
        "mac": null,
        "model": "UNKNOWN",
        "modelName": "OmniTik",
        "name": "nycmesh-...-omni",
        "platformId": "UNKNOWN",
        "platformName": "UNKNOWN",
        "role": "router",
        "serialNumber": null,
        "site": {
          "id": "10bef093-7f8a-4872-9cc0-26ef05b622f2",
          "name": "Stations-xxx",
          "parent": {
            "id": "977f0bae-fcb5-4edc-b4cc-d74cdefb5fce",
            "name": "Stations-yyy",
            "parent": null,
            "status": "active",
            "type": "endpoint"
          },
          "status": "active",
          "type": "endpoint"
        },
        "type": "blackBox"
      },
      "deviceMetadata": {
        "alias": "nycmesh-...-omni"
      },
      "endTimestamp": null,
      "id": "0c58e17c-0f0b-4fde-8b6e-97e6095a8646",
      "inProgress": true,
      "ongoing": true,
      "site": {
        "id": "10bef093-7f8a-4872-9cc0-26ef05b622f2",
        "name": "Stations-xxx",
        "parent": {
          "id": "977f0bae-fcb5-4edc-b4cc-d74cdefb5fce",
          "name": "Stations-yyy",
          "parent": null,
          "status": "active",
          "type": "endpoint"
        },
        "status": "active",
        "type": "endpoint"
      },
      "startTimestamp": "2022-02-14T18:25:48.799Z",
      "type": "outage"
    }
  ],
  "pagination": {
    "count": 1,
    "page": 1,
    "pages": 108,
    "total": 108
  }
}