Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyyaml migration #1172

Draft
wants to merge 17 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$id": "config-metadata.schema.json",
"type": "object",
"properties": {
"operation": {
"oneOf": [
{
"const": "UPDATE"
},
{
"const": "INITIALIZE"
},
{
"const": "EXPORT"
}
]
}
},
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$id": "entity-add-schema.schema.json",
"type": "object",
"properties": {
"operation": {
"const": "ADD"
},
"code": true,
"connections": true,
"type": true,
"links": true,
"translation": true,
"cloud_device_id": true
},
"required": ["operation"],
"allOf": [
{
"$ref": "entity-base-schema.schema.json"
}
],
"additionalProperties": false,
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"$id": "entity-attributes.schema.json",
"type": "object",
"properties": {
"code": {
"type": "string"
},
"connections": {
"type": "object",
"patternProperties": {
"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$": {
"anyOf": [
{
"type": "array",
"items": {
"type": "string"
}
},
{
"type": "string"
}
]
}
}
},
"links": {
"type": "object",
"patternProperties": {
"^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$": {
"patternProperties": {
".*": {"type": "string"}
}
}
}
},
"translation": {
"type": "object",
"patternProperties": {
".*": {"$ref": "translation.schema.json"}
}
},
"type": {
"type": "string"
}
},
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"$id": "entity-base-schema.schema.json",
"type": "object",
"properties": {
"cloud_device_id": {
"type": "string"
},
"code": {
"type": "string"
},
"guid": {
"type": "string"
},
"type": {
"type": "string",
"pattern": "^(.*\/.*)"
},
"connections": true,
"links": true,
"translation": true
},
"allOf": [
{
"$ref": "entity-attributes.schema.json"
}
],
"required": ["type"],
"dependentRequired": {"translation": ["cloud_device_id"]},
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"$id": "entity-block-schema.schema.json",
"type": "object",
"oneOf": [
{
"$ref": "entity-update-schema.schema.json"
},
{
"$ref": "entity-add-schema.schema.json"
},
{
"$ref": "entity-delete-schema.schema.json"
},
{
"$ref": "entity-export-schema.schema.json"
},
{
"$ref": "entity-noop-schema.schema.json"
}
],
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"$id": "entity-delete-schema.schema.json",
"type": "object",
"properties": {
"operation": {
"const": "DELETE"
},
"code": true
},
"allOf": [
{
"$ref": "entity-base-schema.schema.json"
}
],
"required": ["operation"],
"additionalProperties": false,
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$id": "entity-export-schema.schema.json",
"type": "object",
"properties": {
"etag": {
"type": "string"
},
"type": {
"type": "string"
},
"operation": {
"const": "EXPORT"
},
"code": true,
"connections": true,
"links": true,
"translation": true,
"cloud_device_id": true
},
"allOf": [
{
"$ref": "entity-base-schema.schema.json"
}
],
"required": ["operation", "etag"],
"additionProperties": false,
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"$id": "entity-noop-schema.schema.json",
"type": "object",
"allOf": [
{
"$ref": "entity-base-schema.schema.json"
}
],
"properties": {
"code": true,
"connections": true,
"type": true,
"links": true,
"translation": true,
"etag": true,
"cloud_device_id": true
},
"additionalProperties": false,
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"$id": "entity-update-schema.schema.json",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"dependentRequired": {
"update_mask": [
"operation"
]
},
"properties": {
"etag": {
"type": "string"
},
"operation": {
"const": "UPDATE"
},
"update_mask": {
"type": "array",
"uniqueItems": true
},
"code": true,
"connections": true,
"links": true,
"translation": true,
"cloud_device_id": true
},
"allOf": [
{
"$ref": "entity-base-schema.schema.json"
}
],
"required": [
"etag",
"operation"
],
"type": "object"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"$id": "translation.schema.json",
"type": "object",
"properties": {
"present_value": {
"type": "string"
},
"states": {
"type": "object",
"patternProperties": {
".*": {
"type": "string"
}
}
},
"units": {
"type": "object",
"properties": {
"key": {
"type": "string"
},
"values": {
"type": "object",
"properties": {
".*": {
"type": "string"
}
}
}
},
"required": ["key", "values"]
}
},
"required": [
"present_value"
],
"additionalProperties": false,
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
2 changes: 1 addition & 1 deletion tools/validators/instance_validator/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@
'ruamel.yaml==0.17.4', 'strictyaml==1.4.2',
'google-cloud-pubsub', 'googleapis-common-protos',
'google-auth', 'google-auth-oauthlib',
'protobuf', 'proto-plus'],
'protobuf', 'proto-plus', 'jsonschema'],
python_requires='>=3.9',
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Two metadata blocks (bad)

SDC_EXT-18-GUID:
code: SDC_EXT-18

CONFIG_METADATA:
operation: UPDATE

CONFIG_METADATA:
operation: INITIALIZE

US-SEA-BLDG1-GUID:
# Building
3cf600dc-0e48-40ad-9807-ba98018e9946:
type: FACILITIES/BUILDING
code: US-SEA-BLDG1
connections:
# Listed entities are sources on connections
62b81ce8-f8bf-47e6-86b8-20870f9712e3: FEEDS
8dff2e92-b619-4259-a683-c946bd0ff612: CONTAINS
blah: bad additional property
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

CONFIG_METADATA:
operation: INITIALIZE

# Building
US-SEA-BLDG1-GUID:
135d08f4-8df0-46ae-86cb-16b953870aeb:
type: FACILITIES/BUILDING/ERRORORO
code: US-SEA-BLDG1
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

CONFIG_METADATA:
operation: EXPORT

US-SEA-BLDG1-GUID:
type: FACILITIES/BUILDING
type: FACILITIES/123456b
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
# limitations under the License.

# Cannot have update mask on an ADD operation
CONFIG_METADATA:
operation: UPDATE

SDC_EXT-17-GUID:
type: HVAC/SDC_EXT
code: SDC_EXT-17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
CONFIG_METADATA:
operation: UPDATE

US-SEA-BLDG1-GUID:
04e831e8-7e08-4c68-a920-b23065e41e5e:
operation: UPDATE
type: FACILITIES/BUILDING
code: US-SEA-BLDG1
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
# Bad entity export operation missing etag

CONFIG_METADATA:
operation: UPDATE
operation: EXPORT

SDC_EXT-19-GUID:
04e831e8-7e08-4c68-a920-b23065e41e5e:
type: HVAC/SDC_EXT
code: SDC_EXT-19
cloud_device_id: "baz"
Expand Down
Loading
Loading