Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REST API: make the profile configurable as request parameter
To make this possible, after parsing the query string but before performing the request, the desired profile needs to be loaded. A new method `load_profile` is added to the `BaseResource` class. All methods that access the storage, such as the `get` methods, need to invoke this method before handing the request. The `load_profile` method will call `load_profile` with `allow_switch` set to True, in order to allow changing the profile if another had already been loaded. The profile that is loaded is determined from the `profile` query parameter specified in the request. If not specified, the profile will be taken that was specified in the `kwargs` of the resources constructor. Note that the parsing of the request path and query parameters had to be refactored a bit to prevent the parsing having to be performed twice, which would result in a performance regression. When the REST API is invoked through the `verdi` CLI, the profile specified by the `-p` option, or the default profile if not specified, is passed to the API, which will be passed to the resource constructors. This guarantees that if `profile` is not specified in the query parameters the profile with which `verdi restapi` was invoked will be loaded.
- Loading branch information