enhomie.restful package#

Subpackages#

Submodules#

enhomie.restful.conftest module#

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.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.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.params module#

class enhomie.restful.params.RestfulServiceParams[source]#

Bases: HomieParamsModel

Process and validate the Homie configuration parameters.

Fields#

Field

Type

Required

Default

Constraints

authenticate

dict[str, str] | None

No

None

min_length=1

bind_addr

str

No

'127.0.0.1'

min_length=1

bind_port

int

No

8420

ge=0, le=65535

ssl_capem

str | None

No

None

min_length=1

ssl_mykey

str | None

No

None

min_length=1

ssl_mypem

str | None

No

None

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

enhomie.restful.persist module#

class enhomie.restful.persist.HomiePersistEntries[source]#

Bases: BaseModel

Contain the information regarding the persistent values.

Fields#

Field

Type

Required

Default

elapsed

float

Yes

entries

list[HomiePersistRecord]

Yes

entries: Annotated[list[HomiePersistRecord], FieldInfo(annotation=NoneType, required=True, description='Entries related to the request')]#
elapsed: Annotated[float, FieldInfo(annotation=NoneType, required=True, description='Seconds elapsed since request')]#
async enhomie.restful.persist.get_persists(request: Request) HomiePersistEntries[source]#

Handle the API request and return using response model.

enhomie.restful.server module#

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#

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 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.

property fastapi: FastAPI | None#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

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.

operate() None[source]#

Perform the operation related to Homie service members.

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#

class enhomie.restful.RestfulService(homie: Homie)[source]#

Bases: object

Application programming interface using Homie Automate.

Parameters:

homie – Primary class instance for Homie Automate.

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.

property fastapi: FastAPI | None#

Return the value for the attribute from class instance.

Returns:

Value for the attribute from class instance.

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.

operate() None[source]#

Perform the operation related to Homie service members.

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[source]#

Bases: HomieParamsModel

Process and validate the Homie configuration parameters.

Fields#

Field

Type

Required

Default

Constraints

authenticate

dict[str, str] | None

No

None

min_length=1

bind_addr

str

No

'127.0.0.1'

min_length=1

bind_port

int

No

8420

ge=0, le=65535

ssl_capem

str | None

No

None

min_length=1

ssl_mykey

str | None

No

None

min_length=1

ssl_mypem

str | None

No

None

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