evercycle_api.py
Command-line client and Python library for the Evercycle API.
Classes
- class evercycle_api.EvercycleApiClient(api_dir=None)
Main client class for authenticating and calling Evercycle APIs.
- Parameters:
api_dir (str) – Base directory containing
auth.propertiesandconfig/sub-directory. Defaults toos.getcwd().
- load_auth_properties() dict[str, str]
Load
auth.propertieskey/value pairs into a dictionary.
- save_auth_properties(props) None
Write a dictionary of properties back to
auth.properties.
- authenticate(username=None, password=None) bool
Authenticate with
/v1/auth/signin.If credentials are not provided, they are loaded from
config/auth-signin.json.On success, extracts
AccessToken,IdToken, andRefreshTokenand saves them toauth.properties.- Returns:
True on success, False on failure.
- get_available_apis() dict[str, dict]
Scan the
config/directory for*.jsonfiles and build a map of available APIs. Each entry containsmethod,path,description, andconfig_file.
- list_apis() None
Print a formatted list of available APIs to the terminal.
- call_api(api_name: str, *args) bool
Call a specific API endpoint using its JSON config.
Argument mapping by API name:
get-asset-id: first arg replaces{id}in pathedit-asset-id: first arg = id, second arg = JSON body stringgrade: first arg = id, second arg = grade, third arg = JSON bodycreate,single-confirm,create-request: first arg = JSON body
Injects
access-tokenandAuthorizationheaders fromauth_propsbefore making the request.Prints request details and response to stdout and returns True/False.
- Parameters:
api_name (str) – Name of the API config.
args – Variable positional arguments (see mapping above).
- Returns:
True if the HTTP call succeeds (2xx), False otherwise.
Functions
- evercycle_api.main()
CLI entry point supporting three subcommands:
auth [--username] [--password]call <api_name> [params...]list