diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..44b38f7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +# OS X Finder Files +.DS_Store + +# Local Setup Scripts for Repo +local_helper_scripts/* diff --git a/DataLoader.json b/DataLoader.json new file mode 100644 index 0000000..93738ed --- /dev/null +++ b/DataLoader.json @@ -0,0 +1,54 @@ +{ + "fabric": { + "eventTypes": [ + "equinix.fabric.connection.attribute.changed", + "equinix.fabric.connection.bgpipv4_session_status.connect", + "equinix.fabric.connection.bgpipv4_session_status.established", + "equinix.fabric.connection.bgpipv4_session_status.idle", + "equinix.fabric.connection.bgpipv6_session_status.connect", + "equinix.fabric.connection.bgpipv6_session_status.established", + "equinix.fabric.connection.bgpipv6_session_status.idle", + "equinix.fabric.connection.state.deprovisioned", + "equinix.fabric.connection.state.deprovisioning", + "equinix.fabric.connection.state.pending", + "equinix.fabric.connection.state.pending_approval", + "equinix.fabric.connection.state.pending_interface_configuration", + "equinix.fabric.connection.state.provisioned", + "equinix.fabric.connection.state.provisioning", + "equinix.fabric.connection.status.down", + "equinix.fabric.connection.status.up", + "equinix.fabric.metric", + "equinix.fabric.network.state.deprovisioned", + "equinix.fabric.network.state.deprovisioning", + "equinix.fabric.network.state.provisioned", + "equinix.fabric.network.state.provisioning", + "equinix.fabric.port.state.deprovisioned", + "equinix.fabric.port.state.failed", + "equinix.fabric.port.state.provisioned", + "equinix.fabric.port.status.down", + "equinix.fabric.port.status.up", + "equinix.fabric.router.state.deprovisioned", + "equinix.fabric.router.state.deprovisioning", + "equinix.fabric.router.state.failed", + "equinix.fabric.router.state.not_deprovisioned", + "equinix.fabric.router.state.not_provisioned", + "equinix.fabric.router.state.provisioned", + "equinix.fabric.router.state.provisioning", + "equinix.fabric.router.state.reprovisioning", + "equinix.fabric.service_token.attribute.changed", + "equinix.fabric.service_token.state.deleted", + "equinix.fabric.service_token.state.inactive" + ], + "metricNames": [ + "equinix.fabric.connection.bandwidth_rx.usage", + "equinix.fabric.connection.bandwidth_tx.usage", + "equinix.fabric.metro.{:asideMetroCode}_{:zsideMetroCode}.latency", + "equinix.fabric.port.bandwidth_rx.usage", + "equinix.fabric.port.bandwidth_tx.usage", + "equinix.fabric.port.packets_dropped_rx.count", + "equinix.fabric.port.packets_dropped_tx.count", + "equinix.fabric.port.packets_erred_rx.count", + "equinix.fabric.port.packets_erred_tx.count" + ] + } +} diff --git a/README.md b/README.md index 17d324d..ed72b9f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,19 @@ # cloud-events -Equinix published CloudEvents Types + +Equinix published [CloudEvent](https://cloudevents.io/) Types + +Definitive "source of truth" for the Equinix Observability event data formats + +## CloudEvents in this repository + +The following data payloads are the supported events and formats for Equinix Observability + + + +|Product|Schemas|Types| +|Equinix Fabric ChangeAlert|[JSON](https://equinix.github.io/equinix-cloudevents/jsonschema/equinix/events/fabric/v1/ChangeAlert.json)|
Data Type:
`equinix.events.fabric.v1.ChangeAlert`
CloudEvent Type(s):

