Developer Interface

This part of the documentation presents all the classes of Coworks.

Microservices

class coworks.TechMicroService(name: str | None = None, stage_prefixed: bool = True, **kwargs)

Simple tech microservice.

See TechMicroservices for more information.

New in version 0.8.0: The stage_prefixed parameter was added.

add_coworks_routes(bp_state: BlueprintSetupState | None = None) None

Creates all routes for a microservice.

Parameters:

bp_state – The blueprint state.

app_context()

Override to initialize coworks microservice.

auto_find_instance_path()

Instance path may be redefined by an environment variable.

create_url_adapter(_request: CoworksRequest | None)

Creates a URL adapter for the given request. The URL adapter is created at a point where the request context is not yet set up so the request is passed explicitly.

New in version 0.6.

Changed in version 0.9: This can now also be called without a request object when the URL adapter is created for the application context.

Changed in version 1.0: SERVER_NAME no longer implicitly enables subdomain matching. Use subdomain_matching instead.

cws_client(aws_event, aws_context)

CoWorks client used by the lambda call.

property header_autorizer_token

The identity source for which authorization is requested usefull only on local. Usually defined in API GAateway Authorizer resource.

property in_lambda_context

Defined as a property to be read only.

init_app()

Called to finalize the application initialization. Mainly to get external variables defined specifically for a workspace.

Deprecated since version 0.8.0.

init_cli()

Called only on cli command. Mainly externalized to allow specific import not needed on deployed implementation.

Deprecated since version 0.8.0.

property routes: list[str]

Returns the list of routes defined in the microservice.

store_response(resp: dict | bytes, request_headers)

Store microservice response in S3 for biz task sequence.

May be redefined for another storage in asynchronous call.

token_authorizer(token: str) bool | str

Defined the authorization process.

If the returned value is False, all routes for all stages are denied. If the returned value is True, all routes for all stages are accepted. If the returned value is a string, then it must be a stage name and all routes are accepted for this stage.

By default, just using the token authentification process (defined from terraform template).

class coworks.Blueprint(name: str | None = None, **kwargs)

Represents a blueprint, list of routes that will be added to microservice when registered.

See Blueprint for more information.

init_app(app)

“.. deprecated:: 0.8.0

init_cli(app)

Deprecated since version 0.8.0.

make_setup_state(app: TechMicroService, options: dict, *args) BlueprintSetupState

Stores creation state for deferred initialization.