CommandableCloudFunctionController

Abstract controller that receives commands via the Google Function protocol to operations automatically generated for commands defined in ICommandable components.

Implements: CloudFunctionController

Description

The CommandableCloudFunctionController class allows you to create abstract controllers that receive commands via the Google Function protocols to operations automatically generated for commnads defined in ICommandable components.

Important points

  • Each command is exposed as an invoke method that receives a command’s name and parameters.

  • Commandable controllers require only 3 lines of code to implement a robust external Google Function-based remote interface.

  • This controller is intended to work inside an Google Function container that exploses registered actions externally.

Configuration parameters

  • dependencies:
    • controller: override for Controller dependency

References

  • *:logger:*:*:1.0: (optional) ILogger components to pass log messages.
  • *:counters:*:*:1.0: (optional) ICounters components to pass collected measurements.

Constructors

CommandableCloudFunctionController(name: str)

  • name: str - controller’s name.

Instance methods

_get_parameters

Returns body from Google Function request. This method can be overloaded in child classes

_get_parameters(req: flask.Request): Parameters

register

Registers all actions in Google Function.

register()

Examples

class MyCommandableCloudFunctionController(CommandableCloudFunctionController):
    def __init__(self):
        super().__init__("mydata")
        self._dependency_resolver.put(
            "controller",
            Descriptor("mygroup","controller","*","*","1.0")
        )
      
controller = MyCommandableCloudFunctionController()

controller.set_references(References.from_tuples(
    Descriptor("mygroup","controller","default","default","1.0"), controller
))

controller.open("123")

print("The Google Function controller is running")