Repository navigation
Add a Client that mirrors the CLI command tree - #48
Merged
Merged
Conversation
from tmxcaliber import Client exposes every API command as an attribute
path built at construction from the route table, so a new route becomes
a method and a command together:
api = Client()
api.threatmodels.threats("aws-s3", feature_class="S3.FC1")
Each operation carries a signature derived from its route. Credentials
resolve as the CLI's do, with api_key and api_url arguments ranked above
both. An incomplete answer raises IncompleteAnswer unless the caller
passes allow_incomplete=True.
The route-to-request logic moves from remote_cli into
lib/remote/operations.py so the CLI and Client share it, and the stored
endpoint note moves onto Settings so both surfaces word it the same way.
Bump to 0.6.0.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a Python library entry point that mirrors the CLI:
What changes
Client, exported from the package root along with the error classes. Every CLI command is an attribute path built at construction fromcontract.ROUTES, so a route the API adds is a method and a command together, with no route named in the library code. Each operation carries aninspect.Signaturederived from its route, sohelp()and argument errors read like an ordinary function.api_keyandapi_urlarguments override both, and when both are passed the credentials file is not read. A key that would reach a stored endpoint raises the CLI's note as aUserWarning.IncompleteAnswer, which carries the rows that did arrive.allow_incomplete=Truemirrors--allow-incomplete.lib/remote/operations.pynow owns the route-to-request logic: path filling, filters, paging and incompleteness.run_api_commandandClientboth call it, and the CLI's behavior is unchanged.Settings.stored_endpoint_noteowns the stored-endpoint wording for both surfaces.sends_environment_key_to_stored_endpointis renamedsends_key_to_stored_endpoint, and it also covers a key passed as an argument.uv.lock.Testing
test/test_remote_api.py, which iterates overROUTESrather than naming routes: every route is reachable at its command path, sends its own path and filters, and has a signature matching its CLI options. It also covers paging,@release, refused arguments, required filters, incompleteness, credential precedence, and the stored-endpoint warning.ruff format --check,ruff checkandmypyare clean.uv buildandtwine checkpass.