Skip to content

docs: document infrahubctl CRUD and schema discovery commands - #10016

Open
petercrocker wants to merge 6 commits into
stablefrom
document-infrahubctl-comm
Open

docs: document infrahubctl CRUD and schema discovery commands#10016
petercrocker wants to merge 6 commits into
stablefrom
document-infrahubctl-comm

Conversation

@petercrocker

@petercrocker petercrocker commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Why

The new infrahubctl CRUD and schema-discovery commands (get, create, update, delete, schema list, schema show) shipped in opsmill/infrahub-sdk-python#900, but the main docs had no narrative for interactive object management from the CLI. The only documented CLI data workflow was bulk YAML loading.

Goal: give users a workflow-focused how-to for the new commands, placed where object-management content already lives, linking out to the generated per-command reference.

Non-goals: does not duplicate the per-command option reference, which is auto-generated in the SDK repo and surfaced at docs.infrahub.app/infrahubctl.

What changed

Behavioral / user-facing:

  • New page Manage objects from the command line (docs/docs/objects/manage-from-cli.mdx) — schema discovery, query with filters/output formats/pagination, create, update, delete, YAML round-trip with infrahubctl object load, and --branch targeting.
  • Linked the page from the Objects hub (objects/overview.mdx) and the Schema & Data sidebar (docs/sidebars.ts).
  • Added an "Inspect the loaded schema" note to schema/create-and-load.mdx for schema list / schema show.

What stayed the same: docs-only change. No backend/frontend code, no schema, no generated files.

How to review

Start with docs/docs/objects/manage-from-cli.mdx. Command signatures and options were verified against the command source in infrahub-sdk-python#900, not the PR summary — note --yes exists only on delete, and --set/--file are mutually exclusive on create/update.

How to test

uv run invoke docs.lint          # Vale + markdownlint
cd docs && npm run build         # Docusaurus build, fails on broken links

Both pass locally; the build reports no broken links.

Checklist

  • External docs updated (this PR)
  • I have reviewed AI generated content
  • Changelog entry — N/A (docs-only)

Summary by cubic

Adds a workflow-focused how‑to for infrahubctl object CRUD and schema discovery from the CLI to enable interactive object management. Examples use the object subcommand (e.g., infrahubctl object get) and link to the generated infrahubctl-object reference; the page is linked from the Objects hub and the Schema & Data sidebar.

  • New Features
    • New page: Manage objects from the command line — schema list/show; object get with filters, output (table/json/csv/yaml), and pagination; object create, object update, object delete; YAML export + object load; and --branch targeting.
    • Clarifies identifiers (UUID/name/HFID) and how to find them via --output json|yaml; explains that update only changes provided fields and that --file mode targets the objects in the file; adds a schema tip to inspect kinds with schema list and schema show.

Written for commit b82b394. Summary will update on new commits.

Review in cubic

Add a how-to for the new infrahubctl end-user commands (get, create,
update, delete, schema list/show) introduced in infrahub-sdk-python#900.

- New spoke docs/docs/objects/manage-from-cli.mdx covering interactive
  object CRUD, output formats, YAML round-trip, and branch targeting
- Link it from the Objects hub and the Schema & Data sidebar
- Add a schema-discovery note to schema/create-and-load.mdx

The exhaustive per-command reference is generated in the SDK repo; these
pages stay workflow-focused and link out to it.
@petercrocker petercrocker added the type/documentation Improvements or additions to documentation label Jul 22, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Shadow auto-approve: would auto-approve. Docs-only addition of a workflow how-to page and a sidebar link. No code, schema, or behavioral changes; clearly beneficial and bounded.

Re-trigger cubic

@petercrocker
petercrocker marked this pull request as ready for review July 23, 2026 12:34
@petercrocker
petercrocker requested review from a team as code owners July 23, 2026 12:34
@petercrocker
petercrocker removed request for a team July 23, 2026 12:34

@PhillSimonds PhillSimonds left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I added comments in line with suggestions just so you can batch commit. the object parameter was missing from the infrahubctl commands.

