workday_rest.py
- Add a function that builds path segments and calls
rest_request().
- Path segments = list of strings that form the path after the base (e.g.
["staffing", "v7", tenant, "workers", worker_id]).
- Get
tenant from get_rest_config()["tenant"].
- Get token in the caller (MCP server or Flask); pass
access_token into the REST helper.
Example (get one worker — already present):
def get_worker(worker_id: str, access_token: str) -> dict:
config = get_rest_config()
tenant = config["tenant"]
if not tenant:
raise ValueError("WORKDAY_TENANT is not set in .env (e.g. hack116_wcpdev1).")
return rest_request(
"GET",
["staffing", "v7", tenant, "workers", worker_id],
access_token,
)
Example (new operation — list workers):
def list_workers(access_token: str, limit: int = 100, offset: int = 0) -> dict:
config = get_rest_config()
tenant = config["tenant"]
if not tenant:
raise ValueError("WORKDAY_TENANT is not set.")
path = ["staffing", "v7", tenant, "workers"]
return rest_request("GET", path, access_token)