feat: add dynamic V1 programmatic API and schema subcommand#525
Merged
ssbarnea merged 2 commits intoansible:mainfrom Feb 23, 2026
Merged
feat: add dynamic V1 programmatic API and schema subcommand#525ssbarnea merged 2 commits intoansible:mainfrom
ssbarnea merged 2 commits intoansible:mainfrom
Conversation
Merged
4 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add a schema-driven Python API (V1 class) for programmatic interaction with ansible-creator, intended for internal Ansible ecosystem tooling (ansible-dev-tools server, VS Code extension, MCP servers). Key features: - Dynamic command discovery via argparse introspection (no maintenance) - schema()/schema_for() for capability introspection - run() constructs argv and feeds real argparse for validation - build_command() returns constructed argv without executing - Output capture via captured_messages parameter on Output class - CreatorResult dataclass with status, path, logs, and message - Explicit path support (init_path/path) or auto temp directory - CLI options (log_file, verbose, etc.) supported through argv - 100% branch coverage on api.py, output.py, schema.py Also adds: - Schema subcommand for CLI schema emission (JSON) - docs/api.md internal API documentation Relates: https://issues.redhat.com/browse/AAP-62949 Co-authored-by: Cursor <[email protected]>
ssbarnea
approved these changes
Feb 23, 2026
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.
Summary
Adds a schema-driven Python API (
V1class inansible_creator.api) for programmatic interaction with ansible-creator, intended for internal Ansible ecosystem tooling (ansible-dev-tools server, VS Code extension, MCP servers). Also adds aschemaCLI subcommand and supporting documentation.V1 API
schema()/schema_for()for capability introspectionrun(*command_path, **kwargs)constructs argv and feeds real argparse for validation and dispatchbuild_command(*command_path, **kwargs)returns the constructed argv without executingCreatorResultdataclass withstatus,path,logs, andmessagecaptured_messagesparameter onOutputclassinit_path/path) or auto temporary directory forinit/addlog_file,verbose,json, etc.) supported through argv constructionaction="count"handling (verbose=2produces-v -v)Architecture
ansible_creator.schema-- root-level module for schema introspection;subcommands/schema.pyis a thin CLI wrapperParser.build_parser()-- shared parser tree construction used by CLI, Schema, and API_build_output,_walk_to_leaf,_action_to_argv) keep method complexity under linter thresholdsAdditional changes
add resource aisubparser to accept apathpositional and--overwrite/--no-overwriteflags, matching all other resource subparsersOutput.critical()in capture mode now routes throughself.log()for consistent file loggingdocs/api.mddocuments the internal APIRelates: https://issues.redhat.com/browse/AAP-62949
Test plan
test_api.pycovering build_command, schema, init, add, error handling, verbosity, output capture, explicit paths, count actions, and unknown kwargsMade with Cursor