evercycle_api.py

Command-line client and Python library for the Evercycle API.

Classes

class evercycle_api.Colors

ANSI color constants for terminal output.

GREEN
YELLOW
RED
NC
class evercycle_api.EvercycleApiClient(api_dir=None)

Main client class for authenticating and calling Evercycle APIs.

Parameters:

api_dir (str) – Base directory containing auth.properties and config/ sub-directory. Defaults to os.getcwd().

load_auth_properties() dict[str, str]

Load auth.properties key/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, and RefreshToken and saves them to auth.properties.

Returns:

True on success, False on failure.

get_available_apis() dict[str, dict]

Scan the config/ directory for *.json files and build a map of available APIs. Each entry contains method, path, description, and config_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 path

  • edit-asset-id: first arg = id, second arg = JSON body string

  • grade: first arg = id, second arg = grade, third arg = JSON body

  • create, single-confirm, create-request: first arg = JSON body

Injects access-token and Authorization headers from auth_props before 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