Beyond that, and I know this is just a documentation PR, but right now the get commands don't show what the HFID/UUID of the node is, so it's a little difficult to understand from a get what you should then use to go and update/delete an existing node. Also, it would be nice to list the HFID/UUID at the beginning of the table, csv, yaml, or json output just to make those subsequent operations super easy.

Comment thread docs/docs/objects/manage-from-cli.mdx Outdated
Omit the identifier to list every object of a kind. Empty columns are hidden by default; pass `--all-columns` to show them:

```bash
infrahubctl get InfraDevice

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
infrahubctl get InfraDevice
infrahubctl object get InfraDevice

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this is just a documentation PR (and not a PR on the feature, but another thought, the ordering from the get shows non-hfid attributes first and doesn't include UUID. It would be good to start the table (leftmost column) with something that can be used to get a device.

Image

Comment thread docs/docs/objects/manage-from-cli.mdx Outdated
Provide an identifier — a UUID, a name, or an HFID — to display a single object in detail. For a multi-part HFID, separate the components with `/`:

```bash
infrahubctl get InfraDevice spine01

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
infrahubctl get InfraDevice spine01
infrahubctl object get InfraDevice spine01

Comment thread docs/docs/objects/manage-from-cli.mdx Outdated
Filter the results by attribute value with `attribute__value=<value>`:

```bash
infrahubctl get InfraDevice --filter name__value=spine01

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
infrahubctl get InfraDevice --filter name__value=spine01
infrahubctl object get InfraDevice --filter name__value=spine01

Comment thread docs/docs/objects/manage-from-cli.mdx Outdated
Page through large result sets with `--limit` and `--offset`:

```bash
infrahubctl get InfraDevice --limit 10 --offset 20

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
infrahubctl get InfraDevice --limit 10 --offset 20
infrahubctl object get InfraDevice --limit 10 --offset 20

Comment thread docs/docs/objects/manage-from-cli.mdx Outdated
Set field values inline with repeatable `--set key=value` flags:

```bash
infrahubctl create InfraDevice --set name=spine01 --set status=active

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
infrahubctl create InfraDevice --set name=spine01 --set status=active
infrahubctl object create InfraDevice --set name=spine01 --set status=active

Comment thread docs/docs/objects/manage-from-cli.mdx Outdated
## Reference

- [`infrahubctl get`]($(base_url)infrahubctl/infrahubctl-get)
- [`infrahubctl create`]($(base_url)infrahubctl/infrahubctl-create)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [`infrahubctl create`]($(base_url)infrahubctl/infrahubctl-create)
- [`infrahubctl object create`]($(base_url)infrahubctl/infrahubctl-create)

Comment thread docs/docs/objects/manage-from-cli.mdx Outdated

- [`infrahubctl get`]($(base_url)infrahubctl/infrahubctl-get)
- [`infrahubctl create`]($(base_url)infrahubctl/infrahubctl-create)
- [`infrahubctl update`]($(base_url)infrahubctl/infrahubctl-update)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [`infrahubctl update`]($(base_url)infrahubctl/infrahubctl-update)
- [`infrahubctl object update`]($(base_url)infrahubctl/infrahubctl-update)

Comment thread docs/docs/objects/manage-from-cli.mdx Outdated
- [`infrahubctl get`]($(base_url)infrahubctl/infrahubctl-get)
- [`infrahubctl create`]($(base_url)infrahubctl/infrahubctl-create)
- [`infrahubctl update`]($(base_url)infrahubctl/infrahubctl-update)
- [`infrahubctl delete`]($(base_url)infrahubctl/infrahubctl-delete)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [`infrahubctl delete`]($(base_url)infrahubctl/infrahubctl-delete)
- [`infrahubctl object delete`]($(base_url)infrahubctl/infrahubctl-delete)

- [`infrahubctl create`]($(base_url)infrahubctl/infrahubctl-create)
- [`infrahubctl update`]($(base_url)infrahubctl/infrahubctl-update)
- [`infrahubctl delete`]($(base_url)infrahubctl/infrahubctl-delete)
- [`infrahubctl schema`]($(base_url)infrahubctl/infrahubctl-schema)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [`infrahubctl schema`]($(base_url)infrahubctl/infrahubctl-schema)
- [`infrahubctl object schema`]($(base_url)infrahubctl/infrahubctl-schema)

infrahubctl schema show <kind> [--branch <branch_name>]
```

