Package: juice-core-uplink-api-client
SHT Rest InterfaceIt is made by two modules to interact with the Juice Core Uplink
API.InstallThe module is now contributed to PyPI, just callpipinstalljuice_core_uplink_api_clientto install the module. If you use poetry to build your package and you want to add it as a dependency use:poetryaddjuice_core_uplink_api_clientif you need to test development version (the main branch in this repository):pipinstall"git+https://www.ict.inaf.it/gitlab/juice-janus/sht_rest_interface.git#egg=juice-core-uplink-api-client&subdirectory=juice-core-uplink-api-client"juice-core-uplink-api-clientThis module is automatically generated using the command below. It must not be
modified manually.openapi-python-clientupdate--pathopenapi.jsonor just using the makefilemakeshortcut. The command is expected to be runt
from the root of the repository (where the makefile is located) and requiresopenapi-python-clientto be installed in the host system.The module is generated from the openapi definition available athttps://juicesoc.esac.esa.int/docs/, butnoticethat 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.1making several changes to fix inconsistencies in the definitionThe original files are mantained here for simplicity:openapi_source.json-> as downloaded fromswaggeropenapi_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-clientAlso 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_corethis 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 exampleFirst, create a client:fromjuice_coreimportSHTRestInterfacei=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):trajectorynamemnemonicis_publiccreatedidauthordescriptionrefine_logptr_file0CREMA_3_0CASE4CASE4True2021-03-04 13:29:58.83519917rlorenteDemonstration Case 41CREMA_5_0CREMA_5_0_OPPORTUNITIES_v0CREMA_5_0_OPPORTUNITIES_v0True2021-08-26 09:12:06.76713931cvallat1st 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/2CREMA_5_0CREMA_5_0_OPPORTUNITIES_v1CREMA_5_0_OPPORTUNITIES_v1True2021-10-04 13:49:49.26268236cvallatAdded 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/3CREMA_5_0CREMA_5_0_OPPORTUNITIES_v2CREMA_5_0_OPPORTUNITIES_v2True2021-10-05 07:24:07.74265337cvallatModified 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 underalyingjuice-core-uplink-api-clientmodule:juice-core-uplink-api-clientA client library for accessing Juice Core Uplink APIdocs athttps://juicesoc.esac.esa.int/docs/browsable athttps://juicesoc.esac.esa.int/readonly_admin/core/UsageFirst, create a client:fromjuice_core_uplink_api_clientimportClientclient=Client(base_url="https://api.example.com")If the endpoints you're going to hit require authentication, useAuthenticatedClientinstead:fromjuice_core_uplink_api_clientimportAuthenticatedClientclient=AuthenticatedClient(base_url="https://api.example.com",token="SuperSecretToken")Now call your endpoint and use your models:fromjuice_core_uplink_api_client.modelsimportMyDataModelfromjuice_core_uplink_api_client.api.my_tagimportget_my_data_modelfromjuice_core_uplink_api_client.typesimportResponsemy_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:fromjuice_core_uplink_api_client.modelsimportMyDataModelfromjuice_core_uplink_api_client.api.my_tagimportget_my_data_modelfromjuice_core_uplink_api_client.typesimportResponsemy_data:MyDataModel=awaitget_my_data_model.asyncio(client=client)response:Response[MyDataModel]=awaitget_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 thatthis 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) orNonesync_detailed: Blocking request that always returns aRequest, optionally withparsedset if the request was successful.asyncio: Likesyncbut async instead of blockingasyncio_detailed: Likesync_detailedbut async instead of blockingAll 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 injuice_core_uplink_api_client.api.defaultBuilding / publishing this ClientThis project usesPoetryto 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 Poetrypoetry config repositories.<your-repository-name> <url-to-your-repository>poetry config http-basic.<your-repository-name> <username> <password>Publish the client withpoetry publish --build -r <your-repository-name>or, if for public PyPI, justpoetry publish --buildIf you want to install this client into another project without publishing it (e.g. for development) then:If that projectis using Poetry, you can simply dopoetry add <path-to-this-client>from that projectIf that project is not using Poetry:Build a wheel withpoetry build -f wheelInstall that wheel from the other projectpip install <path-to-wheel>