wotpy.wot.servient

Class that represents a WoT servient.

Classes

Servient([hostname, catalogue_port, ...])

An entity that is both a WoT client and server at the same time.

TDCatalogueHandler(application, request, ...)

Handler that returns the entire catalogue of Things contained in this servient.

TDHandler(application, request, **kwargs)

Handler that returns the TD document of a given Thing.

Exceptions

ServientStateException

Exception raised when the user modifies the Servient while the Servient is in an inappropriate state.

class wotpy.wot.servient.Servient(hostname=None, catalogue_port=9090, clients=None, clients_config=None, create_default_forms=True)

Bases: object

An entity that is both a WoT client and server at the same time. WoT servers are Web servers that possess capabilities to access underlying IoT devices and expose a public interface named the WoT Interface that may be used by other clients. WoT clients are entities that are able to understand the WoT Interface to send requests and interact with IoT devices exposed by other WoT servients or servers using the capabilities of a Web client such as Web browser.

add_client(client)

Adds a new Protocol Binding client to this servient.

add_credentials(credentials_dict)

Adds a dictionary of credentials for a specific thing.

add_exposed_thing(exposed_thing)

Adds an ExposedThing to this Servient. ExposedThings are disabled by default.

add_server(server)

Adds a new Protocol Binding server to this servient.

property catalogue_port

Returns the current port of the HTTP Thing Description catalogue service.

property clients

Returns the dict of Protocol Binding clients attached to this servient.

disable_exposed_thing(thing_title)

Disables the ExposedThing with the given ID. This is, the servers will not listen for requests for this thing.

disable_td_catalogue()

Disables the servient TD catalogue.

enable_exposed_thing(thing_title)

Enables the ExposedThing with the given ID. This is, the servers will listen for requests for this thing.

property enabled_exposed_things

Returns an iterator for the enabled ExposedThings contained in this Servient.

property exposed_thing_set

Returns the ExposedThingSet instance that contains the ExposedThings of this servient.

property exposed_things

Returns an iterator for the ExposedThings contained in this Servient.

get_exposed_thing(thing_title)

Finds and returns an ExposedThing contained in this servient by Thing Name. Raises ValueError if the ExposedThing is not present.

get_thing_base_url(exposed_thing)

Return the base URL for the given ExposedThing for one of the currently active servers.

property hostname

Hostname attached to this servient.

property is_running

Returns True if the Servient is currently running (i.e. the attached servers have been started).

refresh_forms()

Cleans and regenerates autogenerated Forms for all the ExposedThings and servers contained in this servient.

remove_client(protocol)

Removes the Protocol Binding client with the given protocol from this servient.

remove_exposed_thing(thing_title)

Disables and removes an ExposedThing from this Servient.

remove_server(protocol)

Removes the Protocol Binding server with the given protocol from this servient.

retrieve_credentials(exposed_thing_title)

Retrieves all the credentials associated with the given thing.

select_client(td, name)

Returns the Protocol Binding client instance to communicate with the given Interaction.

property servers

Returns the dict of Protocol Binding servers attached to this servient.

async shutdown()

Stops the server configured under this servient.

async shutdown_hook()

Hook that is implemented by subclass.

async start()

Starts the servers and returns an instance of the WoT object.

async startup_hook()

Hook that is implemented by subclass.

exception wotpy.wot.servient.ServientStateException

Bases: Exception

Exception raised when the user modifies the Servient while the Servient is in an inappropriate state.

class wotpy.wot.servient.TDCatalogueHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)

Bases: RequestHandler

Handler that returns the entire catalogue of Things contained in this servient. May return TDs in expanded format or URL pointers to the individual TDs.

get()
initialize(servient)
class wotpy.wot.servient.TDHandler(application: Application, request: HTTPServerRequest, **kwargs: Any)

Bases: RequestHandler

Handler that returns the TD document of a given Thing.

get(thing_url_name)
initialize(servient)