`schema show` prints the attributes and relationships of a kind, which is useful when querying or creating objects with [`infrahubctl`](../objects/manage-from-cli).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`schema show` prints the attributes and relationships of a kind, which is useful when querying or creating objects with [`infrahubctl`](../objects/manage-from-cli).
`infrahubctl schema show` prints the attributes and relationships of a kind, which is useful when querying or creating objects with [`infrahubctl`](../objects/manage-from-cli).

Address review feedback on PR #10016:
- Explain how to find an object's identifier (UUID/name/HFID) for use
  with update and delete, including via --output json/yaml
- Document that update only changes the fields provided and does not
  clear omitted attributes/relationships, and that --file mode targets
  the objects declared in the file
@petercrocker

Copy link
Copy Markdown
Contributor Author

@PhillSimonds thanks for the review.

I looked into the SDK source on opsmill/infrahub-sdk-python#900 before applying the object prefix. get/create/update/delete are registered as top-level infrahubctl commands in cli_commands.py:

app.command(name="get")(get_command)
app.command(name="create")(create_command)
app.command(name="update")(update_command)
app.command(name="delete")(delete_command)

They aren't under the object group — ctl/object.py only registers load and dump. So infrahubctl object get would error, and infrahubctl object schema isn't valid either (schema is its own top-level group). I've kept the top-level form for that reason. If the plan is to namespace these under object, that's an SDK change on #900 first — happy to update the docs to match once it lands.

I did address your other points (pushed in cfdfd76):

  • Finding the identifier for update/delete — added a note that the identifier is the object's UUID / name / HFID, and that --output json / --output yaml shows the id and HFID alongside the other fields.
  • update --file null-vs-skip — confirmed from update.py that an update only changes the fields you provide; omitted attributes/relationships keep their current values (not cleared). Documented that, plus the fact that --file mode targets the objects declared in the file.

The output-column ordering (identifier first) and a --set-none flag to explicitly clear fields are both good ideas, but they're SDK-side changes rather than docs — worth opening against opsmill/infrahub-sdk-python.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Confidence score: 3/5

  • In docs/docs/objects/manage-from-cli.mdx, the documented list workflow appears to omit UUID/HFID in JSON/CSV/YAML output, so users can’t obtain the identifier required for subsequent update/delete steps, which can block object management end-to-end. Align the docs with actual CLI behavior (or update examples/commands to surface id/HFID in list output) so the workflow is executable.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/docs/objects/manage-from-cli.mdx">

<violation number="1" location="docs/docs/objects/manage-from-cli.mdx:48">
P2: Users cannot follow this documented list workflow to obtain the UUID or HFID needed for a later `update` or `delete`: JSON/CSV/YAML list output omits both identifiers, while only detail JSON includes `id` and the formatters do not emit an HFID field. Please either document querying each object by name/HFID for detail output or update the CLI formatter contract so list output includes the identifiers described here; the affected implementation is opsmill/infrahub-sdk-python#900/infrahub_sdk/ctl/formatters/base.py:80-103.</violation>
</file>

Shadow auto-approve: would not auto-approve because issues were found.

Re-trigger cubic

infrahubctl get InfraDevice spine01
```

The identifier you pass to `update` and `delete` is any of these three values. To find it for an object in a list, use its name or HFID directly, or switch to `--output json` or `--output yaml` to see the object's UUID (`id`) and HFID alongside the other fields.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: Users cannot follow this documented list workflow to obtain the UUID or HFID needed for a later update or delete: JSON/CSV/YAML list output omits both identifiers, while only detail JSON includes id and the formatters do not emit an HFID field. Please either document querying each object by name/HFID for detail output or update the CLI formatter contract so list output includes the identifiers described here; the affected implementation is opsmill/infrahub-sdk-python#900/infrahub_sdk/ctl/formatters/base.py:80-103.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At docs/docs/objects/manage-from-cli.mdx, line 48:

<comment>Users cannot follow this documented list workflow to obtain the UUID or HFID needed for a later `update` or `delete`: JSON/CSV/YAML list output omits both identifiers, while only detail JSON includes `id` and the formatters do not emit an HFID field. Please either document querying each object by name/HFID for detail output or update the CLI formatter contract so list output includes the identifiers described here; the affected implementation is opsmill/infrahub-sdk-python#900/infrahub_sdk/ctl/formatters/base.py:80-103.</comment>

<file context>
@@ -45,6 +45,8 @@ Provide an identifier — a UUID, a name, or an HFID — to display a single obj
 infrahubctl get InfraDevice spine01

+The identifier you pass to update and delete is any of these three values. To find it for an object in a list, use its name or HFID directly, or switch to --output json or --output yaml to see the object's UUID (id) and HFID alongside the other fields.
+
Filter the results by attribute value with attribute__value=<value>:
</file context>


</details>

```suggestion
The identifier you pass to `update` and `delete` is any of these three values. To find it for an object in a list, use its name or HFID directly, or query the object by name or HFID to display its UUID (`id`) in the detailed output.

