A client library for accessing Juice Core Uplink API
Project description
SHT Rest Interface
It is made by two modules to interact with the Juice Core Uplink API.
Install
The module is now contributed to PyPI, just call
pip install juice_core_uplink_api_client
to install the module. If you use poetry to build your package and you want to add it as a dependency use:
poetry add juice_core_uplink_api_client
juice-core-uplink-api-client
This module is automatically generated using the command below. It must not be modified manually.
openapi-python-client update --path openapi.json
or just using the makefile make
shortcut. The command is expected to be runt
from the root of the repository (where the makefile is located) and requires
openapi-python-client
to be installed in the host system.
The module is generated from the openapi definition available at https://juicesoc.esac.esa.int/docs/, but notice that the openapi.json definition is a modified version of the one available at that link. The file was modified by:
- updating the file to openapi 3.1
- making several changes to fix inconsistencies in the definition
The original files are mantained here for simplicity:
openapi_source.json
-> as downloaded from swaggeropenapi_converted.json
-> updated to version 3.x using [https://converter.swagger.io/#/Converter/convertByUrl](swagger converter service)openapi.json
-> used to generate the module with openapi-python-client
Also note that only some issues were corrected in the openapi.json file, hence the generated module is not complete, and it is not granted to work. If you find any additional inconsistency, please report it to the repo issue tracker.
juice_core
this module is a wrapper around the automatically generated module. It is made by a class with several methods to interact with the API. It is just a stub to start disucssing the API interface. It is not complete and it is not guaranteed to work.
Usage example
First, create a client:
from juice_core import SHTRestInterface
i = SHTRestInterface()
and access the list of available plans on the server:
i.plans()
will output a pandas dataframe with the list of plans (just some here):
trajectory | name | mnemonic | is_public | created | id | author | description | refine_log | ptr_file | |
---|---|---|---|---|---|---|---|---|---|---|
0 | CREMA_3_0 | CASE4 | CASE4 | True | 2021-03-04 13:29:58.835199 | 17 | rlorente | Demonstration Case 4 | ||
1 | CREMA_5_0 | CREMA_5_0_OPPORTUNITIES_v0 | CREMA_5_0_OPPORTUNITIES_v0 | True | 2021-08-26 09:12:06.767139 | 31 | cvallat | 1st run opf opportunities generation (UC22), based on existing definitions of oppportunities (inherited from crema 3_0) | https://juicesoc.esac.esa.int/rest_api/file/trajectory%23CREMA_5_0.ptx/ | |
2 | CREMA_5_0 | CREMA_5_0_OPPORTUNITIES_v1 | CREMA_5_0_OPPORTUNITIES_v1 | True | 2021-10-04 13:49:49.262682 | 36 | cvallat | Added two opportunities for JMAG_CALROL for the last 2 perijoves before JOI (PJ69 not considered since too clsoe to GoI for observations to take place --> MPAD rule) | https://juicesoc.esac.esa.int/rest_api/file/trajectory%23CREMA_5_0.ptx/ | |
3 | CREMA_5_0 | CREMA_5_0_OPPORTUNITIES_v2 | CREMA_5_0_OPPORTUNITIES_v2 | True | 2021-10-05 07:24:07.742653 | 37 | cvallat | Modified GANYMEDE_GM opportunity around 3G3 for WG3 prime allocation (1 hour centered at CA) | https://juicesoc.esac.esa.int/rest_api/file/trajectory%23CREMA_5_0.ptx/ |
You can also directly interact with the underalying juice-core-uplink-api-client
module:
juice-core-uplink-api-client
A client library for accessing Juice Core Uplink API
docs at https://juicesoc.esac.esa.int/docs/
browsable at https://juicesoc.esac.esa.int/readonly_admin/core/
Usage
First, create a client:
from juice_core_uplink_api_client import Client
client = Client(base_url="https://api.example.com")
If the endpoints you're going to hit require authentication, use AuthenticatedClient
instead:
from juice_core_uplink_api_client import AuthenticatedClient
client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
Now call your endpoint and use your models:
from juice_core_uplink_api_client.models import MyDataModel
from juice_core_uplink_api_client.api.my_tag import get_my_data_model
from juice_core_uplink_api_client.types import Response
my_data: MyDataModel = get_my_data_model.sync(client=client)
# or if you need more info (e.g. status_code)
response: Response[MyDataModel] = get_my_data_model.sync_detailed(client=client)
Or do the same thing with an async version:
from juice_core_uplink_api_client.models import MyDataModel
from juice_core_uplink_api_client.api.my_tag import get_my_data_model
from juice_core_uplink_api_client.types import Response
my_data: MyDataModel = await get_my_data_model.asyncio(client=client)
response: Response[MyDataModel] = await get_my_data_model.asyncio_detailed(client=client)
By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.
client = AuthenticatedClient(
base_url="https://internal_api.example.com",
token="SuperSecretToken",
verify_ssl="/path/to/certificate_bundle.pem",
)
You can also disable certificate validation altogether, but beware that this is a security risk.
client = AuthenticatedClient(
base_url="https://internal_api.example.com",
token="SuperSecretToken",
verify_ssl=False
)
Things to know:
-
Every path/method combo becomes a Python module with four functions:
sync
: Blocking request that returns parsed data (if successful) orNone
sync_detailed
: Blocking request that always returns aRequest
, optionally withparsed
set if the request was successful.asyncio
: Likesync
but async instead of blockingasyncio_detailed
: Likesync_detailed
but async instead of blocking
-
All path/query params, and bodies become method arguments.
-
If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
-
Any endpoint which did not have a tag will be in
juice_core_uplink_api_client.api.default
Building / publishing this Client
This project uses Poetry to manage dependencies and packaging. Here are the basics:
- Update the metadata in pyproject.toml (e.g. authors, version)
- If you're using a private repository, configure it with Poetry
poetry config repositories.<your-repository-name> <url-to-your-repository>
poetry config http-basic.<your-repository-name> <username> <password>
- Publish the client with
poetry publish --build -r <your-repository-name>
or, if for public PyPI, justpoetry publish --build
If you want to install this client into another project without publishing it (e.g. for development) then:
- If that project is using Poetry, you can simply do
poetry add <path-to-this-client>
from that project - If that project is not using Poetry:
- Build a wheel with
poetry build -f wheel
- Install that wheel from the other project
pip install <path-to-wheel>
- Build a wheel with
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
Built Distribution
Hashes for juice_core_uplink_api_client-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d518683e17885bd21e7fa67bc2698131d51dab1e1b001c903412ee9cf3366ab1 |
|
MD5 | ff5cba5563214074c9784a642d3afa4b |
|
BLAKE2b-256 | e3b6d9c2b754ec133612c79b907a92d44405555edb90380c1b5505ec74ab8ba8 |
Hashes for juice_core_uplink_api_client-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 428e5f0206e999d95b66c9873f8c7e576739efb6429b2edbefb5ec9109ccd474 |
|
MD5 | bd28ac579e8963d35e5bee86d0162828 |
|
BLAKE2b-256 | 5eeb89d1f1d16ce1e60f36c9e74ce4baea694081a7e4dd291c0650cd1b1e83ab |