| +|Equinix Fabric ChangeEvent|[JSON](https://equinix.github.io/equinix-cloudevents/jsonschema/equinix/events/fabric/v1/ChangeEvent.json)|
Data Type:
`equinix.events.fabric.v1.ChangeEvent`
CloudEvent Type(s):
`equinix.fabric.router.state.provisioning`
`equinix.fabric.router.state.provisioned`
`equinix.fabric.router.state.reprovisioning`
`equinix.fabric.router.state.deprovisioning`
`equinix.fabric.router.state.deprovisioned`
`equinix.fabric.router.state.failed`
`equinix.fabric.router.state.not_provisioned`
`equinix.fabric.router.state.not_deprovisioned`
`equinix.fabric.port.state.provisioned`
`equinix.fabric.port.state.deprovisioned`
`equinix.fabric.port.state.failed`
`equinix.fabric.port.status.up`
`equinix.fabric.port.status.down`
`equinix.fabric.service_token.state.inactive`
`equinix.fabric.service_token.state.deleted`
`equinix.fabric.service_token.attribute.changed`
`equinix.fabric.connection.state.pending`
`equinix.fabric.connection.state.pending_interface_configuration`
`equinix.fabric.connection.state.provisioning`
`equinix.fabric.connection.state.provisioned`
`equinix.fabric.connection.state.deprovisioning`
`equinix.fabric.connection.state.deprovisioned`
`equinix.fabric.connection.state.pending_approval`
`equinix.fabric.connection.attribute.changed`
`equinix.fabric.connection.status.up`
`equinix.fabric.connection.status.down`
`equinix.fabric.connection.bgpipv4_session_status.established`
`equinix.fabric.connection.bgpipv4_session_status.idle`
`equinix.fabric.connection.bgpipv4_session_status.connect`
`equinix.fabric.connection.bgpipv6_session_status.established`
`equinix.fabric.connection.bgpipv6_session_status.idle`
`equinix.fabric.connection.bgpipv6_session_status.connect`
`equinix.fabric.network.state.provisioning`
`equinix.fabric.network.state.provisioned`
`equinix.fabric.network.state.deprovisioning`
`equinix.fabric.network.state.deprovisioned`
| +|Equinix Fabric MetricAlert|[JSON](https://equinix.github.io/equinix-cloudevents/jsonschema/equinix/events/fabric/v1/MetricAlert.json)|
Data Type:
`equinix.events.fabric.v1.MetricAlert`
CloudEvent Type(s):

| +|Equinix Fabric MetricEvent|[JSON](https://equinix.github.io/equinix-cloudevents/jsonschema/equinix/events/fabric/v1/MetricEvent.json)|
Data Type:
`equinix.events.fabric.v1.MetricEvent`
CloudEvent Type(s):
`equinix.fabric.metric`

Metric Type(s):
`equinix.fabric.port.packets_erred_rx.count`
`equinix.fabric.port.packets_erred_tx.count`
`equinix.fabric.port.packets_dropped_rx.count`
`equinix.fabric.port.packets_dropped_tx.count`
`equinix.fabric.metro.{:asideMetroCode}_{:zsideMetroCode}.latency`
`equinix.fabric.connection.bandwidth_rx.usage`
`equinix.fabric.connection.bandwidth_tx.usage`
`equinix.fabric.port.bandwidth_rx.usage`
`equinix.fabric.port.bandwidth_tx.usage`| + + diff --git a/jsonschema/catalog.json b/jsonschema/catalog.json index 81c607e..f303b6a 100644 --- a/jsonschema/catalog.json +++ b/jsonschema/catalog.json @@ -1,3 +1,88 @@ { - "events": "Details of events to be published on github webpages." -} \ No newline at end of file + "$schema": "https://json.schemastore.org/schema-catalog", + "version": 1, + "schemas": [ + { + "url": "https://equinix.github.io/equinix-cloudevents/jsonschema/equinix/events/fabric/v1/ChangeAlert.json", + "product": "Equinix Fabric ChangeAlert", + "name": "ChangeAlert", + "description": "The data within all ChangeAlert events.", + "datatype": "equinix.events.fabric.v1.ChangeAlert", + "cloudeventTypes": [] + }, + { + "url": "https://equinix.github.io/equinix-cloudevents/jsonschema/equinix/events/fabric/v1/ChangeEvent.json", + "product": "Equinix Fabric ChangeEvent", + "name": "ChangeEvent", + "description": "The data within all ChangeEvent events.", + "datatype": "equinix.events.fabric.v1.ChangeEvent", + "cloudeventTypes": [ + "equinix.fabric.router.state.provisioning", + "equinix.fabric.router.state.provisioned", + "equinix.fabric.router.state.reprovisioning", + "equinix.fabric.router.state.deprovisioning", + "equinix.fabric.router.state.deprovisioned", + "equinix.fabric.router.state.failed", + "equinix.fabric.router.state.not_provisioned", + "equinix.fabric.router.state.not_deprovisioned", + "equinix.fabric.port.state.provisioned", + "equinix.fabric.port.state.deprovisioned", + "equinix.fabric.port.state.failed", + "equinix.fabric.port.status.up", + "equinix.fabric.port.status.down", + "equinix.fabric.service_token.state.inactive", + "equinix.fabric.service_token.state.deleted", + "equinix.fabric.service_token.attribute.changed", + "equinix.fabric.connection.state.pending", + "equinix.fabric.connection.state.pending_interface_configuration", + "equinix.fabric.connection.state.provisioning", + "equinix.fabric.connection.state.provisioned", + "equinix.fabric.connection.state.deprovisioning", + "equinix.fabric.connection.state.deprovisioned", + "equinix.fabric.connection.state.pending_approval", + "equinix.fabric.connection.attribute.changed", + "equinix.fabric.connection.status.up", + "equinix.fabric.connection.status.down", + "equinix.fabric.connection.bgpipv4_session_status.established", + "equinix.fabric.connection.bgpipv4_session_status.idle", + "equinix.fabric.connection.bgpipv4_session_status.connect", + "equinix.fabric.connection.bgpipv6_session_status.established", + "equinix.fabric.connection.bgpipv6_session_status.idle", + "equinix.fabric.connection.bgpipv6_session_status.connect", + "equinix.fabric.network.state.provisioning", + "equinix.fabric.network.state.provisioned", + "equinix.fabric.network.state.deprovisioning", + "equinix.fabric.network.state.deprovisioned" + ] + }, + { + "url": "https://equinix.github.io/equinix-cloudevents/jsonschema/equinix/events/fabric/v1/MetricAlert.json", + "product": "Equinix Fabric MetricAlert", + "name": "MetricAlert", + "description": "The data within all MetricAlert events.", + "datatype": "equinix.events.fabric.v1.MetricAlert", + "cloudeventTypes": [] + }, + { + "url": "https://equinix.github.io/equinix-cloudevents/jsonschema/equinix/events/fabric/v1/MetricEvent.json", + "product": "Equinix Fabric MetricEvent", + "name": "MetricEvent", + "description": "The data within all MetricEvent events.", + "datatype": "equinix.events.fabric.v1.MetricEvent", + "cloudeventTypes": [ + "equinix.fabric.metric" + ], + "metricNames": [ + "equinix.fabric.port.packets_erred_rx.count", + "equinix.fabric.port.packets_erred_tx.count", + "equinix.fabric.port.packets_dropped_rx.count", + "equinix.fabric.port.packets_dropped_tx.count", + "equinix.fabric.metro.{:asideMetroCode}_{:zsideMetroCode}.latency", + "equinix.fabric.connection.bandwidth_rx.usage", + "equinix.fabric.connection.bandwidth_tx.usage", + "equinix.fabric.port.bandwidth_rx.usage", + "equinix.fabric.port.bandwidth_tx.usage" + ] + } + ] +} diff --git a/jsonschema/equinix/events/fabric/connections/ConnectionStatusEventData.json b/jsonschema/equinix/events/fabric/connections/ConnectionStatusEventData.json deleted file mode 100644 index c5e4d22..0000000 --- a/jsonschema/equinix/events/fabric/connections/ConnectionStatusEventData.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "empty": "To be populated" -} \ No newline at end of file diff --git a/jsonschema/equinix/events/fabric/v1/ChangeAlert.json b/jsonschema/equinix/events/fabric/v1/ChangeAlert.json new file mode 100644 index 0000000..3175b44 --- /dev/null +++ b/jsonschema/equinix/events/fabric/v1/ChangeAlert.json @@ -0,0 +1,155 @@ +{ + "$id": "https://equinix.github.io/equinix-cloudevents/jsonschema/equinix/events/fabric/v1/ChangeAlert.json", + "name": "ChangeAlert", + "examples": [], + "package": "equinix.events.fabric.v1", + "datatype": "equinix.events.fabric.v1.ChangeAlert", + "cloudeventTypes": [], + "product": "Equinix Fabric ChangeAlert", + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/Data", + "definitions": { + "Data": { + "properties": { + "resource": { + "$ref": "#/definitions/Resource", + "additionalProperties": true, + "description": "Optional. The Backup event payload. Unset for deletion events." + }, + "alertRule": { + "type": "object", + "items": { + "$ref": "#/definitions/AlertRule", + "additionalProperties": true + }, + "description": "Metadata about the AlertRule triggering the Alert" + }, + "message": { + "type": "string", + "description": "Supporting message describing the event" + } + }, + "additionalProperties": true, + "type": "object", + "title": "ChangeAlert Event Data", + "description": "The data within all ChangeAlert events." + }, + "Resource": { + "properties": { + "href": { + "type": "string", + "description": "Link to the resource that has generated the event" + }, + "type": { + "type": "string", + "description": "Type of the resource generating the event" + }, + "uuid": { + "type": "string", + "description": "Equinix assigned unique identifier of the resource generating the event" + }, + "name": { + "type": "string", + "description": "Name of the resource generating the event" + }, + "state": { + "type": "string", + "description": "State of the resource generating the event" + }, + "description": { + "type": "string", + "description": "Description of the resource generating the event" + }, + "change": { + "$ref": "#/definitions/Change", + "additionalProperties": true, + "description": "Change information for the resource that fired the event" + } + }, + "additionalProperties": true, + "type": "object", + "title": "Resource", + "description": "Schema of the resource that fired the event" + }, + "AlertRule": { + "properties": { + "href": { + "type": "string", + "description": "Link to the resource that has generated the alert" + }, + "type": { + "type": "string", + "description": "Type of the resource generating the alert" + }, + "uuid": { + "type": "string", + "description": "Equinix assigned unique identifier of the resource generating the alert" + }, + "name": { + "type": "string", + "description": "Name of the resource generating the event" + } + }, + "additionalProperties": true, + "type": "object", + "title": "AlertRule", + "description": "Schema definition of AlertRule data" + }, + "Change": { + "properties": { + "uuid": { + "type": "string", + "description": "Uuid of the of change for the resource target of the event" + }, + "type": { + "type": "string", + "description": "Type of the change happening on the resource for the target of the event" + }, + "status": { + "type": "string", + "description": "Status of the change event on the resource target" + }, + "createdDateTime": { + "type": "string", + "description": "The time that the resource that fired the event was created", + "format": "date-time" + }, + "data": { + "type": "array", + "description": "Data of the change event", + "items": { + "$ref": "#/definitions/ChangeData" + } + } + }, + "additionalProperties": true, + "type": "object", + "title": "Change", + "description": "Change attribute schema" + }, + "ChangeData": { + "properties": { + "op": { + "type": "string", + "description": "The operation performed on the resource under change" + }, + "path": { + "type": "string", + "description": "The attribute on the resource being changed" + }, + "value": { + "type": "string", + "description": "The current value of the attribute under change" + }, + "previousValue": { + "type": "string", + "description": "The previous value of the attribute under change" + } + }, + "additionalProperties": true, + "type": "object", + "title": "ChangeData", + "description": "ChangeData attribute schema" + } + } +} diff --git a/jsonschema/equinix/events/fabric/v1/ChangeEvent.json b/jsonschema/equinix/events/fabric/v1/ChangeEvent.json new file mode 100644 index 0000000..ecc3f7f --- /dev/null +++ b/jsonschema/equinix/events/fabric/v1/ChangeEvent.json @@ -0,0 +1,160 @@ +{ + "$id": "https://equinix.github.io/equinix-cloudevents/jsonschema/equinix/events/fabric/v1/ChangeEvent.json", + "name": "ChangeEvent", + "examples": [], + "package": "equinix.events.fabric.v1", + "datatype": "equinix.events.fabric.v1.ChangeEvent", + "cloudeventTypes": [ + "equinix.fabric.router.state.provisioning", + "equinix.fabric.router.state.provisioned", + "equinix.fabric.router.state.reprovisioning", + "equinix.fabric.router.state.deprovisioning", + "equinix.fabric.router.state.deprovisioned", + "equinix.fabric.router.state.failed", + "equinix.fabric.router.state.not_provisioned", + "equinix.fabric.router.state.not_deprovisioned", + "equinix.fabric.port.state.provisioned", + "equinix.fabric.port.state.deprovisioned", + "equinix.fabric.port.state.failed", + "equinix.fabric.port.status.up", + "equinix.fabric.port.status.down", + "equinix.fabric.service_token.state.inactive", + "equinix.fabric.service_token.state.deleted", + "equinix.fabric.service_token.attribute.changed", + "equinix.fabric.connection.state.pending", + "equinix.fabric.connection.state.pending_interface_configuration", + "equinix.fabric.connection.state.provisioning", + "equinix.fabric.connection.state.provisioned", + "equinix.fabric.connection.state.deprovisioning", + "equinix.fabric.connection.state.deprovisioned", + "equinix.fabric.connection.state.pending_approval", + "equinix.fabric.connection.attribute.changed", + "equinix.fabric.connection.status.up", + "equinix.fabric.connection.status.down", + "equinix.fabric.connection.bgpipv4_session_status.established", + "equinix.fabric.connection.bgpipv4_session_status.idle", + "equinix.fabric.connection.bgpipv4_session_status.connect", + "equinix.fabric.connection.bgpipv6_session_status.established", + "equinix.fabric.connection.bgpipv6_session_status.idle", + "equinix.fabric.connection.bgpipv6_session_status.connect", + "equinix.fabric.network.state.provisioning", + "equinix.fabric.network.state.provisioned", + "equinix.fabric.network.state.deprovisioning", + "equinix.fabric.network.state.deprovisioned" + ], + "product": "Equinix Fabric ChangeEvent", + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/Data", + "definitions": { + "Data": { + "properties": { + "resource": { + "$ref": "#/definitions/Resource", + "additionalProperties": true, + "description": "Optional. The Backup event payload. Unset for deletion events." + }, + "message": { + "type": "string", + "description": "Supporting message describing the event" + } + }, + "additionalProperties": true, + "type": "object", + "title": "ChangeEvent Event Data", + "description": "The data within all ChangeEvent events." + }, + "Resource": { + "properties": { + "href": { + "type": "string", + "description": "Link to the resource that has generated the event" + }, + "type": { + "type": "string", + "description": "Type of the resource generating the event" + }, + "uuid": { + "type": "string", + "description": "Equinix assigned unique identifier of the resource generating the event" + }, + "name": { + "type": "string", + "description": "Name of the resource generating the event" + }, + "state": { + "type": "string", + "description": "State of the resource generating the event" + }, + "description": { + "type": "string", + "description": "Description of the resource generating the event" + }, + "change": { + "$ref": "#/definitions/Change", + "additionalProperties": true, + "description": "Change information for the resource that fired the event" + } + }, + "additionalProperties": true, + "type": "object", + "title": "Resource", + "description": "Schema of the resource that fired the event" + }, + "Change": { + "properties": { + "uuid": { + "type": "string", + "description": "Uuid of the of change for the resource target of the event" + }, + "type": { + "type": "string", + "description": "Type of the change happening on the resource for the target of the event" + }, + "status": { + "type": "string", + "description": "Status of the change event on the resource target" + }, + "createdDateTime": { + "type": "string", + "description": "The time that the resource that fired the event was created", + "format": "date-time" + }, + "data": { + "type": "array", + "description": "Data of the change event", + "items": { + "$ref": "#/definitions/ChangeData" + } + } + }, + "additionalProperties": true, + "type": "object", + "title": "Change", + "description": "Change attribute schema" + }, + "ChangeData": { + "properties": { + "op": { + "type": "string", + "description": "The operation performed on the resource under change" + }, + "path": { + "type": "string", + "description": "The attribute on the resource being changed" + }, + "value": { + "type": "string", + "description": "The current value of the attribute under change" + }, + "previousValue": { + "type": "string", + "description": "The previous value of the attribute under change" + } + }, + "additionalProperties": true, + "type": "object", + "title": "ChangeData", + "description": "ChangeData attribute schema" + } + } +} diff --git a/jsonschema/equinix/events/fabric/v1/MetricAlert.json b/jsonschema/equinix/events/fabric/v1/MetricAlert.json new file mode 100644 index 0000000..41c55ae --- /dev/null +++ b/jsonschema/equinix/events/fabric/v1/MetricAlert.json @@ -0,0 +1,154 @@ +{ + "$id": "https://equinix.github.io/equinix-cloudevents/jsonschema/equinix/events/fabric/v1/MetricAlert.json", + "name": "MetricAlert", + "examples": [], + "package": "equinix.events.fabric.v1", + "datatype": "equinix.events.fabric.v1.MetricAlert", + "cloudeventTypes": [], + "product": "Equinix Fabric MetricAlert", + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/Data", + "definitions": { + "Data": { + "properties": { + "resource": { + "$ref": "#/definitions/Resource", + "additionalProperties": true, + "description": "Optional. The Backup event payload. Unset for deletion events." + }, + "metrics": { + "type": "array", + "items": { + "$ref": "#/definitions/Metric", + "additionalProperties": true + }, + "description": "Specific details of the metric" + }, + "alertRule": { + "type": "object", + "items": { + "$ref": "#/definitions/AlertRule", + "additionalProperties": true + }, + "description": "Metadata about the AlertRule triggering the Alert" + }, + "message": { + "type": "string", + "description": "Supporting message describing the event" + } + }, + "additionalProperties": true, + "type": "object", + "title": "MetricAlert Event Data", + "description": "The data within all MetricAlert events." + }, + "Resource": { + "properties": { + "href": { + "type": "string", + "description": "Link to the resource that has generated the event" + }, + "type": { + "type": "string", + "description": "Type of the resource generating the event" + }, + "uuid": { + "type": "string", + "description": "Equinix assigned unique identifier of the resource generating the event" + }, + "name": { + "type": "string", + "description": "Name of the resource generating the event" + }, + "state": { + "type": "string", + "description": "State of the resource generating the event" + }, + "description": { + "type": "string", + "description": "Description of the resource generating the event" + } + }, + "additionalProperties": true, + "type": "object", + "title": "Resource", + "description": "Schema of the resource that fired the event" + }, + "Metric": { + "properties": { + "type": { + "type": "string", + "description": "The type of the metric" + }, + "name": { + "type": "string", + "description": "The name of the metric" + }, + "unit": { + "type": "string", + "description": "Unified Code for Units of Measure" + }, + "interval": { + "type": "string", + "description": "The time interval that the metric datapoints refer to" + }, + "dataPoints": { + "type": "array", + "description": "Metric data values and end times", + "items": { + "$ref": "#/definitions/DataPoint" + } + } + }, + "additionalProperties": true, + "type": "object", + "title": "Metrics", + "description": "Schema definition of Metrics data" + }, + "DataPoint": { + "properties": { + "startDateTime": { + "type": "string", + "description": "The start time of the metric data point value given", + "format": "date-time" + }, + "endDateTime": { + "type": "string", + "description": "The end time of the metric data point value given", + "format": "date-time" + }, + "value": { + "type": "number", + "description": "The value of the metric data point" + } + }, + "type": "object", + "title": "DataPoints", + "additionalProperties": true + }, + "AlertRule": { + "properties": { + "href": { + "type": "string", + "description": "Link to the resource that has generated the alert" + }, + "type": { + "type": "string", + "description": "Type of the resource generating the alert" + }, + "uuid": { + "type": "string", + "description": "Equinix assigned unique identifier of the resource generating the alert" + }, + "name": { + "type": "string", + "description": "Name of the resource generating the event" + } + }, + "additionalProperties": true, + "type": "object", + "title": "AlertRule", + "description": "Schema definition of AlertRule data" + } + } +} diff --git a/jsonschema/equinix/events/fabric/v1/MetricEvent.json b/jsonschema/equinix/events/fabric/v1/MetricEvent.json new file mode 100644 index 0000000..9c7f13c --- /dev/null +++ b/jsonschema/equinix/events/fabric/v1/MetricEvent.json @@ -0,0 +1,135 @@ +{ + "$id": "https://equinix.github.io/equinix-cloudevents/jsonschema/equinix/events/fabric/v1/MetricEvent.json", + "name": "MetricEvent", + "examples": [], + "package": "equinix.events.fabric.v1", + "datatype": "equinix.events.fabric.v1.MetricEvent", + "cloudeventTypes": [ + "equinix.fabric.metric" + ], + "product": "Equinix Fabric MetricEvent", + "$schema": "http://json-schema.org/draft-04/schema#", + "$ref": "#/definitions/Data", + "metricNames": [ + "equinix.fabric.port.packets_erred_rx.count", + "equinix.fabric.port.packets_erred_tx.count", + "equinix.fabric.port.packets_dropped_rx.count", + "equinix.fabric.port.packets_dropped_tx.count", + "equinix.fabric.metro.{:asideMetroCode}_{:zsideMetroCode}.latency", + "equinix.fabric.connection.bandwidth_rx.usage", + "equinix.fabric.connection.bandwidth_tx.usage", + "equinix.fabric.port.bandwidth_rx.usage", + "equinix.fabric.port.bandwidth_tx.usage" + ], + "definitions": { + "Data": { + "properties": { + "resource": { + "$ref": "#/definitions/Resource", + "additionalProperties": true, + "description": "Optional. The Backup event payload. Unset for deletion events." + }, + "metrics": { + "type": "array", + "items": { + "$ref": "#/definitions/Metric", + "additionalProperties": true + }, + "description": "Specific details of the metric" + }, + "message": { + "type": "string", + "description": "Supporting message describing the event" + } + }, + "additionalProperties": true, + "type": "object", + "title": "MetricEvent Event Data", + "description": "The data within all MetricEvent events." + }, + "Resource": { + "properties": { + "href": { + "type": "string", + "description": "Link to the resource that has generated the event" + }, + "type": { + "type": "string", + "description": "Type of the resource generating the event" + }, + "uuid": { + "type": "string", + "description": "Equinix assigned unique identifier of the resource generating the event" + }, + "name": { + "type": "string", + "description": "Name of the resource generating the event" + }, + "state": { + "type": "string", + "description": "State of the resource generating the event" + }, + "description": { + "type": "string", + "description": "Description of the resource generating the event" + } + }, + "additionalProperties": true, + "type": "object", + "title": "Resource", + "description": "Schema of the resource that fired the event" + }, + "Metric": { + "properties": { + "type": { + "type": "string", + "description": "The type of the metric" + }, + "name": { + "type": "string", + "description": "The name of the metric" + }, + "unit": { + "type": "string", + "description": "Unified Code for Units of Measure" + }, + "interval": { + "type": "string", + "description": "The time interval that the metric datapoints refer to" + }, + "dataPoints": { + "type": "array", + "description": "Metric data values and end times", + "items": { + "$ref": "#/definitions/DataPoint" + } + } + }, + "additionalProperties": true, + "type": "object", + "title": "Metrics", + "description": "Schema definition of Metrics data" + }, + "DataPoint": { + "properties": { + "startDateTime": { + "type": "string", + "description": "The start time of the metric data point value given", + "format": "date-time" + }, + "endDateTime": { + "type": "string", + "description": "The end time of the metric data point value given", + "format": "date-time" + }, + "value": { + "type": "number", + "description": "The value of the metric data point" + } + }, + "type": "object", + "title": "DataPoints", + "additionalProperties": true + } + } +} diff --git a/scripts/generate_json_catalog.py b/scripts/generate_json_catalog.py new file mode 100644 index 0000000..114f148 --- /dev/null +++ b/scripts/generate_json_catalog.py @@ -0,0 +1,39 @@ +import os +import json + +def retrieve_json_schemas(): + directory = os.path.dirname(os.path.abspath(__file__)) + '/../jsonschema' + json_schemas = [] + for root, dirs, files in os.walk(directory): + for file in files: + if file.endswith('.json') and file != "catalog.json": + with open(root + "/" + file, "r") as eventFile: + data = json.load(eventFile) + newItem = { + "url": data["$id"], + "product": data["product"], + "name": data["name"], + "description": data["definitions"]["Data"]["description"], + "datatype": data["datatype"], + "cloudeventTypes": data["cloudeventTypes"] + } + if "metricNames" in data: + newItem["metricNames"] = data["metricNames"] + json_schemas.append(newItem) + json_schemas.sort(key=lambda x: x["url"]) + return json_schemas + +def write_json_schemas_to_catalog_file(json_schemas): + catalog = { + "$schema": 'https://json.schemastore.org/schema-catalog', + "version": 1, + "schemas": json_schemas + } + with open(os.path.dirname(os.path.abspath(__file__)) + "/../jsonschema/catalog.json", "w") as catalogFile: + catalogFile.write(json.dumps(catalog, indent=4)) + catalogFile.write("\n") + + +if __name__ == "__main__": + json_schemas = retrieve_json_schemas() + write_json_schemas_to_catalog_file(json_schemas) \ No newline at end of file diff --git a/scripts/generate_readme_event_catalog.py b/scripts/generate_readme_event_catalog.py new file mode 100644 index 0000000..6cd05b9 --- /dev/null +++ b/scripts/generate_readme_event_catalog.py @@ -0,0 +1,38 @@ +import os +import json + +def table_row(schema): + cloudEventTypes = "
".join(map(lambda x: f"`{x}`", schema["cloudeventTypes"])) + metrics = "" + if "metricNames" in schema: + metricNames = "
".join(map(lambda x: f"`{x}`", schema["metricNames"])) + metrics = f"
Metric Type(s):
{metricNames}" + return f"|{schema["product"]}|[JSON]({schema["url"]})|
Data Type:
`{schema["datatype"]}`
CloudEvent Type(s):
{cloudEventTypes}
{metrics}|" + +def replace_readme_catalog(): + readme_path = os.path.dirname(os.path.abspath(__file__)) + "/../README.md" + catalog_path = os.path.dirname(os.path.abspath(__file__)) + "/../jsonschema/catalog.json" + with open(catalog_path, "r") as catalog_file: + catalog = json.load(catalog_file) + schemas = "\n".join(map(table_row, catalog["schemas"])) + + replacement_readme_catalog = f""" +|Product|Schemas|Types| +{schemas} +""" + + with open(readme_path, "r+") as readme_file: + content = readme_file.read() + readme_file.seek(0) + generation_start = "" + generation_end = "" + header = content[:content.index(generation_start)+len(generation_start)] + footer = content[content.index(generation_end):] + readme_file.write(f"""{header} +{replacement_readme_catalog} +{footer}""") + readme_file.truncate() + + +if __name__ == "__main__": + replace_readme_catalog() \ No newline at end of file diff --git a/scripts/update_data_loader.py b/scripts/update_data_loader.py new file mode 100644 index 0000000..570d1e4 --- /dev/null +++ b/scripts/update_data_loader.py @@ -0,0 +1,35 @@ +import os +import json +from collections import defaultdict + +def retrieve_supported_events(): + directory = os.path.dirname(os.path.abspath(__file__)) + '/../jsonschema' + dataLoaderStructure = {} + for root, dirs, files in os.walk(directory): + for file in files: + if file.endswith('.json') and file != "catalog.json": + with open(root + "/" + file, "r") as eventFile: + product = root.split("/")[-2] + data = json.load(eventFile) + if product not in dataLoaderStructure: + dataLoaderStructure[product] = { + "eventTypes": [], + "metricNames": [], + } + dataLoaderStructure[product]["eventTypes"].extend(data["cloudeventTypes"]) + if "metricNames" in data: + dataLoaderStructure[product]["metricNames"].extend(data["metricNames"]) + dataLoaderStructure[product]["eventTypes"] = sorted(set(dataLoaderStructure[product]["eventTypes"])) + dataLoaderStructure[product]["metricNames"] = sorted(set(dataLoaderStructure[product]["metricNames"])) + + return dict(sorted(dataLoaderStructure.items())) + +def writeSupportedEventsToDataLoaderFile(supportedEvents): + with open(os.path.dirname(os.path.abspath(__file__)) + "/../DataLoader.json", "w") as eventsFile: + eventsFile.write(json.dumps(supportedEvents, indent=4)) + eventsFile.write("\n") + + +if __name__ == "__main__": + supportedEvents = retrieve_supported_events() + writeSupportedEventsToDataLoaderFile(supportedEvents)