tree: e0c68d1662fa95bbdce760eb9e52029a5f873f72 [path history] [tgz]
  1. call_templates/
  2. .gitignore
  3. __init__.py
  4. gen_call_scripts.py
  5. README.md
api/contrib/README.md

contrib/

This folder provides some functionality that may not be 100% supported yet. Things here may break at any time and are not necessarily expected to be updated before the breaking changes are accepted.

gen_call_scripts, call_templates/ and call_scripts/

The call_templates directory contains a set of example json input files for making api calls. The call_scripts directory is an ignored directory generated by the gen_call_scripts script. gen_call_scripts will create scripts of the form service__method that call their corresponding endpoint. They look for service__method_input.json files and write to service__method_output.json in the call_scripts directory.

Examples

To do the generation:

cd ~/chromiumos/chromite/api/contrib/
./gen_call_scripts

Then to run a specific endpoint (e.g. VersionService/Get):

cd call_scripts/
./version__get

Which will produce something like:

Running chromite.api.VersionService/Get
13:16:21: DEBUG: Services registered successfully.
Completed chromite.api.VersionService/Get
Success!
Return Code: 0
Result:
{
  "version": {
    "major": 1
  }
}

Everything between Running ... and Completed ... in the output is the output produced by the endpoint itself. The Result: portion is simply the output.json file contents, e.g. cat version__get_output.json.

Notes

Changes made in the call_scripts/ input files will NOT be overwritten by changes in the example inputs in call_templates/. The only exception is that new templates in call_templates/ will replace empty inputs (i.e. those containing just {}), which is what gen_call_scripts produces when it has no example input file. call_scripts/ may be deleted at any time and will be regenerated from scratch, you will only lose changes you made to your input files.

You must be aware of the context of the endpoints for everything to work properly. These scripts only provide a more convenient way to call the endpoints, there is no automatic precondition checking or running. For example, you must manually run the endpoints to create the sysroot and build packages before running image__create. The endpoints are capable of using an existing sysroot, but compatibility is not guaranteed. This is especially true for endpoints that have specific USE flags that differ from those used to build out your sysroot. Often endpoints that are extracting data (e.g. the ArtifactsService) will work with any existing sysroot.