Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
cdfb316
Use new mutation names for getting pool resources (#465)
gmazoyer Jul 17, 2025
937eaae
Add protocols for Infrahub 1.4
ogenstad Aug 4, 2025
021a378
Merge pull request #488 from opsmill/pog-infrahub-develop-protocols
ogenstad Aug 4, 2025
760cf3a
Merge develop into infrahub-develop (#489)
gmazoyer Aug 7, 2025
f9be10d
Support infrahub.yml or infrahub.yaml configuration files
petercrocker Aug 10, 2025
06905fa
ruff
petercrocker Aug 10, 2025
c1d1bd4
Merge pull request #496 from opsmill/develop
ajtmccarty Aug 13, 2025
bf9571b
Merge pull request #492 from opsmill/pmc-yaml-2
dgarros Aug 24, 2025
5349382
Merge pull request #507 from opsmill/develop
ogenstad Aug 25, 2025
ab99599
Merge pull request #510 from opsmill/stable
ogenstad Aug 27, 2025
49335ca
Merge pull request #517 from opsmill/stable
gmazoyer Aug 28, 2025
ed6673e
IHS-154 Deprecate using `raise_for_error = False` (#508)
gmazoyer Sep 1, 2025
82556f1
fix(docs): broken links to .infrahub.yml
fatih-acar Sep 1, 2025
828e81c
Merge pull request #525 from opsmill/stable
ogenstad Sep 5, 2025
28ea246
Bump actions/setup-python from 5 to 6
dependabot[bot] Sep 8, 2025
ef4ffe3
Bump actions/labeler from 5.0.0 to 6.0.1
dependabot[bot] Sep 8, 2025
b3251ab
Bump actions/setup-node from 4 to 5
dependabot[bot] Sep 8, 2025
7301060
Merge pull request #534 from opsmill/dependabot/github_actions/develo…
ogenstad Sep 9, 2025
41dfe7c
Merge pull request #532 from opsmill/dependabot/github_actions/develo…
ogenstad Sep 9, 2025
9222be5
Clean up typing for proxy config
ogenstad Sep 10, 2025
1c7922f
Merge pull request #533 from opsmill/dependabot/github_actions/develo…
ogenstad Sep 10, 2025
90f7be1
Fix return types
ogenstad Sep 10, 2025
751b7da
Fix typing for substract params
ogenstad Sep 10, 2025
89d4e9f
Merge pull request #541 from opsmill/pog-test-return-types
ogenstad Sep 11, 2025
90bad6d
Merge pull request #540 from opsmill/pog-substract-param-typing
ogenstad Sep 11, 2025
ac60214
Merge pull request #539 from opsmill/pog-proxy-config-typing
ogenstad Sep 11, 2025
0a1d3eb
Merge pull request #530 from opsmill/develop
dgarros Sep 14, 2025
285b5a4
Merge branch 'stable' into 'develop' with resolved conflicts
ogenstad Sep 16, 2025
e7ed981
Format with ruff
ogenstad Sep 16, 2025
c111658
IFC-1811: Replace toml package with tomllib and tomli optionally (#551)
solababs Sep 17, 2025
654fc80
Merge pull request #550 from opsmill/pog-stable-to-develop-20250916
ogenstad Sep 17, 2025
9340fd2
Add convert_object_type method (#554)
LucasG0 Sep 19, 2025
471bfac
Add support for clearing optional attributes (#548) (#557)
infrahub-github-bot-app[bot] Sep 22, 2025
840d98a
IHS-147: Fix schema load failure exception (#555)
solababs Sep 22, 2025
6cdd780
Add to object conversion input (#558)
LucasG0 Sep 24, 2025
f9ccf10
Merge pull request #559 from opsmill/stable
dgarros Sep 30, 2025
2c16773
Object file range expansion (#561)
minitriga Sep 30, 2025
d058d6f
Bump peter-evans/repository-dispatch from 3 to 4
dependabot[bot] Oct 6, 2025
cb4c330
Merge branch 'develop' into 'infrahub-develop' with resolved conflicts
ogenstad Oct 7, 2025
2a0c092
Merge pull request #566 from opsmill/pog-infrahub-develop-merge-confl…
ogenstad Oct 7, 2025
f7b39f0
IHS-163 Add required change for IFC-1820 (display_label) (#556)
gmazoyer Oct 7, 2025
a9f9740
bump version to v1.15.0b0
wvandeun Oct 7, 2025
cea3266
Merge pull request #568 from opsmill/wvd-20251007-prep-release-1.15.0b0
wvandeun Oct 7, 2025
34fda2d
Merge pull request #569 from opsmill/stable
ogenstad Oct 7, 2025
6610115
Merge pull request #570 from opsmill/develop
ogenstad Oct 8, 2025
7fbc329
Range Expansion Imrovements (#571)
minitriga Oct 9, 2025
cf599ac
IHS-170: Disable rich console print markup causing regex reformatting…
solababs Oct 10, 2025
f238ec6
Merge pull request #575 from opsmill/develop
dgarros Oct 11, 2025
9aaadad
Merge pull request #564 from opsmill/dependabot/github_actions/develo…
dgarros Oct 11, 2025
423cfbf
Merge pull request #577 from opsmill/stable
dgarros Oct 11, 2025
0ca3ee4
add infrahubctl graphql generate-return-types command
dgarros Oct 13, 2025
d490fd8
Add branch support to get_graphql_schema
dgarros Oct 13, 2025
b61c7bd
Merge pull request #546 from opsmill/dga-20250913-graphql-return-types
dgarros Oct 13, 2025
0f3b29b
Merge pull request #576 from opsmill/develop
dgarros Oct 13, 2025
0f5a1df
Extend GeneratorDefinition with flags to control execution
dgarros Oct 14, 2025
a6c6ac6
Merge pull request #578 from opsmill/dga-20250909-generator-flags
dgarros Oct 14, 2025
7a7104c
bump version to 1.15.0b1
wvandeun Oct 20, 2025
2dcc1db
Merge pull request #584 from opsmill/wvd-20251020-prep-release-1.15.0b1
wvandeun Oct 20, 2025
7b7612d
Process schema deprecation warnings
ogenstad Oct 17, 2025
4c8134d
Merge pull request #582 from opsmill/pog-process-schema-deprecations
ogenstad Oct 24, 2025
5fb0758
IHS-128: Replace `Sync` in protocol sync classes schema name (#586)
solababs Oct 29, 2025
c50ee21
Merge pull request #587 from opsmill/develop
ogenstad Oct 29, 2025
7b4adf7
Resolve merge conflict for infrahub_sdk/client.py
ogenstad Oct 31, 2025
9f1a0f8
Replace strategy in object file with parameters section (#585)
dgarros Nov 3, 2025
7f40f0b
Merge pull request #594 from opsmill/pog-stable-to-develop-20251031
ogenstad Nov 3, 2025
b52cd94
Merge pull request #592 from opsmill/stable
ogenstad Nov 3, 2025
115333e
Merge pull request #598 from opsmill/develop
ogenstad Nov 3, 2025
9fb8d3c
Add `graph_version` and `status` to branch (#600)
gmazoyer Nov 6, 2025
7b0e10d
Merge branch 'stable' into fac-merge-stable-into-develop
fatih-acar Nov 7, 2025
89426c6
Merge pull request #605 from opsmill/fac-merge-stable-into-develop
fatih-acar Nov 7, 2025
a151dc8
Merge pull request #607 from opsmill/develop
fatih-acar Nov 7, 2025
e3d2bff
Merge branch 'stable' into fac-merge-stable-into-develop
fatih-acar Nov 10, 2025
e37672c
Merge pull request #610 from opsmill/fac-merge-stable-into-develop
fatih-acar Nov 10, 2025
f43c73a
Merge pull request #612 from opsmill/develop
fatih-acar Nov 10, 2025
bb1acc1
fix: update infrahub-testcontainers to 1.5.0b2
fatih-acar Nov 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ jobs:
with:
submodules: true
- name: Install NodeJS
uses: actions/setup-node@v4
uses: actions/setup-node@v5
with:
node-version: 20
cache: 'npm'
cache-dependency-path: docs/package-lock.json
- name: "Install dependencies"
run: npm install
- name: "Setup Python environment"
run: "pip install invoke toml"
run: "pip install invoke"
- name: "Build docs website"
run: "invoke docs"

Expand Down Expand Up @@ -176,7 +176,7 @@ jobs:
- name: "Install dependencies"
run: "poetry install --no-interaction --no-ansi --extras ctl"
- name: "Setup environment"
run: "pip install invoke toml"
run: "poetry run pip install invoke"
- name: "Validate generated documentation"
run: "poetry run invoke docs-validate"

Expand Down Expand Up @@ -236,7 +236,11 @@ jobs:
run: |
pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }} --python python${{ matrix.python-version }}
poetry config virtualenvs.create true --local
pip install invoke toml codecov
pip install invoke codecov
- name: "Install tomli for Python < 3.11"
if: matrix.python-version == '3.9' || matrix.python-version == '3.10'
run: |
pip install tomli
- name: "Install Package"
run: "poetry install --all-extras"
- name: "Mypy Tests"
Expand Down Expand Up @@ -289,7 +293,7 @@ jobs:
run: |
pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
poetry config virtualenvs.create true --local
pip install invoke toml codecov
pip install invoke codecov
- name: "Install Package"
run: "poetry install --all-extras"
- name: "Integration Tests"
Expand Down Expand Up @@ -362,7 +366,7 @@ jobs:
# run: |
# pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }}
# poetry config virtualenvs.create true --local
# pip install invoke toml codecov
# pip install invoke codecov

# - name: "Install Package"
# run: "poetry install --all-extras"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/repository-dispatch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
uses: actions/checkout@v5

- name: Repository Dispatch
uses: peter-evans/repository-dispatch@v3
uses: peter-evans/repository-dispatch@v4
with:
token: ${{ secrets.GH_UPDATE_PACKAGE_OTTO }}
# if matrix.repo contains a slash, use it literally; otherwise look up the secret named by matrix.repo
Expand Down
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
- id: check-ast
- id: check-case-conflict
- id: check-merge-conflict
- id: check-toml
- id: check-yaml
- id: end-of-file-fixer

- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.11.9
hooks:
# Run the linter.
- id: ruff
args: [--fix]
# Run the formatter.
- id: ruff-format
1 change: 0 additions & 1 deletion .vale/styles/Infrahub/branded-terms-case-swap.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ swap:
(?:[Gg]itlab): GitLab
(?:gitpod): GitPod
(?:grafana): Grafana
(?:[^/][Gg]raphql): GraphQL
(?:[Ii]nflux[Dd]b): InfluxDB
infrahub(?:\s|$): Infrahub
(?:jinja2): Jinja2
Expand Down
1 change: 1 addition & 0 deletions changelog/+branch-graph-version-status.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `graph_version` and `status` properties to `Branch`
1 change: 1 addition & 0 deletions changelog/+convert-object-type.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `convert_object_type` method to allow converting an object to another type.
1 change: 1 addition & 0 deletions changelog/+f6791a3d.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added deprecation warnings when loading or checking schemas
1 change: 1 addition & 0 deletions changelog/+gql-command.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add `infrahubctl graphql` commands to export schema and generate Pydantic types from GraphQL queries
1 change: 1 addition & 0 deletions changelog/380.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replaced the `Sync` word in the protocol schema name so that the correct kind can be gotten from the cache
1 change: 1 addition & 0 deletions changelog/464.housekeeping.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Handle error gracefully when loading schema instead of failing with an exception
1 change: 1 addition & 0 deletions changelog/493.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Deprecate the use of `raise_for_error=False` across several methods, using a try/except pattern is preferred.
1 change: 1 addition & 0 deletions changelog/528.housekeeping.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Replace toml package with tomllib and tomli optionally for when Python version is less than 3.11
1 change: 1 addition & 0 deletions changelog/560.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add the ability to perform range expansions in object files. This feature allows users to define patterns in string fields that will be expanded into multiple objects, facilitating bulk object creation and management. The implementation includes validation to ensure that all expanded lists have the same length, preventing inconsistencies. Documentation has been updated to explain how to use this feature, including examples of valid and invalid configurations.
1 change: 1 addition & 0 deletions changelog/565.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Disable rich console print markup causing regex reformatting
56 changes: 56 additions & 0 deletions docs/docs/infrahubctl/infrahubctl-graphql.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# `infrahubctl graphql`

Various GraphQL related commands.

**Usage**:

```console
$ infrahubctl graphql [OPTIONS] COMMAND [ARGS]...
```

**Options**:

* `--install-completion`: Install completion for the current shell.
* `--show-completion`: Show completion for the current shell, to copy it or customize the installation.
* `--help`: Show this message and exit.

**Commands**:

* `export-schema`: Export the GraphQL schema to a file.
* `generate-return-types`: Create Pydantic Models for GraphQL query...

## `infrahubctl graphql export-schema`

Export the GraphQL schema to a file.

**Usage**:

```console
$ infrahubctl graphql export-schema [OPTIONS]
```

**Options**:

* `--destination PATH`: Path to the GraphQL schema file. [default: schema.graphql]
* `--config-file TEXT`: [env var: INFRAHUBCTL_CONFIG; default: infrahubctl.toml]
* `--help`: Show this message and exit.

## `infrahubctl graphql generate-return-types`

Create Pydantic Models for GraphQL query return types

**Usage**:

```console
$ infrahubctl graphql generate-return-types [OPTIONS] [QUERY]
```

**Arguments**:

* `[QUERY]`: Location of the GraphQL query file(s). Defaults to current directory if not specified.

**Options**:

* `--schema PATH`: Path to the GraphQL schema file. [default: schema.graphql]
* `--config-file TEXT`: [env var: INFRAHUBCTL_CONFIG; default: infrahubctl.toml]
* `--help`: Show this message and exit.
Comment on lines +1 to +56
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Add required Diataxis frontmatter.

Docs under docs/ must declare their Diataxis classification via frontmatter; without it this page can’t be indexed correctly and violates the documentation guidelines. Please add the appropriate metadata at the top (e.g., classify this as a “Reference” page) before the heading.

As per coding guidelines.

Apply this diff:

+# ---
+# title: infrahubctl GraphQL CLI reference
+# description: Reference for the infrahubctl graphql command group and its subcommands.
+# type: Reference
+# ---
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# `infrahubctl graphql`
Various GraphQL related commands.
**Usage**:
```console
$ infrahubctl graphql [OPTIONS] COMMAND [ARGS]...
```
**Options**:
* `--install-completion`: Install completion for the current shell.
* `--show-completion`: Show completion for the current shell, to copy it or customize the installation.
* `--help`: Show this message and exit.
**Commands**:
* `export-schema`: Export the GraphQL schema to a file.
* `generate-return-types`: Create Pydantic Models for GraphQL query...
## `infrahubctl graphql export-schema`
Export the GraphQL schema to a file.
**Usage**:
```console
$ infrahubctl graphql export-schema [OPTIONS]
```
**Options**:
* `--destination PATH`: Path to the GraphQL schema file. [default: schema.graphql]
* `--config-file TEXT`: [env var: INFRAHUBCTL_CONFIG; default: infrahubctl.toml]
* `--help`: Show this message and exit.
## `infrahubctl graphql generate-return-types`
Create Pydantic Models for GraphQL query return types
**Usage**:
```console
$ infrahubctl graphql generate-return-types [OPTIONS] [QUERY]
```
**Arguments**:
* `[QUERY]`: Location of the GraphQL query file(s). Defaults to current directory if not specified.
**Options**:
* `--schema PATH`: Path to the GraphQL schema file. [default: schema.graphql]
* `--config-file TEXT`: [env var: INFRAHUBCTL_CONFIG; default: infrahubctl.toml]
* `--help`: Show this message and exit.
---
title: infrahubctl GraphQL CLI reference
description: Reference for the infrahubctl graphql command group and its subcommands.
type: Reference
---
# `infrahubctl graphql`
Various GraphQL related commands.
**Usage**:
🧰 Tools
🪛 LanguageTool

[grammar] ~3-~3: Use a hyphen to join words.
Context: ...# infrahubctl graphql Various GraphQL related commands. Usage: ```consol...

(QB_NEW_EN_HYPHEN)

🤖 Prompt for AI Agents
In docs/docs/infrahubctl/infrahubctl-graphql.mdx around lines 1 to 56, the file
is missing required Diataxis frontmatter so the page can’t be indexed; add a
YAML frontmatter block at the very top of the file containing at minimum a
diataxis classification (e.g., diataxis: Reference) and a title (e.g., title:
"infrahubctl graphql"); ensure the frontmatter block is placed before the first
heading and includes any standard site keys you use (layout, slug, sidebar) so
the page conforms to the docs guidelines.

50 changes: 49 additions & 1 deletion docs/docs/python-sdk/guides/python-typing.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,52 @@ from lib.protocols import MyOwnObject
my_object = client.get(MyOwnObject, name__value="example")
```

> if you don't have your own Python module, it's possible to use relative path by having the `procotols.py` in the same directory as your script/transform/generator
> if you don't have your own Python module, it's possible to use relative path by having the `protocols.py` in the same directory as your script/transform/generator

## Generating Pydantic models from GraphQL queries

When working with GraphQL queries, you can generate type-safe Pydantic models that correspond to your query return types. This provides excellent type safety and IDE support for your GraphQL operations.

### Why use generated return types?

Generated Pydantic models from GraphQL queries offer several important benefits:

- **Type Safety**: Catch type errors during development time instead of at runtime
- **IDE Support**: Get autocomplete, type hints, and better IntelliSense in your IDE
- **Documentation**: Generated models serve as living documentation of your GraphQL API
- **Validation**: Automatic validation of query responses against the expected schema

### Generating return types

Use the `infrahubctl graphql generate-return-types` command to create Pydantic models from your GraphQL queries:

```shell
# Generate models for queries in current directory
infrahubctl graphql generate-return-types

# Generate models for specific query files
infrahubctl graphql generate-return-types queries/get_devices.gql
```

> You can also export the GraphQL schema first using the `infrahubctl graphql export-schema` command:

### Example workflow

1. **Create your GraphQL queries** in `.gql` files:

2. **Generate the Pydantic models**:

```shell
infrahubctl graphql generate-return-types queries/
```

The command will generate the Python file per query based on the name of the query.

3. **Use the generated models** in your Python code

```python
from .queries.get_devices import GetDevicesQuery

response = await client.execute_graphql(query=MY_QUERY)
data = GetDevicesQuery(**response)
```
114 changes: 114 additions & 0 deletions docs/docs/python-sdk/topics/object_file.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,24 @@ apiVersion: infrahub.app/v1
kind: Object
spec:
kind: <NamespaceName>
parameters:
expand_range: <boolean> # Optional, defaults to false
data:
- [...]
```

> Multiple documents in a single YAML file are also supported, each document will be loaded separately. Documents are separated by `---`

### Data Processing Parameters

The `parameters` field controls how the data in the object file is processed before loading into Infrahub:

| Parameter | Description | Default |
|-----------|-------------|---------|
| `expand_range` | When set to `true`, range patterns (e.g., `[1-5]`) in string fields are expanded into multiple objects. | `false` |

When `expand_range` is not specified, it defaults to `false`.

### Relationship of cardinality one

A relationship of cardinality one can either reference an existing node via its HFID or create a new node if it doesn't exist.
Expand Down Expand Up @@ -195,3 +207,105 @@ Metadata support is planned for future releases. Currently, the Object file does
2. Keep object files organized by model type or purpose.
3. Validate object files before loading them into production environments.
4. Use comments in your YAML files to document complex relationships or dependencies.

## Range Expansion in Object Files

The Infrahub Python SDK supports **range expansion** for string fields in object files when the `parameters > expand_range` is set to `true`. This feature allows you to specify a range pattern (e.g., `[1-5]`) in any string value, and the SDK will automatically expand it into multiple objects during validation and processing.

```yaml
---
apiVersion: infrahub.app/v1
kind: Object
spec:
kind: BuiltinLocation
parameters:
expand_range: true # Enable range expansion
data:
- name: AMS[1-3]
type: Country
```

### How Range Expansion Works

- Any string field containing a pattern like `[1-5]`, `[10-15]`, or `[1,3,5]` will be expanded into multiple objects.
- If multiple fields in the same object use range expansion, **all expanded lists must have the same length**. If not, validation will fail.
- The expansion is performed before validation and processing, so all downstream logic works on the expanded data.

### Examples

#### Single Field Expansion

```yaml
spec:
kind: BuiltinLocation
parameters:
expand_range: true
data:
- name: AMS[1-3]
type: Country
```

This will expand to:

```yaml
- name: AMS1
type: Country
- name: AMS2
type: Country
- name: AMS3
type: Country
```

#### Multiple Field Expansion (Matching Lengths)

```yaml
spec:
kind: BuiltinLocation
parameters:
expand_range: true
data:
- name: AMS[1-3]
description: Datacenter [A-C]
type: Country
```

This will expand to:

```yaml
- name: AMS1
description: Datacenter A
type: Country
- name: AMS2
description: Datacenter B
type: Country
- name: AMS3
description: Datacenter C
type: Country
```

#### Error: Mismatched Range Lengths

If you use ranges of different lengths in multiple fields:

```yaml
spec:
kind: BuiltinLocation
parameters:
expand_range: true
data:
- name: AMS[1-3]
description: "Datacenter [10-15]"
type: Country
```

This will **fail validation** with an error like:

```bash
Range expansion mismatch: fields expanded to different lengths: [3, 6]
```

### Notes

- Range expansion is supported for any string field in the `data` section.
- If no range pattern is present, the field is left unchanged.
- If expansion fails for any field, validation will fail with an error message.
2 changes: 1 addition & 1 deletion docs/docusaurus.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const config: Config = {
additionalLanguages: ["bash", "python", "markup-templating", "django", "json", "toml", "yaml"],
},
} satisfies Preset.ThemeConfig,

markdown: {
format: "mdx",
preprocessor: ({ filePath, fileContent }) => {
Expand Down
Loading