diff --git a/.gitignore b/.gitignore index 76e2215..b33d8cd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,6 @@ *.schema docs/ -new/ucentral.schema.json -new/ucentral.schema.pretty.json new/docs/ -new/central.schema.json -new/ucentral.schema.pretty.json +schema.new/ucentral.schema.json +schema.new/ucentral.schema.pretty.json +schema.new/ucentral.state.pretty.json diff --git a/new/generate.sh b/new/generate.sh deleted file mode 100755 index 8467110..0000000 --- a/new/generate.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -./merge-schema.py -mkdir -p docs -generate-schema-doc --config expand_buttons=true ucentral.schema.pretty.json docs/ucentral-schema.html diff --git a/new/config-raw.yml b/schema.new/config/config-raw.yml similarity index 100% rename from new/config-raw.yml rename to schema.new/config/config-raw.yml diff --git a/new/definitions.yml b/schema.new/config/definitions.yml similarity index 100% rename from new/definitions.yml rename to schema.new/config/definitions.yml diff --git a/new/globals.yml b/schema.new/config/globals.yml similarity index 100% rename from new/globals.yml rename to schema.new/config/globals.yml diff --git a/new/interface.bridge.yml b/schema.new/config/interface.bridge.yml similarity index 100% rename from new/interface.bridge.yml rename to schema.new/config/interface.bridge.yml diff --git a/new/interface.ethernet.yml b/schema.new/config/interface.ethernet.yml similarity index 100% rename from new/interface.ethernet.yml rename to schema.new/config/interface.ethernet.yml diff --git a/new/interface.ipv4.dhcp-lease.yml b/schema.new/config/interface.ipv4.dhcp-lease.yml similarity index 100% rename from new/interface.ipv4.dhcp-lease.yml rename to schema.new/config/interface.ipv4.dhcp-lease.yml diff --git a/new/interface.ipv4.yml b/schema.new/config/interface.ipv4.yml similarity index 100% rename from new/interface.ipv4.yml rename to schema.new/config/interface.ipv4.yml diff --git a/new/interface.ssid.captive.yml b/schema.new/config/interface.ssid.captive.yml similarity index 100% rename from new/interface.ssid.captive.yml rename to schema.new/config/interface.ssid.captive.yml diff --git a/new/interface.ssid.encryption.yml b/schema.new/config/interface.ssid.encryption.yml similarity index 100% rename from new/interface.ssid.encryption.yml rename to schema.new/config/interface.ssid.encryption.yml diff --git a/new/interface.ssid.pass-point.yml b/schema.new/config/interface.ssid.pass-point.yml similarity index 100% rename from new/interface.ssid.pass-point.yml rename to schema.new/config/interface.ssid.pass-point.yml diff --git a/new/interface.ssid.radius.local-user.yml b/schema.new/config/interface.ssid.radius.local-user.yml similarity index 100% rename from new/interface.ssid.radius.local-user.yml rename to schema.new/config/interface.ssid.radius.local-user.yml diff --git a/new/interface.ssid.radius.server.yml b/schema.new/config/interface.ssid.radius.server.yml similarity index 100% rename from new/interface.ssid.radius.server.yml rename to schema.new/config/interface.ssid.radius.server.yml diff --git a/new/interface.ssid.radius.yml b/schema.new/config/interface.ssid.radius.yml similarity index 100% rename from new/interface.ssid.radius.yml rename to schema.new/config/interface.ssid.radius.yml diff --git a/new/interface.ssid.rate-limit.yml b/schema.new/config/interface.ssid.rate-limit.yml similarity index 100% rename from new/interface.ssid.rate-limit.yml rename to schema.new/config/interface.ssid.rate-limit.yml diff --git a/new/interface.ssid.rates.yml b/schema.new/config/interface.ssid.rates.yml similarity index 100% rename from new/interface.ssid.rates.yml rename to schema.new/config/interface.ssid.rates.yml diff --git a/new/interface.ssid.roaming.yml b/schema.new/config/interface.ssid.roaming.yml similarity index 100% rename from new/interface.ssid.roaming.yml rename to schema.new/config/interface.ssid.roaming.yml diff --git a/new/interface.ssid.rrm.yml b/schema.new/config/interface.ssid.rrm.yml similarity index 100% rename from new/interface.ssid.rrm.yml rename to schema.new/config/interface.ssid.rrm.yml diff --git a/new/interface.ssid.yml b/schema.new/config/interface.ssid.yml similarity index 100% rename from new/interface.ssid.yml rename to schema.new/config/interface.ssid.yml diff --git a/new/interface.vlan.yml b/schema.new/config/interface.vlan.yml similarity index 100% rename from new/interface.vlan.yml rename to schema.new/config/interface.vlan.yml diff --git a/new/interface.yml b/schema.new/config/interface.yml similarity index 100% rename from new/interface.yml rename to schema.new/config/interface.yml diff --git a/new/metrics.yml b/schema.new/config/metrics.yml similarity index 100% rename from new/metrics.yml rename to schema.new/config/metrics.yml diff --git a/new/radio.he.yml b/schema.new/config/radio.he.yml similarity index 100% rename from new/radio.he.yml rename to schema.new/config/radio.he.yml diff --git a/new/radio.yml b/schema.new/config/radio.yml similarity index 100% rename from new/radio.yml rename to schema.new/config/radio.yml diff --git a/new/service.lldp.yml b/schema.new/config/service.lldp.yml similarity index 100% rename from new/service.lldp.yml rename to schema.new/config/service.lldp.yml diff --git a/new/service.log.yml b/schema.new/config/service.log.yml similarity index 100% rename from new/service.log.yml rename to schema.new/config/service.log.yml diff --git a/new/service.mdns.yml b/schema.new/config/service.mdns.yml similarity index 100% rename from new/service.mdns.yml rename to schema.new/config/service.mdns.yml diff --git a/new/service.ntp.yml b/schema.new/config/service.ntp.yml similarity index 100% rename from new/service.ntp.yml rename to schema.new/config/service.ntp.yml diff --git a/new/service.rtty.yml b/schema.new/config/service.rtty.yml similarity index 100% rename from new/service.rtty.yml rename to schema.new/config/service.rtty.yml diff --git a/new/service.ssh.yml b/schema.new/config/service.ssh.yml similarity index 100% rename from new/service.ssh.yml rename to schema.new/config/service.ssh.yml diff --git a/new/service.wifi-steering.yml b/schema.new/config/service.wifi-steering.yml similarity index 100% rename from new/service.wifi-steering.yml rename to schema.new/config/service.wifi-steering.yml diff --git a/new/service.yml b/schema.new/config/service.yml similarity index 100% rename from new/service.yml rename to schema.new/config/service.yml diff --git a/new/ucentral.yml b/schema.new/config/ucentral.yml similarity index 100% rename from new/ucentral.yml rename to schema.new/config/ucentral.yml diff --git a/new/unit.yml b/schema.new/config/unit.yml similarity index 100% rename from new/unit.yml rename to schema.new/config/unit.yml diff --git a/new/generate-example.uc b/schema.new/generate-example.uc similarity index 100% rename from new/generate-example.uc rename to schema.new/generate-example.uc diff --git a/new/generate-reader.uc b/schema.new/generate-reader.uc similarity index 100% rename from new/generate-reader.uc rename to schema.new/generate-reader.uc diff --git a/schema.new/generate.sh b/schema.new/generate.sh new file mode 100755 index 0000000..c05be1b --- /dev/null +++ b/schema.new/generate.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +./merge-schema.py schema config ucentral.yml ucentral.schema.json 1 +./merge-schema.py schema config ucentral.yml ucentral.schema.pretty.json 0 +./merge-schema.py state state state.yml ucentral.state.pretty.json 0 +mkdir -p docs +generate-schema-doc --config expand_buttons=true ucentral.schema.pretty.json docs/ucentral-schema.html +generate-schema-doc --config expand_buttons=true ucentral.state.pretty.json docs/ucentral-state.html diff --git a/new/merge-schema.py b/schema.new/merge-schema.py similarity index 74% rename from new/merge-schema.py rename to schema.new/merge-schema.py index e049916..6a12c1a 100755 --- a/new/merge-schema.py +++ b/schema.new/merge-schema.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 +import sys import yaml import json @@ -9,11 +10,12 @@ def schema_filename(list): return file[0].replace("/", ".") + "yml" def entity_name(uri): - name = uri.replace("https://ucentral.io/schema/v1/", "").rstrip("/") + name = uri.replace("https://ucentral.io/" + sys.argv[1] + "/v1/", "").rstrip("/") return name.replace("/", ".") def schema_load(filename): - with open(filename) as stream: + print(sys.argv[2] + "/" + filename) + with open(sys.argv[2] + "/" + filename) as stream: try: schema = yaml.safe_load(stream) return schema @@ -38,12 +40,15 @@ def schema_compile(input, output, definitions, tiny): output[k] = input[k] return output -def schema_generate(filename, tiny): - with open(filename, 'w') as outfile: +def schema_generate(): + with open(sys.argv[4], 'w') as outfile: + tiny = int(sys.argv[5]) defs = {} - schema = schema_compile(schema_load("ucentral.yml"), {}, defs, tiny) + schema = schema_compile(schema_load(sys.argv[3]), {}, defs, tiny) schema["definitions"] = defs json.dump(schema, outfile, ensure_ascii = tiny and False or True, indent = tiny and 0 or 4) -schema_generate('ucentral.schema.json', 1) -schema_generate('ucentral.schema.pretty.json', 0) +if len(sys.argv) != 6: + raise Exception("Invalid parameters"); + +schema_generate() diff --git a/schema.new/state/interface.clients.yml b/schema.new/state/interface.clients.yml new file mode 100644 index 0000000..b3fde41 --- /dev/null +++ b/schema.new/state/interface.clients.yml @@ -0,0 +1,30 @@ +type: array +items: + type: object + description: + An explanation about the purpose of this instance. + properties: + ipv4_addresses: + type: array + description: + An explanation about the purpose of this + items: + type: string + ipv6_addresses: + type: array + description: + An explanation about the purpose of this + items: + type: string + mac: + type: string + description: + An explanation about the purpose of this + ports: + type: array + description: + An explanation about the purpose of this + items: + description: + An explanation about the purpose + type: string diff --git a/schema.new/state/interface.counter.yml b/schema.new/state/interface.counter.yml new file mode 100644 index 0000000..01f94c4 --- /dev/null +++ b/schema.new/state/interface.counter.yml @@ -0,0 +1,41 @@ +type: object +description: + This section contains the traffic counters of the logical interface. Entries + that have a value of 0 will not be included. +properties: + collisions: + type: number + multicast: + type: number + rx_bytes: + type: number + description: + The number of bytes received. + rx_packets: + type: number + description: + The number of packets received. + rx_error: + type: number + description: + The number of receive errors. + rx_dropped: + type: number + description: + The number of received packets that were dropped. + tx_bytes: + type: number + description: + The number of bytes transmitted. + tx_packets: + type: number + description: + The number of packets transmitted. + tx_error: + type: number + description: + The number of transmit errors. + tx_dropped: + type: number + description: + The number of transmitted packets that were dropped. diff --git a/schema.new/state/interface.ipv4-address.yml b/schema.new/state/interface.ipv4-address.yml new file mode 100644 index 0000000..9f1727a --- /dev/null +++ b/schema.new/state/interface.ipv4-address.yml @@ -0,0 +1,7 @@ +type: array +description: + The list of IPv4 addresses being used by this logical interface. +items: + type: string + description: + An IPv4 addreess. diff --git a/schema.new/state/interface.ipv4-lease.yml b/schema.new/state/interface.ipv4-lease.yml new file mode 100644 index 0000000..b737d57 --- /dev/null +++ b/schema.new/state/interface.ipv4-lease.yml @@ -0,0 +1,22 @@ +type: array +items: + type: object + description: + This section describes an IPv4 lease that we have served + properties: + address: + type: string + description: + The IPv4 that has been assigned to the networking client. + assigned: + type: string + description: + The unix time stamp when this lease was assigned. + hostname: + type: string + description: + The hostname that the client included in his request. + mac: + type: string + description: + The MAC address of the client that this lease was assigned to. diff --git a/schema.new/state/interface.ipv6-address.yml b/schema.new/state/interface.ipv6-address.yml new file mode 100644 index 0000000..08bb5b1 --- /dev/null +++ b/schema.new/state/interface.ipv6-address.yml @@ -0,0 +1,12 @@ +type: array +items: + type: object + description: + An IPv6 address assigned to this logical interface. + properties: + address: + type: string + description: The actual IPv6 address/mask + valid: + type: number + description: How much longer this delegation is valid for. diff --git a/schema.new/state/interface.ipv6-lease.yml b/schema.new/state/interface.ipv6-lease.yml new file mode 100644 index 0000000..118825c --- /dev/null +++ b/schema.new/state/interface.ipv6-lease.yml @@ -0,0 +1,17 @@ +type: array +description: +items: + type: object + description: + This section describes an IPv6 lease that we have served. + properties: + addresses: + type: array + description: + A list of all IPv6 addresses that were assigned to this host. + items: + type: string + hostname: + type: string + description: + The hostname that the client sent in its solicit message. diff --git a/schema.new/state/interface.lldp.yml b/schema.new/state/interface.lldp.yml new file mode 100644 index 0000000..afd7db5 --- /dev/null +++ b/schema.new/state/interface.lldp.yml @@ -0,0 +1,30 @@ +type: array +items: + type: object + description: + A list of all LLDP peers that this logical interface is connected to. + properties: + capability: + type: array + description: + The device capabilities that our neighbour is announcing. + items: + type: string + description: + type: string + description: + The chassis description that our neighbour is announcing. + id: + type: string + description: + The chassis ID/MAC that our neighbour is announcing. + management_ips: + type: array + description: + The management IPs that our neighbour is announcing. + items: + type: string + port: + type: string + description: + The physical network port that we see this neighbour on. diff --git a/schema.new/state/interface.ssid.association.yml b/schema.new/state/interface.ssid.association.yml new file mode 100644 index 0000000..c02a8d4 --- /dev/null +++ b/schema.new/state/interface.ssid.association.yml @@ -0,0 +1,36 @@ +type: array +description: + A list all OBSS that this BSS is connected to. The contained entries + depend opertational mode. + * AP - all associated stationd + * STA - the remote AP + * mesh - all mesh peers that we can see + * wds - the remote wds peer +items: + description: An explanation about the purpose + of this instance. + properties: + bssid: + type: string + description: + The BSSID of the remote BSS. + rssi: + type: number + description: + The RX signal strength of the remore BSS. (dBm) + rx_bytes: + type: number + description: + The number of bytes received. + rx_packets: + type: number + description: + The number of packets received. + tx_bytes: + type: number + description: + The number of bytes transmitted. + tx_failed: + type: number + description: + The number of packets transmitted. diff --git a/schema.new/state/interface.ssid.yml b/schema.new/state/interface.ssid.yml new file mode 100644 index 0000000..1e1e09a --- /dev/null +++ b/schema.new/state/interface.ssid.yml @@ -0,0 +1,34 @@ +type: array +items: + type: object + description: + This section contains the current state of a SSID being brodcasted or + connected to by this device. + properties: + bssid: + type: string + description: + The BSSID used by this BSS instance. + ssid: + type: string + description: + The SSID that we are broadcasting or connecting to. + mode: + type: string + description: + The operational mode of the BSS. + enum: + - ap + - sta + - mesh + - wds + radio: + type: object + description: + A reference to the section describing the physical radio within this + document. (#/radios/X) + properties: + ref: + type: string + associations: + $ref: "https://ucentral.io/state/v1/interface/ssid/association/" diff --git a/schema.new/state/interface.yml b/schema.new/state/interface.yml new file mode 100644 index 0000000..67ee643 --- /dev/null +++ b/schema.new/state/interface.yml @@ -0,0 +1,45 @@ +type: array +description: + An array containing the runtime state of all logical interfaces.items: +items: + type: object + properties: + uptime: + type: number + description: + The number of seconds since the interface was brought up. + name: + type: string + description: + The administrative name of this logical interface. This field is + freetext + ntp_server: + type: string + description: + The upstream NTP server being used by this interface. + ipv4_leasetime: + type: number + description: + This is the leasetime if the IPv4 address of this logical interface was + acquired via DHCPv4. + dns_servers: + type: array + description: + The list of remote DNS servers that this logical interface uses for + domain name resolution. + items: + type: string + ipv4_addresses: + $ref: "https://ucentral.io/state/v1/interface/ipv4-address/" + ipv4_leases: + $ref: "https://ucentral.io/state/v1/interface/ipv4-lease/" + ipv6_addresses: + $ref: "https://ucentral.io/state/v1/interface/ipv6-address/" + ipv6_leases: + $ref: "https://ucentral.io/state/v1/interface/ipv6-lease/" + counters: + $ref: "https://ucentral.io/state/v1/interface/counter/" + ssids: + $ref: "https://ucentral.io/state/v1/interface/ssid/" + lldp_neighbours: + $ref: "https://ucentral.io/state/v1/interface/lldp/" diff --git a/schema.new/state/radio.yml b/schema.new/state/radio.yml new file mode 100644 index 0000000..369e9f7 --- /dev/null +++ b/schema.new/state/radio.yml @@ -0,0 +1,28 @@ +type: array +description: + An array containing the current operational state of all wifi radios that the + unit has. +items: + type: object + properties: + channel_width: + type: number + description: + The channel width currently being used. + enum: + - 20 + - 40 + - 80 + - 160 + - 320 + frequencies: + type: array + description: + The list of channels frquencies, that the unit is currently operating + on. Anything other than 20MHz will list several frequencies here. + items: + type: number + tx_power: + type: number + description: + The currently configure TX power of the radio in dBm. diff --git a/schema.new/state/state.yml b/schema.new/state/state.yml new file mode 100644 index 0000000..e73936c --- /dev/null +++ b/schema.new/state/state.yml @@ -0,0 +1,11 @@ +$id: https://openwrt.org/ucentral.state.json +$schema: http://json-schema.org/draft-07/schema# +description: OpenWrt uCentral state schema +type: object +properties: + unit: + $ref: "https://ucentral.io/state/v1/unit/" + radios: + $ref: "https://ucentral.io/state/v1/radio/" + interfaces: + $ref: "https://ucentral.io/state/v1/interface/" diff --git a/schema.new/state/unit.yml b/schema.new/state/unit.yml new file mode 100644 index 0000000..7516a54 --- /dev/null +++ b/schema.new/state/unit.yml @@ -0,0 +1,32 @@ +type: object +description: + This section describes the current state of the OS running on the device. +properties: + load: + type: array + description: + This array hold 3 values describing the average system load for the last + 1, 5 and 15 minutes. + items: + type: number + localtime: + type: number + description: + This property contains the current unix time of the device. + memory: + type: object + description: + This section describes the current memory uasge of the device. + properties: + free: + type: number + description: + The amount of free memory. + total: + type: number + description: + The total amount of memory. + uptime: + type: number + description: + The number of seconds since the unit last booted..