@PhillSimonds

PhillSimonds commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

@PhillSimonds thanks for the review.

I looked into the SDK source on opsmill/infrahub-sdk-python#900 before applying the object prefix. get/create/update/delete are registered as top-level infrahubctl commands in cli_commands.py:

app.command(name="get")(get_command)
app.command(name="create")(create_command)
app.command(name="update")(update_command)
app.command(name="delete")(delete_command)

They aren't under the object group — ctl/object.py only registers load and dump. So infrahubctl object get would error, and infrahubctl object schema isn't valid either (schema is its own top-level group). I've kept the top-level form for that reason. If the plan is to namespace these under object, that's an SDK change on #900 first — happy to update the docs to match once it lands.

I did address your other points (pushed in cfdfd76):

  • Finding the identifier for update/delete — added a note that the identifier is the object's UUID / name / HFID, and that --output json / --output yaml shows the id and HFID alongside the other fields.
  • update --file null-vs-skip — confirmed from update.py that an update only changes the fields you provide; omitted attributes/relationships keep their current values (not cleared). Documented that, plus the fact that --file mode targets the objects declared in the file.

The output-column ordering (identifier first) and a --set-none flag to explicitly clear fields are both good ideas, but they're SDK-side changes rather than docs — worth opening against opsmill/infrahub-sdk-python.

@petercrocker ofc!

Thanks for digging in on this! From the version of infrahubctl infrahub is running (v1.22.2) the environment shows the crud operations as sub commands of infrahubctl object rather than infrahubctl.

Screenshot 2026-07-29 at 8 43 10 AM

Those four app.command(name=...) lines are in infrahub_sdk/ctl/object/__init__.py, not cli_commands.py. The app there is the object sub-Typer, mounted in cli_commands.py via app.add_typer(object_app, name="object"), so the leaf name get resolves to infrahubctl object get. Also worth noting ctl/object.py is gone in 1.22.x — it's a package now — and dump is top-level, not part of the object group. Possible you were on an earlier revision of #900, before these got namespaced?

get/create/update/delete are leaf commands of the `object` sub-Typer
(`infrahub_sdk/ctl/object/__init__.py`), mounted via
`add_typer(object_app, name="object")`, so the correct invocation is
`infrahubctl object get` etc. — top-level `infrahubctl get` errors.

Also point the reference links at the generated `infrahubctl-object` page
with per-command anchors; the previous per-verb pages don't exist.
@petercrocker

Copy link
Copy Markdown
Contributor Author

You're right, thanks @PhillSimonds — I was reading an earlier revision of #900, before the object commands were moved into the infrahub_sdk/ctl/object/ package. On 1.22.x they're leaf commands of the object sub-Typer (app.command(name="get")(get_command) in object/__init__.py, mounted via add_typer(object_app, name="object")), so it is infrahubctl object get/create/update/delete, and object.py is gone.

Fixed in b82b394: all CRUD examples now use the object prefix, and the Reference links point at the generated infrahubctl-object page with per-command anchors (the previous per-verb pages didn't exist). Left infrahubctl object load as-is since the object group has its own load, and schema list/schema show stay under the schema group.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 issues found across 1 file (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Shadow auto-approve: would not auto-approve. Auto-approval blocked by 1 unresolved issue from previous reviews.

Re-trigger cubic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants