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.

class enhomie.restful.params.RestfulServiceParams(_parse: Callable[[...], Any] | None = None, *, bind_addr: Annotated[str, MinLen(min_length=1)] = '127.0.0.1', bind_port: Annotated[int, Ge(ge=0), Le(le=65535)] = 8420, authenticate: Annotated[dict[str, str] | None, MinLen(min_length=1)] = None, ssl_capem: Annotated[str | None, MinLen(min_length=1)] = None, ssl_mypem: Annotated[str | None, MinLen(min_length=1)] = None, ssl_mykey: Annotated[str | None, MinLen(min_length=1)] = None)[source]#

Bases: HomieParamsModel

Process and validate the Homie configuration parameters.

authenticate: Annotated[dict[str, str] | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Credentials for authentication', metadata=[MinLen(min_length=1)])]#
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)])]#
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)])]#
model_config = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

ssl_capem: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Filesystem path to certificate', metadata=[MinLen(min_length=1)])]#
ssl_mykey: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Filesystem path to certificate', metadata=[MinLen(min_length=1)])]#
ssl_mypem: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Filesystem path to certificate', metadata=[MinLen(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.

class enhomie.restful.persist.HomiePersistEntries(*, entries: list[HomiePersistRecord], elapsed: float)[source]#

Bases: BaseModel

Contain the information regarding the persistent values.

elapsed: Annotated[float, FieldInfo(annotation=NoneType, required=True, description='Seconds elapsed since request')]#
entries: Annotated[list[HomiePersistRecord], FieldInfo(annotation=NoneType, required=True, description='Entries related to the request')]#
model_config = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

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.

homie: Homie#
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.

operate() None[source]#

Perform the operation related to Homie service members.

property params: RestfulServiceParams#

Return the Pydantic model containing the configuration.

Returns:

Pydantic model containing the configuration.

property running: bool#

Return the list of threads which are determined running.

Returns:

List of threads which are determined running.

start() None[source]#

Start the various threads within the Homie class object.

stop(*args: Any, **kwargs: Any) None[source]#

Stop the various threads within the Homie class object.

Parameters:
  • kwargs – Keyword arguments ignored by the method.

  • args – Positional arguments ignored by the method.

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.

operate() None[source]#

Perform the operation related to Homie service members.

property params: RestfulServiceParams#

Return the Pydantic model containing the configuration.

Returns:

Pydantic model containing the configuration.

property running: bool#

Return the list of threads which are determined running.

Returns:

List of threads which are determined running.

start() None[source]#

Start the various threads within the Homie class object.

stop(*args: Any, **kwargs: Any) None[source]#

Stop the various threads within the Homie class object.

Parameters:
  • kwargs – Keyword arguments ignored by the method.

  • args – Positional arguments ignored by the method.

class enhomie.restful.RestfulServiceParams(_parse: Callable[[...], Any] | None = None, *, bind_addr: Annotated[str, MinLen(min_length=1)] = '127.0.0.1', bind_port: Annotated[int, Ge(ge=0), Le(le=65535)] = 8420, authenticate: Annotated[dict[str, str] | None, MinLen(min_length=1)] = None, ssl_capem: Annotated[str | None, MinLen(min_length=1)] = None, ssl_mypem: Annotated[str | None, MinLen(min_length=1)] = None, ssl_mykey: Annotated[str | None, MinLen(min_length=1)] = None)[source]#

Bases: HomieParamsModel

Process and validate the Homie configuration parameters.

authenticate: Annotated[dict[str, str] | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Credentials for authentication', metadata=[MinLen(min_length=1)])]#
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)])]#
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)])]#
model_config = {'extra': 'forbid'}#

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

ssl_capem: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Filesystem path to certificate', metadata=[MinLen(min_length=1)])]#
ssl_mykey: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Filesystem path to certificate', metadata=[MinLen(min_length=1)])]#
ssl_mypem: Annotated[str | None, FieldInfo(annotation=NoneType, required=False, default=None, description='Filesystem path to certificate', metadata=[MinLen(min_length=1)])]#