Expose the basic REST and public API controllers used in Som Connexió.
Project description
This module builds a REST API controller base, to build endpoints on them in the somconnexio application modules.
Table of contents
Configuration
Create a API key with a user related with the needed security rights to read and modify contracts.
You can follow the next instruccions:
Settings > Technical (debug mode) > Auth API Key
click create and select a user, save.
communicate the API-KEY to the client or app to use the API.
Usage
Two controllers with two collections are set: - APIKeyController, with an api-key authentication. Collection: “sc.api.key.services” - PublicController, for endpoints with no authentication required. Collection: “sc.public.services”
To use them, create service with a Component class using one of these collections.
class PingPublicAPIService(Component):
_name = "ping.public.api.service" # name for the new component
_inherit = "base.rest.service" # always inherit from base.rest.service (se base_rest module)
_collection = "sc.public.services" # collection to use
_usage = "ping" # service_name # collection path
_description = """
Ping services (test the public api)
"""
The collection used will inherit its related Controller _root_path and auth method for the given Component The final endpoint will be formed by the Controller _root_path plus the Component usage plus its child endponts defined in their methods. Example: “/public-api/ping/create”
You can see the PingAuthAPIService or PingPublicAPIService services, left as model references.
Also, a “common_service” test class is created for tests purposes. Tests classes using endpoints can inherit from it to use its API call methods.
Contributors
Som Connexió SCCL <https://somconnexio.coop/>
Gerard Funonsas gerard.funosas@somconnexio.coop
Borja Gimeno borja.gimeno@somconnexio.coop
Coopdevs Treball SCCL <https://coopdevs.coop/>
Daniel Palomar daniel.palomar@coopdevs.org
Cesar Lopez cesar.lopez@coopdevs.org
Carla Berenguer carla.berenguer@coopdevs.org
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file odoo_addon_base_rest_somconnexio-16.0.1.0.1.tar.gz.
File metadata
- Download URL: odoo_addon_base_rest_somconnexio-16.0.1.0.1.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
58cc3456e88cf95923f0548724da3684f9ab0230dbfb979df406e33a73992d2a
|
|
| MD5 |
ea1f003492820f38f2f6feb63d65c405
|
|
| BLAKE2b-256 |
b4c7b79fa67b29026cc5f217f8c5b7e2fdb1c52cb78da9391d7905f18be2a602
|