enhomie.restful package#
Subpackages#
Submodules#
enhomie.restful.conftest module#
Functions and routines associated with Enasis Network Homie Automate.
This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.
- enhomie.restful.conftest.client(restful: RestfulService) TestClient [source]#
Construct the instance for use in the downstream tests.
- Parameters:
restful – Ancilary Homie Automate class instance.
- Returns:
Newly constructed instance of related class.
- enhomie.restful.conftest.invalid(restful: RestfulService) TestClient [source]#
Construct the instance for use in the downstream tests.
- Parameters:
restful – Ancilary Homie Automate class instance.
- Returns:
Newly constructed instance of related class.
- enhomie.restful.conftest.mismatch(restful: RestfulService) TestClient [source]#
Construct the instance for use in the downstream tests.
- Parameters:
restful – Ancilary Homie Automate class instance.
- Returns:
Newly constructed instance of related class.
enhomie.restful.params module#
Functions and routines associated with Enasis Network Homie Automate.
This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.
- pydantic model enhomie.restful.params.RestfulServiceParams[source]#
Bases:
HomieParamsModel
Process and validate the Homie configuration parameters.
Show JSON schema
{ "title": "RestfulServiceParams", "description": "Process and validate the Homie configuration parameters.", "type": "object", "properties": { "bind_addr": { "default": "127.0.0.1", "description": "Which local address to bind", "minLength": 1, "title": "Bind Addr", "type": "string" }, "bind_port": { "default": 8420, "description": "Which port on address to bind", "maximum": 65535, "minimum": 0, "title": "Bind Port", "type": "integer" }, "authenticate": { "anyOf": [ { "additionalProperties": { "type": "string" }, "minProperties": 1, "type": "object" }, { "type": "null" } ], "default": null, "description": "Credentials for authentication", "title": "Authenticate" }, "ssl_capem": { "anyOf": [ { "minLength": 1, "type": "string" }, { "type": "null" } ], "default": null, "description": "Filesystem path to certificate", "title": "Ssl Capem" }, "ssl_mypem": { "anyOf": [ { "minLength": 1, "type": "string" }, { "type": "null" } ], "default": null, "description": "Filesystem path to certificate", "title": "Ssl Mypem" }, "ssl_mykey": { "anyOf": [ { "minLength": 1, "type": "string" }, { "type": "null" } ], "default": null, "description": "Filesystem path to certificate", "title": "Ssl Mykey" } }, "additionalProperties": false }
- Config:
extra: str = forbid
- Fields:
- field authenticate: Annotated[dict[str, str] | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Credentials for authentication', metadata=[MinLen(min_length=1)])] = None#
Credentials for authentication
- Constraints:
min_length = 1
- field bind_addr: Annotated[str, FieldInfo(annotation=NoneType, required=False, default='127.0.0.1', description='Which local address to bind', metadata=[MinLen(min_length=1)])] = '127.0.0.1'#
Which local address to bind
- Constraints:
min_length = 1
- field bind_port: Annotated[int, FieldInfo(annotation=NoneType, required=False, default=8420, description='Which port on address to bind', metadata=[Ge(ge=0), Le(le=65535)])] = 8420#
Which port on address to bind
- Constraints:
ge = 0
le = 65535
- field ssl_capem: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Filesystem path to certificate', metadata=[MinLen(min_length=1)])] = None#
Filesystem path to certificate
- Constraints:
min_length = 1
enhomie.restful.persist module#
Functions and routines associated with Enasis Network Homie Automate.
This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.
- pydantic model enhomie.restful.persist.HomiePersistEntries[source]#
Bases:
BaseModel
Contain the information regarding the persistent values.
Show JSON schema
{ "title": "HomiePersistEntries", "description": "Contain the information regarding the persistent values.", "type": "object", "properties": { "entries": { "description": "Entries related to the request", "items": { "$ref": "#/$defs/HomiePersistRecord" }, "title": "Entries", "type": "array" }, "elapsed": { "description": "Seconds elapsed since request", "title": "Elapsed", "type": "number" } }, "$defs": { "HomiePersistRecord": { "additionalProperties": false, "description": "Contain the information regarding the persistent value.\n\n:param record: Record from the SQLAlchemy query routine.\n:param kwargs: Keyword arguments passed for downstream.", "properties": { "unique": { "description": "Unique key for the value", "minLength": 1, "title": "Unique", "type": "string" }, "value": { "anyOf": [ { "type": "integer" }, { "type": "number" }, { "type": "boolean" }, { "type": "string" }, { "type": "null" } ], "description": "Value stored at unique", "title": "Value" }, "value_unit": { "anyOf": [ { "minLength": 1, "type": "string" }, { "type": "null" } ], "default": null, "description": "Unit for persist value", "title": "Value Unit" }, "value_label": { "anyOf": [ { "minLength": 1, "type": "string" }, { "type": "null" } ], "default": null, "description": "Label for persist value", "title": "Value Label" }, "value_icon": { "anyOf": [ { "minLength": 1, "type": "string" }, { "type": "null" } ], "default": null, "description": "Icon for persist value", "title": "Value Icon" }, "about": { "anyOf": [ { "minLength": 1, "type": "string" }, { "type": "null" } ], "default": null, "description": "About the persist entry", "title": "About" }, "about_label": { "anyOf": [ { "minLength": 1, "type": "string" }, { "type": "null" } ], "default": null, "description": "Label for persist entry", "title": "About Label" }, "about_icon": { "anyOf": [ { "minLength": 1, "type": "string" }, { "type": "null" } ], "default": null, "description": "Icon for persist entry", "title": "About Icon" }, "level": { "anyOf": [ { "enum": [ "failure", "information", "success", "warning" ], "minLength": 1, "type": "string" }, { "type": "null" } ], "default": null, "description": "Severity of persist entry", "title": "Level" }, "tags": { "anyOf": [ { "items": { "type": "string" }, "minItems": 1, "type": "array" }, { "type": "null" } ], "default": null, "description": "Tags for persist entry", "title": "Tags" }, "expire": { "anyOf": [ { "maxLength": 32, "minLength": 20, "type": "string" }, { "type": "null" } ], "default": null, "description": "After when the key expires", "title": "Expire" }, "update": { "description": "When the value was updated", "maxLength": 32, "minLength": 20, "title": "Update", "type": "string" } }, "required": [ "unique", "value", "update" ], "title": "HomiePersistRecord", "type": "object" } }, "additionalProperties": false, "required": [ "entries", "elapsed" ] }
- Config:
extra: str = forbid
- Fields:
- field elapsed: Annotated[float, FieldInfo(annotation=NoneType, required=True, description='Seconds elapsed since request')] [Required]#
Seconds elapsed since request
- field entries: Annotated[list[HomiePersistRecord], FieldInfo(annotation=NoneType, required=True, description='Entries related to the request')] [Required]#
Entries related to the request
- async enhomie.restful.persist.get_persists(request: Request) HomiePersistEntries [source]#
Handle the API request and return using response model.
enhomie.restful.server module#
Functions and routines associated with Enasis Network Homie Automate.
This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.
- class enhomie.restful.server.RestfulApp(restful: RestfulService)[source]#
Bases:
FastAPI
FastAPI application for the Homie Automate RESTful API.
- Parameters:
restful – Primary class instance for the service.
- restful: RestfulService#
- class enhomie.restful.server.RestfulServer(restful: RestfulService, config: Config)[source]#
Bases:
Server
Uvicorn server for Homie Automate RESTful API services.
- Parameters:
restful – Primary class instance for the service.
config – Configuration for parent Uvicorn server.
enhomie.restful.service module#
Functions and routines associated with Enasis Network Homie Automate.
This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.
- class enhomie.restful.service.RestfulService(homie: Homie)[source]#
Bases:
object
Application programming interface using Homie Automate.
- Parameters:
homie – Primary class instance for Homie Automate.
- property fastapi: FastAPI | None#
Return the value for the attribute from class instance.
- Returns:
Value for the attribute from class instance.
- property homie: Homie#
Return the Homie instance to which the instance belongs.
- Returns:
Homie instance to which the instance belongs.
- property params: RestfulServiceParams#
Return the Pydantic model containing the configuration.
- Returns:
Pydantic model containing the configuration.
Module contents#
Functions and routines associated with Enasis Network Homie Automate.
This file is part of Enasis Network software eco-system. Distribution is permitted, for more information consult the project license file.
- class enhomie.restful.RestfulService(homie: Homie)[source]#
Bases:
object
Application programming interface using Homie Automate.
- Parameters:
homie – Primary class instance for Homie Automate.
- property fastapi: FastAPI | None#
Return the value for the attribute from class instance.
- Returns:
Value for the attribute from class instance.
- property homie: Homie#
Return the Homie instance to which the instance belongs.
- Returns:
Homie instance to which the instance belongs.
- property params: RestfulServiceParams#
Return the Pydantic model containing the configuration.
- Returns:
Pydantic model containing the configuration.
- pydantic model enhomie.restful.RestfulServiceParams[source]#
Bases:
HomieParamsModel
Process and validate the Homie configuration parameters.
Show JSON schema
{ "title": "RestfulServiceParams", "description": "Process and validate the Homie configuration parameters.", "type": "object", "properties": { "bind_addr": { "default": "127.0.0.1", "description": "Which local address to bind", "minLength": 1, "title": "Bind Addr", "type": "string" }, "bind_port": { "default": 8420, "description": "Which port on address to bind", "maximum": 65535, "minimum": 0, "title": "Bind Port", "type": "integer" }, "authenticate": { "anyOf": [ { "additionalProperties": { "type": "string" }, "minProperties": 1, "type": "object" }, { "type": "null" } ], "default": null, "description": "Credentials for authentication", "title": "Authenticate" }, "ssl_capem": { "anyOf": [ { "minLength": 1, "type": "string" }, { "type": "null" } ], "default": null, "description": "Filesystem path to certificate", "title": "Ssl Capem" }, "ssl_mypem": { "anyOf": [ { "minLength": 1, "type": "string" }, { "type": "null" } ], "default": null, "description": "Filesystem path to certificate", "title": "Ssl Mypem" }, "ssl_mykey": { "anyOf": [ { "minLength": 1, "type": "string" }, { "type": "null" } ], "default": null, "description": "Filesystem path to certificate", "title": "Ssl Mykey" } }, "additionalProperties": false }
- Config:
extra: str = forbid
- Fields:
- field authenticate: Annotated[dict[str, str] | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Credentials for authentication', metadata=[MinLen(min_length=1)])] = None#
Credentials for authentication
- Constraints:
min_length = 1
- field bind_addr: Annotated[str, FieldInfo(annotation=NoneType, required=False, default='127.0.0.1', description='Which local address to bind', metadata=[MinLen(min_length=1)])] = '127.0.0.1'#
Which local address to bind
- Constraints:
min_length = 1
- field bind_port: Annotated[int, FieldInfo(annotation=NoneType, required=False, default=8420, description='Which port on address to bind', metadata=[Ge(ge=0), Le(le=65535)])] = 8420#
Which port on address to bind
- Constraints:
ge = 0
le = 65535
- field ssl_capem: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Filesystem path to certificate', metadata=[MinLen(min_length=1)])] = None#
Filesystem path to certificate
- Constraints:
min_length = 1