flexmeasures.api.v3_0

Modules

flexmeasures.api.v3_0.accounts

flexmeasures.api.v3_0.assets

flexmeasures.api.v3_0.deprecated

flexmeasures.api.v3_0.health

flexmeasures.api.v3_0.jobs

flexmeasures.api.v3_0.public

flexmeasures.api.v3_0.sensors

flexmeasures.api.v3_0.sources

flexmeasures.api.v3_0.users

flexmeasures.api.v3_0.utils

FlexMeasures API v3

Functions

flexmeasures.api.v3_0.collapse_schema_to_field(spec: APISpec, schema_cls: Type[Schema], field_name: str) → dict[str, Any]

Replace the OpenAPI component named after schema_cls with the OpenAPI schema generated for field_name inside that schema.

flexmeasures.api.v3_0.create_openapi_specs(app: Flask)

Create OpenAPI specs for the API and save them to a JSON file in the static folder. This function should be called when generating docs (and needs extra dependencies).

flexmeasures.api.v3_0.document_rate_limits(spec_dict: dict, trigger_limited_operations: set[tuple])

Document the 429 response on every endpoint the rate limiter guards.

Rate limiting is applied by the limiter rather than by the views themselves (see flexmeasures.api.common.rate_limiting), so no view docstring declares this response. We add it here, so that the published contract keeps matching what the limiter does, without every docstring having to remember to say so.

flexmeasures.api.v3_0.flask_rule_to_openapi_path(rule: str) → str

Turn a Flask rule like “/api/v3_0/assets/<id>/automations/<int:automation_id>” into its OpenAPI path.

Path parameters are spelled in kebab-case, like the rest of the API, as in “/api/v3_0/assets/{id}/automations/{automation-id}”. Flask cannot name a route variable that way, so the rule keeps the underscore, which never reaches the wire.

flexmeasures.api.v3_0.kebab_case_path_parameters(spec_dict: dict)

Spell the path parameters in the paths of the OpenAPI specs in kebab-case (see flask_rule_to_openapi_path).

flexmeasures.api.v3_0.openapi_specs_path() → Path

Return where the OpenAPI specs live: the UI’s static folder, from which they are served.

This is an absolute path inside the installed package, so the specs land in the right place whatever the working directory is, also when FlexMeasures is installed non-editable (as in our Docker image).

flexmeasures.api.v3_0.register_at(app: Flask)

This can be used to register this blueprint together with other api-related things

flexmeasures.api.v3_0.register_path_id_field(spec: APISpec, param_name: str, field: Field, location: str = 'path', required: bool = True)

Register the field as an OpenAPI parameter

flexmeasures.api.v3_0.register_swagger_ui(app: Flask)

Register the Swagger UI blueprint to view the OpenAPI specs.

flexmeasures.api.v3_0.trigger_limited_operations_of(rule, view) → set[tuple]

The (OpenAPI path, method) pairs of this rule, if its view is under the trigger limit.