flexmeasures.ui.crud.api_wrapper

Classes

class flexmeasures.ui.crud.api_wrapper.InternalApi

Simple wrapper around the requests lib, which we use to talk to our actual internal JSON Api via requests. It can only be used to perform requests on the same URL root as the current request. - We use this because it is cleaner than calling the API code directly.

That would re-use the same request we are working on here, which works differently in some ways like content-type and authentication. The Flask/Werkzeug request is also immutable, so we could not adapt the request anyways.

  • Also, we implement auth token handling

  • Finally we have some logic to control which error codes we want to raise.

_maybe_raise(response: requests.Response, do_not_raise_for: list | None = None)

Raise an error in the API (4xx, 5xx) if the error code is not in the list of codes we want to ignore / handle explicitly.

_url_root() str

Get the root for the URLs this API should use to call FlexMeasures.