HardwareObject base configuration schema
Source code in daiquiri/core/schema/hardware/__init__.py
| class HOConfigSchema(Schema):
"""HardwareObject base configuration schema"""
name = fields.Str(metadata={"description": "Object name"})
id = fields.Str(metadata={"description": "Object id"})
auto_id = fields.Bool(
metadata={"description": "Whether the id was automatically generated"}
)
protocol = fields.Str(metadata={"description": "Protocol handler to use"})
url = fields.Str(
metadata={"description": "Url of the device including which protocol to use"}
)
require_staff = fields.Bool(
metadata={"description": "Whether this object requires staff to modify"}
)
attributes = fields.Nested(
HOConfigAttribute,
many=True,
metadata={"description": "Attribute configuration for run time schemas"},
)
@validates_schema
def schema_validate(self, data, **kwargs):
if not (data.get("protocol") or data.get("url")):
raise ValidationError(
"Object must have either a `protocol` or `url` defined"
)
@post_load
def populate(self, data, **kwargs):
if data.get("url"):
protocol, rest = data["url"].split("://")
data["protocol"] = protocol
if not data.get("id"):
parts = rest.split("/")
data["id"] = parts[-1]
data["auto_id"] = True
if not data.get("name"):
data["name"] = data.get("id")
return data
|
Fields:
Name |
Type |
Properties |
Description |
attributes |
Nested |
|
Attribute configuration for run time schemas |
auto_id |
Boolean |
|
Whether the id was automatically generated |
id |
String |
|
Object id |
name |
String |
|
Object name |
protocol |
String |
|
Protocol handler to use |
require_staff |
Boolean |
|
Whether this object requires staff to modify |
url |
String |
|
Url of the device including which protocol to use |