From d69b7f68b07e779374865f505a6977d68a5f3d76 Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Wed, 23 Jul 2025 10:07:00 +0200 Subject: [PATCH 01/24] docs: generate API docs --- .../sdk_ref/infrahub_sdk/analyzer.mdx | 70 ++ .../sdk_ref/infrahub_sdk/async_typer.mdx | 30 + .../python-sdk/sdk_ref/infrahub_sdk/batch.mdx | 75 ++ .../sdk_ref/infrahub_sdk/branch.mdx | 151 ++++ .../sdk_ref/infrahub_sdk/checks.mdx | 100 +++ .../sdk_ref/infrahub_sdk/client.mdx | 828 ++++++++++++++++++ .../sdk_ref/infrahub_sdk/config.mdx | 86 ++ .../sdk_ref/infrahub_sdk/constants.mdx | 10 + .../sdk_ref/infrahub_sdk/context.mdx | 16 + .../sdk_ref/infrahub_sdk/ctl/branch.mdx | 80 ++ .../sdk_ref/infrahub_sdk/ctl/check.mdx | 62 ++ .../sdk_ref/infrahub_sdk/ctl/cli.mdx | 8 + .../sdk_ref/infrahub_sdk/ctl/cli_commands.mdx | 94 ++ .../sdk_ref/infrahub_sdk/ctl/client.mdx | 20 + .../sdk_ref/infrahub_sdk/ctl/config.mdx | 63 ++ .../sdk_ref/infrahub_sdk/ctl/exceptions.mdx | 16 + .../sdk_ref/infrahub_sdk/ctl/exporter.mdx | 24 + .../sdk_ref/infrahub_sdk/ctl/generator.mdx | 20 + .../sdk_ref/infrahub_sdk/ctl/importer.mdx | 24 + .../sdk_ref/infrahub_sdk/ctl/menu.mdx | 38 + .../sdk_ref/infrahub_sdk/ctl/object.mdx | 38 + .../sdk_ref/infrahub_sdk/ctl/parameters.mdx | 18 + .../sdk_ref/infrahub_sdk/ctl/render.mdx | 20 + .../sdk_ref/infrahub_sdk/ctl/repository.mdx | 48 + .../sdk_ref/infrahub_sdk/ctl/schema.mdx | 68 ++ .../sdk_ref/infrahub_sdk/ctl/transform.mdx | 14 + .../sdk_ref/infrahub_sdk/ctl/utils.mdx | 92 ++ .../sdk_ref/infrahub_sdk/ctl/validate.mdx | 38 + .../python-sdk/sdk_ref/infrahub_sdk/data.mdx | 20 + .../python-sdk/sdk_ref/infrahub_sdk/diff.mdx | 30 + .../sdk_ref/infrahub_sdk/exceptions.mdx | 68 ++ .../sdk_ref/infrahub_sdk/generator.mdx | 69 ++ .../sdk_ref/infrahub_sdk/graphql.mdx | 70 ++ .../sdk_ref/infrahub_sdk/groups.mdx | 14 + .../sdk_ref/infrahub_sdk/jinja2.mdx | 20 + .../sdk_ref/infrahub_sdk/node/attribute.mdx | 28 + .../sdk_ref/infrahub_sdk/node/constants.mdx | 8 + .../sdk_ref/infrahub_sdk/node/node.mdx | 345 ++++++++ .../sdk_ref/infrahub_sdk/node/parsers.mdx | 18 + .../sdk_ref/infrahub_sdk/node/property.mdx | 14 + .../infrahub_sdk/node/related_node.mdx | 116 +++ .../infrahub_sdk/node/relationship.mdx | 116 +++ .../sdk_ref/infrahub_sdk/object_store.mdx | 42 + .../sdk_ref/infrahub_sdk/operation.mdx | 54 ++ .../sdk_ref/infrahub_sdk/playback.mdx | 24 + .../sdk_ref/infrahub_sdk/protocols.mdx | 332 +++++++ .../sdk_ref/infrahub_sdk/protocols_base.mdx | 272 ++++++ .../protocols_generator/constants.mdx | 8 + .../protocols_generator/generator.mdx | 36 + .../infrahub_sdk/pytest_plugin/exceptions.mdx | 32 + .../infrahub_sdk/pytest_plugin/items/base.mdx | 65 ++ .../pytest_plugin/items/check.mdx | 60 ++ .../pytest_plugin/items/graphql_query.mdx | 50 ++ .../pytest_plugin/items/jinja2_transform.mdx | 78 ++ .../pytest_plugin/items/python_transform.mdx | 60 ++ .../infrahub_sdk/pytest_plugin/loader.mdx | 36 + .../infrahub_sdk/pytest_plugin/models.mdx | 96 ++ .../infrahub_sdk/pytest_plugin/plugin.mdx | 32 + .../infrahub_sdk/pytest_plugin/utils.mdx | 14 + .../sdk_ref/infrahub_sdk/queries.mdx | 14 + .../sdk_ref/infrahub_sdk/query_groups.mdx | 139 +++ .../sdk_ref/infrahub_sdk/recorder.mdx | 52 ++ .../sdk_ref/infrahub_sdk/repository.mdx | 24 + .../sdk_ref/infrahub_sdk/schema/main.mdx | 208 +++++ .../infrahub_sdk/schema/repository.mdx | 158 ++++ .../sdk_ref/infrahub_sdk/spec/menu.mdx | 34 + .../sdk_ref/infrahub_sdk/spec/object.mdx | 175 ++++ .../python-sdk/sdk_ref/infrahub_sdk/store.mdx | 195 +++++ .../sdk_ref/infrahub_sdk/task/constants.mdx | 8 + .../sdk_ref/infrahub_sdk/task/exceptions.mdx | 16 + .../sdk_ref/infrahub_sdk/task/manager.mdx | 254 ++++++ .../sdk_ref/infrahub_sdk/task/models.mdx | 34 + .../infrahub_sdk/template/exceptions.mdx | 18 + .../sdk_ref/infrahub_sdk/template/filters.mdx | 10 + .../sdk_ref/infrahub_sdk/template/models.mdx | 10 + .../sdk_ref/infrahub_sdk/testing/docker.mdx | 36 + .../infrahub_sdk/testing/repository.mdx | 46 + .../infrahub_sdk/testing/schemas/animal.mdx | 90 ++ .../testing/schemas/car_person.mdx | 138 +++ .../sdk_ref/infrahub_sdk/timestamp.mdx | 60 ++ .../sdk_ref/infrahub_sdk/topological_sort.mdx | 32 + .../infrahub_sdk/transfer/constants.mdx | 8 + .../infrahub_sdk/transfer/exceptions.mdx | 18 + .../transfer/exporter/interface.mdx | 18 + .../infrahub_sdk/transfer/exporter/json.mdx | 36 + .../transfer/importer/interface.mdx | 18 + .../infrahub_sdk/transfer/importer/json.mdx | 48 + .../infrahub_sdk/transfer/schema_sorter.mdx | 18 + .../sdk_ref/infrahub_sdk/transforms.mdx | 49 ++ .../python-sdk/sdk_ref/infrahub_sdk/types.mdx | 76 ++ .../python-sdk/sdk_ref/infrahub_sdk/utils.mdx | 261 ++++++ .../python-sdk/sdk_ref/infrahub_sdk/uuidt.mdx | 47 + .../python-sdk/sdk_ref/infrahub_sdk/yaml.mdx | 88 ++ 93 files changed, 6814 insertions(+) create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/analyzer.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/async_typer.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/batch.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/branch.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/checks.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/config.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/constants.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/context.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/branch.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/check.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli_commands.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/client.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/config.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exceptions.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exporter.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/generator.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/importer.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/menu.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/object.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/parameters.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/render.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/repository.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/schema.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/transform.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/validate.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/data.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/diff.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/exceptions.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/generator.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/graphql.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/groups.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/jinja2.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/attribute.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/constants.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/parsers.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/property.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/related_node.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/object_store.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/operation.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/playback.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_base.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/constants.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/generator.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/exceptions.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/base.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/check.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/graphql_query.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/jinja2_transform.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/python_transform.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/loader.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/models.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/plugin.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/utils.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/queries.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/query_groups.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/recorder.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/repository.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/main.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/repository.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/menu.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/object.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/store.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/constants.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/exceptions.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/manager.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/models.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/exceptions.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/filters.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/models.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/docker.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/repository.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/schemas/animal.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/schemas/car_person.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/timestamp.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/topological_sort.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/constants.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exceptions.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exporter/interface.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exporter/json.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/importer/interface.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/importer/json.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/schema_sorter.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/transforms.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/types.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/utils.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/uuidt.mdx create mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/yaml.mdx diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/analyzer.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/analyzer.mdx new file mode 100644 index 00000000..5a83f8d4 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/analyzer.mdx @@ -0,0 +1,70 @@ +--- +title: analyzer +sidebarTitle: analyzer +--- + +# `infrahub_sdk.analyzer` + +## Classes + +### `GraphQLQueryVariable` + +### `GraphQLOperation` + +### `GraphQLQueryAnalyzer` + +**Methods:** + +#### `is_valid` + +```python +is_valid(self) -> tuple[bool, list[GraphQLError] | None] +``` + +#### `nbr_queries` + +```python +nbr_queries(self) -> int +``` + +#### `operations` + +```python +operations(self) -> list[GraphQLOperation] +``` + +#### `contains_mutation` + +```python +contains_mutation(self) -> bool +``` + +#### `variables` + +```python +variables(self) -> list[GraphQLQueryVariable] +``` + +#### `calculate_depth` + +```python +calculate_depth(self) -> int +``` + +Number of nested levels in the query + + +#### `calculate_height` + +```python +calculate_height(self) -> int +``` + +Total number of fields requested in the query + + +#### `get_fields` + +```python +get_fields(self) -> dict[str, Any] +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/async_typer.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/async_typer.mdx new file mode 100644 index 00000000..c6152a93 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/async_typer.mdx @@ -0,0 +1,30 @@ +--- +title: async_typer +sidebarTitle: async_typer +--- + +# `infrahub_sdk.async_typer` + +## Classes + +### `AsyncTyper` + +**Methods:** + +#### `maybe_run_async` + +```python +maybe_run_async(decorator: Callable, func: Callable) -> Any +``` + +#### `callback` + +```python +callback(self, *args: Any, **kwargs: Any) -> Any +``` + +#### `command` + +```python +command(self, *args: Any, **kwargs: Any) -> Any +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/batch.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/batch.mdx new file mode 100644 index 00000000..9c8487a2 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/batch.mdx @@ -0,0 +1,75 @@ +--- +title: batch +sidebarTitle: batch +--- + +# `infrahub_sdk.batch` + +## Functions + +### `execute_batch_task_in_pool` + +```python +execute_batch_task_in_pool(task: BatchTask, semaphore: asyncio.Semaphore, return_exceptions: bool = False) -> tuple[InfrahubNode | None, Any] +``` + +## Classes + +### `BatchTask` + +### `BatchTaskSync` + +**Methods:** + +#### `execute` + +```python +execute(self, return_exceptions: bool = False) -> tuple[InfrahubNodeSync | None, Any] +``` + +Executes the stored task. + + +### `InfrahubBatch` + +**Methods:** + +#### `num_tasks` + +```python +num_tasks(self) -> int +``` + +#### `add` + +```python +add(self, *args: Any, **kwargs: Any) -> None +``` + +#### `execute` + +```python +execute(self) -> AsyncGenerator +``` + +### `InfrahubBatchSync` + +**Methods:** + +#### `num_tasks` + +```python +num_tasks(self) -> int +``` + +#### `add` + +```python +add(self, *args: Any, **kwargs: Any) -> None +``` + +#### `execute` + +```python +execute(self) -> Generator[tuple[InfrahubNodeSync | None, Any], None, None] +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/branch.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/branch.mdx new file mode 100644 index 00000000..da12a3aa --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/branch.mdx @@ -0,0 +1,151 @@ +--- +title: branch +sidebarTitle: branch +--- + +# `infrahub_sdk.branch` + +## Classes + +### `BranchData` + +### `InfraHubBranchManagerBase` + +**Methods:** + +#### `generate_diff_data_url` + +```python +generate_diff_data_url(cls, client: InfrahubClient | InfrahubClientSync, branch_name: str, branch_only: bool = True, time_from: str | None = None, time_to: str | None = None) -> str +``` + +Generate the URL for the diff_data function. + + +### `InfrahubBranchManager` + +**Methods:** + +#### `create` + +```python +create(self, branch_name: str, sync_with_git: bool = True, description: str = '', wait_until_completion: Literal[True] = True, background_execution: bool | None = False) -> BranchData +``` + +#### `create` + +```python +create(self, branch_name: str, sync_with_git: bool = True, description: str = '', wait_until_completion: Literal[False] = False, background_execution: bool | None = False) -> str +``` + +#### `create` + +```python +create(self, branch_name: str, sync_with_git: bool = True, description: str = '', wait_until_completion: bool = True, background_execution: bool | None = False) -> BranchData | str +``` + +#### `delete` + +```python +delete(self, branch_name: str) -> bool +``` + +#### `rebase` + +```python +rebase(self, branch_name: str) -> BranchData +``` + +#### `validate` + +```python +validate(self, branch_name: str) -> BranchData +``` + +#### `merge` + +```python +merge(self, branch_name: str) -> bool +``` + +#### `all` + +```python +all(self) -> dict[str, BranchData] +``` + +#### `get` + +```python +get(self, branch_name: str) -> BranchData +``` + +#### `diff_data` + +```python +diff_data(self, branch_name: str, branch_only: bool = True, time_from: str | None = None, time_to: str | None = None) -> dict[Any, Any] +``` + +### `InfrahubBranchManagerSync` + +**Methods:** + +#### `all` + +```python +all(self) -> dict[str, BranchData] +``` + +#### `get` + +```python +get(self, branch_name: str) -> BranchData +``` + +#### `create` + +```python +create(self, branch_name: str, sync_with_git: bool = True, description: str = '', wait_until_completion: Literal[True] = True, background_execution: bool | None = False) -> BranchData +``` + +#### `create` + +```python +create(self, branch_name: str, sync_with_git: bool = True, description: str = '', wait_until_completion: Literal[False] = False, background_execution: bool | None = False) -> str +``` + +#### `create` + +```python +create(self, branch_name: str, sync_with_git: bool = True, description: str = '', wait_until_completion: bool = True, background_execution: bool | None = False) -> BranchData | str +``` + +#### `delete` + +```python +delete(self, branch_name: str) -> bool +``` + +#### `diff_data` + +```python +diff_data(self, branch_name: str, branch_only: bool = True, time_from: str | None = None, time_to: str | None = None) -> dict[Any, Any] +``` + +#### `merge` + +```python +merge(self, branch_name: str) -> bool +``` + +#### `rebase` + +```python +rebase(self, branch_name: str) -> BranchData +``` + +#### `validate` + +```python +validate(self, branch_name: str) -> BranchData +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/checks.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/checks.mdx new file mode 100644 index 00000000..801caca0 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/checks.mdx @@ -0,0 +1,100 @@ +--- +title: checks +sidebarTitle: checks +--- + +# `infrahub_sdk.checks` + +## Classes + +### `InfrahubCheckInitializer` + + +Information about the originator of the check. + + +### `InfrahubCheck` + +**Methods:** + +#### `client` + +```python +client(self) -> InfrahubClient +``` + +#### `client` + +```python +client(self, value: InfrahubClient) -> None +``` + +#### `init` + +```python +init(cls, client: InfrahubClient | None = None, *args: Any, **kwargs: Any) -> InfrahubCheck +``` + +Async init method, If an existing InfrahubClient client hasn't been provided, one will be created automatically. + + +#### `errors` + +```python +errors(self) -> list[dict[str, Any]] +``` + +#### `log_error` + +```python +log_error(self, message: str, object_id: str | None = None, object_type: str | None = None) -> None +``` + +#### `log_info` + +```python +log_info(self, message: str, object_id: str | None = None, object_type: str | None = None) -> None +``` + +#### `log_entries` + +```python +log_entries(self) -> str +``` + +#### `branch_name` + +```python +branch_name(self) -> str +``` + +Return the name of the current git branch. + + +#### `validate` + +```python +validate(self, data: dict) -> None +``` + +Code to validate the status of this check. + + +#### `collect_data` + +```python +collect_data(self) -> dict +``` + +Query the result of the GraphQL Query defined in self.query and return the result + + +#### `run` + +```python +run(self, data: dict | None = None) -> bool +``` + +Execute the check after collecting the data from the GraphQL query. +The result of the check is determined based on the presence or not of ERROR log messages. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx new file mode 100644 index 00000000..543aaec9 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx @@ -0,0 +1,828 @@ +--- +title: client +sidebarTitle: client +--- + +# `infrahub_sdk.client` + +## Functions + +### `handle_relogin` + +```python +handle_relogin(func: Callable[..., Coroutine[Any, Any, httpx.Response]]) +``` + +### `handle_relogin_sync` + +```python +handle_relogin_sync(func: Callable[..., httpx.Response]) +``` + +## Classes + +### `ProcessRelationsNode` + +### `ProcessRelationsNodeSync` + +### `BaseClient` + + +Base class for InfrahubClient and InfrahubClientSync + + +**Methods:** + +#### `request_context` + +```python +request_context(self) -> RequestContext | None +``` + +#### `request_context` + +```python +request_context(self, request_context: RequestContext) -> None +``` + +#### `start_tracking` + +```python +start_tracking(self, identifier: str | None = None, params: dict[str, Any] | None = None, delete_unused_nodes: bool = False, group_type: str | None = None, group_params: dict[str, Any] | None = None, branch: str | None = None) -> Self +``` + +#### `set_context_properties` + +```python +set_context_properties(self, identifier: str, params: dict[str, str] | None = None, delete_unused_nodes: bool = True, reset: bool = True, group_type: str | None = None, group_params: dict[str, Any] | None = None, branch: str | None = None) -> None +``` + +### `InfrahubClient` + + +GraphQL Client to interact with Infrahub. + + +**Methods:** + +#### `get_version` + +```python +get_version(self) -> str +``` + +Return the Infrahub version. + + +#### `get_user` + +```python +get_user(self) -> dict +``` + +Return user information + + +#### `get_user_permissions` + +```python +get_user_permissions(self) -> dict +``` + +Return user permissions + + +#### `create` + +```python +create(self, kind: str, data: dict | None = ..., branch: str | None = ..., **kwargs: Any) -> InfrahubNode +``` + +#### `create` + +```python +create(self, kind: type[SchemaType], data: dict | None = ..., branch: str | None = ..., **kwargs: Any) -> SchemaType +``` + +#### `create` + +```python +create(self, kind: str | type[SchemaType], data: dict | None = None, branch: str | None = None, timeout: int | None = None, **kwargs: Any) -> InfrahubNode | SchemaType +``` + +#### `delete` + +```python +delete(self, kind: str | type[SchemaType], id: str, branch: str | None = None) -> None +``` + +#### `get` + +```python +get(self, kind: type[SchemaType], raise_when_missing: Literal[False], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> SchemaType | None +``` + +#### `get` + +```python +get(self, kind: type[SchemaType], raise_when_missing: Literal[True], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> SchemaType +``` + +#### `get` + +```python +get(self, kind: type[SchemaType], raise_when_missing: bool = ..., at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> SchemaType +``` + +#### `get` + +```python +get(self, kind: str, raise_when_missing: Literal[False], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> InfrahubNode | None +``` + +#### `get` + +```python +get(self, kind: str, raise_when_missing: Literal[True], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> InfrahubNode +``` + +#### `get` + +```python +get(self, kind: str, raise_when_missing: bool = ..., at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> InfrahubNode +``` + +#### `get` + +```python +get(self, kind: str | type[SchemaType], raise_when_missing: bool = True, at: Timestamp | None = None, branch: str | None = None, timeout: int | None = None, id: str | None = None, hfid: list[str] | None = None, include: list[str] | None = None, exclude: list[str] | None = None, populate_store: bool = True, fragment: bool = False, prefetch_relationships: bool = False, property: bool = False, **kwargs: Any) -> InfrahubNode | SchemaType | None +``` + +#### `count` + +```python +count(self, kind: str | type[SchemaType], at: Timestamp | None = None, branch: str | None = None, timeout: int | None = None, partial_match: bool = False, **kwargs: Any) -> int +``` + +Return the number of nodes of a given kind. + + +#### `all` + +```python +all(self, kind: type[SchemaType], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., populate_store: bool = ..., offset: int | None = ..., limit: int | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., parallel: bool = ..., order: Order | None = ...) -> list[SchemaType] +``` + +#### `all` + +```python +all(self, kind: str, at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., populate_store: bool = ..., offset: int | None = ..., limit: int | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., parallel: bool = ..., order: Order | None = ...) -> list[InfrahubNode] +``` + +#### `all` + +```python +all(self, kind: str | type[SchemaType], at: Timestamp | None = None, branch: str | None = None, timeout: int | None = None, populate_store: bool = True, offset: int | None = None, limit: int | None = None, include: list[str] | None = None, exclude: list[str] | None = None, fragment: bool = False, prefetch_relationships: bool = False, property: bool = False, parallel: bool = False, order: Order | None = None) -> list[InfrahubNode] | list[SchemaType] +``` + +Retrieve all nodes of a given kind + +**Args:** +- `kind`: kind of the nodes to query +- `at`: Time of the query. Defaults to Now. +- `branch`: Name of the branch to query from. Defaults to default_branch. +- `populate_store`: Flag to indicate whether to populate the store with the retrieved nodes. +- `timeout`: Overrides default timeout used when querying the graphql API. Specified in seconds. +- `offset`: The offset for pagination. +- `limit`: The limit for pagination. +- `include`: List of attributes or relationships to include in the query. +- `exclude`: List of attributes or relationships to exclude from the query. +- `fragment`: Flag to use GraphQL fragments for generic schemas. +- `prefetch_relationships`: Flag to indicate whether to prefetch related node data. +- `parallel`: Whether to use parallel processing for the query. +- `order`: Ordering related options. Setting `disable=True` enhances performances. + +**Returns:** +- list\[InfrahubNode]: List of Nodes + + +#### `filters` + +```python +filters(self, kind: type[SchemaType], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., populate_store: bool = ..., offset: int | None = ..., limit: int | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., fragment: bool = ..., prefetch_relationships: bool = ..., partial_match: bool = ..., property: bool = ..., parallel: bool = ..., order: Order | None = ..., **kwargs: Any) -> list[SchemaType] +``` + +#### `filters` + +```python +filters(self, kind: str, at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., populate_store: bool = ..., offset: int | None = ..., limit: int | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., fragment: bool = ..., prefetch_relationships: bool = ..., partial_match: bool = ..., property: bool = ..., parallel: bool = ..., order: Order | None = ..., **kwargs: Any) -> list[InfrahubNode] +``` + +#### `filters` + +```python +filters(self, kind: str | type[SchemaType], at: Timestamp | None = None, branch: str | None = None, timeout: int | None = None, populate_store: bool = True, offset: int | None = None, limit: int | None = None, include: list[str] | None = None, exclude: list[str] | None = None, fragment: bool = False, prefetch_relationships: bool = False, partial_match: bool = False, property: bool = False, parallel: bool = False, order: Order | None = None, **kwargs: Any) -> list[InfrahubNode] | list[SchemaType] +``` + +Retrieve nodes of a given kind based on provided filters. + +**Args:** +- `kind`: kind of the nodes to query +- `at`: Time of the query. Defaults to Now. +- `branch`: Name of the branch to query from. Defaults to default_branch. +- `timeout`: Overrides default timeout used when querying the graphql API. Specified in seconds. +- `populate_store`: Flag to indicate whether to populate the store with the retrieved nodes. +- `offset`: The offset for pagination. +- `limit`: The limit for pagination. +- `include`: List of attributes or relationships to include in the query. +- `exclude`: List of attributes or relationships to exclude from the query. +- `fragment`: Flag to use GraphQL fragments for generic schemas. +- `prefetch_relationships`: Flag to indicate whether to prefetch related node data. +- `partial_match`: Allow partial match of filter criteria for the query. +- `parallel`: Whether to use parallel processing for the query. +- `order`: Ordering related options. Setting `disable=True` enhances performances. +- `**kwargs`: Additional filter criteria for the query. + +**Returns:** +- list\[InfrahubNodeSync]: List of Nodes that match the given filters. + + +#### `clone` + +```python +clone(self, branch: str | None = None) -> InfrahubClient +``` + +Return a cloned version of the client using the same configuration + + +#### `execute_graphql` + +```python +execute_graphql(self, query: str, variables: dict | None = None, branch_name: str | None = None, at: str | Timestamp | None = None, timeout: int | None = None, raise_for_error: bool = True, tracker: str | None = None) -> dict +``` + +Execute a GraphQL query (or mutation). +If retry_on_failure is True, the query will retry until the server becomes reacheable. + +**Args:** +- `query`: GraphQL Query to execute, can be a query or a mutation +- `variables`: Variables to pass along with the GraphQL query. Defaults to None. +- `branch_name`: Name of the branch on which the query will be executed. Defaults to None. +- `at`: Time when the query should be executed. Defaults to None. +- `timeout`: Timeout in second for the query. Defaults to None. +- `raise_for_error`: Flag to indicate that we need to raise an exception if the response has some errors. Defaults to True. + +Raises: + GraphQLError: _description_ + +**Returns:** +- _description_ + + +#### `refresh_login` + +```python +refresh_login(self) -> None +``` + +#### `login` + +```python +login(self, refresh: bool = False) -> None +``` + +#### `query_gql_query` + +```python +query_gql_query(self, name: str, variables: dict | None = None, update_group: bool = False, subscribers: list[str] | None = None, params: dict | None = None, branch_name: str | None = None, at: str | None = None, timeout: int | None = None, tracker: str | None = None, raise_for_error: bool = True) -> dict +``` + +#### `get_diff_summary` + +```python +get_diff_summary(self, branch: str, timeout: int | None = None, tracker: str | None = None, raise_for_error: bool = True) -> list[NodeDiff] +``` + +#### `allocate_next_ip_address` + +```python +allocate_next_ip_address(self, resource_pool: CoreNode, kind: type[SchemaType], identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[True] = True) -> SchemaType +``` + +#### `allocate_next_ip_address` + +```python +allocate_next_ip_address(self, resource_pool: CoreNode, kind: type[SchemaType], identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[False] = False) -> SchemaType | None +``` + +#### `allocate_next_ip_address` + +```python +allocate_next_ip_address(self, resource_pool: CoreNode, kind: type[SchemaType], identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: bool = ...) -> SchemaType +``` + +#### `allocate_next_ip_address` + +```python +allocate_next_ip_address(self, resource_pool: CoreNode, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[True] = True) -> CoreNode +``` + +#### `allocate_next_ip_address` + +```python +allocate_next_ip_address(self, resource_pool: CoreNode, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[False] = False) -> CoreNode | None +``` + +#### `allocate_next_ip_address` + +```python +allocate_next_ip_address(self, resource_pool: CoreNode, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: bool = ...) -> CoreNode | None +``` + +#### `allocate_next_ip_address` + +```python +allocate_next_ip_address(self, resource_pool: CoreNode, kind: type[SchemaType] | None = None, identifier: str | None = None, prefix_length: int | None = None, address_type: str | None = None, data: dict[str, Any] | None = None, branch: str | None = None, timeout: int | None = None, tracker: str | None = None, raise_for_error: bool = True) -> CoreNode | SchemaType | None +``` + +Allocate a new IP address by using the provided resource pool. + +**Args:** +- `resource_pool`: Node corresponding to the pool to allocate resources from. +- `identifier`: Value to perform idempotent allocation, the same resource will be returned for a given identifier. +- `prefix_length`: Length of the prefix to set on the address to allocate. +- `address_type`: Kind of the address to allocate. +- `data`: A key/value map to use to set attributes values on the allocated address. +- `branch`: Name of the branch to allocate from. Defaults to default_branch. +- `timeout`: Flag to indicate whether to populate the store with the retrieved nodes. +- `tracker`: The offset for pagination. +- `raise_for_error`: The limit for pagination. + +Returns: + InfrahubNode: Node corresponding to the allocated resource. + + +#### `allocate_next_ip_prefix` + +```python +allocate_next_ip_prefix(self, resource_pool: CoreNode, kind: type[SchemaType], identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[True] = True) -> SchemaType +``` + +#### `allocate_next_ip_prefix` + +```python +allocate_next_ip_prefix(self, resource_pool: CoreNode, kind: type[SchemaType], identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[False] = False) -> SchemaType | None +``` + +#### `allocate_next_ip_prefix` + +```python +allocate_next_ip_prefix(self, resource_pool: CoreNode, kind: type[SchemaType], identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: bool = ...) -> SchemaType +``` + +#### `allocate_next_ip_prefix` + +```python +allocate_next_ip_prefix(self, resource_pool: CoreNode, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[True] = True) -> CoreNode +``` + +#### `allocate_next_ip_prefix` + +```python +allocate_next_ip_prefix(self, resource_pool: CoreNode, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[False] = False) -> CoreNode | None +``` + +#### `allocate_next_ip_prefix` + +```python +allocate_next_ip_prefix(self, resource_pool: CoreNode, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: bool = ...) -> CoreNode | None +``` + +#### `allocate_next_ip_prefix` + +```python +allocate_next_ip_prefix(self, resource_pool: CoreNode, kind: type[SchemaType] | None = None, identifier: str | None = None, prefix_length: int | None = None, member_type: str | None = None, prefix_type: str | None = None, data: dict[str, Any] | None = None, branch: str | None = None, timeout: int | None = None, tracker: str | None = None, raise_for_error: bool = True) -> CoreNode | SchemaType | None +``` + +Allocate a new IP prefix by using the provided resource pool. + +**Args:** +- `resource_pool`: Node corresponding to the pool to allocate resources from. +- `identifier`: Value to perform idempotent allocation, the same resource will be returned for a given identifier. +- `prefix_length`: Length of the prefix to allocate. +- `member_type`: Member type of the prefix to allocate. +- `prefix_type`: Kind of the prefix to allocate. +- `data`: A key/value map to use to set attributes values on the allocated prefix. +- `branch`: Name of the branch to allocate from. Defaults to default_branch. +- `timeout`: Flag to indicate whether to populate the store with the retrieved nodes. +- `tracker`: The offset for pagination. +- `raise_for_error`: The limit for pagination. + +Returns: + InfrahubNode: Node corresponding to the allocated resource. + + +#### `create_batch` + +```python +create_batch(self, return_exceptions: bool = False) -> InfrahubBatch +``` + +#### `get_list_repositories` + +```python +get_list_repositories(self, branches: dict[str, BranchData] | None = None, kind: str = 'CoreGenericRepository') -> dict[str, RepositoryData] +``` + +#### `repository_update_commit` + +```python +repository_update_commit(self, branch_name: str, repository_id: str, commit: str, is_read_only: bool = False) -> bool +``` + +### `InfrahubClientSync` + +**Methods:** + +#### `get_version` + +```python +get_version(self) -> str +``` + +Return the Infrahub version. + + +#### `get_user` + +```python +get_user(self) -> dict +``` + +Return user information + + +#### `get_user_permissions` + +```python +get_user_permissions(self) -> dict +``` + +Return user permissions + + +#### `create` + +```python +create(self, kind: str, data: dict | None = ..., branch: str | None = ..., **kwargs: Any) -> InfrahubNodeSync +``` + +#### `create` + +```python +create(self, kind: type[SchemaTypeSync], data: dict | None = ..., branch: str | None = ..., **kwargs: Any) -> SchemaTypeSync +``` + +#### `create` + +```python +create(self, kind: str | type[SchemaTypeSync], data: dict | None = None, branch: str | None = None, timeout: int | None = None, **kwargs: Any) -> InfrahubNodeSync | SchemaTypeSync +``` + +#### `delete` + +```python +delete(self, kind: str | type[SchemaTypeSync], id: str, branch: str | None = None) -> None +``` + +#### `clone` + +```python +clone(self, branch: str | None = None) -> InfrahubClientSync +``` + +Return a cloned version of the client using the same configuration + + +#### `execute_graphql` + +```python +execute_graphql(self, query: str, variables: dict | None = None, branch_name: str | None = None, at: str | Timestamp | None = None, timeout: int | None = None, raise_for_error: bool = True, tracker: str | None = None) -> dict +``` + +Execute a GraphQL query (or mutation). +If retry_on_failure is True, the query will retry until the server becomes reacheable. + +**Args:** +- `query`: GraphQL Query to execute, can be a query or a mutation +- `variables`: Variables to pass along with the GraphQL query. Defaults to None. +- `branch_name`: Name of the branch on which the query will be executed. Defaults to None. +- `at`: Time when the query should be executed. Defaults to None. +- `timeout`: Timeout in second for the query. Defaults to None. +- `raise_for_error`: Flag to indicate that we need to raise an exception if the response has some errors. Defaults to True. + +Raises: + GraphQLError: When an error occurs during the execution of the GraphQL query or mutation. + +**Returns:** +- The result of the GraphQL query or mutation. + + +#### `count` + +```python +count(self, kind: str | type[SchemaType], at: Timestamp | None = None, branch: str | None = None, timeout: int | None = None, partial_match: bool = False, **kwargs: Any) -> int +``` + +Return the number of nodes of a given kind. + + +#### `all` + +```python +all(self, kind: type[SchemaTypeSync], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., populate_store: bool = ..., offset: int | None = ..., limit: int | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., parallel: bool = ..., order: Order | None = ...) -> list[SchemaTypeSync] +``` + +#### `all` + +```python +all(self, kind: str, at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., populate_store: bool = ..., offset: int | None = ..., limit: int | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., parallel: bool = ..., order: Order | None = ...) -> list[InfrahubNodeSync] +``` + +#### `all` + +```python +all(self, kind: str | type[SchemaTypeSync], at: Timestamp | None = None, branch: str | None = None, timeout: int | None = None, populate_store: bool = True, offset: int | None = None, limit: int | None = None, include: list[str] | None = None, exclude: list[str] | None = None, fragment: bool = False, prefetch_relationships: bool = False, property: bool = False, parallel: bool = False, order: Order | None = None) -> list[InfrahubNodeSync] | list[SchemaTypeSync] +``` + +Retrieve all nodes of a given kind + +**Args:** +- `kind`: kind of the nodes to query +- `at`: Time of the query. Defaults to Now. +- `branch`: Name of the branch to query from. Defaults to default_branch. +- `timeout`: Overrides default timeout used when querying the graphql API. Specified in seconds. +- `populate_store`: Flag to indicate whether to populate the store with the retrieved nodes. +- `offset`: The offset for pagination. +- `limit`: The limit for pagination. +- `include`: List of attributes or relationships to include in the query. +- `exclude`: List of attributes or relationships to exclude from the query. +- `fragment`: Flag to use GraphQL fragments for generic schemas. +- `prefetch_relationships`: Flag to indicate whether to prefetch related node data. +- `parallel`: Whether to use parallel processing for the query. +- `order`: Ordering related options. Setting `disable=True` enhances performances. + +**Returns:** +- list\[InfrahubNodeSync]: List of Nodes + + +#### `filters` + +```python +filters(self, kind: type[SchemaTypeSync], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., populate_store: bool = ..., offset: int | None = ..., limit: int | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., fragment: bool = ..., prefetch_relationships: bool = ..., partial_match: bool = ..., property: bool = ..., parallel: bool = ..., order: Order | None = ..., **kwargs: Any) -> list[SchemaTypeSync] +``` + +#### `filters` + +```python +filters(self, kind: str, at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., populate_store: bool = ..., offset: int | None = ..., limit: int | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., fragment: bool = ..., prefetch_relationships: bool = ..., partial_match: bool = ..., property: bool = ..., parallel: bool = ..., order: Order | None = ..., **kwargs: Any) -> list[InfrahubNodeSync] +``` + +#### `filters` + +```python +filters(self, kind: str | type[SchemaTypeSync], at: Timestamp | None = None, branch: str | None = None, timeout: int | None = None, populate_store: bool = True, offset: int | None = None, limit: int | None = None, include: list[str] | None = None, exclude: list[str] | None = None, fragment: bool = False, prefetch_relationships: bool = False, partial_match: bool = False, property: bool = False, parallel: bool = False, order: Order | None = None, **kwargs: Any) -> list[InfrahubNodeSync] | list[SchemaTypeSync] +``` + +Retrieve nodes of a given kind based on provided filters. + +**Args:** +- `kind`: kind of the nodes to query +- `at`: Time of the query. Defaults to Now. +- `branch`: Name of the branch to query from. Defaults to default_branch. +- `timeout`: Overrides default timeout used when querying the graphql API. Specified in seconds. +- `populate_store`: Flag to indicate whether to populate the store with the retrieved nodes. +- `offset`: The offset for pagination. +- `limit`: The limit for pagination. +- `include`: List of attributes or relationships to include in the query. +- `exclude`: List of attributes or relationships to exclude from the query. +- `fragment`: Flag to use GraphQL fragments for generic schemas. +- `prefetch_relationships`: Flag to indicate whether to prefetch related node data. +- `partial_match`: Allow partial match of filter criteria for the query. +- `parallel`: Whether to use parallel processing for the query. +- `order`: Ordering related options. Setting `disable=True` enhances performances. +- `**kwargs`: Additional filter criteria for the query. + +**Returns:** +- list\[InfrahubNodeSync]: List of Nodes that match the given filters. + + +#### `get` + +```python +get(self, kind: type[SchemaTypeSync], raise_when_missing: Literal[False], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> SchemaTypeSync | None +``` + +#### `get` + +```python +get(self, kind: type[SchemaTypeSync], raise_when_missing: Literal[True], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> SchemaTypeSync +``` + +#### `get` + +```python +get(self, kind: type[SchemaTypeSync], raise_when_missing: bool = ..., at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> SchemaTypeSync +``` + +#### `get` + +```python +get(self, kind: str, raise_when_missing: Literal[False], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> InfrahubNodeSync | None +``` + +#### `get` + +```python +get(self, kind: str, raise_when_missing: Literal[True], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> InfrahubNodeSync +``` + +#### `get` + +```python +get(self, kind: str, raise_when_missing: bool = ..., at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> InfrahubNodeSync +``` + +#### `get` + +```python +get(self, kind: str | type[SchemaTypeSync], raise_when_missing: bool = True, at: Timestamp | None = None, branch: str | None = None, timeout: int | None = None, id: str | None = None, hfid: list[str] | None = None, include: list[str] | None = None, exclude: list[str] | None = None, populate_store: bool = True, fragment: bool = False, prefetch_relationships: bool = False, property: bool = False, **kwargs: Any) -> InfrahubNodeSync | SchemaTypeSync | None +``` + +#### `create_batch` + +```python +create_batch(self, return_exceptions: bool = False) -> InfrahubBatchSync +``` + +Create a batch to execute multiple queries concurrently. + +Executing the batch will be performed using a thread pool, meaning it cannot guarantee the execution order. It is not recommended to use such +batch to manipulate objects that depend on each others. + + +#### `get_list_repositories` + +```python +get_list_repositories(self, branches: dict[str, BranchData] | None = None, kind: str = 'CoreGenericRepository') -> dict[str, RepositoryData] +``` + +#### `query_gql_query` + +```python +query_gql_query(self, name: str, variables: dict | None = None, update_group: bool = False, subscribers: list[str] | None = None, params: dict | None = None, branch_name: str | None = None, at: str | None = None, timeout: int | None = None, tracker: str | None = None, raise_for_error: bool = True) -> dict +``` + +#### `get_diff_summary` + +```python +get_diff_summary(self, branch: str, timeout: int | None = None, tracker: str | None = None, raise_for_error: bool = True) -> list[NodeDiff] +``` + +#### `allocate_next_ip_address` + +```python +allocate_next_ip_address(self, resource_pool: CoreNodeSync, kind: type[SchemaTypeSync], identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[True] = True) -> SchemaTypeSync +``` + +#### `allocate_next_ip_address` + +```python +allocate_next_ip_address(self, resource_pool: CoreNodeSync, kind: type[SchemaTypeSync], identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[False] = False) -> SchemaTypeSync | None +``` + +#### `allocate_next_ip_address` + +```python +allocate_next_ip_address(self, resource_pool: CoreNodeSync, kind: type[SchemaTypeSync], identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: bool = ...) -> SchemaTypeSync +``` + +#### `allocate_next_ip_address` + +```python +allocate_next_ip_address(self, resource_pool: CoreNodeSync, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[True] = True) -> CoreNodeSync +``` + +#### `allocate_next_ip_address` + +```python +allocate_next_ip_address(self, resource_pool: CoreNodeSync, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[False] = False) -> CoreNodeSync | None +``` + +#### `allocate_next_ip_address` + +```python +allocate_next_ip_address(self, resource_pool: CoreNodeSync, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: bool = ...) -> CoreNodeSync | None +``` + +#### `allocate_next_ip_address` + +```python +allocate_next_ip_address(self, resource_pool: CoreNodeSync, kind: type[SchemaTypeSync] | None = None, identifier: str | None = None, prefix_length: int | None = None, address_type: str | None = None, data: dict[str, Any] | None = None, branch: str | None = None, timeout: int | None = None, tracker: str | None = None, raise_for_error: bool = True) -> CoreNodeSync | SchemaTypeSync | None +``` + +Allocate a new IP address by using the provided resource pool. + +**Args:** +- `resource_pool`: Node corresponding to the pool to allocate resources from. +- `identifier`: Value to perform idempotent allocation, the same resource will be returned for a given identifier. +- `prefix_length`: Length of the prefix to set on the address to allocate. +- `address_type`: Kind of the address to allocate. +- `data`: A key/value map to use to set attributes values on the allocated address. +- `branch`: Name of the branch to allocate from. Defaults to default_branch. +- `timeout`: Flag to indicate whether to populate the store with the retrieved nodes. +- `tracker`: The offset for pagination. +- `raise_for_error`: The limit for pagination. + +Returns: + InfrahubNodeSync: Node corresponding to the allocated resource. + + +#### `allocate_next_ip_prefix` + +```python +allocate_next_ip_prefix(self, resource_pool: CoreNodeSync, kind: type[SchemaTypeSync], identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[True] = True) -> SchemaTypeSync +``` + +#### `allocate_next_ip_prefix` + +```python +allocate_next_ip_prefix(self, resource_pool: CoreNodeSync, kind: type[SchemaTypeSync], identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[False] = False) -> SchemaTypeSync | None +``` + +#### `allocate_next_ip_prefix` + +```python +allocate_next_ip_prefix(self, resource_pool: CoreNodeSync, kind: type[SchemaTypeSync], identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: bool = ...) -> SchemaTypeSync +``` + +#### `allocate_next_ip_prefix` + +```python +allocate_next_ip_prefix(self, resource_pool: CoreNodeSync, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[True] = True) -> CoreNodeSync +``` + +#### `allocate_next_ip_prefix` + +```python +allocate_next_ip_prefix(self, resource_pool: CoreNodeSync, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[False] = False) -> CoreNodeSync | None +``` + +#### `allocate_next_ip_prefix` + +```python +allocate_next_ip_prefix(self, resource_pool: CoreNodeSync, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: bool = ...) -> CoreNodeSync | None +``` + +#### `allocate_next_ip_prefix` + +```python +allocate_next_ip_prefix(self, resource_pool: CoreNodeSync, kind: type[SchemaTypeSync] | None = None, identifier: str | None = None, prefix_length: int | None = None, member_type: str | None = None, prefix_type: str | None = None, data: dict[str, Any] | None = None, branch: str | None = None, timeout: int | None = None, tracker: str | None = None, raise_for_error: bool = True) -> CoreNodeSync | SchemaTypeSync | None +``` + +Allocate a new IP prefix by using the provided resource pool. + +**Args:** +- `resource_pool`: Node corresponding to the pool to allocate resources from. +- `identifier`: Value to perform idempotent allocation, the same resource will be returned for a given identifier. +- `size`: Length of the prefix to allocate. +- `member_type`: Member type of the prefix to allocate. +- `prefix_type`: Kind of the prefix to allocate. +- `data`: A key/value map to use to set attributes values on the allocated prefix. +- `branch`: Name of the branch to allocate from. Defaults to default_branch. +- `timeout`: Flag to indicate whether to populate the store with the retrieved nodes. +- `tracker`: The offset for pagination. +- `raise_for_error`: The limit for pagination. + +Returns: + InfrahubNodeSync: Node corresponding to the allocated resource. + + +#### `repository_update_commit` + +```python +repository_update_commit(self, branch_name: str, repository_id: str, commit: str, is_read_only: bool = False) -> bool +``` + +#### `refresh_login` + +```python +refresh_login(self) -> None +``` + +#### `login` + +```python +login(self, refresh: bool = False) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/config.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/config.mdx new file mode 100644 index 00000000..991413a8 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/config.mdx @@ -0,0 +1,86 @@ +--- +title: config +sidebarTitle: config +--- + +# `infrahub_sdk.config` + +## Classes + +### `ProxyMountsConfig` + +**Methods:** + +#### `is_set` + +```python +is_set(self) -> bool +``` + +### `ConfigBase` + +**Methods:** + +#### `validate_credentials_input` + +```python +validate_credentials_input(cls, values: dict[str, Any]) -> dict[str, Any] +``` + +#### `set_transport` + +```python +set_transport(cls, values: dict[str, Any]) -> dict[str, Any] +``` + +#### `validate_mix_authentication_schemes` + +```python +validate_mix_authentication_schemes(cls, values: dict[str, Any]) -> dict[str, Any] +``` + +#### `validate_address` + +```python +validate_address(cls, value: str) -> str +``` + +#### `validate_proxy_config` + +```python +validate_proxy_config(self) -> Self +``` + +#### `default_infrahub_branch` + +```python +default_infrahub_branch(self) -> str +``` + +#### `password_authentication` + +```python +password_authentication(self) -> bool +``` + +### `Config` + +**Methods:** + +#### `logger` + +```python +logger(self) -> InfrahubLoggers +``` + +#### `set_custom_recorder` + +```python +set_custom_recorder(cls, values: dict[str, Any]) -> dict[str, Any] +``` + +#### `clone` + +```python +clone(self, branch: str | None = None) -> Config +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/constants.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/constants.mdx new file mode 100644 index 00000000..f94dac79 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/constants.mdx @@ -0,0 +1,10 @@ +--- +title: constants +sidebarTitle: constants +--- + +# `infrahub_sdk.constants` + +## Classes + +### `InfrahubClientMode` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/context.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/context.mdx new file mode 100644 index 00000000..84b63958 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/context.mdx @@ -0,0 +1,16 @@ +--- +title: context +sidebarTitle: context +--- + +# `infrahub_sdk.context` + +## Classes + +### `ContextAccount` + +### `RequestContext` + + +The context can be used to override settings such as the account within mutations. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/branch.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/branch.mdx new file mode 100644 index 00000000..59cd4d61 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/branch.mdx @@ -0,0 +1,80 @@ +--- +title: branch +sidebarTitle: branch +--- + +# `infrahub_sdk.ctl.branch` + +## Functions + +### `callback` + +```python +callback() -> None +``` + + +Manage the branches in a remote Infrahub instance. + +List, create, merge, rebase .. + + +### `list_branch` + +```python +list_branch(_: str = CONFIG_PARAM) -> None +``` + + +List all existing branches. + + +### `create` + +```python +create(branch_name: str = typer.Argument(..., help='Name of the branch to create'), description: str = typer.Option(default='', help='Description of the branch'), sync_with_git: bool = typer.Option(False, help='Extend the branch to Git and have Infrahub create the branch in connected repositories.'), isolated: bool = typer.Option(True, hidden=True, help='Set the branch to isolated mode (deprecated)'), _: str = CONFIG_PARAM) -> None +``` + + +Create a new branch. + + +### `delete` + +```python +delete(branch_name: str, _: str = CONFIG_PARAM) -> None +``` + + +Delete a branch. + + +### `rebase` + +```python +rebase(branch_name: str, _: str = CONFIG_PARAM) -> None +``` + + +Rebase a Branch with main. + + +### `merge` + +```python +merge(branch_name: str, _: str = CONFIG_PARAM) -> None +``` + + +Merge a Branch with main. + + +### `validate` + +```python +validate(branch_name: str, _: str = CONFIG_PARAM) -> None +``` + + +Validate if a branch has some conflict and is passing all the tests (NOT IMPLEMENTED YET). + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/check.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/check.mdx new file mode 100644 index 00000000..4cebb85f --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/check.mdx @@ -0,0 +1,62 @@ +--- +title: check +sidebarTitle: check +--- + +# `infrahub_sdk.ctl.check` + +## Functions + +### `callback` + +```python +callback() -> None +``` + + +Execute user-defined checks. + + +### `run` + +```python +run() -> None +``` + + +Locate and execute all checks under the defined path. + + +### `run_check` + +```python +run_check(check_module: CheckModule, client: InfrahubClient, format_json: bool, path: str, repository_config: InfrahubRepositoryConfig, branch: str | None = None, params: dict | None = None) -> bool +``` + +### `run_targeted_check` + +```python +run_targeted_check(check_module: CheckModule, client: InfrahubClient, format_json: bool, path: str, repository_config: InfrahubRepositoryConfig, variables: dict[str, str], branch: str | None = None) -> bool +``` + +### `run_checks` + +```python +run_checks(check_modules: list[CheckModule], format_json: bool, path: str, variables: dict[str, str], repository_config: InfrahubRepositoryConfig, branch: str | None = None) -> None +``` + +### `get_modules` + +```python +get_modules(check_definitions: list[InfrahubCheckDefinitionConfig]) -> list[CheckModule] +``` + +### `list_checks` + +```python +list_checks(repository_config: InfrahubRepositoryConfig) -> None +``` + +## Classes + +### `CheckModule` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli.mdx new file mode 100644 index 00000000..1a024ba1 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli.mdx @@ -0,0 +1,8 @@ +--- +title: cli +sidebarTitle: cli +--- + +# `infrahub_sdk.ctl.cli` + +*This module is empty or contains only private/internal implementations.* diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli_commands.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli_commands.mdx new file mode 100644 index 00000000..29c7fea6 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli_commands.mdx @@ -0,0 +1,94 @@ +--- +title: cli_commands +sidebarTitle: cli_commands +--- + +# `infrahub_sdk.ctl.cli_commands` + +## Functions + +### `check` + +```python +check(check_name: str = typer.Argument(default='', help='Name of the Python check'), branch: Optional[str] = None, path: str = typer.Option('.', help='Root directory'), debug: bool = False, format_json: bool = False, _: str = CONFIG_PARAM, list_available: bool = typer.Option(False, '--list', help='Show available Python checks'), variables: Optional[list[str]] = typer.Argument(None, help='Variables to pass along with the query. Format key=value key=value.')) -> None +``` + + +Execute user-defined checks. + + +### `generator` + +```python +generator(generator_name: str = typer.Argument(default='', help='Name of the Generator'), branch: Optional[str] = None, path: str = typer.Option('.', help='Root directory'), debug: bool = False, _: str = CONFIG_PARAM, list_available: bool = typer.Option(False, '--list', help='Show available Generators'), variables: Optional[list[str]] = typer.Argument(None, help='Variables to pass along with the query. Format key=value key=value.')) -> None +``` + + +Run a generator script. + + +### `run` + +```python +run(script: Path, method: str = 'run', debug: bool = False, _: str = CONFIG_PARAM, branch: str = typer.Option(None, help='Branch on which to run the script.'), concurrent: Optional[int] = typer.Option(None, help='Maximum number of requests to execute at the same time.', envvar='INFRAHUB_MAX_CONCURRENT_EXECUTION'), timeout: int = typer.Option(60, help='Timeout in sec', envvar='INFRAHUB_TIMEOUT'), variables: Optional[list[str]] = typer.Argument(None, help='Variables to pass along with the query. Format key=value key=value.')) -> None +``` + + +Execute a script. + + +### `render_jinja2_template` + +```python +render_jinja2_template(template_path: Path, variables: dict[str, Any], data: dict[str, Any]) -> str +``` + +### `render` + +```python +render(transform_name: str = typer.Argument(default='', help='Name of the Python transformation', show_default=False), variables: Optional[list[str]] = typer.Argument(None, help='Variables to pass along with the query. Format key=value key=value.'), branch: str = typer.Option(None, help='Branch on which to render the transform.'), debug: bool = False, _: str = CONFIG_PARAM, list_available: bool = typer.Option(False, '--list', help='Show available transforms'), out: str = typer.Option(None, help='Path to a file to save the result.')) -> None +``` + + +Render a local Jinja2 Transform for debugging purpose. + + +### `transform` + +```python +transform(transform_name: str = typer.Argument(default='', help='Name of the Python transformation', show_default=False), variables: Optional[list[str]] = typer.Argument(None, help='Variables to pass along with the query. Format key=value key=value.'), branch: str = typer.Option(None, help='Branch on which to run the transformation'), debug: bool = False, _: str = CONFIG_PARAM, list_available: bool = typer.Option(False, '--list', help='Show available transforms'), out: str = typer.Option(None, help='Path to a file to save the result.')) -> None +``` + + +Render a local transform (TransformPython) for debugging purpose. + + +### `protocols` + +```python +protocols(schemas: list[Path] = typer.Option(None, help='List of schemas or directory to load.'), branch: str = typer.Option(None, help='Branch of schema to export Python protocols for.'), sync: bool = typer.Option(False, help='Generate for sync or async.'), _: str = CONFIG_PARAM, out: str = typer.Option('schema_protocols.py', help='Path to a file to save the result.')) -> None +``` + + +Export Python protocols corresponding to a schema. + + +### `version` + +```python +version() -> None +``` + + +Display the version of Python and the version of the Python SDK in use. + + +### `info` + +```python +info(detail: bool = typer.Option(False, help='Display detailed information.'), _: str = CONFIG_PARAM) -> None +``` + + +Display the status of the Python SDK. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/client.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/client.mdx new file mode 100644 index 00000000..e61ca981 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/client.mdx @@ -0,0 +1,20 @@ +--- +title: client +sidebarTitle: client +--- + +# `infrahub_sdk.ctl.client` + +## Functions + +### `initialize_client` + +```python +initialize_client(branch: str | None = None, identifier: str | None = None, timeout: int | None = None, max_concurrent_execution: int | None = None, retry_on_failure: bool | None = None) -> InfrahubClient +``` + +### `initialize_client_sync` + +```python +initialize_client_sync(branch: str | None = None, identifier: str | None = None, timeout: int | None = None, max_concurrent_execution: int | None = None, retry_on_failure: bool | None = None) -> InfrahubClientSync +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/config.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/config.mdx new file mode 100644 index 00000000..247f56af --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/config.mdx @@ -0,0 +1,63 @@ +--- +title: config +sidebarTitle: config +--- + +# `infrahub_sdk.ctl.config` + + +Config Class. + +## Classes + +### `Settings` + + +Main Settings Class for the project. + + +**Methods:** + +#### `cleanup_server_address` + +```python +cleanup_server_address(cls, v: str) -> str +``` + +### `ConfiguredSettings` + +**Methods:** + +#### `active` + +```python +active(self) -> Settings +``` + +#### `load` + +```python +load(self, config_file: str | Path = 'infrahubctl.toml', config_data: dict | None = None) -> None +``` + +Load configuration. + +Configuration is loaded from a config file in toml format that contains the settings, +or from a dictionary of those settings passed in as "config_data" + + +#### `load_and_exit` + +```python +load_and_exit(self, config_file: str | Path = 'infrahubctl.toml', config_data: dict | None = None) -> None +``` + +Calls load, but wraps it in a try except block. + +This is done to handle a ValidationErorr which is raised when settings are specified but invalid. +In such cases, a message is printed to the screen indicating the settings which don't pass validation. + +**Args:** +- `config_file_name`: [description]. Defaults to "pyprojectctl.toml". +- `config_data`: [description]. Defaults to None. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exceptions.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exceptions.mdx new file mode 100644 index 00000000..0a796151 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exceptions.mdx @@ -0,0 +1,16 @@ +--- +title: exceptions +sidebarTitle: exceptions +--- + +# `infrahub_sdk.ctl.exceptions` + +## Classes + +### `Error` + + +Infrahub CTL Base exception. + + +### `QueryNotFoundError` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exporter.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exporter.mdx new file mode 100644 index 00000000..1c20de3a --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exporter.mdx @@ -0,0 +1,24 @@ +--- +title: exporter +sidebarTitle: exporter +--- + +# `infrahub_sdk.ctl.exporter` + +## Functions + +### `directory_name_with_timestamp` + +```python +directory_name_with_timestamp() -> str +``` + +### `dump` + +```python +dump(namespace: list[str] = typer.Option([], help='Namespace(s) to export'), directory: Path = typer.Option(directory_name_with_timestamp, help='Directory path to store export'), quiet: bool = typer.Option(False, help='No console output'), _: str = CONFIG_PARAM, branch: str = typer.Option(None, help='Branch from which to export'), concurrent: int = typer.Option(4, help='Maximum number of requests to execute at the same time.', envvar='INFRAHUB_MAX_CONCURRENT_EXECUTION'), timeout: int = typer.Option(60, help='Timeout in sec', envvar='INFRAHUB_TIMEOUT'), exclude: list[str] = typer.Option(['CoreAccount'], help='Prevent node kind(s) from being exported, CoreAccount is excluded by default')) -> None +``` + + +Export nodes and their relationships out of the database. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/generator.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/generator.mdx new file mode 100644 index 00000000..fad2698d --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/generator.mdx @@ -0,0 +1,20 @@ +--- +title: generator +sidebarTitle: generator +--- + +# `infrahub_sdk.ctl.generator` + +## Functions + +### `run` + +```python +run(generator_name: str, path: str, debug: bool, list_available: bool, branch: str | None = None, variables: Optional[list[str]] = None) -> None +``` + +### `list_generators` + +```python +list_generators(repository_config: InfrahubRepositoryConfig) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/importer.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/importer.mdx new file mode 100644 index 00000000..a05b76fb --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/importer.mdx @@ -0,0 +1,24 @@ +--- +title: importer +sidebarTitle: importer +--- + +# `infrahub_sdk.ctl.importer` + +## Functions + +### `local_directory` + +```python +local_directory() -> Path +``` + +### `load` + +```python +load(directory: Path = typer.Option(local_directory, help='Directory path of exported data'), continue_on_error: bool = typer.Option(False, help='Allow exceptions during loading and display them when complete'), quiet: bool = typer.Option(False, help='No console output'), _: str = CONFIG_PARAM, branch: str = typer.Option(None, help='Branch from which to export'), concurrent: Optional[int] = typer.Option(None, help='Maximum number of requests to execute at the same time.', envvar='INFRAHUB_MAX_CONCURRENT_EXECUTION'), timeout: int = typer.Option(60, help='Timeout in sec', envvar='INFRAHUB_TIMEOUT')) -> None +``` + + +Import nodes and their relationships into the database. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/menu.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/menu.mdx new file mode 100644 index 00000000..f274cfb4 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/menu.mdx @@ -0,0 +1,38 @@ +--- +title: menu +sidebarTitle: menu +--- + +# `infrahub_sdk.ctl.menu` + +## Functions + +### `callback` + +```python +callback() -> None +``` + + +Manage the menu in a remote Infrahub instance. + + +### `load` + +```python +load(menus: list[Path], debug: bool = False, branch: str = typer.Option(None, help='Branch on which to load the menu.'), _: str = CONFIG_PARAM) -> None +``` + + +Load one or multiple menu files into Infrahub. + + +### `validate` + +```python +validate(paths: list[Path], debug: bool = False, branch: str = typer.Option(None, help='Branch on which to validate the objects.'), _: str = CONFIG_PARAM) -> None +``` + + +Validate one or multiple menu files. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/object.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/object.mdx new file mode 100644 index 00000000..3aef7663 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/object.mdx @@ -0,0 +1,38 @@ +--- +title: object +sidebarTitle: object +--- + +# `infrahub_sdk.ctl.object` + +## Functions + +### `callback` + +```python +callback() -> None +``` + + +Manage objects in a remote Infrahub instance. + + +### `load` + +```python +load(paths: list[Path], debug: bool = False, branch: str = typer.Option(None, help='Branch on which to load the objects.'), _: str = CONFIG_PARAM) -> None +``` + + +Load one or multiple objects files into Infrahub. + + +### `validate` + +```python +validate(paths: list[Path], debug: bool = False, branch: str = typer.Option(None, help='Branch on which to validate the objects.'), _: str = CONFIG_PARAM) -> None +``` + + +Validate one or multiple objects files. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/parameters.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/parameters.mdx new file mode 100644 index 00000000..1005151d --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/parameters.mdx @@ -0,0 +1,18 @@ +--- +title: parameters +sidebarTitle: parameters +--- + +# `infrahub_sdk.ctl.parameters` + +## Functions + +### `load_configuration` + +```python +load_configuration(value: str) -> str +``` + + +Load the configuration file using default environment variables or from the specified configuration file + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/render.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/render.mdx new file mode 100644 index 00000000..918c47a1 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/render.mdx @@ -0,0 +1,20 @@ +--- +title: render +sidebarTitle: render +--- + +# `infrahub_sdk.ctl.render` + +## Functions + +### `list_jinja2_transforms` + +```python +list_jinja2_transforms(config: InfrahubRepositoryConfig) -> None +``` + +### `print_template_errors` + +```python +print_template_errors(error: JinjaTemplateError, console: Console) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/repository.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/repository.mdx new file mode 100644 index 00000000..f3ab2bf1 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/repository.mdx @@ -0,0 +1,48 @@ +--- +title: repository +sidebarTitle: repository +--- + +# `infrahub_sdk.ctl.repository` + +## Functions + +### `get_repository_config` + +```python +get_repository_config(repo_config_file: Path) -> InfrahubRepositoryConfig +``` + +### `load_repository_config_file` + +```python +load_repository_config_file(repo_config_file: Path) -> dict +``` + +### `callback` + +```python +callback() -> None +``` + + +Manage the repositories in a remote Infrahub instance. + +List, create, delete .. + + +### `add` + +```python +add(name: str, location: str, description: str = '', username: Optional[str] = None, password: str = '', ref: str = '', read_only: bool = False, debug: bool = False, _: str = CONFIG_PARAM) -> None +``` + + +Add a new repository. + + +### `list` + +```python +list(branch: Optional[str] = typer.Option(None, help='Branch on which to list repositories.'), debug: bool = False, _: str = CONFIG_PARAM) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/schema.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/schema.mdx new file mode 100644 index 00000000..40f1a708 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/schema.mdx @@ -0,0 +1,68 @@ +--- +title: schema +sidebarTitle: schema +--- + +# `infrahub_sdk.ctl.schema` + +## Functions + +### `callback` + +```python +callback() -> None +``` + + +Manage the schema in a remote Infrahub instance. + + +### `validate_schema_content_and_exit` + +```python +validate_schema_content_and_exit(client: InfrahubClient, schemas: list[SchemaFile]) -> None +``` + +### `display_schema_load_errors` + +```python +display_schema_load_errors(response: dict[str, Any], schemas_data: list[dict]) -> None +``` + +### `handle_non_detail_errors` + +```python +handle_non_detail_errors(response: dict[str, Any]) -> None +``` + +### `valid_error_path` + +```python +valid_error_path(loc_path: list[Any]) -> bool +``` + +### `get_node` + +```python +get_node(schemas_data: list[dict], schema_index: int, node_index: int) -> dict | None +``` + +### `load` + +```python +load(schemas: list[Path], debug: bool = False, branch: str = typer.Option(None, help='Branch on which to load the schema.'), wait: int = typer.Option(0, help='Time in seconds to wait until the schema has converged across all workers'), _: str = CONFIG_PARAM) -> None +``` + + +Load one or multiple schema files into Infrahub. + + +### `check` + +```python +check(schemas: list[Path], debug: bool = False, branch: str = typer.Option(None, help='Branch on which to check the schema.'), _: str = CONFIG_PARAM) -> None +``` + + +Check if schema files are valid and what would be the impact of loading them with Infrahub. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/transform.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/transform.mdx new file mode 100644 index 00000000..10181b92 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/transform.mdx @@ -0,0 +1,14 @@ +--- +title: transform +sidebarTitle: transform +--- + +# `infrahub_sdk.ctl.transform` + +## Functions + +### `list_transforms` + +```python +list_transforms(config: InfrahubRepositoryConfig) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx new file mode 100644 index 00000000..1d4feb74 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx @@ -0,0 +1,92 @@ +--- +title: utils +sidebarTitle: utils +--- + +# `infrahub_sdk.ctl.utils` + +## Functions + +### `init_logging` + +```python +init_logging(debug: bool = False) -> None +``` + +### `handle_exception` + +```python +handle_exception(exc: Exception, console: Console, exit_code: int) -> NoReturn +``` + + +Handle exeception in a different fashion based on its type. + + +### `catch_exception` + +```python +catch_exception(console: Console | None = None, exit_code: int = 1) -> Callable[[Callable[..., T]], Callable[..., T | Coroutine[Any, Any, T]]] +``` + + +Decorator to handle exception for commands. + + +### `execute_graphql_query` + +```python +execute_graphql_query(query: str, variables_dict: dict[str, Any], repository_config: InfrahubRepositoryConfig, branch: str | None = None, debug: bool = False) -> dict +``` + +### `print_graphql_errors` + +```python +print_graphql_errors(console: Console, errors: list) -> None +``` + +### `parse_cli_vars` + +```python +parse_cli_vars(variables: Optional[list[str]]) -> dict[str, str] +``` + +### `find_graphql_query` + +```python +find_graphql_query(name: str, directory: str | Path = '.') -> str +``` + +### `render_action_rich` + +```python +render_action_rich(value: str) -> str +``` + +### `get_fixtures_dir` + +```python +get_fixtures_dir() -> Path +``` + + +Get the directory which stores fixtures that are common to multiple unit/integration tests. + + +### `load_yamlfile_from_disk_and_exit` + +```python +load_yamlfile_from_disk_and_exit(paths: list[Path], file_type: type[YamlFileVar], console: Console) -> list[YamlFileVar] +``` + +### `display_object_validate_format_success` + +```python +display_object_validate_format_success(file: ObjectFile, console: Console) -> None +``` + +### `display_object_validate_format_error` + +```python +display_object_validate_format_error(file: ObjectFile, error: ValidationError, console: Console) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/validate.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/validate.mdx new file mode 100644 index 00000000..e36ec385 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/validate.mdx @@ -0,0 +1,38 @@ +--- +title: validate +sidebarTitle: validate +--- + +# `infrahub_sdk.ctl.validate` + +## Functions + +### `callback` + +```python +callback() -> None +``` + + +Helper to validate the format of various files. + + +### `validate_schema` + +```python +validate_schema(schema: Path, _: str = CONFIG_PARAM) -> None +``` + + +Validate the format of a schema file either in JSON or YAML + + +### `validate_graphql` + +```python +validate_graphql(query: str, variables: Optional[list[str]] = typer.Argument(None, help='Variables to pass along with the query. Format key=value key=value.'), debug: bool = typer.Option(False, help='Display more troubleshooting information.'), branch: str = typer.Option(None, help='Branch on which to validate the GraphQL Query.'), _: str = CONFIG_PARAM, out: str = typer.Option(None, help='Path to a file to save the result.')) -> None +``` + + +Validate the format of a GraphQL Query stored locally by executing it on a remote GraphQL endpoint + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/data.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/data.mdx new file mode 100644 index 00000000..6f6a6877 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/data.mdx @@ -0,0 +1,20 @@ +--- +title: data +sidebarTitle: data +--- + +# `infrahub_sdk.data` + +## Classes + +### `RepositoryBranchInfo` + +### `RepositoryData` + +**Methods:** + +#### `get_staging_branch` + +```python +get_staging_branch(self) -> str | None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/diff.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/diff.mdx new file mode 100644 index 00000000..0c25d3c0 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/diff.mdx @@ -0,0 +1,30 @@ +--- +title: diff +sidebarTitle: diff +--- + +# `infrahub_sdk.diff` + +## Functions + +### `get_diff_summary_query` + +```python +get_diff_summary_query() -> str +``` + +### `diff_tree_node_to_node_diff` + +```python +diff_tree_node_to_node_diff(node_dict: dict[str, Any], branch_name: str) -> NodeDiff +``` + +## Classes + +### `NodeDiff` + +### `NodeDiffElement` + +### `NodeDiffSummary` + +### `NodeDiffPeer` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/exceptions.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/exceptions.mdx new file mode 100644 index 00000000..50016d5d --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/exceptions.mdx @@ -0,0 +1,68 @@ +--- +title: exceptions +sidebarTitle: exceptions +--- + +# `infrahub_sdk.exceptions` + +## Classes + +### `Error` + +### `JsonDecodeError` + +### `ServerNotReachableError` + +### `ServerNotResponsiveError` + +### `GraphQLError` + +### `BranchNotFoundError` + +### `SchemaNotFoundError` + +### `ModuleImportError` + +### `NodeNotFoundError` + +### `NodeInvalidError` + +### `ResourceNotDefinedError` + + +Raised when trying to access a resource that hasn't been defined. + + +### `InfrahubCheckNotFoundError` + +### `InfrahubTransformNotFoundError` + +### `ValidationError` + +### `ObjectValidationError` + +### `AuthenticationError` + +### `URLNotFoundError` + +### `FeatureNotSupportedError` + + +Raised when trying to use a method on a node that doesn't support it. + + +### `UninitializedError` + + +Raised when an object requires an initialization step before use + + +### `InvalidResponseError` + + +Raised when an object requires an initialization step before use + + +### `FileNotValidError` + +### `TimestampFormatError` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/generator.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/generator.mdx new file mode 100644 index 00000000..cf4a20a0 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/generator.mdx @@ -0,0 +1,69 @@ +--- +title: generator +sidebarTitle: generator +--- + +# `infrahub_sdk.generator` + +## Classes + +### `InfrahubGenerator` + + +Infrahub Generator class + + +**Methods:** + +#### `subscribers` + +```python +subscribers(self) -> list[str] | None +``` + +#### `client` + +```python +client(self) -> InfrahubClient +``` + +#### `client` + +```python +client(self, value: InfrahubClient) -> None +``` + +#### `collect_data` + +```python +collect_data(self) -> dict +``` + +Query the result of the GraphQL Query defined in self.query and return the result + + +#### `run` + +```python +run(self, identifier: str, data: dict | None = None) -> None +``` + +Execute the generator after collecting the data from the GraphQL query. + + +#### `generate` + +```python +generate(self, data: dict) -> None +``` + +Code to run the generator + +Any child class of the InfrahubGenerator us expected to provide this method. The method is expected +to use the provided InfrahubClient contained in self.client to create or update any nodes in an idempotent +way as the method could be executed multiple times. Typically this would be done by using: + +await new_or_updated_object.save(allow_upsert=True) + +The tracking system will be responsible for deleting nodes that are no longer required. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/graphql.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/graphql.mdx new file mode 100644 index 00000000..3824dc99 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/graphql.mdx @@ -0,0 +1,70 @@ +--- +title: graphql +sidebarTitle: graphql +--- + +# `infrahub_sdk.graphql` + +## Functions + +### `convert_to_graphql_as_string` + +```python +convert_to_graphql_as_string(value: str | bool | list | BaseModel | Enum | Any, convert_enum: bool = False) -> str +``` + +### `render_variables_to_string` + +```python +render_variables_to_string(data: dict[str, type[str | int | float | bool]]) -> str +``` + + +Render a dict into a variable string that will be used in a GraphQL Query. + +The $ sign will be automatically added to the name of the query. + + +### `render_query_block` + +```python +render_query_block(data: dict, offset: int = 4, indentation: int = 4, convert_enum: bool = False) -> list[str] +``` + +### `render_input_block` + +```python +render_input_block(data: dict, offset: int = 4, indentation: int = 4, convert_enum: bool = False) -> list[str] +``` + +## Classes + +### `BaseGraphQLQuery` + +**Methods:** + +#### `render_first_line` + +```python +render_first_line(self) -> str +``` + +### `Query` + +**Methods:** + +#### `render` + +```python +render(self, convert_enum: bool = False) -> str +``` + +### `Mutation` + +**Methods:** + +#### `render` + +```python +render(self, convert_enum: bool = False) -> str +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/groups.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/groups.mdx new file mode 100644 index 00000000..ffe53eee --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/groups.mdx @@ -0,0 +1,14 @@ +--- +title: groups +sidebarTitle: groups +--- + +# `infrahub_sdk.groups` + +## Functions + +### `group_add_subscriber` + +```python +group_add_subscriber(client: InfrahubClient, group: InfrahubNode, subscribers: list[str], branch: str) -> dict +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/jinja2.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/jinja2.mdx new file mode 100644 index 00000000..ca1bfb43 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/jinja2.mdx @@ -0,0 +1,20 @@ +--- +title: jinja2 +sidebarTitle: jinja2 +--- + +# `infrahub_sdk.jinja2` + +## Functions + +### `identify_faulty_jinja_code` + +```python +identify_faulty_jinja_code(traceback: Traceback, nbr_context_lines: int = 3) -> list[tuple[Frame, Syntax]] +``` + + +This function identifies the faulty Jinja2 code and beautify it to provide meaningful information to the user. + +We use the rich's Traceback to parse the complete stack trace and extract Frames for each expection found in the trace. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/attribute.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/attribute.mdx new file mode 100644 index 00000000..77d69e16 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/attribute.mdx @@ -0,0 +1,28 @@ +--- +title: attribute +sidebarTitle: attribute +--- + +# `infrahub_sdk.node.attribute` + +## Classes + +### `Attribute` + + +Represents an attribute of a Node, including its schema, value, and properties. + + +**Methods:** + +#### `value` + +```python +value(self) -> Any +``` + +#### `value` + +```python +value(self, value: Any) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/constants.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/constants.mdx new file mode 100644 index 00000000..290f923e --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/constants.mdx @@ -0,0 +1,8 @@ +--- +title: constants +sidebarTitle: constants +--- + +# `infrahub_sdk.node.constants` + +*This module is empty or contains only private/internal implementations.* diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx new file mode 100644 index 00000000..37dbe586 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx @@ -0,0 +1,345 @@ +--- +title: node +sidebarTitle: node +--- + +# `infrahub_sdk.node.node` + +## Classes + +### `InfrahubNodeBase` + + +Base class for InfrahubNode and InfrahubNodeSync + + +**Methods:** + +#### `get_branch` + +```python +get_branch(self) -> str +``` + +#### `get_path_value` + +```python +get_path_value(self, path: str) -> Any +``` + +#### `get_human_friendly_id` + +```python +get_human_friendly_id(self) -> list[str] | None +``` + +#### `get_human_friendly_id_as_string` + +```python +get_human_friendly_id_as_string(self, include_kind: bool = False) -> str | None +``` + +#### `hfid` + +```python +hfid(self) -> list[str] | None +``` + +#### `hfid_str` + +```python +hfid_str(self) -> str | None +``` + +#### `get_kind` + +```python +get_kind(self) -> str +``` + +#### `get_all_kinds` + +```python +get_all_kinds(self) -> list[str] +``` + +#### `is_ip_prefix` + +```python +is_ip_prefix(self) -> bool +``` + +#### `is_ip_address` + +```python +is_ip_address(self) -> bool +``` + +#### `is_resource_pool` + +```python +is_resource_pool(self) -> bool +``` + +#### `get_raw_graphql_data` + +```python +get_raw_graphql_data(self) -> dict | None +``` + +#### `generate_query_data_init` + +```python +generate_query_data_init(self, filters: dict[str, Any] | None = None, offset: int | None = None, limit: int | None = None, include: list[str] | None = None, exclude: list[str] | None = None, partial_match: bool = False, order: Order | None = None) -> dict[str, Any | dict] +``` + +#### `extract` + +```python +extract(self, params: dict[str, str]) -> dict[str, Any] +``` + +Extract some datapoints defined in a flat notation. + + +### `InfrahubNode` + + +Represents a Infrahub node in an asynchronous context. + + +**Methods:** + +#### `from_graphql` + +```python +from_graphql(cls, client: InfrahubClient, branch: str, data: dict, schema: MainSchemaTypesAPI | None = None, timeout: int | None = None) -> Self +``` + +#### `generate` + +```python +generate(self, nodes: list[str] | None = None) -> None +``` + +#### `artifact_generate` + +```python +artifact_generate(self, name: str) -> None +``` + +#### `artifact_fetch` + +```python +artifact_fetch(self, name: str) -> str | dict[str, Any] +``` + +#### `delete` + +```python +delete(self, timeout: int | None = None, request_context: RequestContext | None = None) -> None +``` + +#### `save` + +```python +save(self, allow_upsert: bool = False, update_group_context: bool | None = None, timeout: int | None = None, request_context: RequestContext | None = None) -> None +``` + +#### `generate_query_data` + +```python +generate_query_data(self, filters: dict[str, Any] | None = None, offset: int | None = None, limit: int | None = None, include: list[str] | None = None, exclude: list[str] | None = None, fragment: bool = False, prefetch_relationships: bool = False, partial_match: bool = False, property: bool = False, order: Order | None = None) -> dict[str, Any | dict] +``` + +#### `generate_query_data_node` + +```python +generate_query_data_node(self, include: list[str] | None = None, exclude: list[str] | None = None, inherited: bool = True, insert_alias: bool = False, prefetch_relationships: bool = False, property: bool = False) -> dict[str, Any | dict] +``` + +Generate the node part of a GraphQL Query with attributes and nodes. + +**Args:** +- `include`: List of attributes or relationships to include. Defaults to None. +- `exclude`: List of attributes or relationships to exclude. Defaults to None. +- `inherited`: Indicated of the attributes and the relationships inherited from generics should be included as well. + Defaults to True. +- `insert_alias`: If True, inserts aliases in the query for each attribute or relationship. +- `prefetch_relationships`: If True, pre-fetches relationship data as part of the query. + +**Returns:** +- dict\[str, Union\[Any, Dict]]: GraphQL query in dictionary format + + +#### `add_relationships` + +```python +add_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None +``` + +#### `remove_relationships` + +```python +remove_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None +``` + +#### `create` + +```python +create(self, allow_upsert: bool = False, timeout: int | None = None, request_context: RequestContext | None = None) -> None +``` + +#### `update` + +```python +update(self, do_full_update: bool = False, timeout: int | None = None, request_context: RequestContext | None = None) -> None +``` + +#### `get_pool_allocated_resources` + +```python +get_pool_allocated_resources(self, resource: InfrahubNode) -> list[InfrahubNode] +``` + +Fetch all nodes that were allocated for the pool and a given resource. + +**Args:** +- `resource`: The resource from which the nodes were allocated. + +**Returns:** +- list\[InfrahubNode]: The allocated nodes. + + +#### `get_pool_resources_utilization` + +```python +get_pool_resources_utilization(self) -> list[dict[str, Any]] +``` + +Fetch the utilization of each resource for the pool. + +**Returns:** +- list\[dict\[str, Any]]: A list containing the allocation numbers for each resource of the pool. + + +### `InfrahubNodeSync` + + +Represents a Infrahub node in a synchronous context. + + +**Methods:** + +#### `from_graphql` + +```python +from_graphql(cls, client: InfrahubClientSync, branch: str, data: dict, schema: MainSchemaTypesAPI | None = None, timeout: int | None = None) -> Self +``` + +#### `generate` + +```python +generate(self, nodes: list[str] | None = None) -> None +``` + +#### `artifact_generate` + +```python +artifact_generate(self, name: str) -> None +``` + +#### `artifact_fetch` + +```python +artifact_fetch(self, name: str) -> str | dict[str, Any] +``` + +#### `delete` + +```python +delete(self, timeout: int | None = None, request_context: RequestContext | None = None) -> None +``` + +#### `save` + +```python +save(self, allow_upsert: bool = False, update_group_context: bool | None = None, timeout: int | None = None, request_context: RequestContext | None = None) -> None +``` + +#### `generate_query_data` + +```python +generate_query_data(self, filters: dict[str, Any] | None = None, offset: int | None = None, limit: int | None = None, include: list[str] | None = None, exclude: list[str] | None = None, fragment: bool = False, prefetch_relationships: bool = False, partial_match: bool = False, property: bool = False, order: Order | None = None) -> dict[str, Any | dict] +``` + +#### `generate_query_data_node` + +```python +generate_query_data_node(self, include: list[str] | None = None, exclude: list[str] | None = None, inherited: bool = True, insert_alias: bool = False, prefetch_relationships: bool = False, property: bool = False) -> dict[str, Any | dict] +``` + +Generate the node part of a GraphQL Query with attributes and nodes. + +**Args:** +- `include`: List of attributes or relationships to include. Defaults to None. +- `exclude`: List of attributes or relationships to exclude. Defaults to None. +- `inherited`: Indicated of the attributes and the relationships inherited from generics should be included as well. + Defaults to True. +- `insert_alias`: If True, inserts aliases in the query for each attribute or relationship. +- `prefetch_relationships`: If True, pre-fetches relationship data as part of the query. + +**Returns:** +- dict\[str, Union\[Any, Dict]]: GraphQL query in dictionary format + + +#### `add_relationships` + +```python +add_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None +``` + +#### `remove_relationships` + +```python +remove_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None +``` + +#### `create` + +```python +create(self, allow_upsert: bool = False, timeout: int | None = None, request_context: RequestContext | None = None) -> None +``` + +#### `update` + +```python +update(self, do_full_update: bool = False, timeout: int | None = None, request_context: RequestContext | None = None) -> None +``` + +#### `get_pool_allocated_resources` + +```python +get_pool_allocated_resources(self, resource: InfrahubNodeSync) -> list[InfrahubNodeSync] +``` + +Fetch all nodes that were allocated for the pool and a given resource. + +**Args:** +- `resource`: The resource from which the nodes were allocated. + +**Returns:** +- list\[InfrahubNodeSync]: The allocated nodes. + + +#### `get_pool_resources_utilization` + +```python +get_pool_resources_utilization(self) -> list[dict[str, Any]] +``` + +Fetch the utilization of each resource for the pool. + +**Returns:** +- list\[dict\[str, Any]]: A list containing the allocation numbers for each resource of the pool. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/parsers.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/parsers.mdx new file mode 100644 index 00000000..f64178ec --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/parsers.mdx @@ -0,0 +1,18 @@ +--- +title: parsers +sidebarTitle: parsers +--- + +# `infrahub_sdk.node.parsers` + +## Functions + +### `parse_human_friendly_id` + +```python +parse_human_friendly_id(hfid: str | list[str]) -> tuple[str | None, list[str]] +``` + + +Parse a human friendly ID into a kind and an identifier. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/property.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/property.mdx new file mode 100644 index 00000000..3a11524c --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/property.mdx @@ -0,0 +1,14 @@ +--- +title: property +sidebarTitle: property +--- + +# `infrahub_sdk.node.property` + +## Classes + +### `NodeProperty` + + +Represents a property of a node, typically used for metadata like display labels. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/related_node.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/related_node.mdx new file mode 100644 index 00000000..231c81f5 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/related_node.mdx @@ -0,0 +1,116 @@ +--- +title: related_node +sidebarTitle: related_node +--- + +# `infrahub_sdk.node.related_node` + +## Classes + +### `RelatedNodeBase` + + +Base class for representing a related node in a relationship. + + +**Methods:** + +#### `id` + +```python +id(self) -> str | None +``` + +#### `hfid` + +```python +hfid(self) -> list[Any] | None +``` + +#### `hfid_str` + +```python +hfid_str(self) -> str | None +``` + +#### `is_resource_pool` + +```python +is_resource_pool(self) -> bool +``` + +#### `initialized` + +```python +initialized(self) -> bool +``` + +#### `display_label` + +```python +display_label(self) -> str | None +``` + +#### `typename` + +```python +typename(self) -> str | None +``` + +#### `kind` + +```python +kind(self) -> str | None +``` + +### `RelatedNode` + + +Represents a RelatedNodeBase in an asynchronous context. + + +**Methods:** + +#### `fetch` + +```python +fetch(self, timeout: int | None = None) -> None +``` + +#### `peer` + +```python +peer(self) -> InfrahubNode +``` + +#### `get` + +```python +get(self) -> InfrahubNode +``` + +### `RelatedNodeSync` + + +Represents a related node in a synchronous context. + + +**Methods:** + +#### `fetch` + +```python +fetch(self, timeout: int | None = None) -> None +``` + +#### `peer` + +```python +peer(self) -> InfrahubNodeSync +``` + +#### `get` + +```python +get(self) -> InfrahubNodeSync +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx new file mode 100644 index 00000000..a63fe714 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx @@ -0,0 +1,116 @@ +--- +title: relationship +sidebarTitle: relationship +--- + +# `infrahub_sdk.node.relationship` + +## Classes + +### `RelationshipManagerBase` + + +Base class for RelationshipManager and RelationshipManagerSync + + +**Methods:** + +#### `peer_ids` + +```python +peer_ids(self) -> list[str] +``` + +#### `peer_hfids` + +```python +peer_hfids(self) -> list[list[Any]] +``` + +#### `peer_hfids_str` + +```python +peer_hfids_str(self) -> list[str] +``` + +#### `has_update` + +```python +has_update(self) -> bool +``` + +### `RelationshipManager` + + +Manages relationships of a node in an asynchronous context. + + +**Methods:** + +#### `fetch` + +```python +fetch(self) -> None +``` + +#### `add` + +```python +add(self, data: str | RelatedNode | dict) -> None +``` + +Add a new peer to this relationship. + + +#### `extend` + +```python +extend(self, data: Iterable[str | RelatedNode | dict]) -> None +``` + +Add new peers to this relationship. + + +#### `remove` + +```python +remove(self, data: str | RelatedNode | dict) -> None +``` + +### `RelationshipManagerSync` + + +Manages relationships of a node in a synchronous context. + + +**Methods:** + +#### `fetch` + +```python +fetch(self) -> None +``` + +#### `add` + +```python +add(self, data: str | RelatedNodeSync | dict) -> None +``` + +Add a new peer to this relationship. + + +#### `extend` + +```python +extend(self, data: Iterable[str | RelatedNodeSync | dict]) -> None +``` + +Add new peers to this relationship. + + +#### `remove` + +```python +remove(self, data: str | RelatedNodeSync | dict) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/object_store.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/object_store.mdx new file mode 100644 index 00000000..2f3cce09 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/object_store.mdx @@ -0,0 +1,42 @@ +--- +title: object_store +sidebarTitle: object_store +--- + +# `infrahub_sdk.object_store` + +## Classes + +### `ObjectStoreBase` + +### `ObjectStore` + +**Methods:** + +#### `get` + +```python +get(self, identifier: str, tracker: str | None = None) -> str +``` + +#### `upload` + +```python +upload(self, content: str, tracker: str | None = None) -> dict[str, str] +``` + +### `ObjectStoreSync` + +**Methods:** + +#### `get` + +```python +get(self, identifier: str, tracker: str | None = None) -> str +``` + +#### `upload` + +```python +upload(self, content: str, tracker: str | None = None) -> dict[str, str] +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/operation.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/operation.mdx new file mode 100644 index 00000000..a6196413 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/operation.mdx @@ -0,0 +1,54 @@ +--- +title: operation +sidebarTitle: operation +--- + +# `infrahub_sdk.operation` + +## Classes + +### `InfrahubOperation` + +**Methods:** + +#### `branch_name` + +```python +branch_name(self) -> str +``` + +Return the name of the current git branch. + + +#### `store` + +```python +store(self) -> NodeStore +``` + +The store will be populated with nodes based on the query during the collection of data if activated + + +#### `nodes` + +```python +nodes(self) -> list[InfrahubNode] +``` + +Returns nodes collected and parsed during the data collection process if this feature is enabled + + +#### `related_nodes` + +```python +related_nodes(self) -> list[InfrahubNode] +``` + +Returns nodes collected and parsed during the data collection process if this feature is enabled + + +#### `process_nodes` + +```python +process_nodes(self, data: dict) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/playback.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/playback.mdx new file mode 100644 index 00000000..e4687058 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/playback.mdx @@ -0,0 +1,24 @@ +--- +title: playback +sidebarTitle: playback +--- + +# `infrahub_sdk.playback` + +## Classes + +### `JSONPlayback` + +**Methods:** + +#### `async_request` + +```python +async_request(self, url: str, method: HTTPMethod, headers: dict[str, Any], timeout: int, payload: dict | None = None) -> httpx.Response +``` + +#### `sync_request` + +```python +sync_request(self, url: str, method: HTTPMethod, headers: dict[str, Any], timeout: int, payload: dict | None = None) -> httpx.Response +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols.mdx new file mode 100644 index 00000000..2368ba66 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols.mdx @@ -0,0 +1,332 @@ +--- +title: protocols +sidebarTitle: protocols +--- + +# `infrahub_sdk.protocols` + +## Classes + +### `BuiltinIPAddress` + +### `BuiltinIPNamespace` + +### `BuiltinIPPrefix` + +### `CoreAction` + +### `CoreArtifactTarget` + +### `CoreBasePermission` + +### `CoreCheck` + +### `CoreComment` + +### `CoreCredential` + +### `CoreGenericAccount` + +### `CoreGenericRepository` + +### `CoreGroup` + +### `CoreMenu` + +### `CoreNodeTriggerMatch` + +### `CoreObjectComponentTemplate` + +### `CoreObjectTemplate` + +### `CoreProfile` + +### `CoreResourcePool` + +### `CoreTaskTarget` + +### `CoreThread` + +### `CoreTransformation` + +### `CoreTriggerRule` + +### `CoreValidator` + +### `CoreWebhook` + +### `LineageOwner` + +### `LineageSource` + +### `BuiltinTag` + +### `CoreAccount` + +### `CoreAccountGroup` + +### `CoreAccountRole` + +### `CoreArtifact` + +### `CoreArtifactCheck` + +### `CoreArtifactDefinition` + +### `CoreArtifactThread` + +### `CoreArtifactValidator` + +### `CoreChangeComment` + +### `CoreChangeThread` + +### `CoreCheckDefinition` + +### `CoreCustomWebhook` + +### `CoreDataCheck` + +### `CoreDataValidator` + +### `CoreFileCheck` + +### `CoreFileThread` + +### `CoreGeneratorAction` + +### `CoreGeneratorCheck` + +### `CoreGeneratorDefinition` + +### `CoreGeneratorGroup` + +### `CoreGeneratorInstance` + +### `CoreGeneratorValidator` + +### `CoreGlobalPermission` + +### `CoreGraphQLQuery` + +### `CoreGraphQLQueryGroup` + +### `CoreGroupAction` + +### `CoreGroupTriggerRule` + +### `CoreIPAddressPool` + +### `CoreIPPrefixPool` + +### `CoreMenuItem` + +### `CoreNodeTriggerAttributeMatch` + +### `CoreNodeTriggerRelationshipMatch` + +### `CoreNodeTriggerRule` + +### `CoreNumberPool` + +### `CoreObjectPermission` + +### `CoreObjectThread` + +### `CorePasswordCredential` + +### `CoreProposedChange` + +### `CoreReadOnlyRepository` + +### `CoreRepository` + +### `CoreRepositoryGroup` + +### `CoreRepositoryValidator` + +### `CoreSchemaCheck` + +### `CoreSchemaValidator` + +### `CoreStandardCheck` + +### `CoreStandardGroup` + +### `CoreStandardWebhook` + +### `CoreThreadComment` + +### `CoreTransformJinja2` + +### `CoreTransformPython` + +### `CoreUserValidator` + +### `InternalAccountToken` + +### `InternalRefreshToken` + +### `IpamNamespace` + +### `BuiltinIPAddressSync` + +### `BuiltinIPNamespaceSync` + +### `BuiltinIPPrefixSync` + +### `CoreActionSync` + +### `CoreArtifactTargetSync` + +### `CoreBasePermissionSync` + +### `CoreCheckSync` + +### `CoreCommentSync` + +### `CoreCredentialSync` + +### `CoreGenericAccountSync` + +### `CoreGenericRepositorySync` + +### `CoreGroupSync` + +### `CoreMenuSync` + +### `CoreNodeTriggerMatchSync` + +### `CoreObjectComponentTemplateSync` + +### `CoreObjectTemplateSync` + +### `CoreProfileSync` + +### `CoreResourcePoolSync` + +### `CoreTaskTargetSync` + +### `CoreThreadSync` + +### `CoreTransformationSync` + +### `CoreTriggerRuleSync` + +### `CoreValidatorSync` + +### `CoreWebhookSync` + +### `LineageOwnerSync` + +### `LineageSourceSync` + +### `BuiltinTagSync` + +### `CoreAccountSync` + +### `CoreAccountGroupSync` + +### `CoreAccountRoleSync` + +### `CoreArtifactSync` + +### `CoreArtifactCheckSync` + +### `CoreArtifactDefinitionSync` + +### `CoreArtifactThreadSync` + +### `CoreArtifactValidatorSync` + +### `CoreChangeCommentSync` + +### `CoreChangeThreadSync` + +### `CoreCheckDefinitionSync` + +### `CoreCustomWebhookSync` + +### `CoreDataCheckSync` + +### `CoreDataValidatorSync` + +### `CoreFileCheckSync` + +### `CoreFileThreadSync` + +### `CoreGeneratorActionSync` + +### `CoreGeneratorCheckSync` + +### `CoreGeneratorDefinitionSync` + +### `CoreGeneratorGroupSync` + +### `CoreGeneratorInstanceSync` + +### `CoreGeneratorValidatorSync` + +### `CoreGlobalPermissionSync` + +### `CoreGraphQLQuerySync` + +### `CoreGraphQLQueryGroupSync` + +### `CoreGroupActionSync` + +### `CoreGroupTriggerRuleSync` + +### `CoreIPAddressPoolSync` + +### `CoreIPPrefixPoolSync` + +### `CoreMenuItemSync` + +### `CoreNodeTriggerAttributeMatchSync` + +### `CoreNodeTriggerRelationshipMatchSync` + +### `CoreNodeTriggerRuleSync` + +### `CoreNumberPoolSync` + +### `CoreObjectPermissionSync` + +### `CoreObjectThreadSync` + +### `CorePasswordCredentialSync` + +### `CoreProposedChangeSync` + +### `CoreReadOnlyRepositorySync` + +### `CoreRepositorySync` + +### `CoreRepositoryGroupSync` + +### `CoreRepositoryValidatorSync` + +### `CoreSchemaCheckSync` + +### `CoreSchemaValidatorSync` + +### `CoreStandardCheckSync` + +### `CoreStandardGroupSync` + +### `CoreStandardWebhookSync` + +### `CoreThreadCommentSync` + +### `CoreTransformJinja2Sync` + +### `CoreTransformPythonSync` + +### `CoreUserValidatorSync` + +### `InternalAccountTokenSync` + +### `InternalRefreshTokenSync` + +### `IpamNamespaceSync` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_base.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_base.mdx new file mode 100644 index 00000000..01665925 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_base.mdx @@ -0,0 +1,272 @@ +--- +title: protocols_base +sidebarTitle: protocols_base +--- + +# `infrahub_sdk.protocols_base` + +## Classes + +### `RelatedNodeBase` + +**Methods:** + +#### `id` + +```python +id(self) -> str | None +``` + +#### `hfid` + +```python +hfid(self) -> list[Any] | None +``` + +#### `hfid_str` + +```python +hfid_str(self) -> str | None +``` + +#### `is_resource_pool` + +```python +is_resource_pool(self) -> bool +``` + +#### `initialized` + +```python +initialized(self) -> bool +``` + +#### `display_label` + +```python +display_label(self) -> str | None +``` + +#### `typename` + +```python +typename(self) -> str | None +``` + +### `RelatedNode` + +### `RelatedNodeSync` + +### `Attribute` + +### `String` + +### `StringOptional` + +### `DateTime` + +### `DateTimeOptional` + +### `HashedPassword` + +### `HashedPasswordOptional` + +### `URL` + +### `URLOptional` + +### `MacAddress` + +### `MacAddressOptional` + +### `Dropdown` + +### `DropdownOptional` + +### `Enum` + +### `EnumOptional` + +### `Integer` + +### `IntegerOptional` + +### `IPHost` + +### `IPHostOptional` + +### `IPNetwork` + +### `IPNetworkOptional` + +### `Boolean` + +### `BooleanOptional` + +### `ListAttribute` + +### `ListAttributeOptional` + +### `JSONAttribute` + +### `JSONAttributeOptional` + +### `AnyAttribute` + +### `AnyAttributeOptional` + +### `CoreNodeBase` + +**Methods:** + +#### `hfid` + +```python +hfid(self) -> list[str] | None +``` + +#### `hfid_str` + +```python +hfid_str(self) -> str | None +``` + +#### `get_human_friendly_id` + +```python +get_human_friendly_id(self) -> list[str] | None +``` + +#### `get_human_friendly_id_as_string` + +```python +get_human_friendly_id_as_string(self, include_kind: bool = False) -> str | None +``` + +#### `get_kind` + +```python +get_kind(self) -> str +``` + +#### `get_all_kinds` + +```python +get_all_kinds(self) -> list[str] +``` + +#### `get_branch` + +```python +get_branch(self) -> str +``` + +#### `is_ip_prefix` + +```python +is_ip_prefix(self) -> bool +``` + +#### `is_ip_address` + +```python +is_ip_address(self) -> bool +``` + +#### `is_resource_pool` + +```python +is_resource_pool(self) -> bool +``` + +#### `get_raw_graphql_data` + +```python +get_raw_graphql_data(self) -> dict | None +``` + +#### `extract` + +```python +extract(self, params: dict[str, str]) -> dict[str, Any] +``` + +### `CoreNode` + +**Methods:** + +#### `save` + +```python +save(self, allow_upsert: bool = False, update_group_context: bool | None = None, timeout: int | None = None, request_context: RequestContext | None = None) -> None +``` + +#### `delete` + +```python +delete(self, timeout: int | None = None, request_context: RequestContext | None = None) -> None +``` + +#### `update` + +```python +update(self, do_full_update: bool, timeout: int | None = None, request_context: RequestContext | None = None) -> None +``` + +#### `create` + +```python +create(self, allow_upsert: bool = False, timeout: int | None = None, request_context: RequestContext | None = None) -> None +``` + +#### `add_relationships` + +```python +add_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None +``` + +#### `remove_relationships` + +```python +remove_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None +``` + +### `CoreNodeSync` + +**Methods:** + +#### `save` + +```python +save(self, allow_upsert: bool = False, update_group_context: bool | None = None, timeout: int | None = None, request_context: RequestContext | None = None) -> None +``` + +#### `delete` + +```python +delete(self, timeout: int | None = None, request_context: RequestContext | None = None) -> None +``` + +#### `update` + +```python +update(self, do_full_update: bool, timeout: int | None = None, request_context: RequestContext | None = None) -> None +``` + +#### `create` + +```python +create(self, allow_upsert: bool = False, timeout: int | None = None, request_context: RequestContext | None = None) -> None +``` + +#### `add_relationships` + +```python +add_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None +``` + +#### `remove_relationships` + +```python +remove_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/constants.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/constants.mdx new file mode 100644 index 00000000..bdebeaff --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/constants.mdx @@ -0,0 +1,8 @@ +--- +title: constants +sidebarTitle: constants +--- + +# `infrahub_sdk.protocols_generator.constants` + +*This module is empty or contains only private/internal implementations.* diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/generator.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/generator.mdx new file mode 100644 index 00000000..3ede33e6 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/generator.mdx @@ -0,0 +1,36 @@ +--- +title: generator +sidebarTitle: generator +--- + +# `infrahub_sdk.protocols_generator.generator` + +## Functions + +### `load_template` + +```python +load_template() -> str +``` + +### `move_to_end_of_list` + +```python +move_to_end_of_list(lst: list, item: str) -> list +``` + + +Move an item to the end of a list if it exists in the list + + +## Classes + +### `CodeGenerator` + +**Methods:** + +#### `render` + +```python +render(self, sync: bool = True) -> str +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/exceptions.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/exceptions.mdx new file mode 100644 index 00000000..5a7fca84 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/exceptions.mdx @@ -0,0 +1,32 @@ +--- +title: exceptions +sidebarTitle: exceptions +--- + +# `infrahub_sdk.pytest_plugin.exceptions` + +## Classes + +### `Error` + + +pytest-infrahub Base exception. + + +### `InvalidResourceConfigError` + +### `DirectoryNotFoundError` + +### `FileNotValidError` + +### `OutputMatchError` + +### `Jinja2TransformError` + +### `Jinja2TransformUndefinedError` + +### `CheckDefinitionError` + +### `CheckResultError` + +### `PythonTransformDefinitionError` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/base.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/base.mdx new file mode 100644 index 00000000..e49e6239 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/base.mdx @@ -0,0 +1,65 @@ +--- +title: base +sidebarTitle: base +--- + +# `infrahub_sdk.pytest_plugin.items.base` + +## Classes + +### `InfrahubItem` + +**Methods:** + +#### `validate_resource_config` + +```python +validate_resource_config(self) -> None +``` + +Make sure that a test resource config is properly defined. + + +#### `get_result_differences` + +```python +get_result_differences(self, computed: Any) -> str | None +``` + +Compute the differences between the computed result and the expected one. + +If the results are not JSON parsable, this method must be redefined to handle them. + + +#### `runtest` + +```python +runtest(self) -> None +``` + +Run the test logic. + + +#### `repr_failure` + +```python +repr_failure(self, excinfo: pytest.ExceptionInfo, style: str | None = None) -> str +``` + +#### `reportinfo` + +```python +reportinfo(self) -> tuple[Path | str, int | None, str] +``` + +#### `repository_base` + +```python +repository_base(self) -> str +``` + +Return the path to the root of the repository + +This will be an absolute path if --infrahub-config-path is an absolut path as happens when +tests are started from within Infrahub server. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/check.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/check.mdx new file mode 100644 index 00000000..1b30a8a7 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/check.mdx @@ -0,0 +1,60 @@ +--- +title: check +sidebarTitle: check +--- + +# `infrahub_sdk.pytest_plugin.items.check` + +## Classes + +### `InfrahubCheckItem` + +**Methods:** + +#### `instantiate_check` + +```python +instantiate_check(self) -> None +``` + +#### `run_check` + +```python +run_check(self, variables: dict[str, Any]) -> Any +``` + +#### `repr_failure` + +```python +repr_failure(self, excinfo: ExceptionInfo, style: str | None = None) -> str +``` + +### `InfrahubCheckSmokeItem` + +**Methods:** + +#### `runtest` + +```python +runtest(self) -> None +``` + +### `InfrahubCheckUnitProcessItem` + +**Methods:** + +#### `runtest` + +```python +runtest(self) -> None +``` + +### `InfrahubCheckIntegrationItem` + +**Methods:** + +#### `runtest` + +```python +runtest(self) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/graphql_query.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/graphql_query.mdx new file mode 100644 index 00000000..dd3d9b58 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/graphql_query.mdx @@ -0,0 +1,50 @@ +--- +title: graphql_query +sidebarTitle: graphql_query +--- + +# `infrahub_sdk.pytest_plugin.items.graphql_query` + +## Classes + +### `InfrahubGraphQLQueryItem` + +**Methods:** + +#### `validate_resource_config` + +```python +validate_resource_config(self) -> None +``` + +#### `execute_query` + +```python +execute_query(self) -> Any +``` + +#### `repr_failure` + +```python +repr_failure(self, excinfo: ExceptionInfo, style: str | None = None) -> str +``` + +### `InfrahubGraphQLQuerySmokeItem` + +**Methods:** + +#### `runtest` + +```python +runtest(self) -> None +``` + +### `InfrahubGraphQLQueryIntegrationItem` + +**Methods:** + +#### `runtest` + +```python +runtest(self) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/jinja2_transform.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/jinja2_transform.mdx new file mode 100644 index 00000000..ca479c55 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/jinja2_transform.mdx @@ -0,0 +1,78 @@ +--- +title: jinja2_transform +sidebarTitle: jinja2_transform +--- + +# `infrahub_sdk.pytest_plugin.items.jinja2_transform` + +## Classes + +### `InfrahubJinja2Item` + +**Methods:** + +#### `get_jinja2_environment` + +```python +get_jinja2_environment(self) -> jinja2.Environment +``` + +#### `get_jinja2_template` + +```python +get_jinja2_template(self) -> jinja2.Template +``` + +#### `render_jinja2_template` + +```python +render_jinja2_template(self, variables: dict[str, Any]) -> str | None +``` + +#### `get_result_differences` + +```python +get_result_differences(self, computed: Any) -> str | None +``` + +#### `repr_failure` + +```python +repr_failure(self, excinfo: ExceptionInfo, style: str | None = None) -> str +``` + +### `InfrahubJinja2TransformSmokeItem` + +**Methods:** + +#### `runtest` + +```python +runtest(self) -> None +``` + +### `InfrahubJinja2TransformUnitRenderItem` + +**Methods:** + +#### `runtest` + +```python +runtest(self) -> None +``` + +#### `repr_failure` + +```python +repr_failure(self, excinfo: ExceptionInfo, style: str | None = None) -> str +``` + +### `InfrahubJinja2TransformIntegrationItem` + +**Methods:** + +#### `runtest` + +```python +runtest(self) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/python_transform.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/python_transform.mdx new file mode 100644 index 00000000..13dd67f3 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/python_transform.mdx @@ -0,0 +1,60 @@ +--- +title: python_transform +sidebarTitle: python_transform +--- + +# `infrahub_sdk.pytest_plugin.items.python_transform` + +## Classes + +### `InfrahubPythonTransformItem` + +**Methods:** + +#### `instantiate_transform` + +```python +instantiate_transform(self) -> None +``` + +#### `run_transform` + +```python +run_transform(self, variables: dict[str, Any]) -> Any +``` + +#### `repr_failure` + +```python +repr_failure(self, excinfo: ExceptionInfo, style: str | None = None) -> str +``` + +### `InfrahubPythonTransformSmokeItem` + +**Methods:** + +#### `runtest` + +```python +runtest(self) -> None +``` + +### `InfrahubPythonTransformUnitProcessItem` + +**Methods:** + +#### `runtest` + +```python +runtest(self) -> None +``` + +### `InfrahubPythonTransformIntegrationItem` + +**Methods:** + +#### `runtest` + +```python +runtest(self) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/loader.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/loader.mdx new file mode 100644 index 00000000..f48b239c --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/loader.mdx @@ -0,0 +1,36 @@ +--- +title: loader +sidebarTitle: loader +--- + +# `infrahub_sdk.pytest_plugin.loader` + +## Classes + +### `InfrahubYamlFile` + +**Methods:** + +#### `get_resource_config` + +```python +get_resource_config(self, group: InfrahubTestGroup) -> Any | None +``` + +Retrieve the resource configuration to apply to all tests in a group. + + +#### `collect_group` + +```python +collect_group(self, group: InfrahubTestGroup) -> Iterable[Item] +``` + +Collect all items for a group. + + +#### `collect` + +```python +collect(self) -> Iterable[Item] +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/models.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/models.mdx new file mode 100644 index 00000000..ad1504e6 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/models.mdx @@ -0,0 +1,96 @@ +--- +title: models +sidebarTitle: models +--- + +# `infrahub_sdk.pytest_plugin.models` + +## Classes + +### `InfrahubTestExpectedResult` + +### `InfrahubTestResource` + +### `InfrahubBaseTest` + + +Basic Infrahub test model used as a common ground for all tests. + + +### `InfrahubInputOutputTest` + +**Methods:** + +#### `parse_user_provided_data` + +```python +parse_user_provided_data(path: Path | None) -> Any +``` + +Read and parse user provided data depending on a file extension. + +This function handles JSON and YAML as they can be used to achieve the same goal. However some users may be more used to one format or +another. If the file extension isn't known, assume the content is plain text. + + +#### `update_paths` + +```python +update_paths(self, base_dir: Path) -> None +``` + +#### `get_input_data` + +```python +get_input_data(self) -> Any +``` + +#### `get_output_data` + +```python +get_output_data(self) -> Any +``` + +### `InfrahubIntegrationTest` + +**Methods:** + +#### `update_paths` + +```python +update_paths(self, base_dir: Path) -> None +``` + +#### `get_variables_data` + +```python +get_variables_data(self) -> dict[str, Any] +``` + +### `InfrahubCheckSmokeTest` + +### `InfrahubCheckUnitProcessTest` + +### `InfrahubCheckIntegrationTest` + +### `InfrahubGraphQLQuerySmokeTest` + +### `InfrahubGraphQLQueryIntegrationTest` + +### `InfrahubJinja2TransformSmokeTest` + +### `InfrahubJinja2TransformUnitRenderTest` + +### `InfrahubJinja2TransformIntegrationTest` + +### `InfrahubPythonTransformSmokeTest` + +### `InfrahubPythonTransformUnitProcessTest` + +### `InfrahubPythonTransformIntegrationTest` + +### `InfrahubTest` + +### `InfrahubTestGroup` + +### `InfrahubTestFileV1` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/plugin.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/plugin.mdx new file mode 100644 index 00000000..ee76f8c1 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/plugin.mdx @@ -0,0 +1,32 @@ +--- +title: plugin +sidebarTitle: plugin +--- + +# `infrahub_sdk.pytest_plugin.plugin` + +## Functions + +### `pytest_addoption` + +```python +pytest_addoption(parser: Parser) -> None +``` + +### `pytest_sessionstart` + +```python +pytest_sessionstart(session: Session) -> None +``` + +### `pytest_collect_file` + +```python +pytest_collect_file(parent: Collector | Item, file_path: Path) -> InfrahubYamlFile | None +``` + +### `pytest_configure` + +```python +pytest_configure(config: Config) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/utils.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/utils.mdx new file mode 100644 index 00000000..ed904129 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/utils.mdx @@ -0,0 +1,14 @@ +--- +title: utils +sidebarTitle: utils +--- + +# `infrahub_sdk.pytest_plugin.utils` + +## Functions + +### `load_repository_config` + +```python +load_repository_config(repo_config_file: Path) -> InfrahubRepositoryConfig +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/queries.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/queries.mdx new file mode 100644 index 00000000..394661ee --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/queries.mdx @@ -0,0 +1,14 @@ +--- +title: queries +sidebarTitle: queries +--- + +# `infrahub_sdk.queries` + +## Functions + +### `get_commit_update_mutation` + +```python +get_commit_update_mutation(is_read_only: bool = False) -> str +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/query_groups.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/query_groups.mdx new file mode 100644 index 00000000..b0e2ac6e --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/query_groups.mdx @@ -0,0 +1,139 @@ +--- +title: query_groups +sidebarTitle: query_groups +--- + +# `infrahub_sdk.query_groups` + +## Classes + +### `InfrahubGroupContextBase` + + +Base class for InfrahubGroupContext and InfrahubGroupContextSync + + +**Methods:** + +#### `set_properties` + +```python +set_properties(self, identifier: str, params: dict[str, str] | None = None, delete_unused_nodes: bool = False, group_type: str | None = None, group_params: dict[str, Any] | None = None, branch: str | None = None) -> None +``` + +Setter method to set the values of identifier and params. + +**Args:** +- `identifier`: The new value for the identifier. +- `params`: A dictionary with new values for the params. + + +### `InfrahubGroupContext` + + +Represents a Infrahub GroupContext in an asynchronous context. + + +**Methods:** + +#### `get_group` + +```python +get_group(self, store_peers: bool = False) -> InfrahubNode | None +``` + +#### `delete_unused` + +```python +delete_unused(self) -> None +``` + +#### `add_related_nodes` + +```python +add_related_nodes(self, ids: list[str], update_group_context: bool | None = None) -> None +``` + +Add related Nodes IDs to the context. + +**Args:** +- `ids`: List of node IDs to be added. +- `update_group_context`: Flag to control whether to update the group context. + + +#### `add_related_groups` + +```python +add_related_groups(self, ids: list[str], update_group_context: bool | None = None) -> None +``` + +Add related Groups IDs to the context. + +**Args:** +- `ids`: List of group IDs to be added. +- `update_group_context`: Flag to control whether to update the group context. + + +#### `update_group` + +```python +update_group(self) -> None +``` + +Create or update (using upsert) a CoreStandardGroup to store all the Nodes and Groups used during an execution. + + +### `InfrahubGroupContextSync` + + +Represents a Infrahub GroupContext in an synchronous context. + + +**Methods:** + +#### `get_group` + +```python +get_group(self, store_peers: bool = False) -> InfrahubNodeSync | None +``` + +#### `delete_unused` + +```python +delete_unused(self) -> None +``` + +#### `add_related_nodes` + +```python +add_related_nodes(self, ids: list[str], update_group_context: bool | None = None) -> None +``` + +Add related Nodes IDs to the context. + +**Args:** +- `ids`: List of node IDs to be added. +- `update_group_context`: Flag to control whether to update the group context. + + +#### `add_related_groups` + +```python +add_related_groups(self, ids: list[str], update_group_context: bool | None = None) -> None +``` + +Add related Groups IDs to the context. + +**Args:** +- `ids`: List of group IDs to be added. +- `update_group_context`: Flag to control whether to update the group context. + + +#### `update_group` + +```python +update_group(self) -> None +``` + +Create or update (using upsert) a CoreStandardGroup to store all the Nodes and Groups used during an execution. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/recorder.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/recorder.mdx new file mode 100644 index 00000000..105a714d --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/recorder.mdx @@ -0,0 +1,52 @@ +--- +title: recorder +sidebarTitle: recorder +--- + +# `infrahub_sdk.recorder` + +## Classes + +### `RecorderType` + +### `Recorder` + +**Methods:** + +#### `record` + +```python +record(self, response: httpx.Response) -> None +``` + +Record the response from Infrahub + + +### `NoRecorder` + +**Methods:** + +#### `record` + +```python +record(response: httpx.Response) -> None +``` + +The NoRecorder just silently returns + + +#### `default` + +```python +default(cls) -> NoRecorder +``` + +### `JSONRecorder` + +**Methods:** + +#### `record` + +```python +record(self, response: httpx.Response) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/repository.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/repository.mdx new file mode 100644 index 00000000..5546beda --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/repository.mdx @@ -0,0 +1,24 @@ +--- +title: repository +sidebarTitle: repository +--- + +# `infrahub_sdk.repository` + +## Classes + +### `GitRepoManager` + +**Methods:** + +#### `initialize_repo` + +```python +initialize_repo(self) -> Repo +``` + +#### `active_branch` + +```python +active_branch(self) -> str | None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/main.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/main.mdx new file mode 100644 index 00000000..74b088ce --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/main.mdx @@ -0,0 +1,208 @@ +--- +title: main +sidebarTitle: main +--- + +# `infrahub_sdk.schema.main` + +## Classes + +### `RelationshipCardinality` + +### `BranchSupportType` + +### `RelationshipKind` + +### `RelationshipDirection` + +### `AttributeKind` + +### `SchemaState` + +### `AllowOverrideType` + +### `RelationshipDeleteBehavior` + +### `AttributeSchema` + +### `AttributeSchemaAPI` + +### `RelationshipSchema` + +### `RelationshipSchemaAPI` + +### `BaseSchemaAttrRel` + +### `BaseSchemaAttrRelAPI` + +**Methods:** + +#### `get_field` + +```python +get_field(self, name: str, raise_on_error: bool = True) -> AttributeSchemaAPI | RelationshipSchemaAPI | None +``` + +#### `get_attribute` + +```python +get_attribute(self, name: str) -> AttributeSchemaAPI +``` + +#### `get_attribute_or_none` + +```python +get_attribute_or_none(self, name: str) -> AttributeSchemaAPI | None +``` + +#### `get_relationship` + +```python +get_relationship(self, name: str) -> RelationshipSchemaAPI +``` + +#### `get_relationship_or_none` + +```python +get_relationship_or_none(self, name: str) -> RelationshipSchemaAPI | None +``` + +#### `get_relationship_by_identifier` + +```python +get_relationship_by_identifier(self, id: str, raise_on_error: bool = True) -> RelationshipSchemaAPI | None +``` + +#### `get_matching_relationship` + +```python +get_matching_relationship(self, id: str, direction: RelationshipDirection = RelationshipDirection.BIDIR) -> RelationshipSchemaAPI +``` + +#### `attribute_names` + +```python +attribute_names(self) -> list[str] +``` + +#### `relationship_names` + +```python +relationship_names(self) -> list[str] +``` + +#### `mandatory_input_names` + +```python +mandatory_input_names(self) -> list[str] +``` + +#### `mandatory_attribute_names` + +```python +mandatory_attribute_names(self) -> list[str] +``` + +#### `mandatory_relationship_names` + +```python +mandatory_relationship_names(self) -> list[str] +``` + +#### `local_attributes` + +```python +local_attributes(self) -> list[AttributeSchemaAPI] +``` + +#### `local_relationships` + +```python +local_relationships(self) -> list[RelationshipSchemaAPI] +``` + +#### `unique_attributes` + +```python +unique_attributes(self) -> list[AttributeSchemaAPI] +``` + +### `BaseSchema` + +**Methods:** + +#### `kind` + +```python +kind(self) -> str +``` + +### `GenericSchema` + +**Methods:** + +#### `convert_api` + +```python +convert_api(self) -> GenericSchemaAPI +``` + +### `GenericSchemaAPI` + + +A Generic can be either an Interface or a Union depending if there are some Attributes or Relationships defined. + + +### `BaseNodeSchema` + +### `NodeSchema` + +**Methods:** + +#### `convert_api` + +```python +convert_api(self) -> NodeSchemaAPI +``` + +### `NodeSchemaAPI` + +### `ProfileSchemaAPI` + +### `TemplateSchemaAPI` + +### `NodeExtensionSchema` + +### `SchemaRoot` + +**Methods:** + +#### `to_schema_dict` + +```python +to_schema_dict(self) -> dict[str, Any] +``` + +### `SchemaRootAPI` + +### `BranchSchema` + +**Methods:** + +#### `from_api_response` + +```python +from_api_response(cls, data: MutableMapping[str, Any]) -> Self +``` + +Convert an API response from /api/schema into a BranchSchema object. + + +#### `from_schema_root_api` + +```python +from_schema_root_api(cls, data: SchemaRootAPI) -> Self +``` + +Convert a SchemaRootAPI object to a BranchSchema object. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/repository.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/repository.mdx new file mode 100644 index 00000000..1d305e98 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/repository.mdx @@ -0,0 +1,158 @@ +--- +title: repository +sidebarTitle: repository +--- + +# `infrahub_sdk.schema.repository` + +## Classes + +### `InfrahubRepositoryConfigElement` + + +Class to regroup all elements of the infrahub configuration for a repository for typing purpose. + + +### `InfrahubRepositoryArtifactDefinitionConfig` + +### `InfrahubJinja2TransformConfig` + +**Methods:** + +#### `template_path_value` + +```python +template_path_value(self) -> str +``` + +#### `payload` + +```python +payload(self) -> dict[str, str] +``` + +### `InfrahubCheckDefinitionConfig` + +**Methods:** + +#### `load_class` + +```python +load_class(self, import_root: str | None = None, relative_path: str | None = None) -> type[InfrahubCheck] +``` + +### `InfrahubGeneratorDefinitionConfig` + +**Methods:** + +#### `load_class` + +```python +load_class(self, import_root: str | None = None, relative_path: str | None = None) -> type[InfrahubGenerator] +``` + +### `InfrahubPythonTransformConfig` + +**Methods:** + +#### `load_class` + +```python +load_class(self, import_root: str | None = None, relative_path: str | None = None) -> type[InfrahubTransform] +``` + +### `InfrahubRepositoryGraphQLConfig` + +**Methods:** + +#### `load_query` + +```python +load_query(self, relative_path: str = '.') -> str +``` + +### `InfrahubObjectConfig` + +### `InfrahubMenuConfig` + +### `InfrahubRepositoryConfig` + +**Methods:** + +#### `unique_items` + +```python +unique_items(cls, v: list[Any]) -> list[Any] +``` + +#### `has_jinja2_transform` + +```python +has_jinja2_transform(self, name: str) -> bool +``` + +#### `get_jinja2_transform` + +```python +get_jinja2_transform(self, name: str) -> InfrahubJinja2TransformConfig +``` + +#### `has_check_definition` + +```python +has_check_definition(self, name: str) -> bool +``` + +#### `get_check_definition` + +```python +get_check_definition(self, name: str) -> InfrahubCheckDefinitionConfig +``` + +#### `has_artifact_definition` + +```python +has_artifact_definition(self, name: str) -> bool +``` + +#### `get_artifact_definition` + +```python +get_artifact_definition(self, name: str) -> InfrahubRepositoryArtifactDefinitionConfig +``` + +#### `has_generator_definition` + +```python +has_generator_definition(self, name: str) -> bool +``` + +#### `get_generator_definition` + +```python +get_generator_definition(self, name: str) -> InfrahubGeneratorDefinitionConfig +``` + +#### `has_python_transform` + +```python +has_python_transform(self, name: str) -> bool +``` + +#### `get_python_transform` + +```python +get_python_transform(self, name: str) -> InfrahubPythonTransformConfig +``` + +#### `has_query` + +```python +has_query(self, name: str) -> bool +``` + +#### `get_query` + +```python +get_query(self, name: str) -> InfrahubRepositoryGraphQLConfig +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/menu.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/menu.mdx new file mode 100644 index 00000000..89aabc9a --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/menu.mdx @@ -0,0 +1,34 @@ +--- +title: menu +sidebarTitle: menu +--- + +# `infrahub_sdk.spec.menu` + +## Classes + +### `InfrahubMenuFileData` + +**Methods:** + +#### `enrich_node` + +```python +enrich_node(cls, data: dict, context: dict) -> dict +``` + +### `MenuFile` + +**Methods:** + +#### `spec` + +```python +spec(self) -> InfrahubMenuFileData +``` + +#### `validate_content` + +```python +validate_content(self) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/object.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/object.mdx new file mode 100644 index 00000000..a0e6bd5f --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/object.mdx @@ -0,0 +1,175 @@ +--- +title: object +sidebarTitle: object +--- + +# `infrahub_sdk.spec.object` + +## Functions + +### `validate_list_of_scalars` + +```python +validate_list_of_scalars(value: list[Any]) -> bool +``` + +### `validate_list_of_hfids` + +```python +validate_list_of_hfids(value: list[Any]) -> bool +``` + +### `validate_list_of_data_dicts` + +```python +validate_list_of_data_dicts(value: list[Any]) -> bool +``` + +### `validate_list_of_objects` + +```python +validate_list_of_objects(value: list[Any]) -> bool +``` + +### `get_relationship_info` + +```python +get_relationship_info(client: InfrahubClient, schema: MainSchemaTypesAPI, name: str, value: Any, branch: str | None = None) -> RelationshipInfo +``` + + +Get the relationship info for a given relationship name. + + +## Classes + +### `RelationshipDataFormat` + +### `RelationshipInfo` + +**Methods:** + +#### `is_bidirectional` + +```python +is_bidirectional(self) -> bool +``` + +Indicate if a relationship with the same identifier exists on the other side + + +#### `is_mandatory` + +```python +is_mandatory(self) -> bool +``` + +#### `is_valid` + +```python +is_valid(self) -> bool +``` + +#### `is_reference` + +```python +is_reference(self) -> bool +``` + +#### `get_context` + +```python +get_context(self, value: Any) -> dict +``` + +Return a dict to insert to the context if the relationship is mandatory + + +#### `find_matching_relationship` + +```python +find_matching_relationship(self, peer_schema: MainSchemaTypesAPI, force: bool = False) -> RelationshipSchema | None +``` + +Find the matching relationship on the other side of the relationship + + +### `InfrahubObjectFileData` + +**Methods:** + +#### `validate_format` + +```python +validate_format(self, client: InfrahubClient, branch: str | None = None) -> list[ObjectValidationError] +``` + +#### `process` + +```python +process(self, client: InfrahubClient, branch: str | None = None) -> None +``` + +#### `validate_object` + +```python +validate_object(cls, client: InfrahubClient, schema: MainSchemaTypesAPI, data: dict, position: list[int | str], context: dict | None = None, branch: str | None = None, default_schema_kind: str | None = None) -> list[ObjectValidationError] +``` + +#### `validate_related_nodes` + +```python +validate_related_nodes(cls, client: InfrahubClient, position: list[int | str], rel_info: RelationshipInfo, data: dict | list[dict], context: dict | None = None, branch: str | None = None, default_schema_kind: str | None = None) -> list[ObjectValidationError] +``` + +#### `enrich_node` + +```python +enrich_node(cls, data: dict, context: dict) -> dict +``` + +#### `create_node` + +```python +create_node(cls, client: InfrahubClient, schema: MainSchemaTypesAPI, data: dict, position: list[int | str], context: dict | None = None, branch: str | None = None, default_schema_kind: str | None = None) -> InfrahubNode +``` + +#### `create_related_nodes` + +```python +create_related_nodes(cls, client: InfrahubClient, rel_info: RelationshipInfo, position: list[int | str], data: dict | list[dict], parent_node: InfrahubNode | None = None, context: dict | None = None, branch: str | None = None, default_schema_kind: str | None = None) -> list[InfrahubNode] +``` + +#### `get_peer_schema` + +```python +get_peer_schema(cls, client: InfrahubClient, peer_kind: str, branch: str | None = None, default_schema_kind: str | None = None) -> MainSchemaTypesAPI +``` + +### `ObjectFile` + +**Methods:** + +#### `spec` + +```python +spec(self) -> InfrahubObjectFileData +``` + +#### `validate_content` + +```python +validate_content(self) -> None +``` + +#### `validate_format` + +```python +validate_format(self, client: InfrahubClient, branch: str | None = None) -> None +``` + +#### `process` + +```python +process(self, client: InfrahubClient, branch: str | None = None) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/store.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/store.mdx new file mode 100644 index 00000000..9166a0b2 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/store.mdx @@ -0,0 +1,195 @@ +--- +title: store +sidebarTitle: store +--- + +# `infrahub_sdk.store` + +## Functions + +### `get_schema_name` + +```python +get_schema_name(schema: type[SchemaType | SchemaTypeSync] | str | None = None) -> str | None +``` + +## Classes + +### `NodeStoreBranch` + +**Methods:** + +#### `count` + +```python +count(self) -> int +``` + +#### `set` + +```python +set(self, node: InfrahubNode | InfrahubNodeSync | CoreNode | CoreNodeSync, key: str | None = None) -> None +``` + +#### `get` + +```python +get(self, key: str | list[str], kind: type[SchemaType | SchemaTypeSync] | str | None = None, raise_when_missing: bool = True) -> InfrahubNode | InfrahubNodeSync | CoreNode | CoreNodeSync | None +``` + +### `NodeStoreBase` + + +Internal Store for InfrahubNode objects. + +Often while creating a lot of new objects, +we need to save them in order to reuse them later to associate them with another node for example. + + +**Methods:** + +#### `count` + +```python +count(self, branch: str | None = None) -> int +``` + +### `NodeStore` + +**Methods:** + +#### `get` + +```python +get(self, key: str | list[str], kind: type[SchemaType], raise_when_missing: Literal[True] = True, branch: str | None = ...) -> SchemaType +``` + +#### `get` + +```python +get(self, key: str | list[str], kind: type[SchemaType], raise_when_missing: Literal[False] = False, branch: str | None = ...) -> SchemaType | None +``` + +#### `get` + +```python +get(self, key: str | list[str], kind: type[SchemaType], raise_when_missing: bool = ..., branch: str | None = ...) -> SchemaType +``` + +#### `get` + +```python +get(self, key: str | list[str], kind: str | None = ..., raise_when_missing: Literal[True] = True, branch: str | None = ...) -> InfrahubNode +``` + +#### `get` + +```python +get(self, key: str | list[str], kind: str | None = ..., raise_when_missing: Literal[False] = False, branch: str | None = ...) -> InfrahubNode | None +``` + +#### `get` + +```python +get(self, key: str | list[str], kind: str | None = ..., raise_when_missing: bool = ..., branch: str | None = ...) -> InfrahubNode +``` + +#### `get` + +```python +get(self, key: str | list[str], kind: str | type[SchemaType] | None = None, raise_when_missing: bool = True, branch: str | None = None) -> InfrahubNode | SchemaType | None +``` + +#### `get_by_hfid` + +```python +get_by_hfid(self, key: str | list[str], raise_when_missing: Literal[True] = True, branch: str | None = ...) -> InfrahubNode +``` + +#### `get_by_hfid` + +```python +get_by_hfid(self, key: str | list[str], raise_when_missing: Literal[False] = False, branch: str | None = ...) -> InfrahubNode | None +``` + +#### `get_by_hfid` + +```python +get_by_hfid(self, key: str | list[str], raise_when_missing: bool = True, branch: str | None = None) -> InfrahubNode | None +``` + +#### `set` + +```python +set(self, node: InfrahubNode | SchemaType, key: str | None = None, branch: str | None = None) -> None +``` + +### `NodeStoreSync` + +**Methods:** + +#### `get` + +```python +get(self, key: str | list[str], kind: type[SchemaTypeSync], raise_when_missing: Literal[True] = True, branch: str | None = ...) -> SchemaTypeSync +``` + +#### `get` + +```python +get(self, key: str | list[str], kind: type[SchemaTypeSync], raise_when_missing: Literal[False] = False, branch: str | None = ...) -> SchemaTypeSync | None +``` + +#### `get` + +```python +get(self, key: str | list[str], kind: type[SchemaTypeSync], raise_when_missing: bool = ..., branch: str | None = ...) -> SchemaTypeSync +``` + +#### `get` + +```python +get(self, key: str | list[str], kind: str | None = ..., raise_when_missing: Literal[True] = True, branch: str | None = ...) -> InfrahubNodeSync +``` + +#### `get` + +```python +get(self, key: str | list[str], kind: str | None = ..., raise_when_missing: Literal[False] = False, branch: str | None = ...) -> InfrahubNodeSync | None +``` + +#### `get` + +```python +get(self, key: str | list[str], kind: str | None = ..., raise_when_missing: bool = ..., branch: str | None = ...) -> InfrahubNodeSync +``` + +#### `get` + +```python +get(self, key: str | list[str], kind: str | type[SchemaTypeSync] | None = None, raise_when_missing: bool = True, branch: str | None = None) -> InfrahubNodeSync | SchemaTypeSync | None +``` + +#### `get_by_hfid` + +```python +get_by_hfid(self, key: str | list[str], raise_when_missing: Literal[True] = True, branch: str | None = ...) -> InfrahubNodeSync +``` + +#### `get_by_hfid` + +```python +get_by_hfid(self, key: str | list[str], raise_when_missing: Literal[False] = False, branch: str | None = ...) -> InfrahubNodeSync | None +``` + +#### `get_by_hfid` + +```python +get_by_hfid(self, key: str | list[str], raise_when_missing: bool = True, branch: str | None = None) -> InfrahubNodeSync | None +``` + +#### `set` + +```python +set(self, node: InfrahubNodeSync | SchemaTypeSync, key: str | None = None, branch: str | None = None) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/constants.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/constants.mdx new file mode 100644 index 00000000..f20f01fd --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/constants.mdx @@ -0,0 +1,8 @@ +--- +title: constants +sidebarTitle: constants +--- + +# `infrahub_sdk.task.constants` + +*This module is empty or contains only private/internal implementations.* diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/exceptions.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/exceptions.mdx new file mode 100644 index 00000000..27ca9ede --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/exceptions.mdx @@ -0,0 +1,16 @@ +--- +title: exceptions +sidebarTitle: exceptions +--- + +# `infrahub_sdk.task.exceptions` + +## Classes + +### `TaskError` + +### `TaskNotFoundError` + +### `TooManyTasksError` + +### `TaskNotCompletedError` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/manager.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/manager.mdx new file mode 100644 index 00000000..fd71561e --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/manager.mdx @@ -0,0 +1,254 @@ +--- +title: manager +sidebarTitle: manager +--- + +# `infrahub_sdk.task.manager` + +## Classes + +### `InfraHubTaskManagerBase` + +### `InfrahubTaskManager` + +**Methods:** + +#### `count` + +```python +count(self, filters: TaskFilter | None = None) -> int +``` + +Count the number of tasks. + +**Args:** +- `filters`: The filter to apply to the tasks. Defaults to None. + +**Returns:** +- The number of tasks. + + +#### `all` + +```python +all(self, limit: int | None = None, offset: int | None = None, timeout: int | None = None, parallel: bool = False, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task] +``` + +Get all tasks. + +**Args:** +- `limit`: The maximum number of tasks to return. Defaults to None. +- `offset`: The offset to start the tasks from. Defaults to None. +- `timeout`: The timeout to wait for the tasks to complete. Defaults to None. +- `parallel`: Whether to query the tasks in parallel. Defaults to False. +- `include_logs`: Whether to include the logs in the tasks. Defaults to False. +- `include_related_nodes`: Whether to include the related nodes in the tasks. Defaults to False. + +**Returns:** +- A list of tasks. + + +#### `filter` + +```python +filter(self, filter: TaskFilter | None = None, limit: int | None = None, offset: int | None = None, timeout: int | None = None, parallel: bool = False, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task] +``` + +Filter tasks. + +**Args:** +- `filter`: The filter to apply to the tasks. Defaults to None. +- `limit`: The maximum number of tasks to return. Defaults to None. +- `offset`: The offset to start the tasks from. Defaults to None. +- `timeout`: The timeout to wait for the tasks to complete. Defaults to None. +- `parallel`: Whether to query the tasks in parallel. Defaults to False. +- `include_logs`: Whether to include the logs in the tasks. Defaults to False. +- `include_related_nodes`: Whether to include the related nodes in the tasks. Defaults to False. + +**Returns:** +- A list of tasks. + + +#### `get` + +```python +get(self, id: str, include_logs: bool = False, include_related_nodes: bool = False) -> Task +``` + +#### `wait_for_completion` + +```python +wait_for_completion(self, id: str, interval: int = 1, timeout: int = 60) -> Task +``` + +Wait for a task to complete. + +**Args:** +- `id`: The id of the task to wait for. +- `interval`: The interval to check the task state. Defaults to 1. +- `timeout`: The timeout to wait for the task to complete. Defaults to 60. + +**Raises:** +- `TaskNotCompletedError`: The task did not complete in the given timeout. + +**Returns:** +- The task object. + + +#### `process_page` + +```python +process_page(client: InfrahubClient, query: Query, page_number: int, timeout: int | None = None) -> tuple[list[Task], int | None] +``` + +Process a single page of results. + +**Args:** +- `client`: The client to use to execute the query. +- `query`: The query to execute. +- `page_number`: The page number to process. +- `timeout`: The timeout to wait for the query to complete. Defaults to None. + +**Returns:** +- A tuple containing a list of tasks and the count of tasks. + + +#### `process_batch` + +```python +process_batch(self, filters: TaskFilter | None = None, timeout: int | None = None, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task] +``` + +Process queries in parallel mode. + + +#### `process_non_batch` + +```python +process_non_batch(self, filters: TaskFilter | None = None, offset: int | None = None, limit: int | None = None, timeout: int | None = None, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task] +``` + +Process queries without parallel mode. + + +### `InfrahubTaskManagerSync` + +**Methods:** + +#### `count` + +```python +count(self, filters: TaskFilter | None = None) -> int +``` + +Count the number of tasks. + +**Args:** +- `filters`: The filter to apply to the tasks. Defaults to None. + +**Returns:** +- The number of tasks. + + +#### `all` + +```python +all(self, limit: int | None = None, offset: int | None = None, timeout: int | None = None, parallel: bool = False, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task] +``` + +Get all tasks. + +**Args:** +- `limit`: The maximum number of tasks to return. Defaults to None. +- `offset`: The offset to start the tasks from. Defaults to None. +- `timeout`: The timeout to wait for the tasks to complete. Defaults to None. +- `parallel`: Whether to query the tasks in parallel. Defaults to False. +- `include_logs`: Whether to include the logs in the tasks. Defaults to False. +- `include_related_nodes`: Whether to include the related nodes in the tasks. Defaults to False. + +**Returns:** +- A list of tasks. + + +#### `filter` + +```python +filter(self, filter: TaskFilter | None = None, limit: int | None = None, offset: int | None = None, timeout: int | None = None, parallel: bool = False, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task] +``` + +Filter tasks. + +**Args:** +- `filter`: The filter to apply to the tasks. Defaults to None. +- `limit`: The maximum number of tasks to return. Defaults to None. +- `offset`: The offset to start the tasks from. Defaults to None. +- `timeout`: The timeout to wait for the tasks to complete. Defaults to None. +- `parallel`: Whether to query the tasks in parallel. Defaults to False. +- `include_logs`: Whether to include the logs in the tasks. Defaults to False. +- `include_related_nodes`: Whether to include the related nodes in the tasks. Defaults to False. + +**Returns:** +- A list of tasks. + + +#### `get` + +```python +get(self, id: str, include_logs: bool = False, include_related_nodes: bool = False) -> Task +``` + +#### `wait_for_completion` + +```python +wait_for_completion(self, id: str, interval: int = 1, timeout: int = 60) -> Task +``` + +Wait for a task to complete. + +**Args:** +- `id`: The id of the task to wait for. +- `interval`: The interval to check the task state. Defaults to 1. +- `timeout`: The timeout to wait for the task to complete. Defaults to 60. + +**Raises:** +- `TaskNotCompletedError`: The task did not complete in the given timeout. + +**Returns:** +- The task object. + + +#### `process_page` + +```python +process_page(client: InfrahubClientSync, query: Query, page_number: int, timeout: int | None = None) -> tuple[list[Task], int | None] +``` + +Process a single page of results. + +**Args:** +- `client`: The client to use to execute the query. +- `query`: The query to execute. +- `page_number`: The page number to process. +- `timeout`: The timeout to wait for the query to complete. Defaults to None. + +**Returns:** +- A tuple containing a list of tasks and the count of tasks. + + +#### `process_batch` + +```python +process_batch(self, filters: TaskFilter | None = None, timeout: int | None = None, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task] +``` + +Process queries in parallel mode. + + +#### `process_non_batch` + +```python +process_non_batch(self, filters: TaskFilter | None = None, offset: int | None = None, limit: int | None = None, timeout: int | None = None, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task] +``` + +Process queries without parallel mode. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/models.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/models.mdx new file mode 100644 index 00000000..ea8f1211 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/models.mdx @@ -0,0 +1,34 @@ +--- +title: models +sidebarTitle: models +--- + +# `infrahub_sdk.task.models` + +## Classes + +### `TaskState` + +### `TaskLog` + +### `TaskRelatedNode` + +### `Task` + +**Methods:** + +#### `from_graphql` + +```python +from_graphql(cls, data: dict) -> Task +``` + +### `TaskFilter` + +**Methods:** + +#### `to_dict` + +```python +to_dict(self) -> dict +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/exceptions.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/exceptions.mdx new file mode 100644 index 00000000..c13f8d2a --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/exceptions.mdx @@ -0,0 +1,18 @@ +--- +title: exceptions +sidebarTitle: exceptions +--- + +# `infrahub_sdk.template.exceptions` + +## Classes + +### `JinjaTemplateError` + +### `JinjaTemplateNotFoundError` + +### `JinjaTemplateSyntaxError` + +### `JinjaTemplateUndefinedError` + +### `JinjaTemplateOperationViolationError` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/filters.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/filters.mdx new file mode 100644 index 00000000..4f93c7d1 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/filters.mdx @@ -0,0 +1,10 @@ +--- +title: filters +sidebarTitle: filters +--- + +# `infrahub_sdk.template.filters` + +## Classes + +### `FilterDefinition` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/models.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/models.mdx new file mode 100644 index 00000000..1a15dc6e --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/models.mdx @@ -0,0 +1,10 @@ +--- +title: models +sidebarTitle: models +--- + +# `infrahub_sdk.template.models` + +## Classes + +### `UndefinedJinja2Error` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/docker.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/docker.mdx new file mode 100644 index 00000000..16c5b509 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/docker.mdx @@ -0,0 +1,36 @@ +--- +title: docker +sidebarTitle: docker +--- + +# `infrahub_sdk.testing.docker` + +## Functions + +### `skip_version` + +```python +skip_version(min_infrahub_version: str | None = None, max_infrahub_version: str | None = None) -> bool +``` + + +Check if a test should be skipped depending on infrahub version. + + +## Classes + +### `TestInfrahubDockerClient` + +**Methods:** + +#### `client` + +```python +client(self, infrahub_port: int) -> InfrahubClient +``` + +#### `client_sync` + +```python +client_sync(self, infrahub_port: int) -> InfrahubClientSync +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/repository.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/repository.mdx new file mode 100644 index 00000000..eeb5fa6f --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/repository.mdx @@ -0,0 +1,46 @@ +--- +title: repository +sidebarTitle: repository +--- + +# `infrahub_sdk.testing.repository` + +## Classes + +### `RepositorySyncStatus` + +### `GitRepoType` + +### `GitRepo` + +**Methods:** + +#### `repo` + +```python +repo(self) -> GitRepoManager +``` + +#### `path` + +```python +path(self) -> str +``` + +#### `init` + +```python +init(self) -> None +``` + +#### `add_to_infrahub` + +```python +add_to_infrahub(self, client: InfrahubClient, branch: str | None = None) -> dict +``` + +#### `wait_for_sync_to_complete` + +```python +wait_for_sync_to_complete(self, client: InfrahubClient, branch: str | None = None, interval: int = 5, retries: int = 6) -> bool +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/schemas/animal.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/schemas/animal.mdx new file mode 100644 index 00000000..4e0cf5e3 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/schemas/animal.mdx @@ -0,0 +1,90 @@ +--- +title: animal +sidebarTitle: animal +--- + +# `infrahub_sdk.testing.schemas.animal` + +## Classes + +### `SchemaAnimal` + +**Methods:** + +#### `schema_animal` + +```python +schema_animal(self) -> GenericSchema +``` + +#### `schema_dog` + +```python +schema_dog(self) -> NodeSchema +``` + +#### `schema_cat` + +```python +schema_cat(self) -> NodeSchema +``` + +#### `schema_person` + +```python +schema_person(self) -> NodeSchema +``` + +#### `schema_base` + +```python +schema_base(self, schema_animal: GenericSchema, schema_person: NodeSchema, schema_cat: NodeSchema, schema_dog: NodeSchema) -> SchemaRoot +``` + +#### `load_schema` + +```python +load_schema(self, client: InfrahubClient, schema_base: SchemaRoot) -> None +``` + +#### `person_liam` + +```python +person_liam(self, client: InfrahubClient) -> InfrahubNode +``` + +#### `person_sophia` + +```python +person_sophia(self, client: InfrahubClient) -> InfrahubNode +``` + +#### `person_ethan` + +```python +person_ethan(self, client: InfrahubClient) -> InfrahubNode +``` + +#### `cat_bella` + +```python +cat_bella(self, client: InfrahubClient, person_ethan: InfrahubNode) -> InfrahubNode +``` + +#### `cat_luna` + +```python +cat_luna(self, client: InfrahubClient, person_ethan: InfrahubNode) -> InfrahubNode +``` + +#### `dog_daisy` + +```python +dog_daisy(self, client: InfrahubClient, person_ethan: InfrahubNode) -> InfrahubNode +``` + +#### `dog_rocky` + +```python +dog_rocky(self, client: InfrahubClient, person_sophia: InfrahubNode) -> InfrahubNode +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/schemas/car_person.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/schemas/car_person.mdx new file mode 100644 index 00000000..a411d340 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/schemas/car_person.mdx @@ -0,0 +1,138 @@ +--- +title: car_person +sidebarTitle: car_person +--- + +# `infrahub_sdk.testing.schemas.car_person` + +## Classes + +### `TestingPersonData` + +### `TestingManufacturerData` + +### `TestingCarData` + +### `SchemaCarPerson` + +**Methods:** + +#### `schema_person_base` + +```python +schema_person_base(self) -> NodeSchema +``` + +#### `schema_car_base` + +```python +schema_car_base(self) -> NodeSchema +``` + +#### `schema_manufacturer_base` + +```python +schema_manufacturer_base(self) -> NodeSchema +``` + +#### `schema_base` + +```python +schema_base(self, schema_car_base: NodeSchema, schema_person_base: NodeSchema, schema_manufacturer_base: NodeSchema) -> SchemaRoot +``` + +#### `person_joe_data` + +```python +person_joe_data(self) -> TestingPersonData +``` + +#### `person_jane_data` + +```python +person_jane_data(self) -> TestingPersonData +``` + +#### `manufacturer_vw_data` + +```python +manufacturer_vw_data(self) -> TestingManufacturerData +``` + +#### `manufacturer_renault_data` + +```python +manufacturer_renault_data(self) -> TestingManufacturerData +``` + +#### `manufacturer_mercedes_data` + +```python +manufacturer_mercedes_data(self) -> TestingManufacturerData +``` + +#### `car_golf_data` + +```python +car_golf_data(self) -> TestingCarData +``` + +#### `person_joe` + +```python +person_joe(self, client: InfrahubClient, person_joe_data: TestingPersonData) -> InfrahubNode +``` + +#### `person_jane` + +```python +person_jane(self, client: InfrahubClient, person_jane_data: TestingPersonData) -> InfrahubNode +``` + +#### `manufacturer_mercedes` + +```python +manufacturer_mercedes(self, client: InfrahubClient, manufacturer_mercedes_data: TestingManufacturerData) -> InfrahubNode +``` + +#### `car_golf` + +```python +car_golf(self, client: InfrahubClient, car_golf_data: TestingCarData, manufacturer_mercedes: InfrahubNode, person_joe: InfrahubNode) -> InfrahubNode +``` + +#### `tag_blue` + +```python +tag_blue(self, client: InfrahubClient) -> InfrahubNode +``` + +#### `tag_red` + +```python +tag_red(self, client: InfrahubClient) -> InfrahubNode +``` + +#### `tag_green` + +```python +tag_green(self, client: InfrahubClient) -> InfrahubNode +``` + +#### `create_persons` + +```python +create_persons(self, client: InfrahubClient, branch: str) -> list[InfrahubNode] +``` + +#### `create_manufacturers` + +```python +create_manufacturers(self, client: InfrahubClient, branch: str) -> list[InfrahubNode] +``` + +#### `create_initial_data` + +```python +create_initial_data(self, client: InfrahubClient, branch: str) -> dict[str, list[InfrahubNode]] +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/timestamp.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/timestamp.mdx new file mode 100644 index 00000000..d009eb55 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/timestamp.mdx @@ -0,0 +1,60 @@ +--- +title: timestamp +sidebarTitle: timestamp +--- + +# `infrahub_sdk.timestamp` + +## Classes + +### `Timestamp` + +**Methods:** + +#### `obj` + +```python +obj(self) -> ZonedDateTime +``` + +#### `to_string` + +```python +to_string(self, with_z: bool = True) -> str +``` + +#### `to_timestamp` + +```python +to_timestamp(self) -> int +``` + +#### `to_datetime` + +```python +to_datetime(self) -> datetime +``` + +#### `get_obj` + +```python +get_obj(self) -> ZonedDateTime +``` + +#### `add_delta` + +```python +add_delta(self, hours: int = 0, minutes: int = 0, seconds: int = 0, microseconds: int = 0) -> Timestamp +``` + +#### `add` + +```python +add(self, years: int = 0, months: int = 0, weeks: int = 0, days: int = 0, hours: float = 0, minutes: float = 0, seconds: float = 0, milliseconds: float = 0, microseconds: float = 0, nanoseconds: int = 0, disambiguate: Literal['compatible'] = 'compatible') -> Timestamp +``` + +#### `subtract` + +```python +subtract(self, years: int = 0, months: int = 0, weeks: int = 0, days: int = 0, hours: float = 0, minutes: float = 0, seconds: float = 0, milliseconds: float = 0, microseconds: float = 0, nanoseconds: int = 0, disambiguate: Literal['compatible'] = 'compatible') -> Timestamp +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/topological_sort.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/topological_sort.mdx new file mode 100644 index 00000000..f4f753dc --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/topological_sort.mdx @@ -0,0 +1,32 @@ +--- +title: topological_sort +sidebarTitle: topological_sort +--- + +# `infrahub_sdk.topological_sort` + +## Functions + +### `topological_sort` + +```python +topological_sort(dependency_dict: Mapping[str, Iterable[str]]) -> list[set[str]] +``` + +### `get_cycles` + +```python +get_cycles(dependency_dict: Mapping[str, Iterable[str]]) -> list[list[str]] +``` + +## Classes + +### `DependencyCycleExistsError` + +**Methods:** + +#### `get_cycle_strings` + +```python +get_cycle_strings(self) -> list[str] +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/constants.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/constants.mdx new file mode 100644 index 00000000..621f23ed --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/constants.mdx @@ -0,0 +1,8 @@ +--- +title: constants +sidebarTitle: constants +--- + +# `infrahub_sdk.transfer.constants` + +*This module is empty or contains only private/internal implementations.* diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exceptions.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exceptions.mdx new file mode 100644 index 00000000..7a400c63 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exceptions.mdx @@ -0,0 +1,18 @@ +--- +title: exceptions +sidebarTitle: exceptions +--- + +# `infrahub_sdk.transfer.exceptions` + +## Classes + +### `TransferError` + +### `FileAlreadyExistsError` + +### `TransferFileNotFoundError` + +### `InvalidNamespaceError` + +### `SchemaImportError` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exporter/interface.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exporter/interface.mdx new file mode 100644 index 00000000..62acfd98 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exporter/interface.mdx @@ -0,0 +1,18 @@ +--- +title: interface +sidebarTitle: interface +--- + +# `infrahub_sdk.transfer.exporter.interface` + +## Classes + +### `ExporterInterface` + +**Methods:** + +#### `export` + +```python +export(self, export_directory: Path, namespaces: list[str], branch: str, exclude: list[str] | None = None) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exporter/json.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exporter/json.mdx new file mode 100644 index 00000000..a160eb52 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exporter/json.mdx @@ -0,0 +1,36 @@ +--- +title: json +sidebarTitle: json +--- + +# `infrahub_sdk.transfer.exporter.json` + +## Classes + +### `LineDelimitedJSONExporter` + +**Methods:** + +#### `wrapped_task_output` + +```python +wrapped_task_output(self, start: str, end: str = '[green]done') -> Generator +``` + +#### `identify_many_to_many_relationships` + +```python +identify_many_to_many_relationships(self, node_schema_map: dict[str, MainSchemaTypesAPI]) -> dict[tuple[str, str], str] +``` + +#### `retrieve_many_to_many_relationships` + +```python +retrieve_many_to_many_relationships(self, node_schema_map: dict[str, MainSchemaTypesAPI], branch: str) -> list[dict[str, Any]] +``` + +#### `export` + +```python +export(self, export_directory: Path, namespaces: list[str], branch: str, exclude: list[str] | None = None) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/importer/interface.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/importer/interface.mdx new file mode 100644 index 00000000..7211b6cd --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/importer/interface.mdx @@ -0,0 +1,18 @@ +--- +title: interface +sidebarTitle: interface +--- + +# `infrahub_sdk.transfer.importer.interface` + +## Classes + +### `ImporterInterface` + +**Methods:** + +#### `import_data` + +```python +import_data(self, import_directory: Path, branch: str) -> None +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/importer/json.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/importer/json.mdx new file mode 100644 index 00000000..4604697d --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/importer/json.mdx @@ -0,0 +1,48 @@ +--- +title: json +sidebarTitle: json +--- + +# `infrahub_sdk.transfer.importer.json` + +## Classes + +### `LineDelimitedJSONImporter` + +**Methods:** + +#### `wrapped_task_output` + +```python +wrapped_task_output(self, start: str, end: str = '[green]done') -> Generator +``` + +#### `import_data` + +```python +import_data(self, import_directory: Path, branch: str) -> None +``` + +#### `remove_and_store_optional_relationships` + +```python +remove_and_store_optional_relationships(self) -> None +``` + +#### `update_optional_relationships` + +```python +update_optional_relationships(self) -> None +``` + +#### `update_many_to_many_relationships` + +```python +update_many_to_many_relationships(self, file: Path) -> None +``` + +#### `execute_batches` + +```python +execute_batches(self, batches: list[InfrahubBatch], progress_bar_message: str = 'Executing batches') -> Sequence[Any] +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/schema_sorter.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/schema_sorter.mdx new file mode 100644 index 00000000..919fb560 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/schema_sorter.mdx @@ -0,0 +1,18 @@ +--- +title: schema_sorter +sidebarTitle: schema_sorter +--- + +# `infrahub_sdk.transfer.schema_sorter` + +## Classes + +### `InfrahubSchemaTopologicalSorter` + +**Methods:** + +#### `get_sorted_node_schema` + +```python +get_sorted_node_schema(self, schemas: Sequence[NodeSchema], required_relationships_only: bool = True, include: list[str] | None = None) -> list[set[str]] +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transforms.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transforms.mdx new file mode 100644 index 00000000..5d51f3ab --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transforms.mdx @@ -0,0 +1,49 @@ +--- +title: transforms +sidebarTitle: transforms +--- + +# `infrahub_sdk.transforms` + +## Classes + +### `InfrahubTransform` + +**Methods:** + +#### `client` + +```python +client(self) -> InfrahubClient +``` + +#### `transform` + +```python +transform(self, data: dict) -> Any +``` + +#### `collect_data` + +```python +collect_data(self) -> dict +``` + +Query the result of the GraphQL Query defined in self.query and return the result + + +#### `run` + +```python +run(self, data: dict | None = None) -> Any +``` + +Execute the transformation after collecting the data from the GraphQL query. + +The result of the check is determined based on the presence or not of ERROR log messages. + +**Args:** +- `data`: The data on which to run the transform. Data will be queried from the API if not provided + +Returns: Transformed data + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/types.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/types.mdx new file mode 100644 index 00000000..7953f5f7 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/types.mdx @@ -0,0 +1,76 @@ +--- +title: types +sidebarTitle: types +--- + +# `infrahub_sdk.types` + +## Classes + +### `HTTPMethod` + +### `RequesterTransport` + +### `SyncRequester` + +### `AsyncRequester` + +### `InfrahubLogger` + +**Methods:** + +#### `debug` + +```python +debug(self, event: str | None = None, *args: Any, **kw: Any) -> Any +``` + +Send a debug event + + +#### `info` + +```python +info(self, event: str | None = None, *args: Any, **kw: Any) -> Any +``` + +Send an info event + + +#### `warning` + +```python +warning(self, event: str | None = None, *args: Any, **kw: Any) -> Any +``` + +Send a warning event + + +#### `error` + +```python +error(self, event: str | None = None, *args: Any, **kw: Any) -> Any +``` + +Send an error event. + + +#### `critical` + +```python +critical(self, event: str | None = None, *args: Any, **kw: Any) -> Any +``` + +Send a critical event. + + +#### `exception` + +```python +exception(self, event: str | None = None, *args: Any, **kw: Any) -> Any +``` + +Send an exception event. + + +### `Order` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/utils.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/utils.mdx new file mode 100644 index 00000000..52ab0eb1 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/utils.mdx @@ -0,0 +1,261 @@ +--- +title: utils +sidebarTitle: utils +--- + +# `infrahub_sdk.utils` + +## Functions + +### `generate_short_id` + +```python +generate_short_id() -> str +``` + + +Generate a short unique ID + + +### `base36encode` + +```python +base36encode(number: int) -> str +``` + +### `base36decode` + +```python +base36decode(data: str) -> int +``` + +### `base16decode` + +```python +base16decode(data: str) -> int +``` + +### `base16encode` + +```python +base16encode(number: int) -> str +``` + +### `get_fixtures_dir` + +```python +get_fixtures_dir() -> Path +``` + + +Get the directory which stores fixtures that are common to multiple unit/integration tests. + + +### `is_valid_uuid` + +```python +is_valid_uuid(value: Any) -> bool +``` + + +Check if the input is a valid UUID. + + +### `decode_json` + +```python +decode_json(response: httpx.Response) -> dict +``` + +### `generate_uuid` + +```python +generate_uuid() -> str +``` + +### `duplicates` + +```python +duplicates(input_list: list) -> list +``` + + +Identify and return all the duplicates in a list. + + +### `intersection` + +```python +intersection(list1: list[Any], list2: list[Any]) -> list +``` + + +Calculate the intersection between 2 lists. + + +### `compare_lists` + +```python +compare_lists(list1: list[Any], list2: list[Any]) -> tuple[list[Any], list[Any], list[Any]] +``` + + +Compare 2 lists and return : +- the intersection of both +- the item present only in list1 +- the item present only in list2 + + +### `deep_merge_dict` + +```python +deep_merge_dict(dicta: dict, dictb: dict, path: list | None = None) -> dict +``` + + +Deep Merge Dictionary B into Dictionary A. +Code is inspired by https://stackoverflow.com/a/7205107 + + +### `str_to_bool` + +```python +str_to_bool(value: str) -> bool +``` + + +Convert a String to a Boolean + + +### `get_flat_value` + +```python +get_flat_value(obj: Any, key: str, separator: str = '__') -> Any +``` + + +Query recursively an value defined in a flat notation (string), on a hierarchy of objects + +**Examples:** + +name__value +module.object.value + + +### `generate_request_filename` + +```python +generate_request_filename(request: httpx.Request) -> str +``` + + +Return a filename for a request sent to the Infrahub API + +This function is used when recording and playing back requests, as Infrahub is using a GraphQL +API it's not possible to rely on the URL endpoint alone to separate one request from another, +for this reason a hash of the payload is included in a filename. + + +### `is_valid_url` + +```python +is_valid_url(url: str) -> bool +``` + +### `get_branch` + +```python +get_branch(branch: str | None = None, directory: str | Path = '.') -> str +``` + + +If branch isn't provide, return the name of the local Git branch. + + +### `dict_hash` + +```python +dict_hash(dictionary: dict[str, Any]) -> str +``` + + +MD5 hash of a dictionary. + + +### `calculate_dict_depth` + +```python +calculate_dict_depth(data: dict, level: int = 1) -> int +``` + + +Calculate the depth of a nested Dictionary recursively. + + +### `calculate_dict_height` + +```python +calculate_dict_height(data: dict, cnt: int = 0) -> int +``` + + +Calculate the number of fields (height) in a nested Dictionary recursively. + + +### `extract_fields` + +```python +extract_fields(selection_set: SelectionSetNode | None) -> dict[str, dict] | None +``` + + +This function extract all the requested fields in a tree of Dict from a SelectionSetNode + +The goal of this function is to limit the fields that we need to query from the backend. + +Currently the function support Fields and InlineFragments but in a combined tree where the fragments are merged together +This implementation may seam counter intuitive but in the current implementation +it's better to have slightly more information at time passed to the query manager. + +In the future we'll probably need to redesign how we read GraphQL queries to generate better Database query. + + +### `extract_fields_first_node` + +```python +extract_fields_first_node(info: GraphQLResolveInfo) -> dict[str, dict] +``` + +### `write_to_file` + +```python +write_to_file(path: Path, value: Any) -> bool +``` + + +Write a given value into a file and return if the operation was successful. + +If the file does not exist, the function will attempt to create it. + + +### `read_file` + +```python +read_file(file_path: Path) -> str +``` + +### `get_user_permissions` + +```python +get_user_permissions(data: list[dict]) -> dict +``` + +### `calculate_time_diff` + +```python +calculate_time_diff(value: str) -> str | None +``` + + +Calculate the time in human format between a timedate in string format and now. + diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/uuidt.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/uuidt.mdx new file mode 100644 index 00000000..f76b6555 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/uuidt.mdx @@ -0,0 +1,47 @@ +--- +title: uuidt +sidebarTitle: uuidt +--- + +# `infrahub_sdk.uuidt` + +## Functions + +### `generate_uuid` + +```python +generate_uuid() -> str +``` + +### `encode_number` + +```python +encode_number(number: int, min_length: int) -> str +``` + + +Encode a number into a base16 string and ensure the result has a minimum size. +If the initial response produced doesn't match the min requirement, +random number will be used to fill the gap + + +## Classes + +### `UUIDT` + +**Methods:** + +#### `short` + +```python +short(self) -> str +``` + +Return the last 8 digit of the UUID (the most random part) + + +#### `new` + +```python +new(cls, namespace: str | None = None) -> UUID +``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/yaml.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/yaml.mdx new file mode 100644 index 00000000..8b44f711 --- /dev/null +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/yaml.mdx @@ -0,0 +1,88 @@ +--- +title: yaml +sidebarTitle: yaml +--- + +# `infrahub_sdk.yaml` + +## Classes + +### `InfrahubFileApiVersion` + +### `InfrahubFileKind` + +### `InfrahubFileData` + +### `LocalFile` + +### `YamlFile` + +**Methods:** + +#### `load_content` + +```python +load_content(self) -> None +``` + +#### `validate_content` + +```python +validate_content(self) -> None +``` + +#### `init` + +```python +init(cls, location: Path, multiple_documents: bool, content: dict | None) -> Self +``` + +#### `load_file_from_disk` + +```python +load_file_from_disk(cls, path: Path) -> list[Self] +``` + +#### `load_from_disk` + +```python +load_from_disk(cls, paths: list[Path]) -> list[Self] +``` + +### `InfrahubFile` + +**Methods:** + +#### `data` + +```python +data(self) -> InfrahubFileData +``` + +#### `version` + +```python +version(self) -> InfrahubFileApiVersion +``` + +#### `kind` + +```python +kind(self) -> InfrahubFileKind +``` + +#### `validate_content` + +```python +validate_content(self) -> None +``` + +### `SchemaFile` + +**Methods:** + +#### `payload` + +```python +payload(self) -> dict[str, Any] +``` From 36610dd6b5f2178025c54d12dbd0fb8c4bc8142a Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Wed, 23 Jul 2025 10:07:36 +0200 Subject: [PATCH 02/24] docs: fix docusaurus interpretation of mdx files with Icon in it --- docs/package-lock.json | 22 ++++++++++++++++++++++ docs/package.json | 1 + docs/src/theme/MDXComponents.js | 10 ++++++++++ 3 files changed, 33 insertions(+) create mode 100644 docs/src/theme/MDXComponents.js diff --git a/docs/package-lock.json b/docs/package-lock.json index b12fb6ab..50d090fb 100644 --- a/docs/package-lock.json +++ b/docs/package-lock.json @@ -10,6 +10,7 @@ "dependencies": { "@docusaurus/core": "^3.7.0", "@docusaurus/preset-classic": "^3.7.0", + "@iconify/react": "^6.0.0", "@mdx-js/react": "^3.0.0", "clsx": "^2.0.0", "prism-react-renderer": "^2.3.0", @@ -4128,6 +4129,27 @@ "@hapi/hoek": "^9.0.0" } }, + "node_modules/@iconify/react": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/@iconify/react/-/react-6.0.0.tgz", + "integrity": "sha512-eqNscABVZS8eCpZLU/L5F5UokMS9mnCf56iS1nM9YYHdH8ZxqZL9zyjSwW60IOQFsXZkilbBiv+1paMXBhSQnw==", + "license": "MIT", + "dependencies": { + "@iconify/types": "^2.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/cyberalien" + }, + "peerDependencies": { + "react": ">=16" + } + }, + "node_modules/@iconify/types": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@iconify/types/-/types-2.0.0.tgz", + "integrity": "sha512-+wluvCrRhXrhyOmRDJ3q8mux9JkKy5SJ/v8ol2tu4FVjyYvtEzkc/3pK15ET6RKg4b4w4BmTk1+gsCUhf21Ykg==", + "license": "MIT" + }, "node_modules/@jest/schemas": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.6.3.tgz", diff --git a/docs/package.json b/docs/package.json index aabc17c5..f1cffe15 100644 --- a/docs/package.json +++ b/docs/package.json @@ -17,6 +17,7 @@ "dependencies": { "@docusaurus/core": "^3.7.0", "@docusaurus/preset-classic": "^3.7.0", + "@iconify/react": "^6.0.0", "@mdx-js/react": "^3.0.0", "clsx": "^2.0.0", "prism-react-renderer": "^2.3.0", diff --git a/docs/src/theme/MDXComponents.js b/docs/src/theme/MDXComponents.js new file mode 100644 index 00000000..cea81a13 --- /dev/null +++ b/docs/src/theme/MDXComponents.js @@ -0,0 +1,10 @@ +import React from 'react'; +// Import the original mapper +import MDXComponents from '@theme-original/MDXComponents'; +import { Icon } from '@iconify/react'; // Import the entire Iconify library. + +export default { + // Re-use the default mapping + ...MDXComponents, + Icon: Icon, // Make the iconify Icon component available in MDX as . +}; \ No newline at end of file From 89511aedfde94ce6589a8c31b4955aae4c3f312c Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Wed, 23 Jul 2025 10:08:02 +0200 Subject: [PATCH 03/24] docs: configure docusaurus sidebar --- docs/sidebars-python-sdk.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/sidebars-python-sdk.ts b/docs/sidebars-python-sdk.ts index e2fc932c..dd80eb72 100644 --- a/docs/sidebars-python-sdk.ts +++ b/docs/sidebars-python-sdk.ts @@ -1,4 +1,4 @@ -import type {SidebarsConfig} from '@docusaurus/plugin-content-docs'; +import type { SidebarsConfig } from '@docusaurus/plugin-content-docs'; const sidebars: SidebarsConfig = { pythonSdkSidebar: [ @@ -35,6 +35,16 @@ const sidebars: SidebarsConfig = { 'topics/object_file', ], }, + { + type: 'category', + label: 'SDK References', + items: [ + { + type: 'autogenerated', + dirName: 'sdk_ref', + }, + ], + }, { type: 'category', label: 'Reference', From 469bf199d8368007217d560f187e541a8bba7540 Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Wed, 23 Jul 2025 11:14:14 +0200 Subject: [PATCH 04/24] chore: add invoke task to generate the documentation --- tasks.py | 50 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/tasks.py b/tasks.py index e10ca2c1..11e4e574 100644 --- a/tasks.py +++ b/tasks.py @@ -2,9 +2,10 @@ import sys from pathlib import Path from shutil import which -from typing import Any +from typing import Any, Union from invoke import Context, task +from invoke.exceptions import UnexpectedExit CURRENT_DIRECTORY = Path(__file__).resolve() DOCUMENTATION_DIRECTORY = CURRENT_DIRECTORY.parent / "docs" @@ -254,3 +255,50 @@ def generate_python_sdk(context: Context) -> None: # noqa: ARG001 """Generate documentation for the Python SDK.""" _generate_infrahub_sdk_configuration_documentation() _generate_infrahub_sdk_template_documentation() + + +@task(name="generate-sdk-api-docs") +def generate_sdk_api_docs(context: Context, output: Union[str, None] = None) -> None: + """Generate API documentation for the Python SDK.""" + + import operator + import shutil + import tempfile + from functools import reduce + + output_dir = Path(output) if output else DOCUMENTATION_DIRECTORY / "docs" / "python-sdk" / "sdk_ref" + + # Create a temporary directory to store the generated documentation + with tempfile.TemporaryDirectory() as tmp_dir: + # Generate the API documentation using mdxify and get flat file structure + exec_cmd = f"mdxify --all --root-module infrahub_sdk --output-dir {tmp_dir}" + try: + context.run(exec_cmd, pty=True) + except UnexpectedExit as e: + if e.result.exited == 127: + print( + " - mdxify is not installed, probably due to the python version being outside its supported range." + ) + sys.exit(1) + + # Remove current obsolete documentation file structure + if (output_dir / "infrahub_sdk").exists(): + shutil.rmtree(output_dir / "infrahub_sdk") + + # Get all .mdx files in the generated doc folder and apply filters + filters = ["__init__"] + filtered_files = [ + file + for file in list(Path(tmp_dir).glob("*.mdx")) + if all(filter.lower() not in file.name for filter in filters) + ] + + # Reorganize the generated relevant files into the desired structure + for mdx_file in filtered_files: + target_path = output_dir / reduce(operator.truediv, (Path(part) for part in mdx_file.name.split("-"))) + + # Create the future parent directory if it doesn't exist + target_path.parent.mkdir(parents=True, exist_ok=True) + + # Move the file to the new location + shutil.move(mdx_file, target_path) From 9b881e82fe5f94aa4f48aacd1dc4642ed3dfd496 Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Wed, 23 Jul 2025 11:31:03 +0200 Subject: [PATCH 05/24] build: add mdxify package --- poetry.lock | 36 ++++++++++++++++++++++++++++++++++-- pyproject.toml | 1 + 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/poetry.lock b/poetry.lock index a1b4c065..c6818a14 100644 --- a/poetry.lock +++ b/poetry.lock @@ -220,7 +220,7 @@ files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] -markers = {main = "(extra == \"ctl\" or extra == \"all\") and platform_system == \"Windows\" or sys_platform == \"win32\"", dev = "platform_system == \"Windows\" or sys_platform == \"win32\""} +markers = {main = "(extra == \"ctl\" or extra == \"all\") and platform_system == \"Windows\" or sys_platform == \"win32\" or python_version >= \"3.10\"", dev = "platform_system == \"Windows\" or sys_platform == \"win32\""} [[package]] name = "coverage" @@ -537,6 +537,22 @@ files = [ {file = "graphql_core-3.2.4-py3-none-any.whl", hash = "sha256:1604f2042edc5f3114f49cac9d77e25863be51b23a54a61a23245cf32f6476f0"}, ] +[[package]] +name = "griffe" +version = "1.8.0" +description = "Signatures for entire Python programs. Extract the structure, the frame, the skeleton of your project, to generate API documentation or find breaking changes in your API." +optional = false +python-versions = ">=3.9" +groups = ["main"] +markers = "python_version >= \"3.10\"" +files = [ + {file = "griffe-1.8.0-py3-none-any.whl", hash = "sha256:110faa744b2c5c84dd432f4fa9aa3b14805dd9519777dd55e8db214320593b02"}, + {file = "griffe-1.8.0.tar.gz", hash = "sha256:0b4658443858465c13b2de07ff5e15a1032bc889cfafad738a476b8b97bb28d7"}, +] + +[package.dependencies] +colorama = ">=0.4" + [[package]] name = "h11" version = "0.14.0" @@ -921,6 +937,22 @@ files = [ ] markers = {main = "extra == \"ctl\" or extra == \"tests\" or extra == \"all\""} +[[package]] +name = "mdxify" +version = "0.2.23" +description = "Generate MDX API documentation from Python modules" +optional = false +python-versions = ">=3.10" +groups = ["main"] +markers = "python_version >= \"3.10\"" +files = [ + {file = "mdxify-0.2.23-py3-none-any.whl", hash = "sha256:9e920bd01bc34f11f6e250cc7a926ed8ae8a29ea39cb4707a69700972965fc4b"}, + {file = "mdxify-0.2.23.tar.gz", hash = "sha256:283ec938c7e11259f949042fad2ec62c3196c82e66c38e7827efa5532bcbfbeb"}, +] + +[package.dependencies] +griffe = ">=0.36.0" + [[package]] name = "mypy" version = "1.11.2" @@ -2394,4 +2426,4 @@ tests = ["Jinja2", "pytest", "pyyaml", "rich"] [metadata] lock-version = "2.1" python-versions = "^3.9, <3.14" -content-hash = "978a8ed3c6f4f4e46d39b8c33affb767a91275ee2bee532a48a7abc3d224deb8" +content-hash = "cdca7035da908c2345cc19398c38c9370a590908321303ce23fa3d7f3a683e1d" diff --git a/pyproject.toml b/pyproject.toml index 2465500f..23089a9e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,6 +45,7 @@ dulwich = "^0.21.4" whenever = ">=0.7.2,<0.8.0" netutils = "^1.0.0" click = { version = "8.1.*", optional = true } +mdxify = {version = "^0.2.23", python = ">=3.10"} [tool.poetry.group.dev.dependencies] pytest = "*" From c0168092a47accc9ab58df14352491af9ec4eee2 Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Wed, 23 Jul 2025 14:54:51 +0200 Subject: [PATCH 06/24] ci: add a rule for checking the SDK API obsolescence --- .github/workflows/ci.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b5501ac6..6876d910 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -180,6 +180,42 @@ jobs: - name: "Validate generated documentation" run: "poetry run invoke docs-validate" + check-api-documentation-obsolescence: + if: | + always() && !cancelled() && + !contains(needs.*.result, 'failure') && + !contains(needs.*.result, 'cancelled') && + (needs.files-changed.outputs.python == 'true') || (needs.files-changed.outputs.documentation_generated == 'true') + needs: ["prepare-environment", "files-changed", "yaml-lint", "python-lint"] + runs-on: "ubuntu-22.04" + env: + DOCS_COMMAND: "poetry run invoke generate-sdk-api-docs" + SDK_API_DOCS_DIR: "docs/docs/python-sdk/sdk_ref" + timeout-minutes: 5 + steps: + - name: "Check out repository code" + uses: "actions/checkout@v4" + with: + submodules: true + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: "3.12" + - name: "Setup Python environment" + run: | + pipx install poetry==${{ needs.prepare-environment.outputs.POETRY_VERSION }} + poetry config virtualenvs.create true --local + poetry env use 3.12 + - name: "Install dependencies" + run: "poetry install --no-interaction --no-ansi --extras ctl" + - name: "Setup environment" + run: "pip install invoke toml" + - name: "Generate SDK API documentation" + run: ${{ env.DOCS_COMMAND }} + - name: "Check if SDK API documentation needs to be refreshed" + run: | + git diff --quiet ${SDK_API_DOCS_DIR} + validate-documentation-style: if: | always() && !cancelled() && From 1484494ce5cb20343d0039216ccf46fc386249f9 Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Wed, 23 Jul 2025 15:17:04 +0200 Subject: [PATCH 07/24] style: fix some python lint error --- .github/workflows/ci.yml | 6 ++---- tasks.py | 6 ++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6876d910..f080d97d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,7 +54,7 @@ jobs: token: ${{ github.token }} filters: .github/file-filters.yml - # ------------------------------------------ All Linter ------------------------------------------ + # ------------------------------------------ All Linter ------------------------------------------ yaml-lint: if: needs.files-changed.outputs.yaml == 'true' @@ -84,7 +84,6 @@ jobs: - name: "Linting: ruff format" run: "ruff format --check --diff ." - markdown-lint: if: | needs.files-changed.outputs.documentation == 'true' || @@ -119,7 +118,6 @@ jobs: env: SHELLCHECK_OPTS: --exclude=SC2086 --exclude=SC2046 --exclude=SC2004 --exclude=SC2129 - documentation: defaults: run: @@ -141,7 +139,7 @@ jobs: uses: actions/setup-node@v4 with: node-version: 20 - cache: 'npm' + cache: "npm" cache-dependency-path: docs/package-lock.json - name: "Install dependencies" run: npm install diff --git a/tasks.py b/tasks.py index 11e4e574..31bd98de 100644 --- a/tasks.py +++ b/tasks.py @@ -1,8 +1,10 @@ +from __future__ import annotations + import asyncio import sys from pathlib import Path from shutil import which -from typing import Any, Union +from typing import Any from invoke import Context, task from invoke.exceptions import UnexpectedExit @@ -258,7 +260,7 @@ def generate_python_sdk(context: Context) -> None: # noqa: ARG001 @task(name="generate-sdk-api-docs") -def generate_sdk_api_docs(context: Context, output: Union[str, None] = None) -> None: +def generate_sdk_api_docs(context: Context, output: str | None = None) -> None: """Generate API documentation for the Python SDK.""" import operator From 1acb7b03f98ece6bbd39d67bd3bc99861ede904b Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Wed, 23 Jul 2025 15:34:03 +0200 Subject: [PATCH 08/24] style: fix some mispelling and style issue in docstrings --- infrahub_sdk/client.py | 12 ++++++------ infrahub_sdk/ctl/utils.py | 2 +- infrahub_sdk/jinja2.py | 2 +- infrahub_sdk/node/node.py | 2 +- infrahub_sdk/pytest_plugin/items/base.py | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/infrahub_sdk/client.py b/infrahub_sdk/client.py index 16c1c73a..9bca0b16 100644 --- a/infrahub_sdk/client.py +++ b/infrahub_sdk/client.py @@ -549,7 +549,7 @@ async def _process_nodes_and_relationships( schema_kind (str): The kind of schema being queried. branch (str): The branch name. prefetch_relationships (bool): Flag to indicate whether to prefetch relationship data. - timeout (int, optional): Overrides default timeout used when querying the graphql API. Specified in seconds. + timeout (int, optional): Overrides default timeout used when querying the GraphQL API. Specified in seconds. Returns: ProcessRelationsNodeSync: A TypedDict containing two lists: @@ -666,7 +666,7 @@ async def all( at (Timestamp, optional): Time of the query. Defaults to Now. branch (str, optional): Name of the branch to query from. Defaults to default_branch. populate_store (bool, optional): Flag to indicate whether to populate the store with the retrieved nodes. - timeout (int, optional): Overrides default timeout used when querying the graphql API. Specified in seconds. + timeout (int, optional): Overrides default timeout used when querying the GraphQL API. Specified in seconds. offset (int, optional): The offset for pagination. limit (int, optional): The limit for pagination. include (list[str], optional): List of attributes or relationships to include in the query. @@ -763,7 +763,7 @@ async def filters( kind (str): kind of the nodes to query at (Timestamp, optional): Time of the query. Defaults to Now. branch (str, optional): Name of the branch to query from. Defaults to default_branch. - timeout (int, optional): Overrides default timeout used when querying the graphql API. Specified in seconds. + timeout (int, optional): Overrides default timeout used when querying the GraphQL API. Specified in seconds. populate_store (bool, optional): Flag to indicate whether to populate the store with the retrieved nodes. offset (int, optional): The offset for pagination. limit (int, optional): The limit for pagination. @@ -1794,7 +1794,7 @@ def all( kind (str): kind of the nodes to query at (Timestamp, optional): Time of the query. Defaults to Now. branch (str, optional): Name of the branch to query from. Defaults to default_branch. - timeout (int, optional): Overrides default timeout used when querying the graphql API. Specified in seconds. + timeout (int, optional): Overrides default timeout used when querying the GraphQL API. Specified in seconds. populate_store (bool, optional): Flag to indicate whether to populate the store with the retrieved nodes. offset (int, optional): The offset for pagination. limit (int, optional): The limit for pagination. @@ -1840,7 +1840,7 @@ def _process_nodes_and_relationships( schema_kind (str): The kind of schema being queried. branch (str): The branch name. prefetch_relationships (bool): Flag to indicate whether to prefetch relationship data. - timeout (int, optional): Overrides default timeout used when querying the graphql API. Specified in seconds. + timeout (int, optional): Overrides default timeout used when querying the GraphQL API. Specified in seconds. Returns: ProcessRelationsNodeSync: A TypedDict containing two lists: @@ -1927,7 +1927,7 @@ def filters( kind (str): kind of the nodes to query at (Timestamp, optional): Time of the query. Defaults to Now. branch (str, optional): Name of the branch to query from. Defaults to default_branch. - timeout (int, optional): Overrides default timeout used when querying the graphql API. Specified in seconds. + timeout (int, optional): Overrides default timeout used when querying the GraphQL API. Specified in seconds. populate_store (bool, optional): Flag to indicate whether to populate the store with the retrieved nodes. offset (int, optional): The offset for pagination. limit (int, optional): The limit for pagination. diff --git a/infrahub_sdk/ctl/utils.py b/infrahub_sdk/ctl/utils.py index 66f86865..027eab4a 100644 --- a/infrahub_sdk/ctl/utils.py +++ b/infrahub_sdk/ctl/utils.py @@ -51,7 +51,7 @@ def init_logging(debug: bool = False) -> None: def handle_exception(exc: Exception, console: Console, exit_code: int) -> NoReturn: - """Handle exeception in a different fashion based on its type.""" + """Handle exception in a different fashion based on its type.""" if isinstance(exc, Exit): raise typer.Exit(code=exc.exit_code) if isinstance(exc, AuthenticationError): diff --git a/infrahub_sdk/jinja2.py b/infrahub_sdk/jinja2.py index 29afbf06..d64d22c1 100644 --- a/infrahub_sdk/jinja2.py +++ b/infrahub_sdk/jinja2.py @@ -7,7 +7,7 @@ def identify_faulty_jinja_code(traceback: Traceback, nbr_context_lines: int = 3) -> list[tuple[Frame, Syntax]]: """This function identifies the faulty Jinja2 code and beautify it to provide meaningful information to the user. - We use the rich's Traceback to parse the complete stack trace and extract Frames for each expection found in the trace. + We use the rich's Traceback to parse the complete stack trace and extract Frames for each exception found in the trace. """ response = [] diff --git a/infrahub_sdk/node/node.py b/infrahub_sdk/node/node.py index f69c6231..ba94712f 100644 --- a/infrahub_sdk/node/node.py +++ b/infrahub_sdk/node/node.py @@ -419,7 +419,7 @@ def generate_query_data_init( return data def extract(self, params: dict[str, str]) -> dict[str, Any]: - """Extract some datapoints defined in a flat notation.""" + """Extract some data points defined in a flat notation.""" result: dict[str, Any] = {} for key, value in params.items(): result[key] = get_flat_value(self, key=value) diff --git a/infrahub_sdk/pytest_plugin/items/base.py b/infrahub_sdk/pytest_plugin/items/base.py index e00db68a..ce899c3f 100644 --- a/infrahub_sdk/pytest_plugin/items/base.py +++ b/infrahub_sdk/pytest_plugin/items/base.py @@ -75,7 +75,7 @@ def reportinfo(self) -> tuple[Path | str, int | None, str]: def repository_base(self) -> str: """Return the path to the root of the repository - This will be an absolute path if --infrahub-config-path is an absolut path as happens when + This will be an absolute path if --infrahub-config-path is an absolute path as happens when tests are started from within Infrahub server. """ config_path: Path = getattr(self.session, _infrahub_config_path_attribute) From ff31be5054c382bacc314676752eb300e225f065 Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Wed, 23 Jul 2025 15:36:00 +0200 Subject: [PATCH 09/24] docs: update API documentation --- docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx | 8 ++++---- docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx | 2 +- docs/docs/python-sdk/sdk_ref/infrahub_sdk/jinja2.mdx | 2 +- docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx | 2 +- .../sdk_ref/infrahub_sdk/pytest_plugin/items/base.mdx | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx index 543aaec9..da67527b 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx @@ -192,7 +192,7 @@ Retrieve all nodes of a given kind - `at`: Time of the query. Defaults to Now. - `branch`: Name of the branch to query from. Defaults to default_branch. - `populate_store`: Flag to indicate whether to populate the store with the retrieved nodes. -- `timeout`: Overrides default timeout used when querying the graphql API. Specified in seconds. +- `timeout`: Overrides default timeout used when querying the GraphQL API. Specified in seconds. - `offset`: The offset for pagination. - `limit`: The limit for pagination. - `include`: List of attributes or relationships to include in the query. @@ -230,7 +230,7 @@ Retrieve nodes of a given kind based on provided filters. - `kind`: kind of the nodes to query - `at`: Time of the query. Defaults to Now. - `branch`: Name of the branch to query from. Defaults to default_branch. -- `timeout`: Overrides default timeout used when querying the graphql API. Specified in seconds. +- `timeout`: Overrides default timeout used when querying the GraphQL API. Specified in seconds. - `populate_store`: Flag to indicate whether to populate the store with the retrieved nodes. - `offset`: The offset for pagination. - `limit`: The limit for pagination. @@ -562,7 +562,7 @@ Retrieve all nodes of a given kind - `kind`: kind of the nodes to query - `at`: Time of the query. Defaults to Now. - `branch`: Name of the branch to query from. Defaults to default_branch. -- `timeout`: Overrides default timeout used when querying the graphql API. Specified in seconds. +- `timeout`: Overrides default timeout used when querying the GraphQL API. Specified in seconds. - `populate_store`: Flag to indicate whether to populate the store with the retrieved nodes. - `offset`: The offset for pagination. - `limit`: The limit for pagination. @@ -601,7 +601,7 @@ Retrieve nodes of a given kind based on provided filters. - `kind`: kind of the nodes to query - `at`: Time of the query. Defaults to Now. - `branch`: Name of the branch to query from. Defaults to default_branch. -- `timeout`: Overrides default timeout used when querying the graphql API. Specified in seconds. +- `timeout`: Overrides default timeout used when querying the GraphQL API. Specified in seconds. - `populate_store`: Flag to indicate whether to populate the store with the retrieved nodes. - `offset`: The offset for pagination. - `limit`: The limit for pagination. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx index 1d4feb74..e7c88ee8 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx @@ -20,7 +20,7 @@ handle_exception(exc: Exception, console: Console, exit_code: int) -> NoReturn ``` -Handle exeception in a different fashion based on its type. +Handle exception in a different fashion based on its type. ### `catch_exception` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/jinja2.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/jinja2.mdx index ca1bfb43..55c7c02d 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/jinja2.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/jinja2.mdx @@ -16,5 +16,5 @@ identify_faulty_jinja_code(traceback: Traceback, nbr_context_lines: int = 3) -> This function identifies the faulty Jinja2 code and beautify it to provide meaningful information to the user. -We use the rich's Traceback to parse the complete stack trace and extract Frames for each expection found in the trace. +We use the rich's Traceback to parse the complete stack trace and extract Frames for each exception found in the trace. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx index 37dbe586..364c08bf 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx @@ -99,7 +99,7 @@ generate_query_data_init(self, filters: dict[str, Any] | None = None, offset: in extract(self, params: dict[str, str]) -> dict[str, Any] ``` -Extract some datapoints defined in a flat notation. +Extract some data points defined in a flat notation. ### `InfrahubNode` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/base.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/base.mdx index e49e6239..3e69552b 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/base.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/base.mdx @@ -60,6 +60,6 @@ repository_base(self) -> str Return the path to the root of the repository -This will be an absolute path if --infrahub-config-path is an absolut path as happens when +This will be an absolute path if --infrahub-config-path is an absolute path as happens when tests are started from within Infrahub server. From 9d0a674480742c598be1e2249cb5bbee78600111 Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Wed, 23 Jul 2025 15:58:39 +0200 Subject: [PATCH 10/24] style: fix linting issues in the generated documentation --- .../sdk_ref/infrahub_sdk/analyzer.mdx | 2 - .../python-sdk/sdk_ref/infrahub_sdk/batch.mdx | 1 - .../sdk_ref/infrahub_sdk/branch.mdx | 1 - .../sdk_ref/infrahub_sdk/checks.mdx | 7 ---- .../sdk_ref/infrahub_sdk/client.mdx | 41 ++++++++----------- .../sdk_ref/infrahub_sdk/context.mdx | 2 - .../sdk_ref/infrahub_sdk/ctl/branch.mdx | 14 ------- .../sdk_ref/infrahub_sdk/ctl/check.mdx | 4 -- .../sdk_ref/infrahub_sdk/ctl/cli_commands.mdx | 16 -------- .../sdk_ref/infrahub_sdk/ctl/config.mdx | 6 +-- .../sdk_ref/infrahub_sdk/ctl/exceptions.mdx | 2 - .../sdk_ref/infrahub_sdk/ctl/exporter.mdx | 2 - .../sdk_ref/infrahub_sdk/ctl/importer.mdx | 2 - .../sdk_ref/infrahub_sdk/ctl/menu.mdx | 6 --- .../sdk_ref/infrahub_sdk/ctl/object.mdx | 6 --- .../sdk_ref/infrahub_sdk/ctl/parameters.mdx | 2 - .../sdk_ref/infrahub_sdk/ctl/repository.mdx | 4 -- .../sdk_ref/infrahub_sdk/ctl/schema.mdx | 6 --- .../sdk_ref/infrahub_sdk/ctl/utils.mdx | 6 --- .../sdk_ref/infrahub_sdk/ctl/validate.mdx | 6 --- .../sdk_ref/infrahub_sdk/exceptions.mdx | 8 ---- .../sdk_ref/infrahub_sdk/generator.mdx | 5 --- .../sdk_ref/infrahub_sdk/graphql.mdx | 2 - .../sdk_ref/infrahub_sdk/jinja2.mdx | 2 - .../sdk_ref/infrahub_sdk/node/attribute.mdx | 2 - .../sdk_ref/infrahub_sdk/node/node.mdx | 23 +++++------ .../sdk_ref/infrahub_sdk/node/parsers.mdx | 2 - .../sdk_ref/infrahub_sdk/node/property.mdx | 2 - .../infrahub_sdk/node/related_node.mdx | 6 --- .../infrahub_sdk/node/relationship.mdx | 10 ----- .../sdk_ref/infrahub_sdk/operation.mdx | 4 -- .../protocols_generator/generator.mdx | 2 - .../infrahub_sdk/pytest_plugin/exceptions.mdx | 2 - .../infrahub_sdk/pytest_plugin/items/base.mdx | 4 -- .../infrahub_sdk/pytest_plugin/loader.mdx | 2 - .../infrahub_sdk/pytest_plugin/models.mdx | 3 -- .../sdk_ref/infrahub_sdk/query_groups.mdx | 18 +++----- .../sdk_ref/infrahub_sdk/recorder.mdx | 2 - .../sdk_ref/infrahub_sdk/schema/main.mdx | 4 -- .../infrahub_sdk/schema/repository.mdx | 2 - .../sdk_ref/infrahub_sdk/spec/object.mdx | 5 --- .../python-sdk/sdk_ref/infrahub_sdk/store.mdx | 2 - .../sdk_ref/infrahub_sdk/task/manager.mdx | 36 +++++++++------- .../sdk_ref/infrahub_sdk/testing/docker.mdx | 2 - .../sdk_ref/infrahub_sdk/transforms.mdx | 3 +- .../python-sdk/sdk_ref/infrahub_sdk/types.mdx | 6 --- .../python-sdk/sdk_ref/infrahub_sdk/utils.mdx | 35 +--------------- .../python-sdk/sdk_ref/infrahub_sdk/uuidt.mdx | 3 -- 48 files changed, 56 insertions(+), 277 deletions(-) diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/analyzer.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/analyzer.mdx index 5a83f8d4..ffd5047f 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/analyzer.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/analyzer.mdx @@ -53,7 +53,6 @@ calculate_depth(self) -> int Number of nested levels in the query - #### `calculate_height` ```python @@ -62,7 +61,6 @@ calculate_height(self) -> int Total number of fields requested in the query - #### `get_fields` ```python diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/batch.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/batch.mdx index 9c8487a2..7cee706a 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/batch.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/batch.mdx @@ -29,7 +29,6 @@ execute(self, return_exceptions: bool = False) -> tuple[InfrahubNodeSync | None, Executes the stored task. - ### `InfrahubBatch` **Methods:** diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/branch.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/branch.mdx index da12a3aa..c3e9db56 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/branch.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/branch.mdx @@ -21,7 +21,6 @@ generate_diff_data_url(cls, client: InfrahubClient | InfrahubClientSync, branch_ Generate the URL for the diff_data function. - ### `InfrahubBranchManager` **Methods:** diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/checks.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/checks.mdx index 801caca0..8905dac9 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/checks.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/checks.mdx @@ -9,10 +9,8 @@ sidebarTitle: checks ### `InfrahubCheckInitializer` - Information about the originator of the check. - ### `InfrahubCheck` **Methods:** @@ -37,7 +35,6 @@ init(cls, client: InfrahubClient | None = None, *args: Any, **kwargs: Any) -> In Async init method, If an existing InfrahubClient client hasn't been provided, one will be created automatically. - #### `errors` ```python @@ -70,7 +67,6 @@ branch_name(self) -> str Return the name of the current git branch. - #### `validate` ```python @@ -79,7 +75,6 @@ validate(self, data: dict) -> None Code to validate the status of this check. - #### `collect_data` ```python @@ -88,7 +83,6 @@ collect_data(self) -> dict Query the result of the GraphQL Query defined in self.query and return the result - #### `run` ```python @@ -97,4 +91,3 @@ run(self, data: dict | None = None) -> bool Execute the check after collecting the data from the GraphQL query. The result of the check is determined based on the presence or not of ERROR log messages. - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx index da67527b..e83112f6 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx @@ -27,10 +27,8 @@ handle_relogin_sync(func: Callable[..., httpx.Response]) ### `BaseClient` - Base class for InfrahubClient and InfrahubClientSync - **Methods:** #### `request_context` @@ -59,10 +57,8 @@ set_context_properties(self, identifier: str, params: dict[str, str] | None = No ### `InfrahubClient` - GraphQL Client to interact with Infrahub. - **Methods:** #### `get_version` @@ -73,7 +69,6 @@ get_version(self) -> str Return the Infrahub version. - #### `get_user` ```python @@ -82,7 +77,6 @@ get_user(self) -> dict Return user information - #### `get_user_permissions` ```python @@ -91,7 +85,6 @@ get_user_permissions(self) -> dict Return user permissions - #### `create` ```python @@ -166,7 +159,6 @@ count(self, kind: str | type[SchemaType], at: Timestamp | None = None, branch: s Return the number of nodes of a given kind. - #### `all` ```python @@ -188,6 +180,7 @@ all(self, kind: str | type[SchemaType], at: Timestamp | None = None, branch: str Retrieve all nodes of a given kind **Args:** + - `kind`: kind of the nodes to query - `at`: Time of the query. Defaults to Now. - `branch`: Name of the branch to query from. Defaults to default_branch. @@ -203,8 +196,8 @@ Retrieve all nodes of a given kind - `order`: Ordering related options. Setting `disable=True` enhances performances. **Returns:** -- list\[InfrahubNode]: List of Nodes +- list\[InfrahubNode]: List of Nodes #### `filters` @@ -227,6 +220,7 @@ filters(self, kind: str | type[SchemaType], at: Timestamp | None = None, branch: Retrieve nodes of a given kind based on provided filters. **Args:** + - `kind`: kind of the nodes to query - `at`: Time of the query. Defaults to Now. - `branch`: Name of the branch to query from. Defaults to default_branch. @@ -244,8 +238,8 @@ Retrieve nodes of a given kind based on provided filters. - `**kwargs`: Additional filter criteria for the query. **Returns:** -- list\[InfrahubNodeSync]: List of Nodes that match the given filters. +- list\[InfrahubNodeSync]: List of Nodes that match the given filters. #### `clone` @@ -255,7 +249,6 @@ clone(self, branch: str | None = None) -> InfrahubClient Return a cloned version of the client using the same configuration - #### `execute_graphql` ```python @@ -266,6 +259,7 @@ Execute a GraphQL query (or mutation). If retry_on_failure is True, the query will retry until the server becomes reacheable. **Args:** + - `query`: GraphQL Query to execute, can be a query or a mutation - `variables`: Variables to pass along with the GraphQL query. Defaults to None. - `branch_name`: Name of the branch on which the query will be executed. Defaults to None. @@ -277,8 +271,8 @@ Raises: GraphQLError: _description_ **Returns:** -- _description_ +- _description_ #### `refresh_login` @@ -349,6 +343,7 @@ allocate_next_ip_address(self, resource_pool: CoreNode, kind: type[SchemaType] | Allocate a new IP address by using the provided resource pool. **Args:** + - `resource_pool`: Node corresponding to the pool to allocate resources from. - `identifier`: Value to perform idempotent allocation, the same resource will be returned for a given identifier. - `prefix_length`: Length of the prefix to set on the address to allocate. @@ -362,7 +357,6 @@ Allocate a new IP address by using the provided resource pool. Returns: InfrahubNode: Node corresponding to the allocated resource. - #### `allocate_next_ip_prefix` ```python @@ -408,6 +402,7 @@ allocate_next_ip_prefix(self, resource_pool: CoreNode, kind: type[SchemaType] | Allocate a new IP prefix by using the provided resource pool. **Args:** + - `resource_pool`: Node corresponding to the pool to allocate resources from. - `identifier`: Value to perform idempotent allocation, the same resource will be returned for a given identifier. - `prefix_length`: Length of the prefix to allocate. @@ -422,7 +417,6 @@ Allocate a new IP prefix by using the provided resource pool. Returns: InfrahubNode: Node corresponding to the allocated resource. - #### `create_batch` ```python @@ -453,7 +447,6 @@ get_version(self) -> str Return the Infrahub version. - #### `get_user` ```python @@ -462,7 +455,6 @@ get_user(self) -> dict Return user information - #### `get_user_permissions` ```python @@ -471,7 +463,6 @@ get_user_permissions(self) -> dict Return user permissions - #### `create` ```python @@ -504,7 +495,6 @@ clone(self, branch: str | None = None) -> InfrahubClientSync Return a cloned version of the client using the same configuration - #### `execute_graphql` ```python @@ -515,6 +505,7 @@ Execute a GraphQL query (or mutation). If retry_on_failure is True, the query will retry until the server becomes reacheable. **Args:** + - `query`: GraphQL Query to execute, can be a query or a mutation - `variables`: Variables to pass along with the GraphQL query. Defaults to None. - `branch_name`: Name of the branch on which the query will be executed. Defaults to None. @@ -526,8 +517,8 @@ Raises: GraphQLError: When an error occurs during the execution of the GraphQL query or mutation. **Returns:** -- The result of the GraphQL query or mutation. +- The result of the GraphQL query or mutation. #### `count` @@ -537,7 +528,6 @@ count(self, kind: str | type[SchemaType], at: Timestamp | None = None, branch: s Return the number of nodes of a given kind. - #### `all` ```python @@ -559,6 +549,7 @@ all(self, kind: str | type[SchemaTypeSync], at: Timestamp | None = None, branch: Retrieve all nodes of a given kind **Args:** + - `kind`: kind of the nodes to query - `at`: Time of the query. Defaults to Now. - `branch`: Name of the branch to query from. Defaults to default_branch. @@ -574,8 +565,8 @@ Retrieve all nodes of a given kind - `order`: Ordering related options. Setting `disable=True` enhances performances. **Returns:** -- list\[InfrahubNodeSync]: List of Nodes +- list\[InfrahubNodeSync]: List of Nodes #### `filters` @@ -598,6 +589,7 @@ filters(self, kind: str | type[SchemaTypeSync], at: Timestamp | None = None, bra Retrieve nodes of a given kind based on provided filters. **Args:** + - `kind`: kind of the nodes to query - `at`: Time of the query. Defaults to Now. - `branch`: Name of the branch to query from. Defaults to default_branch. @@ -615,8 +607,8 @@ Retrieve nodes of a given kind based on provided filters. - `**kwargs`: Additional filter criteria for the query. **Returns:** -- list\[InfrahubNodeSync]: List of Nodes that match the given filters. +- list\[InfrahubNodeSync]: List of Nodes that match the given filters. #### `get` @@ -671,7 +663,6 @@ Create a batch to execute multiple queries concurrently. Executing the batch will be performed using a thread pool, meaning it cannot guarantee the execution order. It is not recommended to use such batch to manipulate objects that depend on each others. - #### `get_list_repositories` ```python @@ -735,6 +726,7 @@ allocate_next_ip_address(self, resource_pool: CoreNodeSync, kind: type[SchemaTyp Allocate a new IP address by using the provided resource pool. **Args:** + - `resource_pool`: Node corresponding to the pool to allocate resources from. - `identifier`: Value to perform idempotent allocation, the same resource will be returned for a given identifier. - `prefix_length`: Length of the prefix to set on the address to allocate. @@ -748,7 +740,6 @@ Allocate a new IP address by using the provided resource pool. Returns: InfrahubNodeSync: Node corresponding to the allocated resource. - #### `allocate_next_ip_prefix` ```python @@ -794,6 +785,7 @@ allocate_next_ip_prefix(self, resource_pool: CoreNodeSync, kind: type[SchemaType Allocate a new IP prefix by using the provided resource pool. **Args:** + - `resource_pool`: Node corresponding to the pool to allocate resources from. - `identifier`: Value to perform idempotent allocation, the same resource will be returned for a given identifier. - `size`: Length of the prefix to allocate. @@ -808,7 +800,6 @@ Allocate a new IP prefix by using the provided resource pool. Returns: InfrahubNodeSync: Node corresponding to the allocated resource. - #### `repository_update_commit` ```python diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/context.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/context.mdx index 84b63958..f39051a7 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/context.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/context.mdx @@ -11,6 +11,4 @@ sidebarTitle: context ### `RequestContext` - The context can be used to override settings such as the account within mutations. - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/branch.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/branch.mdx index 59cd4d61..6684d47f 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/branch.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/branch.mdx @@ -13,68 +13,54 @@ sidebarTitle: branch callback() -> None ``` - Manage the branches in a remote Infrahub instance. List, create, merge, rebase .. - ### `list_branch` ```python list_branch(_: str = CONFIG_PARAM) -> None ``` - List all existing branches. - ### `create` ```python create(branch_name: str = typer.Argument(..., help='Name of the branch to create'), description: str = typer.Option(default='', help='Description of the branch'), sync_with_git: bool = typer.Option(False, help='Extend the branch to Git and have Infrahub create the branch in connected repositories.'), isolated: bool = typer.Option(True, hidden=True, help='Set the branch to isolated mode (deprecated)'), _: str = CONFIG_PARAM) -> None ``` - Create a new branch. - ### `delete` ```python delete(branch_name: str, _: str = CONFIG_PARAM) -> None ``` - Delete a branch. - ### `rebase` ```python rebase(branch_name: str, _: str = CONFIG_PARAM) -> None ``` - Rebase a Branch with main. - ### `merge` ```python merge(branch_name: str, _: str = CONFIG_PARAM) -> None ``` - Merge a Branch with main. - ### `validate` ```python validate(branch_name: str, _: str = CONFIG_PARAM) -> None ``` - Validate if a branch has some conflict and is passing all the tests (NOT IMPLEMENTED YET). - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/check.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/check.mdx index 4cebb85f..45a9f53f 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/check.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/check.mdx @@ -13,20 +13,16 @@ sidebarTitle: check callback() -> None ``` - Execute user-defined checks. - ### `run` ```python run() -> None ``` - Locate and execute all checks under the defined path. - ### `run_check` ```python diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli_commands.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli_commands.mdx index 29c7fea6..c8904fd4 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli_commands.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli_commands.mdx @@ -13,30 +13,24 @@ sidebarTitle: cli_commands check(check_name: str = typer.Argument(default='', help='Name of the Python check'), branch: Optional[str] = None, path: str = typer.Option('.', help='Root directory'), debug: bool = False, format_json: bool = False, _: str = CONFIG_PARAM, list_available: bool = typer.Option(False, '--list', help='Show available Python checks'), variables: Optional[list[str]] = typer.Argument(None, help='Variables to pass along with the query. Format key=value key=value.')) -> None ``` - Execute user-defined checks. - ### `generator` ```python generator(generator_name: str = typer.Argument(default='', help='Name of the Generator'), branch: Optional[str] = None, path: str = typer.Option('.', help='Root directory'), debug: bool = False, _: str = CONFIG_PARAM, list_available: bool = typer.Option(False, '--list', help='Show available Generators'), variables: Optional[list[str]] = typer.Argument(None, help='Variables to pass along with the query. Format key=value key=value.')) -> None ``` - Run a generator script. - ### `run` ```python run(script: Path, method: str = 'run', debug: bool = False, _: str = CONFIG_PARAM, branch: str = typer.Option(None, help='Branch on which to run the script.'), concurrent: Optional[int] = typer.Option(None, help='Maximum number of requests to execute at the same time.', envvar='INFRAHUB_MAX_CONCURRENT_EXECUTION'), timeout: int = typer.Option(60, help='Timeout in sec', envvar='INFRAHUB_TIMEOUT'), variables: Optional[list[str]] = typer.Argument(None, help='Variables to pass along with the query. Format key=value key=value.')) -> None ``` - Execute a script. - ### `render_jinja2_template` ```python @@ -49,46 +43,36 @@ render_jinja2_template(template_path: Path, variables: dict[str, Any], data: dic render(transform_name: str = typer.Argument(default='', help='Name of the Python transformation', show_default=False), variables: Optional[list[str]] = typer.Argument(None, help='Variables to pass along with the query. Format key=value key=value.'), branch: str = typer.Option(None, help='Branch on which to render the transform.'), debug: bool = False, _: str = CONFIG_PARAM, list_available: bool = typer.Option(False, '--list', help='Show available transforms'), out: str = typer.Option(None, help='Path to a file to save the result.')) -> None ``` - Render a local Jinja2 Transform for debugging purpose. - ### `transform` ```python transform(transform_name: str = typer.Argument(default='', help='Name of the Python transformation', show_default=False), variables: Optional[list[str]] = typer.Argument(None, help='Variables to pass along with the query. Format key=value key=value.'), branch: str = typer.Option(None, help='Branch on which to run the transformation'), debug: bool = False, _: str = CONFIG_PARAM, list_available: bool = typer.Option(False, '--list', help='Show available transforms'), out: str = typer.Option(None, help='Path to a file to save the result.')) -> None ``` - Render a local transform (TransformPython) for debugging purpose. - ### `protocols` ```python protocols(schemas: list[Path] = typer.Option(None, help='List of schemas or directory to load.'), branch: str = typer.Option(None, help='Branch of schema to export Python protocols for.'), sync: bool = typer.Option(False, help='Generate for sync or async.'), _: str = CONFIG_PARAM, out: str = typer.Option('schema_protocols.py', help='Path to a file to save the result.')) -> None ``` - Export Python protocols corresponding to a schema. - ### `version` ```python version() -> None ``` - Display the version of Python and the version of the Python SDK in use. - ### `info` ```python info(detail: bool = typer.Option(False, help='Display detailed information.'), _: str = CONFIG_PARAM) -> None ``` - Display the status of the Python SDK. - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/config.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/config.mdx index 247f56af..614bc1cf 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/config.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/config.mdx @@ -5,17 +5,14 @@ sidebarTitle: config # `infrahub_sdk.ctl.config` - Config Class. ## Classes ### `Settings` - Main Settings Class for the project. - **Methods:** #### `cleanup_server_address` @@ -45,7 +42,6 @@ Load configuration. Configuration is loaded from a config file in toml format that contains the settings, or from a dictionary of those settings passed in as "config_data" - #### `load_and_exit` ```python @@ -58,6 +54,6 @@ This is done to handle a ValidationErorr which is raised when settings are speci In such cases, a message is printed to the screen indicating the settings which don't pass validation. **Args:** + - `config_file_name`: [description]. Defaults to "pyprojectctl.toml". - `config_data`: [description]. Defaults to None. - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exceptions.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exceptions.mdx index 0a796151..5499dcff 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exceptions.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exceptions.mdx @@ -9,8 +9,6 @@ sidebarTitle: exceptions ### `Error` - Infrahub CTL Base exception. - ### `QueryNotFoundError` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exporter.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exporter.mdx index 1c20de3a..63335216 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exporter.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exporter.mdx @@ -19,6 +19,4 @@ directory_name_with_timestamp() -> str dump(namespace: list[str] = typer.Option([], help='Namespace(s) to export'), directory: Path = typer.Option(directory_name_with_timestamp, help='Directory path to store export'), quiet: bool = typer.Option(False, help='No console output'), _: str = CONFIG_PARAM, branch: str = typer.Option(None, help='Branch from which to export'), concurrent: int = typer.Option(4, help='Maximum number of requests to execute at the same time.', envvar='INFRAHUB_MAX_CONCURRENT_EXECUTION'), timeout: int = typer.Option(60, help='Timeout in sec', envvar='INFRAHUB_TIMEOUT'), exclude: list[str] = typer.Option(['CoreAccount'], help='Prevent node kind(s) from being exported, CoreAccount is excluded by default')) -> None ``` - Export nodes and their relationships out of the database. - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/importer.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/importer.mdx index a05b76fb..bbb99aea 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/importer.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/importer.mdx @@ -19,6 +19,4 @@ local_directory() -> Path load(directory: Path = typer.Option(local_directory, help='Directory path of exported data'), continue_on_error: bool = typer.Option(False, help='Allow exceptions during loading and display them when complete'), quiet: bool = typer.Option(False, help='No console output'), _: str = CONFIG_PARAM, branch: str = typer.Option(None, help='Branch from which to export'), concurrent: Optional[int] = typer.Option(None, help='Maximum number of requests to execute at the same time.', envvar='INFRAHUB_MAX_CONCURRENT_EXECUTION'), timeout: int = typer.Option(60, help='Timeout in sec', envvar='INFRAHUB_TIMEOUT')) -> None ``` - Import nodes and their relationships into the database. - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/menu.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/menu.mdx index f274cfb4..ad1c92d7 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/menu.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/menu.mdx @@ -13,26 +13,20 @@ sidebarTitle: menu callback() -> None ``` - Manage the menu in a remote Infrahub instance. - ### `load` ```python load(menus: list[Path], debug: bool = False, branch: str = typer.Option(None, help='Branch on which to load the menu.'), _: str = CONFIG_PARAM) -> None ``` - Load one or multiple menu files into Infrahub. - ### `validate` ```python validate(paths: list[Path], debug: bool = False, branch: str = typer.Option(None, help='Branch on which to validate the objects.'), _: str = CONFIG_PARAM) -> None ``` - Validate one or multiple menu files. - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/object.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/object.mdx index 3aef7663..7ed1aac9 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/object.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/object.mdx @@ -13,26 +13,20 @@ sidebarTitle: object callback() -> None ``` - Manage objects in a remote Infrahub instance. - ### `load` ```python load(paths: list[Path], debug: bool = False, branch: str = typer.Option(None, help='Branch on which to load the objects.'), _: str = CONFIG_PARAM) -> None ``` - Load one or multiple objects files into Infrahub. - ### `validate` ```python validate(paths: list[Path], debug: bool = False, branch: str = typer.Option(None, help='Branch on which to validate the objects.'), _: str = CONFIG_PARAM) -> None ``` - Validate one or multiple objects files. - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/parameters.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/parameters.mdx index 1005151d..c3c927d7 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/parameters.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/parameters.mdx @@ -13,6 +13,4 @@ sidebarTitle: parameters load_configuration(value: str) -> str ``` - Load the configuration file using default environment variables or from the specified configuration file - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/repository.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/repository.mdx index f3ab2bf1..9d42debf 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/repository.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/repository.mdx @@ -25,22 +25,18 @@ load_repository_config_file(repo_config_file: Path) -> dict callback() -> None ``` - Manage the repositories in a remote Infrahub instance. List, create, delete .. - ### `add` ```python add(name: str, location: str, description: str = '', username: Optional[str] = None, password: str = '', ref: str = '', read_only: bool = False, debug: bool = False, _: str = CONFIG_PARAM) -> None ``` - Add a new repository. - ### `list` ```python diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/schema.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/schema.mdx index 40f1a708..667df63f 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/schema.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/schema.mdx @@ -13,10 +13,8 @@ sidebarTitle: schema callback() -> None ``` - Manage the schema in a remote Infrahub instance. - ### `validate_schema_content_and_exit` ```python @@ -53,16 +51,12 @@ get_node(schemas_data: list[dict], schema_index: int, node_index: int) -> dict | load(schemas: list[Path], debug: bool = False, branch: str = typer.Option(None, help='Branch on which to load the schema.'), wait: int = typer.Option(0, help='Time in seconds to wait until the schema has converged across all workers'), _: str = CONFIG_PARAM) -> None ``` - Load one or multiple schema files into Infrahub. - ### `check` ```python check(schemas: list[Path], debug: bool = False, branch: str = typer.Option(None, help='Branch on which to check the schema.'), _: str = CONFIG_PARAM) -> None ``` - Check if schema files are valid and what would be the impact of loading them with Infrahub. - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx index e7c88ee8..875d298d 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx @@ -19,20 +19,16 @@ init_logging(debug: bool = False) -> None handle_exception(exc: Exception, console: Console, exit_code: int) -> NoReturn ``` - Handle exception in a different fashion based on its type. - ### `catch_exception` ```python catch_exception(console: Console | None = None, exit_code: int = 1) -> Callable[[Callable[..., T]], Callable[..., T | Coroutine[Any, Any, T]]] ``` - Decorator to handle exception for commands. - ### `execute_graphql_query` ```python @@ -69,10 +65,8 @@ render_action_rich(value: str) -> str get_fixtures_dir() -> Path ``` - Get the directory which stores fixtures that are common to multiple unit/integration tests. - ### `load_yamlfile_from_disk_and_exit` ```python diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/validate.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/validate.mdx index e36ec385..2ffa3799 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/validate.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/validate.mdx @@ -13,26 +13,20 @@ sidebarTitle: validate callback() -> None ``` - Helper to validate the format of various files. - ### `validate_schema` ```python validate_schema(schema: Path, _: str = CONFIG_PARAM) -> None ``` - Validate the format of a schema file either in JSON or YAML - ### `validate_graphql` ```python validate_graphql(query: str, variables: Optional[list[str]] = typer.Argument(None, help='Variables to pass along with the query. Format key=value key=value.'), debug: bool = typer.Option(False, help='Display more troubleshooting information.'), branch: str = typer.Option(None, help='Branch on which to validate the GraphQL Query.'), _: str = CONFIG_PARAM, out: str = typer.Option(None, help='Path to a file to save the result.')) -> None ``` - Validate the format of a GraphQL Query stored locally by executing it on a remote GraphQL endpoint - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/exceptions.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/exceptions.mdx index 50016d5d..7ebde17b 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/exceptions.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/exceptions.mdx @@ -29,10 +29,8 @@ sidebarTitle: exceptions ### `ResourceNotDefinedError` - Raised when trying to access a resource that hasn't been defined. - ### `InfrahubCheckNotFoundError` ### `InfrahubTransformNotFoundError` @@ -47,22 +45,16 @@ Raised when trying to access a resource that hasn't been defined. ### `FeatureNotSupportedError` - Raised when trying to use a method on a node that doesn't support it. - ### `UninitializedError` - Raised when an object requires an initialization step before use - ### `InvalidResponseError` - Raised when an object requires an initialization step before use - ### `FileNotValidError` ### `TimestampFormatError` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/generator.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/generator.mdx index cf4a20a0..e43498f6 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/generator.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/generator.mdx @@ -9,10 +9,8 @@ sidebarTitle: generator ### `InfrahubGenerator` - Infrahub Generator class - **Methods:** #### `subscribers` @@ -41,7 +39,6 @@ collect_data(self) -> dict Query the result of the GraphQL Query defined in self.query and return the result - #### `run` ```python @@ -50,7 +47,6 @@ run(self, identifier: str, data: dict | None = None) -> None Execute the generator after collecting the data from the GraphQL query. - #### `generate` ```python @@ -66,4 +62,3 @@ way as the method could be executed multiple times. Typically this would be done await new_or_updated_object.save(allow_upsert=True) The tracking system will be responsible for deleting nodes that are no longer required. - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/graphql.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/graphql.mdx index 3824dc99..437f8739 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/graphql.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/graphql.mdx @@ -19,12 +19,10 @@ convert_to_graphql_as_string(value: str | bool | list | BaseModel | Enum | Any, render_variables_to_string(data: dict[str, type[str | int | float | bool]]) -> str ``` - Render a dict into a variable string that will be used in a GraphQL Query. The $ sign will be automatically added to the name of the query. - ### `render_query_block` ```python diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/jinja2.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/jinja2.mdx index 55c7c02d..12f4b24c 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/jinja2.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/jinja2.mdx @@ -13,8 +13,6 @@ sidebarTitle: jinja2 identify_faulty_jinja_code(traceback: Traceback, nbr_context_lines: int = 3) -> list[tuple[Frame, Syntax]] ``` - This function identifies the faulty Jinja2 code and beautify it to provide meaningful information to the user. We use the rich's Traceback to parse the complete stack trace and extract Frames for each exception found in the trace. - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/attribute.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/attribute.mdx index 77d69e16..e0cbba24 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/attribute.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/attribute.mdx @@ -9,10 +9,8 @@ sidebarTitle: attribute ### `Attribute` - Represents an attribute of a Node, including its schema, value, and properties. - **Methods:** #### `value` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx index 364c08bf..82ce44d3 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx @@ -9,10 +9,8 @@ sidebarTitle: node ### `InfrahubNodeBase` - Base class for InfrahubNode and InfrahubNodeSync - **Methods:** #### `get_branch` @@ -101,13 +99,10 @@ extract(self, params: dict[str, str]) -> dict[str, Any] Extract some data points defined in a flat notation. - ### `InfrahubNode` - Represents a Infrahub node in an asynchronous context. - **Methods:** #### `from_graphql` @@ -161,6 +156,7 @@ generate_query_data_node(self, include: list[str] | None = None, exclude: list[s Generate the node part of a GraphQL Query with attributes and nodes. **Args:** + - `include`: List of attributes or relationships to include. Defaults to None. - `exclude`: List of attributes or relationships to exclude. Defaults to None. - `inherited`: Indicated of the attributes and the relationships inherited from generics should be included as well. @@ -169,8 +165,8 @@ Generate the node part of a GraphQL Query with attributes and nodes. - `prefetch_relationships`: If True, pre-fetches relationship data as part of the query. **Returns:** -- dict\[str, Union\[Any, Dict]]: GraphQL query in dictionary format +- dict\[str, Union\[Any, Dict]]: GraphQL query in dictionary format #### `add_relationships` @@ -205,11 +201,12 @@ get_pool_allocated_resources(self, resource: InfrahubNode) -> list[InfrahubNode] Fetch all nodes that were allocated for the pool and a given resource. **Args:** + - `resource`: The resource from which the nodes were allocated. **Returns:** -- list\[InfrahubNode]: The allocated nodes. +- list\[InfrahubNode]: The allocated nodes. #### `get_pool_resources_utilization` @@ -220,15 +217,13 @@ get_pool_resources_utilization(self) -> list[dict[str, Any]] Fetch the utilization of each resource for the pool. **Returns:** -- list\[dict\[str, Any]]: A list containing the allocation numbers for each resource of the pool. +- list\[dict\[str, Any]]: A list containing the allocation numbers for each resource of the pool. ### `InfrahubNodeSync` - Represents a Infrahub node in a synchronous context. - **Methods:** #### `from_graphql` @@ -282,6 +277,7 @@ generate_query_data_node(self, include: list[str] | None = None, exclude: list[s Generate the node part of a GraphQL Query with attributes and nodes. **Args:** + - `include`: List of attributes or relationships to include. Defaults to None. - `exclude`: List of attributes or relationships to exclude. Defaults to None. - `inherited`: Indicated of the attributes and the relationships inherited from generics should be included as well. @@ -290,8 +286,8 @@ Generate the node part of a GraphQL Query with attributes and nodes. - `prefetch_relationships`: If True, pre-fetches relationship data as part of the query. **Returns:** -- dict\[str, Union\[Any, Dict]]: GraphQL query in dictionary format +- dict\[str, Union\[Any, Dict]]: GraphQL query in dictionary format #### `add_relationships` @@ -326,11 +322,12 @@ get_pool_allocated_resources(self, resource: InfrahubNodeSync) -> list[InfrahubN Fetch all nodes that were allocated for the pool and a given resource. **Args:** + - `resource`: The resource from which the nodes were allocated. **Returns:** -- list\[InfrahubNodeSync]: The allocated nodes. +- list\[InfrahubNodeSync]: The allocated nodes. #### `get_pool_resources_utilization` @@ -341,5 +338,5 @@ get_pool_resources_utilization(self) -> list[dict[str, Any]] Fetch the utilization of each resource for the pool. **Returns:** -- list\[dict\[str, Any]]: A list containing the allocation numbers for each resource of the pool. +- list\[dict\[str, Any]]: A list containing the allocation numbers for each resource of the pool. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/parsers.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/parsers.mdx index f64178ec..d058f8eb 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/parsers.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/parsers.mdx @@ -13,6 +13,4 @@ sidebarTitle: parsers parse_human_friendly_id(hfid: str | list[str]) -> tuple[str | None, list[str]] ``` - Parse a human friendly ID into a kind and an identifier. - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/property.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/property.mdx index 3a11524c..d7ad38b5 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/property.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/property.mdx @@ -9,6 +9,4 @@ sidebarTitle: property ### `NodeProperty` - Represents a property of a node, typically used for metadata like display labels. - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/related_node.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/related_node.mdx index 231c81f5..1634208f 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/related_node.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/related_node.mdx @@ -9,10 +9,8 @@ sidebarTitle: related_node ### `RelatedNodeBase` - Base class for representing a related node in a relationship. - **Methods:** #### `id` @@ -65,10 +63,8 @@ kind(self) -> str | None ### `RelatedNode` - Represents a RelatedNodeBase in an asynchronous context. - **Methods:** #### `fetch` @@ -91,10 +87,8 @@ get(self) -> InfrahubNode ### `RelatedNodeSync` - Represents a related node in a synchronous context. - **Methods:** #### `fetch` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx index a63fe714..7de5278d 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx @@ -9,10 +9,8 @@ sidebarTitle: relationship ### `RelationshipManagerBase` - Base class for RelationshipManager and RelationshipManagerSync - **Methods:** #### `peer_ids` @@ -41,10 +39,8 @@ has_update(self) -> bool ### `RelationshipManager` - Manages relationships of a node in an asynchronous context. - **Methods:** #### `fetch` @@ -61,7 +57,6 @@ add(self, data: str | RelatedNode | dict) -> None Add a new peer to this relationship. - #### `extend` ```python @@ -70,7 +65,6 @@ extend(self, data: Iterable[str | RelatedNode | dict]) -> None Add new peers to this relationship. - #### `remove` ```python @@ -79,10 +73,8 @@ remove(self, data: str | RelatedNode | dict) -> None ### `RelationshipManagerSync` - Manages relationships of a node in a synchronous context. - **Methods:** #### `fetch` @@ -99,7 +91,6 @@ add(self, data: str | RelatedNodeSync | dict) -> None Add a new peer to this relationship. - #### `extend` ```python @@ -108,7 +99,6 @@ extend(self, data: Iterable[str | RelatedNodeSync | dict]) -> None Add new peers to this relationship. - #### `remove` ```python diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/operation.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/operation.mdx index a6196413..b1f96d2f 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/operation.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/operation.mdx @@ -19,7 +19,6 @@ branch_name(self) -> str Return the name of the current git branch. - #### `store` ```python @@ -28,7 +27,6 @@ store(self) -> NodeStore The store will be populated with nodes based on the query during the collection of data if activated - #### `nodes` ```python @@ -37,7 +35,6 @@ nodes(self) -> list[InfrahubNode] Returns nodes collected and parsed during the data collection process if this feature is enabled - #### `related_nodes` ```python @@ -46,7 +43,6 @@ related_nodes(self) -> list[InfrahubNode] Returns nodes collected and parsed during the data collection process if this feature is enabled - #### `process_nodes` ```python diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/generator.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/generator.mdx index 3ede33e6..b59c45c7 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/generator.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/generator.mdx @@ -19,10 +19,8 @@ load_template() -> str move_to_end_of_list(lst: list, item: str) -> list ``` - Move an item to the end of a list if it exists in the list - ## Classes ### `CodeGenerator` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/exceptions.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/exceptions.mdx index 5a7fca84..c8d85b8c 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/exceptions.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/exceptions.mdx @@ -9,10 +9,8 @@ sidebarTitle: exceptions ### `Error` - pytest-infrahub Base exception. - ### `InvalidResourceConfigError` ### `DirectoryNotFoundError` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/base.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/base.mdx index 3e69552b..023020a2 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/base.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/base.mdx @@ -19,7 +19,6 @@ validate_resource_config(self) -> None Make sure that a test resource config is properly defined. - #### `get_result_differences` ```python @@ -30,7 +29,6 @@ Compute the differences between the computed result and the expected one. If the results are not JSON parsable, this method must be redefined to handle them. - #### `runtest` ```python @@ -39,7 +37,6 @@ runtest(self) -> None Run the test logic. - #### `repr_failure` ```python @@ -62,4 +59,3 @@ Return the path to the root of the repository This will be an absolute path if --infrahub-config-path is an absolute path as happens when tests are started from within Infrahub server. - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/loader.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/loader.mdx index f48b239c..fe591c02 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/loader.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/loader.mdx @@ -19,7 +19,6 @@ get_resource_config(self, group: InfrahubTestGroup) -> Any | None Retrieve the resource configuration to apply to all tests in a group. - #### `collect_group` ```python @@ -28,7 +27,6 @@ collect_group(self, group: InfrahubTestGroup) -> Iterable[Item] Collect all items for a group. - #### `collect` ```python diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/models.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/models.mdx index ad1504e6..9bd13d23 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/models.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/models.mdx @@ -13,10 +13,8 @@ sidebarTitle: models ### `InfrahubBaseTest` - Basic Infrahub test model used as a common ground for all tests. - ### `InfrahubInputOutputTest` **Methods:** @@ -32,7 +30,6 @@ Read and parse user provided data depending on a file extension. This function handles JSON and YAML as they can be used to achieve the same goal. However some users may be more used to one format or another. If the file extension isn't known, assume the content is plain text. - #### `update_paths` ```python diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/query_groups.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/query_groups.mdx index b0e2ac6e..f5ac9516 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/query_groups.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/query_groups.mdx @@ -9,10 +9,8 @@ sidebarTitle: query_groups ### `InfrahubGroupContextBase` - Base class for InfrahubGroupContext and InfrahubGroupContextSync - **Methods:** #### `set_properties` @@ -24,16 +22,14 @@ set_properties(self, identifier: str, params: dict[str, str] | None = None, dele Setter method to set the values of identifier and params. **Args:** + - `identifier`: The new value for the identifier. - `params`: A dictionary with new values for the params. - ### `InfrahubGroupContext` - Represents a Infrahub GroupContext in an asynchronous context. - **Methods:** #### `get_group` @@ -57,10 +53,10 @@ add_related_nodes(self, ids: list[str], update_group_context: bool | None = None Add related Nodes IDs to the context. **Args:** + - `ids`: List of node IDs to be added. - `update_group_context`: Flag to control whether to update the group context. - #### `add_related_groups` ```python @@ -70,10 +66,10 @@ add_related_groups(self, ids: list[str], update_group_context: bool | None = Non Add related Groups IDs to the context. **Args:** + - `ids`: List of group IDs to be added. - `update_group_context`: Flag to control whether to update the group context. - #### `update_group` ```python @@ -82,13 +78,10 @@ update_group(self) -> None Create or update (using upsert) a CoreStandardGroup to store all the Nodes and Groups used during an execution. - ### `InfrahubGroupContextSync` - Represents a Infrahub GroupContext in an synchronous context. - **Methods:** #### `get_group` @@ -112,10 +105,10 @@ add_related_nodes(self, ids: list[str], update_group_context: bool | None = None Add related Nodes IDs to the context. **Args:** + - `ids`: List of node IDs to be added. - `update_group_context`: Flag to control whether to update the group context. - #### `add_related_groups` ```python @@ -125,10 +118,10 @@ add_related_groups(self, ids: list[str], update_group_context: bool | None = Non Add related Groups IDs to the context. **Args:** + - `ids`: List of group IDs to be added. - `update_group_context`: Flag to control whether to update the group context. - #### `update_group` ```python @@ -136,4 +129,3 @@ update_group(self) -> None ``` Create or update (using upsert) a CoreStandardGroup to store all the Nodes and Groups used during an execution. - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/recorder.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/recorder.mdx index 105a714d..94251b72 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/recorder.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/recorder.mdx @@ -21,7 +21,6 @@ record(self, response: httpx.Response) -> None Record the response from Infrahub - ### `NoRecorder` **Methods:** @@ -34,7 +33,6 @@ record(response: httpx.Response) -> None The NoRecorder just silently returns - #### `default` ```python diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/main.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/main.mdx index 74b088ce..deedc99e 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/main.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/main.mdx @@ -149,10 +149,8 @@ convert_api(self) -> GenericSchemaAPI ### `GenericSchemaAPI` - A Generic can be either an Interface or a Union depending if there are some Attributes or Relationships defined. - ### `BaseNodeSchema` ### `NodeSchema` @@ -197,7 +195,6 @@ from_api_response(cls, data: MutableMapping[str, Any]) -> Self Convert an API response from /api/schema into a BranchSchema object. - #### `from_schema_root_api` ```python @@ -205,4 +202,3 @@ from_schema_root_api(cls, data: SchemaRootAPI) -> Self ``` Convert a SchemaRootAPI object to a BranchSchema object. - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/repository.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/repository.mdx index 1d305e98..4779ebb5 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/repository.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/repository.mdx @@ -9,10 +9,8 @@ sidebarTitle: repository ### `InfrahubRepositoryConfigElement` - Class to regroup all elements of the infrahub configuration for a repository for typing purpose. - ### `InfrahubRepositoryArtifactDefinitionConfig` ### `InfrahubJinja2TransformConfig` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/object.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/object.mdx index a0e6bd5f..9efe0df3 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/object.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/object.mdx @@ -37,10 +37,8 @@ validate_list_of_objects(value: list[Any]) -> bool get_relationship_info(client: InfrahubClient, schema: MainSchemaTypesAPI, name: str, value: Any, branch: str | None = None) -> RelationshipInfo ``` - Get the relationship info for a given relationship name. - ## Classes ### `RelationshipDataFormat` @@ -57,7 +55,6 @@ is_bidirectional(self) -> bool Indicate if a relationship with the same identifier exists on the other side - #### `is_mandatory` ```python @@ -84,7 +81,6 @@ get_context(self, value: Any) -> dict Return a dict to insert to the context if the relationship is mandatory - #### `find_matching_relationship` ```python @@ -93,7 +89,6 @@ find_matching_relationship(self, peer_schema: MainSchemaTypesAPI, force: bool = Find the matching relationship on the other side of the relationship - ### `InfrahubObjectFileData` **Methods:** diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/store.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/store.mdx index 9166a0b2..681ddd5d 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/store.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/store.mdx @@ -39,13 +39,11 @@ get(self, key: str | list[str], kind: type[SchemaType | SchemaTypeSync] | str | ### `NodeStoreBase` - Internal Store for InfrahubNode objects. Often while creating a lot of new objects, we need to save them in order to reuse them later to associate them with another node for example. - **Methods:** #### `count` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/manager.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/manager.mdx index fd71561e..c5ccf7e2 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/manager.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/manager.mdx @@ -22,11 +22,12 @@ count(self, filters: TaskFilter | None = None) -> int Count the number of tasks. **Args:** + - `filters`: The filter to apply to the tasks. Defaults to None. **Returns:** -- The number of tasks. +- The number of tasks. #### `all` @@ -37,6 +38,7 @@ all(self, limit: int | None = None, offset: int | None = None, timeout: int | No Get all tasks. **Args:** + - `limit`: The maximum number of tasks to return. Defaults to None. - `offset`: The offset to start the tasks from. Defaults to None. - `timeout`: The timeout to wait for the tasks to complete. Defaults to None. @@ -45,8 +47,8 @@ Get all tasks. - `include_related_nodes`: Whether to include the related nodes in the tasks. Defaults to False. **Returns:** -- A list of tasks. +- A list of tasks. #### `filter` @@ -57,6 +59,7 @@ filter(self, filter: TaskFilter | None = None, limit: int | None = None, offset: Filter tasks. **Args:** + - `filter`: The filter to apply to the tasks. Defaults to None. - `limit`: The maximum number of tasks to return. Defaults to None. - `offset`: The offset to start the tasks from. Defaults to None. @@ -66,8 +69,8 @@ Filter tasks. - `include_related_nodes`: Whether to include the related nodes in the tasks. Defaults to False. **Returns:** -- A list of tasks. +- A list of tasks. #### `get` @@ -84,16 +87,18 @@ wait_for_completion(self, id: str, interval: int = 1, timeout: int = 60) -> Task Wait for a task to complete. **Args:** + - `id`: The id of the task to wait for. - `interval`: The interval to check the task state. Defaults to 1. - `timeout`: The timeout to wait for the task to complete. Defaults to 60. **Raises:** + - `TaskNotCompletedError`: The task did not complete in the given timeout. **Returns:** -- The task object. +- The task object. #### `process_page` @@ -104,14 +109,15 @@ process_page(client: InfrahubClient, query: Query, page_number: int, timeout: in Process a single page of results. **Args:** + - `client`: The client to use to execute the query. - `query`: The query to execute. - `page_number`: The page number to process. - `timeout`: The timeout to wait for the query to complete. Defaults to None. **Returns:** -- A tuple containing a list of tasks and the count of tasks. +- A tuple containing a list of tasks and the count of tasks. #### `process_batch` @@ -121,7 +127,6 @@ process_batch(self, filters: TaskFilter | None = None, timeout: int | None = Non Process queries in parallel mode. - #### `process_non_batch` ```python @@ -130,7 +135,6 @@ process_non_batch(self, filters: TaskFilter | None = None, offset: int | None = Process queries without parallel mode. - ### `InfrahubTaskManagerSync` **Methods:** @@ -144,11 +148,12 @@ count(self, filters: TaskFilter | None = None) -> int Count the number of tasks. **Args:** + - `filters`: The filter to apply to the tasks. Defaults to None. **Returns:** -- The number of tasks. +- The number of tasks. #### `all` @@ -159,6 +164,7 @@ all(self, limit: int | None = None, offset: int | None = None, timeout: int | No Get all tasks. **Args:** + - `limit`: The maximum number of tasks to return. Defaults to None. - `offset`: The offset to start the tasks from. Defaults to None. - `timeout`: The timeout to wait for the tasks to complete. Defaults to None. @@ -167,8 +173,8 @@ Get all tasks. - `include_related_nodes`: Whether to include the related nodes in the tasks. Defaults to False. **Returns:** -- A list of tasks. +- A list of tasks. #### `filter` @@ -179,6 +185,7 @@ filter(self, filter: TaskFilter | None = None, limit: int | None = None, offset: Filter tasks. **Args:** + - `filter`: The filter to apply to the tasks. Defaults to None. - `limit`: The maximum number of tasks to return. Defaults to None. - `offset`: The offset to start the tasks from. Defaults to None. @@ -188,8 +195,8 @@ Filter tasks. - `include_related_nodes`: Whether to include the related nodes in the tasks. Defaults to False. **Returns:** -- A list of tasks. +- A list of tasks. #### `get` @@ -206,16 +213,18 @@ wait_for_completion(self, id: str, interval: int = 1, timeout: int = 60) -> Task Wait for a task to complete. **Args:** + - `id`: The id of the task to wait for. - `interval`: The interval to check the task state. Defaults to 1. - `timeout`: The timeout to wait for the task to complete. Defaults to 60. **Raises:** + - `TaskNotCompletedError`: The task did not complete in the given timeout. **Returns:** -- The task object. +- The task object. #### `process_page` @@ -226,14 +235,15 @@ process_page(client: InfrahubClientSync, query: Query, page_number: int, timeout Process a single page of results. **Args:** + - `client`: The client to use to execute the query. - `query`: The query to execute. - `page_number`: The page number to process. - `timeout`: The timeout to wait for the query to complete. Defaults to None. **Returns:** -- A tuple containing a list of tasks and the count of tasks. +- A tuple containing a list of tasks and the count of tasks. #### `process_batch` @@ -243,7 +253,6 @@ process_batch(self, filters: TaskFilter | None = None, timeout: int | None = Non Process queries in parallel mode. - #### `process_non_batch` ```python @@ -251,4 +260,3 @@ process_non_batch(self, filters: TaskFilter | None = None, offset: int | None = ``` Process queries without parallel mode. - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/docker.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/docker.mdx index 16c5b509..c41bf7b9 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/docker.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/docker.mdx @@ -13,10 +13,8 @@ sidebarTitle: docker skip_version(min_infrahub_version: str | None = None, max_infrahub_version: str | None = None) -> bool ``` - Check if a test should be skipped depending on infrahub version. - ## Classes ### `TestInfrahubDockerClient` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transforms.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transforms.mdx index 5d51f3ab..bb80aab3 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transforms.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transforms.mdx @@ -31,7 +31,6 @@ collect_data(self) -> dict Query the result of the GraphQL Query defined in self.query and return the result - #### `run` ```python @@ -43,7 +42,7 @@ Execute the transformation after collecting the data from the GraphQL query. The result of the check is determined based on the presence or not of ERROR log messages. **Args:** + - `data`: The data on which to run the transform. Data will be queried from the API if not provided Returns: Transformed data - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/types.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/types.mdx index 7953f5f7..c263a0df 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/types.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/types.mdx @@ -27,7 +27,6 @@ debug(self, event: str | None = None, *args: Any, **kw: Any) -> Any Send a debug event - #### `info` ```python @@ -36,7 +35,6 @@ info(self, event: str | None = None, *args: Any, **kw: Any) -> Any Send an info event - #### `warning` ```python @@ -45,7 +43,6 @@ warning(self, event: str | None = None, *args: Any, **kw: Any) -> Any Send a warning event - #### `error` ```python @@ -54,7 +51,6 @@ error(self, event: str | None = None, *args: Any, **kw: Any) -> Any Send an error event. - #### `critical` ```python @@ -63,7 +59,6 @@ critical(self, event: str | None = None, *args: Any, **kw: Any) -> Any Send a critical event. - #### `exception` ```python @@ -72,5 +67,4 @@ exception(self, event: str | None = None, *args: Any, **kw: Any) -> Any Send an exception event. - ### `Order` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/utils.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/utils.mdx index 52ab0eb1..5729b76d 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/utils.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/utils.mdx @@ -13,10 +13,8 @@ sidebarTitle: utils generate_short_id() -> str ``` - Generate a short unique ID - ### `base36encode` ```python @@ -47,20 +45,16 @@ base16encode(number: int) -> str get_fixtures_dir() -> Path ``` - Get the directory which stores fixtures that are common to multiple unit/integration tests. - ### `is_valid_uuid` ```python is_valid_uuid(value: Any) -> bool ``` - Check if the input is a valid UUID. - ### `decode_json` ```python @@ -79,61 +73,51 @@ generate_uuid() -> str duplicates(input_list: list) -> list ``` - Identify and return all the duplicates in a list. - ### `intersection` ```python intersection(list1: list[Any], list2: list[Any]) -> list ``` - Calculate the intersection between 2 lists. - ### `compare_lists` ```python compare_lists(list1: list[Any], list2: list[Any]) -> tuple[list[Any], list[Any], list[Any]] ``` - Compare 2 lists and return : + - the intersection of both - the item present only in list1 - the item present only in list2 - ### `deep_merge_dict` ```python deep_merge_dict(dicta: dict, dictb: dict, path: list | None = None) -> dict ``` - Deep Merge Dictionary B into Dictionary A. Code is inspired by https://stackoverflow.com/a/7205107 - ### `str_to_bool` ```python str_to_bool(value: str) -> bool ``` - Convert a String to a Boolean - ### `get_flat_value` ```python get_flat_value(obj: Any, key: str, separator: str = '__') -> Any ``` - Query recursively an value defined in a flat notation (string), on a hierarchy of objects **Examples:** @@ -141,21 +125,18 @@ Query recursively an value defined in a flat notation (string), on a hierarchy o name__value module.object.value - ### `generate_request_filename` ```python generate_request_filename(request: httpx.Request) -> str ``` - Return a filename for a request sent to the Infrahub API This function is used when recording and playing back requests, as Infrahub is using a GraphQL API it's not possible to rely on the URL endpoint alone to separate one request from another, for this reason a hash of the payload is included in a filename. - ### `is_valid_url` ```python @@ -168,47 +149,38 @@ is_valid_url(url: str) -> bool get_branch(branch: str | None = None, directory: str | Path = '.') -> str ``` - If branch isn't provide, return the name of the local Git branch. - ### `dict_hash` ```python dict_hash(dictionary: dict[str, Any]) -> str ``` - MD5 hash of a dictionary. - ### `calculate_dict_depth` ```python calculate_dict_depth(data: dict, level: int = 1) -> int ``` - Calculate the depth of a nested Dictionary recursively. - ### `calculate_dict_height` ```python calculate_dict_height(data: dict, cnt: int = 0) -> int ``` - Calculate the number of fields (height) in a nested Dictionary recursively. - ### `extract_fields` ```python extract_fields(selection_set: SelectionSetNode | None) -> dict[str, dict] | None ``` - This function extract all the requested fields in a tree of Dict from a SelectionSetNode The goal of this function is to limit the fields that we need to query from the backend. @@ -219,7 +191,6 @@ it's better to have slightly more information at time passed to the query manage In the future we'll probably need to redesign how we read GraphQL queries to generate better Database query. - ### `extract_fields_first_node` ```python @@ -232,12 +203,10 @@ extract_fields_first_node(info: GraphQLResolveInfo) -> dict[str, dict] write_to_file(path: Path, value: Any) -> bool ``` - Write a given value into a file and return if the operation was successful. If the file does not exist, the function will attempt to create it. - ### `read_file` ```python @@ -256,6 +225,4 @@ get_user_permissions(data: list[dict]) -> dict calculate_time_diff(value: str) -> str | None ``` - Calculate the time in human format between a timedate in string format and now. - diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/uuidt.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/uuidt.mdx index f76b6555..47d3d8ae 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/uuidt.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/uuidt.mdx @@ -19,12 +19,10 @@ generate_uuid() -> str encode_number(number: int, min_length: int) -> str ``` - Encode a number into a base16 string and ensure the result has a minimum size. If the initial response produced doesn't match the min requirement, random number will be used to fill the gap - ## Classes ### `UUIDT` @@ -39,7 +37,6 @@ short(self) -> str Return the last 8 digit of the UUID (the most random part) - #### `new` ```python From ce543b87a919570e633b2f30ffdc238055c2d4ad Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Wed, 23 Jul 2025 15:59:07 +0200 Subject: [PATCH 11/24] ci: update the CI rule to fix linting on the generated documentation --- tasks.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/tasks.py b/tasks.py index 31bd98de..b75a6a25 100644 --- a/tasks.py +++ b/tasks.py @@ -7,7 +7,6 @@ from typing import Any from invoke import Context, task -from invoke.exceptions import UnexpectedExit CURRENT_DIRECTORY = Path(__file__).resolve() DOCUMENTATION_DIRECTORY = CURRENT_DIRECTORY.parent / "docs" @@ -270,18 +269,15 @@ def generate_sdk_api_docs(context: Context, output: str | None = None) -> None: output_dir = Path(output) if output else DOCUMENTATION_DIRECTORY / "docs" / "python-sdk" / "sdk_ref" + if not is_tool_installed("mdxify"): + print(" - mdxify is not installed, skipping documentation generation") + return + # Create a temporary directory to store the generated documentation with tempfile.TemporaryDirectory() as tmp_dir: # Generate the API documentation using mdxify and get flat file structure exec_cmd = f"mdxify --all --root-module infrahub_sdk --output-dir {tmp_dir}" - try: - context.run(exec_cmd, pty=True) - except UnexpectedExit as e: - if e.result.exited == 127: - print( - " - mdxify is not installed, probably due to the python version being outside its supported range." - ) - sys.exit(1) + context.run(exec_cmd, pty=True) # Remove current obsolete documentation file structure if (output_dir / "infrahub_sdk").exists(): @@ -304,3 +300,11 @@ def generate_sdk_api_docs(context: Context, output: str | None = None) -> None: # Move the file to the new location shutil.move(mdx_file, target_path) + + # Fix possible linting issues in the generated documentation + if not is_tool_installed("markdownlint-cli2"): + print(" - markdownlint-cli2 is not installed, skipping documentation linting") + return + + exec_cmd = f"markdownlint-cli2 {output_dir}/ --fix --config .markdownlint.yaml" + context.run(exec_cmd, pty=True) From 0619e370ed145d5f54dba17347d1a54936388de1 Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Wed, 23 Jul 2025 16:20:53 +0200 Subject: [PATCH 12/24] build: move mdxify to dev group in poetry --- poetry.lock | 8 ++++---- pyproject.toml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/poetry.lock b/poetry.lock index c6818a14..bbe5984c 100644 --- a/poetry.lock +++ b/poetry.lock @@ -220,7 +220,7 @@ files = [ {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, ] -markers = {main = "(extra == \"ctl\" or extra == \"all\") and platform_system == \"Windows\" or sys_platform == \"win32\" or python_version >= \"3.10\"", dev = "platform_system == \"Windows\" or sys_platform == \"win32\""} +markers = {main = "(extra == \"ctl\" or extra == \"all\") and platform_system == \"Windows\" or sys_platform == \"win32\"", dev = "platform_system == \"Windows\" or sys_platform == \"win32\" or python_version >= \"3.10\""} [[package]] name = "coverage" @@ -543,7 +543,7 @@ version = "1.8.0" description = "Signatures for entire Python programs. Extract the structure, the frame, the skeleton of your project, to generate API documentation or find breaking changes in your API." optional = false python-versions = ">=3.9" -groups = ["main"] +groups = ["dev"] markers = "python_version >= \"3.10\"" files = [ {file = "griffe-1.8.0-py3-none-any.whl", hash = "sha256:110faa744b2c5c84dd432f4fa9aa3b14805dd9519777dd55e8db214320593b02"}, @@ -943,7 +943,7 @@ version = "0.2.23" description = "Generate MDX API documentation from Python modules" optional = false python-versions = ">=3.10" -groups = ["main"] +groups = ["dev"] markers = "python_version >= \"3.10\"" files = [ {file = "mdxify-0.2.23-py3-none-any.whl", hash = "sha256:9e920bd01bc34f11f6e250cc7a926ed8ae8a29ea39cb4707a69700972965fc4b"}, @@ -2426,4 +2426,4 @@ tests = ["Jinja2", "pytest", "pyyaml", "rich"] [metadata] lock-version = "2.1" python-versions = "^3.9, <3.14" -content-hash = "cdca7035da908c2345cc19398c38c9370a590908321303ce23fa3d7f3a683e1d" +content-hash = "3be561b51687bf09fe7a2c6d5954cb158e474eb42b9388a65f3e3bc94cb15b6a" diff --git a/pyproject.toml b/pyproject.toml index 23089a9e..c96709f1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,9 +45,9 @@ dulwich = "^0.21.4" whenever = ">=0.7.2,<0.8.0" netutils = "^1.0.0" click = { version = "8.1.*", optional = true } -mdxify = {version = "^0.2.23", python = ">=3.10"} [tool.poetry.group.dev.dependencies] +mdxify = {version = "^0.2.23", python = ">=3.10"} pytest = "*" pytest-asyncio = "<0.23" pytest-clarity = "^1.0.1" From f733340295f4041f53bdf32fe8d99eac74a09f0e Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Thu, 24 Jul 2025 10:51:04 +0200 Subject: [PATCH 13/24] ci: update the CI rule to install markdownlint for properly fixing generated docs in invoke command --- .github/workflows/ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f080d97d..f2c087c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -208,6 +208,14 @@ jobs: run: "poetry install --no-interaction --no-ansi --extras ctl" - name: "Setup environment" run: "pip install invoke toml" + - name: Install Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "npm" + cache-dependency-path: "**/package-lock.json" + - name: Install markdown linter + run: npm install -g markdownlint-cli2 - name: "Generate SDK API documentation" run: ${{ env.DOCS_COMMAND }} - name: "Check if SDK API documentation needs to be refreshed" From d017fcfed08a0e2f96618141e4113b18556d7636 Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Thu, 24 Jul 2025 10:54:34 +0200 Subject: [PATCH 14/24] ci: troubleshoot CI rule --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2c087c1..c8b303ab 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -220,7 +220,7 @@ jobs: run: ${{ env.DOCS_COMMAND }} - name: "Check if SDK API documentation needs to be refreshed" run: | - git diff --quiet ${SDK_API_DOCS_DIR} + git diff ${SDK_API_DOCS_DIR} validate-documentation-style: if: | From 0703af885d910103c958435a1e340de238234fcc Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Thu, 24 Jul 2025 13:59:17 +0200 Subject: [PATCH 15/24] docs: update docs after rebase --- .../sdk_ref/infrahub_sdk/ctl/utils.mdx | 4 +-- .../infrahub_sdk/node/relationship.mdx | 30 +++++++++---------- .../python-sdk/sdk_ref/infrahub_sdk/yaml.mdx | 14 ++++----- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx index 875d298d..a8727bd3 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx @@ -73,13 +73,13 @@ Get the directory which stores fixtures that are common to multiple unit/integra load_yamlfile_from_disk_and_exit(paths: list[Path], file_type: type[YamlFileVar], console: Console) -> list[YamlFileVar] ``` -### `display_object_validate_format_success` +### `display_object_validate_format_success` ```python display_object_validate_format_success(file: ObjectFile, console: Console) -> None ``` -### `display_object_validate_format_error` +### `display_object_validate_format_error` ```python display_object_validate_format_error(file: ObjectFile, error: ValidationError, console: Console) -> None diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx index 7de5278d..4db44128 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx @@ -7,49 +7,49 @@ sidebarTitle: relationship ## Classes -### `RelationshipManagerBase` +### `RelationshipManagerBase` Base class for RelationshipManager and RelationshipManagerSync **Methods:** -#### `peer_ids` +#### `peer_ids` ```python peer_ids(self) -> list[str] ``` -#### `peer_hfids` +#### `peer_hfids` ```python peer_hfids(self) -> list[list[Any]] ``` -#### `peer_hfids_str` +#### `peer_hfids_str` ```python peer_hfids_str(self) -> list[str] ``` -#### `has_update` +#### `has_update` ```python has_update(self) -> bool ``` -### `RelationshipManager` +### `RelationshipManager` Manages relationships of a node in an asynchronous context. **Methods:** -#### `fetch` +#### `fetch` ```python fetch(self) -> None ``` -#### `add` +#### `add` ```python add(self, data: str | RelatedNode | dict) -> None @@ -57,7 +57,7 @@ add(self, data: str | RelatedNode | dict) -> None Add a new peer to this relationship. -#### `extend` +#### `extend` ```python extend(self, data: Iterable[str | RelatedNode | dict]) -> None @@ -65,25 +65,25 @@ extend(self, data: Iterable[str | RelatedNode | dict]) -> None Add new peers to this relationship. -#### `remove` +#### `remove` ```python remove(self, data: str | RelatedNode | dict) -> None ``` -### `RelationshipManagerSync` +### `RelationshipManagerSync` Manages relationships of a node in a synchronous context. **Methods:** -#### `fetch` +#### `fetch` ```python fetch(self) -> None ``` -#### `add` +#### `add` ```python add(self, data: str | RelatedNodeSync | dict) -> None @@ -91,7 +91,7 @@ add(self, data: str | RelatedNodeSync | dict) -> None Add a new peer to this relationship. -#### `extend` +#### `extend` ```python extend(self, data: Iterable[str | RelatedNodeSync | dict]) -> None @@ -99,7 +99,7 @@ extend(self, data: Iterable[str | RelatedNodeSync | dict]) -> None Add new peers to this relationship. -#### `remove` +#### `remove` ```python remove(self, data: str | RelatedNodeSync | dict) -> None diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/yaml.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/yaml.mdx index 8b44f711..40af0a2c 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/yaml.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/yaml.mdx @@ -49,39 +49,39 @@ load_file_from_disk(cls, path: Path) -> list[Self] load_from_disk(cls, paths: list[Path]) -> list[Self] ``` -### `InfrahubFile` +### `InfrahubFile` **Methods:** -#### `data` +#### `data` ```python data(self) -> InfrahubFileData ``` -#### `version` +#### `version` ```python version(self) -> InfrahubFileApiVersion ``` -#### `kind` +#### `kind` ```python kind(self) -> InfrahubFileKind ``` -#### `validate_content` +#### `validate_content` ```python validate_content(self) -> None ``` -### `SchemaFile` +### `SchemaFile` **Methods:** -#### `payload` +#### `payload` ```python payload(self) -> dict[str, Any] From 9f994406ead2ba647e31853a8c926d30bcbd54e6 Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Thu, 24 Jul 2025 14:01:44 +0200 Subject: [PATCH 16/24] ci: resume git diff check --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c8b303ab..f2c087c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -220,7 +220,7 @@ jobs: run: ${{ env.DOCS_COMMAND }} - name: "Check if SDK API documentation needs to be refreshed" run: | - git diff ${SDK_API_DOCS_DIR} + git diff --quiet ${SDK_API_DOCS_DIR} validate-documentation-style: if: | From ed095d24de11319c7217fd5d15481c998d35443c Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Fri, 25 Jul 2025 09:53:16 +0200 Subject: [PATCH 17/24] ci: exclude the newly generated documentation from vale inspection --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2c087c1..23a52258 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -245,7 +245,7 @@ jobs: env: VALE_VERSION: ${{ env.VALE_VERSION }} - name: "Validate documentation style" - run: ./vale $(find ./docs -type f \( -name "*.mdx" -o -name "*.md" \) ) + run: ./vale $(find ./docs -type d -name sdk_ref -prune -o -type f \( -name "*.mdx" -o -name "*.md" \) ) unit-tests: env: From fb08b5f5ab3fde57bc5305e5bf2abe2a04f86464 Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Fri, 25 Jul 2025 09:54:39 +0200 Subject: [PATCH 18/24] docs: update API docs after rebasing --- .../infrahub_sdk/node/relationship.mdx | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx index 4db44128..50d9a31c 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx @@ -7,49 +7,49 @@ sidebarTitle: relationship ## Classes -### `RelationshipManagerBase` +### `RelationshipManagerBase` Base class for RelationshipManager and RelationshipManagerSync **Methods:** -#### `peer_ids` +#### `peer_ids` ```python peer_ids(self) -> list[str] ``` -#### `peer_hfids` +#### `peer_hfids` ```python peer_hfids(self) -> list[list[Any]] ``` -#### `peer_hfids_str` +#### `peer_hfids_str` ```python peer_hfids_str(self) -> list[str] ``` -#### `has_update` +#### `has_update` ```python has_update(self) -> bool ``` -### `RelationshipManager` +### `RelationshipManager` Manages relationships of a node in an asynchronous context. **Methods:** -#### `fetch` +#### `fetch` ```python fetch(self) -> None ``` -#### `add` +#### `add` ```python add(self, data: str | RelatedNode | dict) -> None @@ -57,7 +57,7 @@ add(self, data: str | RelatedNode | dict) -> None Add a new peer to this relationship. -#### `extend` +#### `extend` ```python extend(self, data: Iterable[str | RelatedNode | dict]) -> None @@ -65,25 +65,25 @@ extend(self, data: Iterable[str | RelatedNode | dict]) -> None Add new peers to this relationship. -#### `remove` +#### `remove` ```python remove(self, data: str | RelatedNode | dict) -> None ``` -### `RelationshipManagerSync` +### `RelationshipManagerSync` Manages relationships of a node in a synchronous context. **Methods:** -#### `fetch` +#### `fetch` ```python fetch(self) -> None ``` -#### `add` +#### `add` ```python add(self, data: str | RelatedNodeSync | dict) -> None @@ -91,7 +91,7 @@ add(self, data: str | RelatedNodeSync | dict) -> None Add a new peer to this relationship. -#### `extend` +#### `extend` ```python extend(self, data: Iterable[str | RelatedNodeSync | dict]) -> None @@ -99,7 +99,7 @@ extend(self, data: Iterable[str | RelatedNodeSync | dict]) -> None Add new peers to this relationship. -#### `remove` +#### `remove` ```python remove(self, data: str | RelatedNodeSync | dict) -> None From 4980873f8dbf378001baf3ede8ffba53b0de422d Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Fri, 25 Jul 2025 09:59:08 +0200 Subject: [PATCH 19/24] ci: fine tune find command --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 23a52258..f5fa441a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -245,7 +245,7 @@ jobs: env: VALE_VERSION: ${{ env.VALE_VERSION }} - name: "Validate documentation style" - run: ./vale $(find ./docs -type d -name sdk_ref -prune -o -type f \( -name "*.mdx" -o -name "*.md" \) ) + run: ./vale $(find ./docs -type d -name sdk_ref -prune -false -o -type f \( -name "*.mdx" -o -name "*.md" \) ) unit-tests: env: From e101d9ae8e1c484486857ed5d261e93ff9e10aab Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Fri, 25 Jul 2025 10:21:51 +0200 Subject: [PATCH 20/24] chore: add towncrier changelog fragment for #201 --- changelog/201.added.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/201.added.md diff --git a/changelog/201.added.md b/changelog/201.added.md new file mode 100644 index 00000000..b64cb2fa --- /dev/null +++ b/changelog/201.added.md @@ -0,0 +1 @@ +Add support for automatic Python SDK API from docstrings in the code. \ No newline at end of file From 9f13b948cc5b3f7a245ab1a24eabd13d41eca22a Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Mon, 28 Jul 2025 13:55:26 +0200 Subject: [PATCH 21/24] docs: relocate the API reference on the sidebar --- docs/sidebars-python-sdk.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/sidebars-python-sdk.ts b/docs/sidebars-python-sdk.ts index dd80eb72..49d7a606 100644 --- a/docs/sidebars-python-sdk.ts +++ b/docs/sidebars-python-sdk.ts @@ -37,18 +37,18 @@ const sidebars: SidebarsConfig = { }, { type: 'category', - label: 'SDK References', + label: 'Reference', items: [ { - type: 'autogenerated', - dirName: 'sdk_ref', + type: 'category', + label: 'Python SDK API', + items: [ + { + type: 'autogenerated', + dirName: 'sdk_ref', + }, + ], }, - ], - }, - { - type: 'category', - label: 'Reference', - items: [ 'reference/config', 'reference/templating', ], From 59a76454d15625e998aec75a2f863b3c81d4e852 Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Fri, 1 Aug 2025 13:04:56 +0200 Subject: [PATCH 22/24] refactor: update invoke task for generate API docs --- tasks.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tasks.py b/tasks.py index b75a6a25..93cbd2c4 100644 --- a/tasks.py +++ b/tasks.py @@ -262,6 +262,12 @@ def generate_python_sdk(context: Context) -> None: # noqa: ARG001 def generate_sdk_api_docs(context: Context, output: str | None = None) -> None: """Generate API documentation for the Python SDK.""" + # This is the list of code modules to generate documentation for. + MODULES_LIST = [ + "infrahub_sdk.client", + "infrahub_sdk.node.node", + ] + import operator import shutil import tempfile @@ -276,7 +282,7 @@ def generate_sdk_api_docs(context: Context, output: str | None = None) -> None: # Create a temporary directory to store the generated documentation with tempfile.TemporaryDirectory() as tmp_dir: # Generate the API documentation using mdxify and get flat file structure - exec_cmd = f"mdxify --all --root-module infrahub_sdk --output-dir {tmp_dir}" + exec_cmd = f"mdxify {' '.join(MODULES_LIST)} --output-dir {tmp_dir}" context.run(exec_cmd, pty=True) # Remove current obsolete documentation file structure From cf303090253b634b726c03d4b75d2d6fabd9a26b Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Fri, 1 Aug 2025 13:05:25 +0200 Subject: [PATCH 23/24] docs: update the documentation to only a specified subset --- .../sdk_ref/infrahub_sdk/analyzer.mdx | 68 ---- .../sdk_ref/infrahub_sdk/async_typer.mdx | 30 -- .../python-sdk/sdk_ref/infrahub_sdk/batch.mdx | 74 ---- .../sdk_ref/infrahub_sdk/branch.mdx | 150 -------- .../sdk_ref/infrahub_sdk/checks.mdx | 93 ----- .../sdk_ref/infrahub_sdk/client.mdx | 198 +++++------ .../sdk_ref/infrahub_sdk/config.mdx | 86 ----- .../sdk_ref/infrahub_sdk/constants.mdx | 10 - .../sdk_ref/infrahub_sdk/context.mdx | 14 - .../sdk_ref/infrahub_sdk/ctl/branch.mdx | 66 ---- .../sdk_ref/infrahub_sdk/ctl/check.mdx | 58 --- .../sdk_ref/infrahub_sdk/ctl/cli.mdx | 8 - .../sdk_ref/infrahub_sdk/ctl/cli_commands.mdx | 78 ---- .../sdk_ref/infrahub_sdk/ctl/client.mdx | 20 -- .../sdk_ref/infrahub_sdk/ctl/config.mdx | 59 ---- .../sdk_ref/infrahub_sdk/ctl/exceptions.mdx | 14 - .../sdk_ref/infrahub_sdk/ctl/exporter.mdx | 22 -- .../sdk_ref/infrahub_sdk/ctl/generator.mdx | 20 -- .../sdk_ref/infrahub_sdk/ctl/importer.mdx | 22 -- .../sdk_ref/infrahub_sdk/ctl/menu.mdx | 32 -- .../sdk_ref/infrahub_sdk/ctl/object.mdx | 32 -- .../sdk_ref/infrahub_sdk/ctl/parameters.mdx | 16 - .../sdk_ref/infrahub_sdk/ctl/render.mdx | 20 -- .../sdk_ref/infrahub_sdk/ctl/repository.mdx | 44 --- .../sdk_ref/infrahub_sdk/ctl/schema.mdx | 62 ---- .../sdk_ref/infrahub_sdk/ctl/transform.mdx | 14 - .../sdk_ref/infrahub_sdk/ctl/utils.mdx | 86 ----- .../sdk_ref/infrahub_sdk/ctl/validate.mdx | 32 -- .../python-sdk/sdk_ref/infrahub_sdk/data.mdx | 20 -- .../python-sdk/sdk_ref/infrahub_sdk/diff.mdx | 30 -- .../sdk_ref/infrahub_sdk/exceptions.mdx | 60 ---- .../sdk_ref/infrahub_sdk/generator.mdx | 64 ---- .../sdk_ref/infrahub_sdk/graphql.mdx | 68 ---- .../sdk_ref/infrahub_sdk/groups.mdx | 14 - .../sdk_ref/infrahub_sdk/jinja2.mdx | 18 - .../sdk_ref/infrahub_sdk/node/attribute.mdx | 26 -- .../sdk_ref/infrahub_sdk/node/constants.mdx | 8 - .../sdk_ref/infrahub_sdk/node/node.mdx | 90 ++--- .../sdk_ref/infrahub_sdk/node/parsers.mdx | 16 - .../sdk_ref/infrahub_sdk/node/property.mdx | 12 - .../infrahub_sdk/node/related_node.mdx | 110 ------ .../infrahub_sdk/node/relationship.mdx | 106 ------ .../sdk_ref/infrahub_sdk/object_store.mdx | 42 --- .../sdk_ref/infrahub_sdk/operation.mdx | 50 --- .../sdk_ref/infrahub_sdk/playback.mdx | 24 -- .../sdk_ref/infrahub_sdk/protocols.mdx | 332 ------------------ .../sdk_ref/infrahub_sdk/protocols_base.mdx | 272 -------------- .../protocols_generator/constants.mdx | 8 - .../protocols_generator/generator.mdx | 34 -- .../infrahub_sdk/pytest_plugin/exceptions.mdx | 30 -- .../infrahub_sdk/pytest_plugin/items/base.mdx | 61 ---- .../pytest_plugin/items/check.mdx | 60 ---- .../pytest_plugin/items/graphql_query.mdx | 50 --- .../pytest_plugin/items/jinja2_transform.mdx | 78 ---- .../pytest_plugin/items/python_transform.mdx | 60 ---- .../infrahub_sdk/pytest_plugin/loader.mdx | 34 -- .../infrahub_sdk/pytest_plugin/models.mdx | 93 ----- .../infrahub_sdk/pytest_plugin/plugin.mdx | 32 -- .../infrahub_sdk/pytest_plugin/utils.mdx | 14 - .../sdk_ref/infrahub_sdk/queries.mdx | 14 - .../sdk_ref/infrahub_sdk/query_groups.mdx | 131 ------- .../sdk_ref/infrahub_sdk/recorder.mdx | 50 --- .../sdk_ref/infrahub_sdk/repository.mdx | 24 -- .../sdk_ref/infrahub_sdk/schema/main.mdx | 204 ----------- .../infrahub_sdk/schema/repository.mdx | 156 -------- .../sdk_ref/infrahub_sdk/spec/menu.mdx | 34 -- .../sdk_ref/infrahub_sdk/spec/object.mdx | 170 --------- .../python-sdk/sdk_ref/infrahub_sdk/store.mdx | 193 ---------- .../sdk_ref/infrahub_sdk/task/constants.mdx | 8 - .../sdk_ref/infrahub_sdk/task/exceptions.mdx | 16 - .../sdk_ref/infrahub_sdk/task/manager.mdx | 262 -------------- .../sdk_ref/infrahub_sdk/task/models.mdx | 34 -- .../infrahub_sdk/template/exceptions.mdx | 18 - .../sdk_ref/infrahub_sdk/template/filters.mdx | 10 - .../sdk_ref/infrahub_sdk/template/models.mdx | 10 - .../sdk_ref/infrahub_sdk/testing/docker.mdx | 34 -- .../infrahub_sdk/testing/repository.mdx | 46 --- .../infrahub_sdk/testing/schemas/animal.mdx | 90 ----- .../testing/schemas/car_person.mdx | 138 -------- .../sdk_ref/infrahub_sdk/timestamp.mdx | 60 ---- .../sdk_ref/infrahub_sdk/topological_sort.mdx | 32 -- .../infrahub_sdk/transfer/constants.mdx | 8 - .../infrahub_sdk/transfer/exceptions.mdx | 18 - .../transfer/exporter/interface.mdx | 18 - .../infrahub_sdk/transfer/exporter/json.mdx | 36 -- .../transfer/importer/interface.mdx | 18 - .../infrahub_sdk/transfer/importer/json.mdx | 48 --- .../infrahub_sdk/transfer/schema_sorter.mdx | 18 - .../sdk_ref/infrahub_sdk/transforms.mdx | 48 --- .../python-sdk/sdk_ref/infrahub_sdk/types.mdx | 70 ---- .../python-sdk/sdk_ref/infrahub_sdk/utils.mdx | 228 ------------ .../python-sdk/sdk_ref/infrahub_sdk/uuidt.mdx | 44 --- .../python-sdk/sdk_ref/infrahub_sdk/yaml.mdx | 88 ----- 93 files changed, 144 insertions(+), 5576 deletions(-) delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/analyzer.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/async_typer.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/batch.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/branch.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/checks.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/config.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/constants.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/context.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/branch.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/check.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli_commands.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/client.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/config.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exceptions.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exporter.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/generator.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/importer.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/menu.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/object.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/parameters.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/render.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/repository.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/schema.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/transform.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/validate.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/data.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/diff.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/exceptions.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/generator.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/graphql.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/groups.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/jinja2.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/attribute.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/constants.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/parsers.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/property.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/related_node.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/object_store.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/operation.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/playback.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_base.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/constants.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/generator.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/exceptions.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/base.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/check.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/graphql_query.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/jinja2_transform.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/python_transform.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/loader.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/models.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/plugin.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/utils.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/queries.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/query_groups.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/recorder.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/repository.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/main.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/repository.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/menu.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/object.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/store.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/constants.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/exceptions.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/manager.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/models.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/exceptions.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/filters.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/models.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/docker.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/repository.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/schemas/animal.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/schemas/car_person.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/timestamp.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/topological_sort.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/constants.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exceptions.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exporter/interface.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exporter/json.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/importer/interface.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/importer/json.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/schema_sorter.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/transforms.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/types.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/utils.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/uuidt.mdx delete mode 100644 docs/docs/python-sdk/sdk_ref/infrahub_sdk/yaml.mdx diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/analyzer.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/analyzer.mdx deleted file mode 100644 index ffd5047f..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/analyzer.mdx +++ /dev/null @@ -1,68 +0,0 @@ ---- -title: analyzer -sidebarTitle: analyzer ---- - -# `infrahub_sdk.analyzer` - -## Classes - -### `GraphQLQueryVariable` - -### `GraphQLOperation` - -### `GraphQLQueryAnalyzer` - -**Methods:** - -#### `is_valid` - -```python -is_valid(self) -> tuple[bool, list[GraphQLError] | None] -``` - -#### `nbr_queries` - -```python -nbr_queries(self) -> int -``` - -#### `operations` - -```python -operations(self) -> list[GraphQLOperation] -``` - -#### `contains_mutation` - -```python -contains_mutation(self) -> bool -``` - -#### `variables` - -```python -variables(self) -> list[GraphQLQueryVariable] -``` - -#### `calculate_depth` - -```python -calculate_depth(self) -> int -``` - -Number of nested levels in the query - -#### `calculate_height` - -```python -calculate_height(self) -> int -``` - -Total number of fields requested in the query - -#### `get_fields` - -```python -get_fields(self) -> dict[str, Any] -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/async_typer.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/async_typer.mdx deleted file mode 100644 index c6152a93..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/async_typer.mdx +++ /dev/null @@ -1,30 +0,0 @@ ---- -title: async_typer -sidebarTitle: async_typer ---- - -# `infrahub_sdk.async_typer` - -## Classes - -### `AsyncTyper` - -**Methods:** - -#### `maybe_run_async` - -```python -maybe_run_async(decorator: Callable, func: Callable) -> Any -``` - -#### `callback` - -```python -callback(self, *args: Any, **kwargs: Any) -> Any -``` - -#### `command` - -```python -command(self, *args: Any, **kwargs: Any) -> Any -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/batch.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/batch.mdx deleted file mode 100644 index 7cee706a..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/batch.mdx +++ /dev/null @@ -1,74 +0,0 @@ ---- -title: batch -sidebarTitle: batch ---- - -# `infrahub_sdk.batch` - -## Functions - -### `execute_batch_task_in_pool` - -```python -execute_batch_task_in_pool(task: BatchTask, semaphore: asyncio.Semaphore, return_exceptions: bool = False) -> tuple[InfrahubNode | None, Any] -``` - -## Classes - -### `BatchTask` - -### `BatchTaskSync` - -**Methods:** - -#### `execute` - -```python -execute(self, return_exceptions: bool = False) -> tuple[InfrahubNodeSync | None, Any] -``` - -Executes the stored task. - -### `InfrahubBatch` - -**Methods:** - -#### `num_tasks` - -```python -num_tasks(self) -> int -``` - -#### `add` - -```python -add(self, *args: Any, **kwargs: Any) -> None -``` - -#### `execute` - -```python -execute(self) -> AsyncGenerator -``` - -### `InfrahubBatchSync` - -**Methods:** - -#### `num_tasks` - -```python -num_tasks(self) -> int -``` - -#### `add` - -```python -add(self, *args: Any, **kwargs: Any) -> None -``` - -#### `execute` - -```python -execute(self) -> Generator[tuple[InfrahubNodeSync | None, Any], None, None] -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/branch.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/branch.mdx deleted file mode 100644 index c3e9db56..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/branch.mdx +++ /dev/null @@ -1,150 +0,0 @@ ---- -title: branch -sidebarTitle: branch ---- - -# `infrahub_sdk.branch` - -## Classes - -### `BranchData` - -### `InfraHubBranchManagerBase` - -**Methods:** - -#### `generate_diff_data_url` - -```python -generate_diff_data_url(cls, client: InfrahubClient | InfrahubClientSync, branch_name: str, branch_only: bool = True, time_from: str | None = None, time_to: str | None = None) -> str -``` - -Generate the URL for the diff_data function. - -### `InfrahubBranchManager` - -**Methods:** - -#### `create` - -```python -create(self, branch_name: str, sync_with_git: bool = True, description: str = '', wait_until_completion: Literal[True] = True, background_execution: bool | None = False) -> BranchData -``` - -#### `create` - -```python -create(self, branch_name: str, sync_with_git: bool = True, description: str = '', wait_until_completion: Literal[False] = False, background_execution: bool | None = False) -> str -``` - -#### `create` - -```python -create(self, branch_name: str, sync_with_git: bool = True, description: str = '', wait_until_completion: bool = True, background_execution: bool | None = False) -> BranchData | str -``` - -#### `delete` - -```python -delete(self, branch_name: str) -> bool -``` - -#### `rebase` - -```python -rebase(self, branch_name: str) -> BranchData -``` - -#### `validate` - -```python -validate(self, branch_name: str) -> BranchData -``` - -#### `merge` - -```python -merge(self, branch_name: str) -> bool -``` - -#### `all` - -```python -all(self) -> dict[str, BranchData] -``` - -#### `get` - -```python -get(self, branch_name: str) -> BranchData -``` - -#### `diff_data` - -```python -diff_data(self, branch_name: str, branch_only: bool = True, time_from: str | None = None, time_to: str | None = None) -> dict[Any, Any] -``` - -### `InfrahubBranchManagerSync` - -**Methods:** - -#### `all` - -```python -all(self) -> dict[str, BranchData] -``` - -#### `get` - -```python -get(self, branch_name: str) -> BranchData -``` - -#### `create` - -```python -create(self, branch_name: str, sync_with_git: bool = True, description: str = '', wait_until_completion: Literal[True] = True, background_execution: bool | None = False) -> BranchData -``` - -#### `create` - -```python -create(self, branch_name: str, sync_with_git: bool = True, description: str = '', wait_until_completion: Literal[False] = False, background_execution: bool | None = False) -> str -``` - -#### `create` - -```python -create(self, branch_name: str, sync_with_git: bool = True, description: str = '', wait_until_completion: bool = True, background_execution: bool | None = False) -> BranchData | str -``` - -#### `delete` - -```python -delete(self, branch_name: str) -> bool -``` - -#### `diff_data` - -```python -diff_data(self, branch_name: str, branch_only: bool = True, time_from: str | None = None, time_to: str | None = None) -> dict[Any, Any] -``` - -#### `merge` - -```python -merge(self, branch_name: str) -> bool -``` - -#### `rebase` - -```python -rebase(self, branch_name: str) -> BranchData -``` - -#### `validate` - -```python -validate(self, branch_name: str) -> BranchData -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/checks.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/checks.mdx deleted file mode 100644 index 8905dac9..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/checks.mdx +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: checks -sidebarTitle: checks ---- - -# `infrahub_sdk.checks` - -## Classes - -### `InfrahubCheckInitializer` - -Information about the originator of the check. - -### `InfrahubCheck` - -**Methods:** - -#### `client` - -```python -client(self) -> InfrahubClient -``` - -#### `client` - -```python -client(self, value: InfrahubClient) -> None -``` - -#### `init` - -```python -init(cls, client: InfrahubClient | None = None, *args: Any, **kwargs: Any) -> InfrahubCheck -``` - -Async init method, If an existing InfrahubClient client hasn't been provided, one will be created automatically. - -#### `errors` - -```python -errors(self) -> list[dict[str, Any]] -``` - -#### `log_error` - -```python -log_error(self, message: str, object_id: str | None = None, object_type: str | None = None) -> None -``` - -#### `log_info` - -```python -log_info(self, message: str, object_id: str | None = None, object_type: str | None = None) -> None -``` - -#### `log_entries` - -```python -log_entries(self) -> str -``` - -#### `branch_name` - -```python -branch_name(self) -> str -``` - -Return the name of the current git branch. - -#### `validate` - -```python -validate(self, data: dict) -> None -``` - -Code to validate the status of this check. - -#### `collect_data` - -```python -collect_data(self) -> dict -``` - -Query the result of the GraphQL Query defined in self.query and return the result - -#### `run` - -```python -run(self, data: dict | None = None) -> bool -``` - -Execute the check after collecting the data from the GraphQL query. -The result of the check is determined based on the presence or not of ERROR log messages. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx index e83112f6..94f25565 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/client.mdx @@ -7,13 +7,13 @@ sidebarTitle: client ## Functions -### `handle_relogin` +### `handle_relogin` ```python handle_relogin(func: Callable[..., Coroutine[Any, Any, httpx.Response]]) ``` -### `handle_relogin_sync` +### `handle_relogin_sync` ```python handle_relogin_sync(func: Callable[..., httpx.Response]) @@ -21,47 +21,47 @@ handle_relogin_sync(func: Callable[..., httpx.Response]) ## Classes -### `ProcessRelationsNode` +### `ProcessRelationsNode` -### `ProcessRelationsNodeSync` +### `ProcessRelationsNodeSync` -### `BaseClient` +### `BaseClient` Base class for InfrahubClient and InfrahubClientSync **Methods:** -#### `request_context` +#### `request_context` ```python request_context(self) -> RequestContext | None ``` -#### `request_context` +#### `request_context` ```python request_context(self, request_context: RequestContext) -> None ``` -#### `start_tracking` +#### `start_tracking` ```python start_tracking(self, identifier: str | None = None, params: dict[str, Any] | None = None, delete_unused_nodes: bool = False, group_type: str | None = None, group_params: dict[str, Any] | None = None, branch: str | None = None) -> Self ``` -#### `set_context_properties` +#### `set_context_properties` ```python set_context_properties(self, identifier: str, params: dict[str, str] | None = None, delete_unused_nodes: bool = True, reset: bool = True, group_type: str | None = None, group_params: dict[str, Any] | None = None, branch: str | None = None) -> None ``` -### `InfrahubClient` +### `InfrahubClient` GraphQL Client to interact with Infrahub. **Methods:** -#### `get_version` +#### `get_version` ```python get_version(self) -> str @@ -69,7 +69,7 @@ get_version(self) -> str Return the Infrahub version. -#### `get_user` +#### `get_user` ```python get_user(self) -> dict @@ -77,7 +77,7 @@ get_user(self) -> dict Return user information -#### `get_user_permissions` +#### `get_user_permissions` ```python get_user_permissions(self) -> dict @@ -85,73 +85,73 @@ get_user_permissions(self) -> dict Return user permissions -#### `create` +#### `create` ```python create(self, kind: str, data: dict | None = ..., branch: str | None = ..., **kwargs: Any) -> InfrahubNode ``` -#### `create` +#### `create` ```python create(self, kind: type[SchemaType], data: dict | None = ..., branch: str | None = ..., **kwargs: Any) -> SchemaType ``` -#### `create` +#### `create` ```python create(self, kind: str | type[SchemaType], data: dict | None = None, branch: str | None = None, timeout: int | None = None, **kwargs: Any) -> InfrahubNode | SchemaType ``` -#### `delete` +#### `delete` ```python delete(self, kind: str | type[SchemaType], id: str, branch: str | None = None) -> None ``` -#### `get` +#### `get` ```python get(self, kind: type[SchemaType], raise_when_missing: Literal[False], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> SchemaType | None ``` -#### `get` +#### `get` ```python get(self, kind: type[SchemaType], raise_when_missing: Literal[True], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> SchemaType ``` -#### `get` +#### `get` ```python get(self, kind: type[SchemaType], raise_when_missing: bool = ..., at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> SchemaType ``` -#### `get` +#### `get` ```python get(self, kind: str, raise_when_missing: Literal[False], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> InfrahubNode | None ``` -#### `get` +#### `get` ```python get(self, kind: str, raise_when_missing: Literal[True], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> InfrahubNode ``` -#### `get` +#### `get` ```python get(self, kind: str, raise_when_missing: bool = ..., at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> InfrahubNode ``` -#### `get` +#### `get` ```python get(self, kind: str | type[SchemaType], raise_when_missing: bool = True, at: Timestamp | None = None, branch: str | None = None, timeout: int | None = None, id: str | None = None, hfid: list[str] | None = None, include: list[str] | None = None, exclude: list[str] | None = None, populate_store: bool = True, fragment: bool = False, prefetch_relationships: bool = False, property: bool = False, **kwargs: Any) -> InfrahubNode | SchemaType | None ``` -#### `count` +#### `count` ```python count(self, kind: str | type[SchemaType], at: Timestamp | None = None, branch: str | None = None, timeout: int | None = None, partial_match: bool = False, **kwargs: Any) -> int @@ -159,19 +159,19 @@ count(self, kind: str | type[SchemaType], at: Timestamp | None = None, branch: s Return the number of nodes of a given kind. -#### `all` +#### `all` ```python all(self, kind: type[SchemaType], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., populate_store: bool = ..., offset: int | None = ..., limit: int | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., parallel: bool = ..., order: Order | None = ...) -> list[SchemaType] ``` -#### `all` +#### `all` ```python all(self, kind: str, at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., populate_store: bool = ..., offset: int | None = ..., limit: int | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., parallel: bool = ..., order: Order | None = ...) -> list[InfrahubNode] ``` -#### `all` +#### `all` ```python all(self, kind: str | type[SchemaType], at: Timestamp | None = None, branch: str | None = None, timeout: int | None = None, populate_store: bool = True, offset: int | None = None, limit: int | None = None, include: list[str] | None = None, exclude: list[str] | None = None, fragment: bool = False, prefetch_relationships: bool = False, property: bool = False, parallel: bool = False, order: Order | None = None) -> list[InfrahubNode] | list[SchemaType] @@ -199,19 +199,19 @@ Retrieve all nodes of a given kind - list\[InfrahubNode]: List of Nodes -#### `filters` +#### `filters` ```python filters(self, kind: type[SchemaType], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., populate_store: bool = ..., offset: int | None = ..., limit: int | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., fragment: bool = ..., prefetch_relationships: bool = ..., partial_match: bool = ..., property: bool = ..., parallel: bool = ..., order: Order | None = ..., **kwargs: Any) -> list[SchemaType] ``` -#### `filters` +#### `filters` ```python filters(self, kind: str, at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., populate_store: bool = ..., offset: int | None = ..., limit: int | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., fragment: bool = ..., prefetch_relationships: bool = ..., partial_match: bool = ..., property: bool = ..., parallel: bool = ..., order: Order | None = ..., **kwargs: Any) -> list[InfrahubNode] ``` -#### `filters` +#### `filters` ```python filters(self, kind: str | type[SchemaType], at: Timestamp | None = None, branch: str | None = None, timeout: int | None = None, populate_store: bool = True, offset: int | None = None, limit: int | None = None, include: list[str] | None = None, exclude: list[str] | None = None, fragment: bool = False, prefetch_relationships: bool = False, partial_match: bool = False, property: bool = False, parallel: bool = False, order: Order | None = None, **kwargs: Any) -> list[InfrahubNode] | list[SchemaType] @@ -241,7 +241,7 @@ Retrieve nodes of a given kind based on provided filters. - list\[InfrahubNodeSync]: List of Nodes that match the given filters. -#### `clone` +#### `clone` ```python clone(self, branch: str | None = None) -> InfrahubClient @@ -249,7 +249,7 @@ clone(self, branch: str | None = None) -> InfrahubClient Return a cloned version of the client using the same configuration -#### `execute_graphql` +#### `execute_graphql` ```python execute_graphql(self, query: str, variables: dict | None = None, branch_name: str | None = None, at: str | Timestamp | None = None, timeout: int | None = None, raise_for_error: bool = True, tracker: str | None = None) -> dict @@ -274,67 +274,67 @@ Raises: - _description_ -#### `refresh_login` +#### `refresh_login` ```python refresh_login(self) -> None ``` -#### `login` +#### `login` ```python login(self, refresh: bool = False) -> None ``` -#### `query_gql_query` +#### `query_gql_query` ```python query_gql_query(self, name: str, variables: dict | None = None, update_group: bool = False, subscribers: list[str] | None = None, params: dict | None = None, branch_name: str | None = None, at: str | None = None, timeout: int | None = None, tracker: str | None = None, raise_for_error: bool = True) -> dict ``` -#### `get_diff_summary` +#### `get_diff_summary` ```python get_diff_summary(self, branch: str, timeout: int | None = None, tracker: str | None = None, raise_for_error: bool = True) -> list[NodeDiff] ``` -#### `allocate_next_ip_address` +#### `allocate_next_ip_address` ```python allocate_next_ip_address(self, resource_pool: CoreNode, kind: type[SchemaType], identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[True] = True) -> SchemaType ``` -#### `allocate_next_ip_address` +#### `allocate_next_ip_address` ```python allocate_next_ip_address(self, resource_pool: CoreNode, kind: type[SchemaType], identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[False] = False) -> SchemaType | None ``` -#### `allocate_next_ip_address` +#### `allocate_next_ip_address` ```python allocate_next_ip_address(self, resource_pool: CoreNode, kind: type[SchemaType], identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: bool = ...) -> SchemaType ``` -#### `allocate_next_ip_address` +#### `allocate_next_ip_address` ```python allocate_next_ip_address(self, resource_pool: CoreNode, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[True] = True) -> CoreNode ``` -#### `allocate_next_ip_address` +#### `allocate_next_ip_address` ```python allocate_next_ip_address(self, resource_pool: CoreNode, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[False] = False) -> CoreNode | None ``` -#### `allocate_next_ip_address` +#### `allocate_next_ip_address` ```python allocate_next_ip_address(self, resource_pool: CoreNode, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: bool = ...) -> CoreNode | None ``` -#### `allocate_next_ip_address` +#### `allocate_next_ip_address` ```python allocate_next_ip_address(self, resource_pool: CoreNode, kind: type[SchemaType] | None = None, identifier: str | None = None, prefix_length: int | None = None, address_type: str | None = None, data: dict[str, Any] | None = None, branch: str | None = None, timeout: int | None = None, tracker: str | None = None, raise_for_error: bool = True) -> CoreNode | SchemaType | None @@ -357,43 +357,43 @@ Allocate a new IP address by using the provided resource pool. Returns: InfrahubNode: Node corresponding to the allocated resource. -#### `allocate_next_ip_prefix` +#### `allocate_next_ip_prefix` ```python allocate_next_ip_prefix(self, resource_pool: CoreNode, kind: type[SchemaType], identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[True] = True) -> SchemaType ``` -#### `allocate_next_ip_prefix` +#### `allocate_next_ip_prefix` ```python allocate_next_ip_prefix(self, resource_pool: CoreNode, kind: type[SchemaType], identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[False] = False) -> SchemaType | None ``` -#### `allocate_next_ip_prefix` +#### `allocate_next_ip_prefix` ```python allocate_next_ip_prefix(self, resource_pool: CoreNode, kind: type[SchemaType], identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: bool = ...) -> SchemaType ``` -#### `allocate_next_ip_prefix` +#### `allocate_next_ip_prefix` ```python allocate_next_ip_prefix(self, resource_pool: CoreNode, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[True] = True) -> CoreNode ``` -#### `allocate_next_ip_prefix` +#### `allocate_next_ip_prefix` ```python allocate_next_ip_prefix(self, resource_pool: CoreNode, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[False] = False) -> CoreNode | None ``` -#### `allocate_next_ip_prefix` +#### `allocate_next_ip_prefix` ```python allocate_next_ip_prefix(self, resource_pool: CoreNode, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: bool = ...) -> CoreNode | None ``` -#### `allocate_next_ip_prefix` +#### `allocate_next_ip_prefix` ```python allocate_next_ip_prefix(self, resource_pool: CoreNode, kind: type[SchemaType] | None = None, identifier: str | None = None, prefix_length: int | None = None, member_type: str | None = None, prefix_type: str | None = None, data: dict[str, Any] | None = None, branch: str | None = None, timeout: int | None = None, tracker: str | None = None, raise_for_error: bool = True) -> CoreNode | SchemaType | None @@ -417,29 +417,29 @@ Allocate a new IP prefix by using the provided resource pool. Returns: InfrahubNode: Node corresponding to the allocated resource. -#### `create_batch` +#### `create_batch` ```python create_batch(self, return_exceptions: bool = False) -> InfrahubBatch ``` -#### `get_list_repositories` +#### `get_list_repositories` ```python get_list_repositories(self, branches: dict[str, BranchData] | None = None, kind: str = 'CoreGenericRepository') -> dict[str, RepositoryData] ``` -#### `repository_update_commit` +#### `repository_update_commit` ```python repository_update_commit(self, branch_name: str, repository_id: str, commit: str, is_read_only: bool = False) -> bool ``` -### `InfrahubClientSync` +### `InfrahubClientSync` **Methods:** -#### `get_version` +#### `get_version` ```python get_version(self) -> str @@ -447,7 +447,7 @@ get_version(self) -> str Return the Infrahub version. -#### `get_user` +#### `get_user` ```python get_user(self) -> dict @@ -455,7 +455,7 @@ get_user(self) -> dict Return user information -#### `get_user_permissions` +#### `get_user_permissions` ```python get_user_permissions(self) -> dict @@ -463,31 +463,31 @@ get_user_permissions(self) -> dict Return user permissions -#### `create` +#### `create` ```python create(self, kind: str, data: dict | None = ..., branch: str | None = ..., **kwargs: Any) -> InfrahubNodeSync ``` -#### `create` +#### `create` ```python create(self, kind: type[SchemaTypeSync], data: dict | None = ..., branch: str | None = ..., **kwargs: Any) -> SchemaTypeSync ``` -#### `create` +#### `create` ```python create(self, kind: str | type[SchemaTypeSync], data: dict | None = None, branch: str | None = None, timeout: int | None = None, **kwargs: Any) -> InfrahubNodeSync | SchemaTypeSync ``` -#### `delete` +#### `delete` ```python delete(self, kind: str | type[SchemaTypeSync], id: str, branch: str | None = None) -> None ``` -#### `clone` +#### `clone` ```python clone(self, branch: str | None = None) -> InfrahubClientSync @@ -495,7 +495,7 @@ clone(self, branch: str | None = None) -> InfrahubClientSync Return a cloned version of the client using the same configuration -#### `execute_graphql` +#### `execute_graphql` ```python execute_graphql(self, query: str, variables: dict | None = None, branch_name: str | None = None, at: str | Timestamp | None = None, timeout: int | None = None, raise_for_error: bool = True, tracker: str | None = None) -> dict @@ -520,7 +520,7 @@ Raises: - The result of the GraphQL query or mutation. -#### `count` +#### `count` ```python count(self, kind: str | type[SchemaType], at: Timestamp | None = None, branch: str | None = None, timeout: int | None = None, partial_match: bool = False, **kwargs: Any) -> int @@ -528,19 +528,19 @@ count(self, kind: str | type[SchemaType], at: Timestamp | None = None, branch: s Return the number of nodes of a given kind. -#### `all` +#### `all` ```python all(self, kind: type[SchemaTypeSync], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., populate_store: bool = ..., offset: int | None = ..., limit: int | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., parallel: bool = ..., order: Order | None = ...) -> list[SchemaTypeSync] ``` -#### `all` +#### `all` ```python all(self, kind: str, at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., populate_store: bool = ..., offset: int | None = ..., limit: int | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., parallel: bool = ..., order: Order | None = ...) -> list[InfrahubNodeSync] ``` -#### `all` +#### `all` ```python all(self, kind: str | type[SchemaTypeSync], at: Timestamp | None = None, branch: str | None = None, timeout: int | None = None, populate_store: bool = True, offset: int | None = None, limit: int | None = None, include: list[str] | None = None, exclude: list[str] | None = None, fragment: bool = False, prefetch_relationships: bool = False, property: bool = False, parallel: bool = False, order: Order | None = None) -> list[InfrahubNodeSync] | list[SchemaTypeSync] @@ -568,19 +568,19 @@ Retrieve all nodes of a given kind - list\[InfrahubNodeSync]: List of Nodes -#### `filters` +#### `filters` ```python filters(self, kind: type[SchemaTypeSync], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., populate_store: bool = ..., offset: int | None = ..., limit: int | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., fragment: bool = ..., prefetch_relationships: bool = ..., partial_match: bool = ..., property: bool = ..., parallel: bool = ..., order: Order | None = ..., **kwargs: Any) -> list[SchemaTypeSync] ``` -#### `filters` +#### `filters` ```python filters(self, kind: str, at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., populate_store: bool = ..., offset: int | None = ..., limit: int | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., fragment: bool = ..., prefetch_relationships: bool = ..., partial_match: bool = ..., property: bool = ..., parallel: bool = ..., order: Order | None = ..., **kwargs: Any) -> list[InfrahubNodeSync] ``` -#### `filters` +#### `filters` ```python filters(self, kind: str | type[SchemaTypeSync], at: Timestamp | None = None, branch: str | None = None, timeout: int | None = None, populate_store: bool = True, offset: int | None = None, limit: int | None = None, include: list[str] | None = None, exclude: list[str] | None = None, fragment: bool = False, prefetch_relationships: bool = False, partial_match: bool = False, property: bool = False, parallel: bool = False, order: Order | None = None, **kwargs: Any) -> list[InfrahubNodeSync] | list[SchemaTypeSync] @@ -610,49 +610,49 @@ Retrieve nodes of a given kind based on provided filters. - list\[InfrahubNodeSync]: List of Nodes that match the given filters. -#### `get` +#### `get` ```python get(self, kind: type[SchemaTypeSync], raise_when_missing: Literal[False], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> SchemaTypeSync | None ``` -#### `get` +#### `get` ```python get(self, kind: type[SchemaTypeSync], raise_when_missing: Literal[True], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> SchemaTypeSync ``` -#### `get` +#### `get` ```python get(self, kind: type[SchemaTypeSync], raise_when_missing: bool = ..., at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> SchemaTypeSync ``` -#### `get` +#### `get` ```python get(self, kind: str, raise_when_missing: Literal[False], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> InfrahubNodeSync | None ``` -#### `get` +#### `get` ```python get(self, kind: str, raise_when_missing: Literal[True], at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> InfrahubNodeSync ``` -#### `get` +#### `get` ```python get(self, kind: str, raise_when_missing: bool = ..., at: Timestamp | None = ..., branch: str | None = ..., timeout: int | None = ..., id: str | None = ..., hfid: list[str] | None = ..., include: list[str] | None = ..., exclude: list[str] | None = ..., populate_store: bool = ..., fragment: bool = ..., prefetch_relationships: bool = ..., property: bool = ..., **kwargs: Any) -> InfrahubNodeSync ``` -#### `get` +#### `get` ```python get(self, kind: str | type[SchemaTypeSync], raise_when_missing: bool = True, at: Timestamp | None = None, branch: str | None = None, timeout: int | None = None, id: str | None = None, hfid: list[str] | None = None, include: list[str] | None = None, exclude: list[str] | None = None, populate_store: bool = True, fragment: bool = False, prefetch_relationships: bool = False, property: bool = False, **kwargs: Any) -> InfrahubNodeSync | SchemaTypeSync | None ``` -#### `create_batch` +#### `create_batch` ```python create_batch(self, return_exceptions: bool = False) -> InfrahubBatchSync @@ -663,61 +663,61 @@ Create a batch to execute multiple queries concurrently. Executing the batch will be performed using a thread pool, meaning it cannot guarantee the execution order. It is not recommended to use such batch to manipulate objects that depend on each others. -#### `get_list_repositories` +#### `get_list_repositories` ```python get_list_repositories(self, branches: dict[str, BranchData] | None = None, kind: str = 'CoreGenericRepository') -> dict[str, RepositoryData] ``` -#### `query_gql_query` +#### `query_gql_query` ```python query_gql_query(self, name: str, variables: dict | None = None, update_group: bool = False, subscribers: list[str] | None = None, params: dict | None = None, branch_name: str | None = None, at: str | None = None, timeout: int | None = None, tracker: str | None = None, raise_for_error: bool = True) -> dict ``` -#### `get_diff_summary` +#### `get_diff_summary` ```python get_diff_summary(self, branch: str, timeout: int | None = None, tracker: str | None = None, raise_for_error: bool = True) -> list[NodeDiff] ``` -#### `allocate_next_ip_address` +#### `allocate_next_ip_address` ```python allocate_next_ip_address(self, resource_pool: CoreNodeSync, kind: type[SchemaTypeSync], identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[True] = True) -> SchemaTypeSync ``` -#### `allocate_next_ip_address` +#### `allocate_next_ip_address` ```python allocate_next_ip_address(self, resource_pool: CoreNodeSync, kind: type[SchemaTypeSync], identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[False] = False) -> SchemaTypeSync | None ``` -#### `allocate_next_ip_address` +#### `allocate_next_ip_address` ```python allocate_next_ip_address(self, resource_pool: CoreNodeSync, kind: type[SchemaTypeSync], identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: bool = ...) -> SchemaTypeSync ``` -#### `allocate_next_ip_address` +#### `allocate_next_ip_address` ```python allocate_next_ip_address(self, resource_pool: CoreNodeSync, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[True] = True) -> CoreNodeSync ``` -#### `allocate_next_ip_address` +#### `allocate_next_ip_address` ```python allocate_next_ip_address(self, resource_pool: CoreNodeSync, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[False] = False) -> CoreNodeSync | None ``` -#### `allocate_next_ip_address` +#### `allocate_next_ip_address` ```python allocate_next_ip_address(self, resource_pool: CoreNodeSync, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., address_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: bool = ...) -> CoreNodeSync | None ``` -#### `allocate_next_ip_address` +#### `allocate_next_ip_address` ```python allocate_next_ip_address(self, resource_pool: CoreNodeSync, kind: type[SchemaTypeSync] | None = None, identifier: str | None = None, prefix_length: int | None = None, address_type: str | None = None, data: dict[str, Any] | None = None, branch: str | None = None, timeout: int | None = None, tracker: str | None = None, raise_for_error: bool = True) -> CoreNodeSync | SchemaTypeSync | None @@ -740,43 +740,43 @@ Allocate a new IP address by using the provided resource pool. Returns: InfrahubNodeSync: Node corresponding to the allocated resource. -#### `allocate_next_ip_prefix` +#### `allocate_next_ip_prefix` ```python allocate_next_ip_prefix(self, resource_pool: CoreNodeSync, kind: type[SchemaTypeSync], identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[True] = True) -> SchemaTypeSync ``` -#### `allocate_next_ip_prefix` +#### `allocate_next_ip_prefix` ```python allocate_next_ip_prefix(self, resource_pool: CoreNodeSync, kind: type[SchemaTypeSync], identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[False] = False) -> SchemaTypeSync | None ``` -#### `allocate_next_ip_prefix` +#### `allocate_next_ip_prefix` ```python allocate_next_ip_prefix(self, resource_pool: CoreNodeSync, kind: type[SchemaTypeSync], identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: bool = ...) -> SchemaTypeSync ``` -#### `allocate_next_ip_prefix` +#### `allocate_next_ip_prefix` ```python allocate_next_ip_prefix(self, resource_pool: CoreNodeSync, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[True] = True) -> CoreNodeSync ``` -#### `allocate_next_ip_prefix` +#### `allocate_next_ip_prefix` ```python allocate_next_ip_prefix(self, resource_pool: CoreNodeSync, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: Literal[False] = False) -> CoreNodeSync | None ``` -#### `allocate_next_ip_prefix` +#### `allocate_next_ip_prefix` ```python allocate_next_ip_prefix(self, resource_pool: CoreNodeSync, kind: None = ..., identifier: str | None = ..., prefix_length: int | None = ..., member_type: str | None = ..., prefix_type: str | None = ..., data: dict[str, Any] | None = ..., branch: str | None = ..., timeout: int | None = ..., tracker: str | None = ..., raise_for_error: bool = ...) -> CoreNodeSync | None ``` -#### `allocate_next_ip_prefix` +#### `allocate_next_ip_prefix` ```python allocate_next_ip_prefix(self, resource_pool: CoreNodeSync, kind: type[SchemaTypeSync] | None = None, identifier: str | None = None, prefix_length: int | None = None, member_type: str | None = None, prefix_type: str | None = None, data: dict[str, Any] | None = None, branch: str | None = None, timeout: int | None = None, tracker: str | None = None, raise_for_error: bool = True) -> CoreNodeSync | SchemaTypeSync | None @@ -800,19 +800,19 @@ Allocate a new IP prefix by using the provided resource pool. Returns: InfrahubNodeSync: Node corresponding to the allocated resource. -#### `repository_update_commit` +#### `repository_update_commit` ```python repository_update_commit(self, branch_name: str, repository_id: str, commit: str, is_read_only: bool = False) -> bool ``` -#### `refresh_login` +#### `refresh_login` ```python refresh_login(self) -> None ``` -#### `login` +#### `login` ```python login(self, refresh: bool = False) -> None diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/config.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/config.mdx deleted file mode 100644 index 991413a8..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/config.mdx +++ /dev/null @@ -1,86 +0,0 @@ ---- -title: config -sidebarTitle: config ---- - -# `infrahub_sdk.config` - -## Classes - -### `ProxyMountsConfig` - -**Methods:** - -#### `is_set` - -```python -is_set(self) -> bool -``` - -### `ConfigBase` - -**Methods:** - -#### `validate_credentials_input` - -```python -validate_credentials_input(cls, values: dict[str, Any]) -> dict[str, Any] -``` - -#### `set_transport` - -```python -set_transport(cls, values: dict[str, Any]) -> dict[str, Any] -``` - -#### `validate_mix_authentication_schemes` - -```python -validate_mix_authentication_schemes(cls, values: dict[str, Any]) -> dict[str, Any] -``` - -#### `validate_address` - -```python -validate_address(cls, value: str) -> str -``` - -#### `validate_proxy_config` - -```python -validate_proxy_config(self) -> Self -``` - -#### `default_infrahub_branch` - -```python -default_infrahub_branch(self) -> str -``` - -#### `password_authentication` - -```python -password_authentication(self) -> bool -``` - -### `Config` - -**Methods:** - -#### `logger` - -```python -logger(self) -> InfrahubLoggers -``` - -#### `set_custom_recorder` - -```python -set_custom_recorder(cls, values: dict[str, Any]) -> dict[str, Any] -``` - -#### `clone` - -```python -clone(self, branch: str | None = None) -> Config -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/constants.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/constants.mdx deleted file mode 100644 index f94dac79..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/constants.mdx +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: constants -sidebarTitle: constants ---- - -# `infrahub_sdk.constants` - -## Classes - -### `InfrahubClientMode` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/context.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/context.mdx deleted file mode 100644 index f39051a7..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/context.mdx +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: context -sidebarTitle: context ---- - -# `infrahub_sdk.context` - -## Classes - -### `ContextAccount` - -### `RequestContext` - -The context can be used to override settings such as the account within mutations. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/branch.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/branch.mdx deleted file mode 100644 index 6684d47f..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/branch.mdx +++ /dev/null @@ -1,66 +0,0 @@ ---- -title: branch -sidebarTitle: branch ---- - -# `infrahub_sdk.ctl.branch` - -## Functions - -### `callback` - -```python -callback() -> None -``` - -Manage the branches in a remote Infrahub instance. - -List, create, merge, rebase .. - -### `list_branch` - -```python -list_branch(_: str = CONFIG_PARAM) -> None -``` - -List all existing branches. - -### `create` - -```python -create(branch_name: str = typer.Argument(..., help='Name of the branch to create'), description: str = typer.Option(default='', help='Description of the branch'), sync_with_git: bool = typer.Option(False, help='Extend the branch to Git and have Infrahub create the branch in connected repositories.'), isolated: bool = typer.Option(True, hidden=True, help='Set the branch to isolated mode (deprecated)'), _: str = CONFIG_PARAM) -> None -``` - -Create a new branch. - -### `delete` - -```python -delete(branch_name: str, _: str = CONFIG_PARAM) -> None -``` - -Delete a branch. - -### `rebase` - -```python -rebase(branch_name: str, _: str = CONFIG_PARAM) -> None -``` - -Rebase a Branch with main. - -### `merge` - -```python -merge(branch_name: str, _: str = CONFIG_PARAM) -> None -``` - -Merge a Branch with main. - -### `validate` - -```python -validate(branch_name: str, _: str = CONFIG_PARAM) -> None -``` - -Validate if a branch has some conflict and is passing all the tests (NOT IMPLEMENTED YET). diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/check.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/check.mdx deleted file mode 100644 index 45a9f53f..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/check.mdx +++ /dev/null @@ -1,58 +0,0 @@ ---- -title: check -sidebarTitle: check ---- - -# `infrahub_sdk.ctl.check` - -## Functions - -### `callback` - -```python -callback() -> None -``` - -Execute user-defined checks. - -### `run` - -```python -run() -> None -``` - -Locate and execute all checks under the defined path. - -### `run_check` - -```python -run_check(check_module: CheckModule, client: InfrahubClient, format_json: bool, path: str, repository_config: InfrahubRepositoryConfig, branch: str | None = None, params: dict | None = None) -> bool -``` - -### `run_targeted_check` - -```python -run_targeted_check(check_module: CheckModule, client: InfrahubClient, format_json: bool, path: str, repository_config: InfrahubRepositoryConfig, variables: dict[str, str], branch: str | None = None) -> bool -``` - -### `run_checks` - -```python -run_checks(check_modules: list[CheckModule], format_json: bool, path: str, variables: dict[str, str], repository_config: InfrahubRepositoryConfig, branch: str | None = None) -> None -``` - -### `get_modules` - -```python -get_modules(check_definitions: list[InfrahubCheckDefinitionConfig]) -> list[CheckModule] -``` - -### `list_checks` - -```python -list_checks(repository_config: InfrahubRepositoryConfig) -> None -``` - -## Classes - -### `CheckModule` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli.mdx deleted file mode 100644 index 1a024ba1..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli.mdx +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: cli -sidebarTitle: cli ---- - -# `infrahub_sdk.ctl.cli` - -*This module is empty or contains only private/internal implementations.* diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli_commands.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli_commands.mdx deleted file mode 100644 index c8904fd4..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/cli_commands.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -title: cli_commands -sidebarTitle: cli_commands ---- - -# `infrahub_sdk.ctl.cli_commands` - -## Functions - -### `check` - -```python -check(check_name: str = typer.Argument(default='', help='Name of the Python check'), branch: Optional[str] = None, path: str = typer.Option('.', help='Root directory'), debug: bool = False, format_json: bool = False, _: str = CONFIG_PARAM, list_available: bool = typer.Option(False, '--list', help='Show available Python checks'), variables: Optional[list[str]] = typer.Argument(None, help='Variables to pass along with the query. Format key=value key=value.')) -> None -``` - -Execute user-defined checks. - -### `generator` - -```python -generator(generator_name: str = typer.Argument(default='', help='Name of the Generator'), branch: Optional[str] = None, path: str = typer.Option('.', help='Root directory'), debug: bool = False, _: str = CONFIG_PARAM, list_available: bool = typer.Option(False, '--list', help='Show available Generators'), variables: Optional[list[str]] = typer.Argument(None, help='Variables to pass along with the query. Format key=value key=value.')) -> None -``` - -Run a generator script. - -### `run` - -```python -run(script: Path, method: str = 'run', debug: bool = False, _: str = CONFIG_PARAM, branch: str = typer.Option(None, help='Branch on which to run the script.'), concurrent: Optional[int] = typer.Option(None, help='Maximum number of requests to execute at the same time.', envvar='INFRAHUB_MAX_CONCURRENT_EXECUTION'), timeout: int = typer.Option(60, help='Timeout in sec', envvar='INFRAHUB_TIMEOUT'), variables: Optional[list[str]] = typer.Argument(None, help='Variables to pass along with the query. Format key=value key=value.')) -> None -``` - -Execute a script. - -### `render_jinja2_template` - -```python -render_jinja2_template(template_path: Path, variables: dict[str, Any], data: dict[str, Any]) -> str -``` - -### `render` - -```python -render(transform_name: str = typer.Argument(default='', help='Name of the Python transformation', show_default=False), variables: Optional[list[str]] = typer.Argument(None, help='Variables to pass along with the query. Format key=value key=value.'), branch: str = typer.Option(None, help='Branch on which to render the transform.'), debug: bool = False, _: str = CONFIG_PARAM, list_available: bool = typer.Option(False, '--list', help='Show available transforms'), out: str = typer.Option(None, help='Path to a file to save the result.')) -> None -``` - -Render a local Jinja2 Transform for debugging purpose. - -### `transform` - -```python -transform(transform_name: str = typer.Argument(default='', help='Name of the Python transformation', show_default=False), variables: Optional[list[str]] = typer.Argument(None, help='Variables to pass along with the query. Format key=value key=value.'), branch: str = typer.Option(None, help='Branch on which to run the transformation'), debug: bool = False, _: str = CONFIG_PARAM, list_available: bool = typer.Option(False, '--list', help='Show available transforms'), out: str = typer.Option(None, help='Path to a file to save the result.')) -> None -``` - -Render a local transform (TransformPython) for debugging purpose. - -### `protocols` - -```python -protocols(schemas: list[Path] = typer.Option(None, help='List of schemas or directory to load.'), branch: str = typer.Option(None, help='Branch of schema to export Python protocols for.'), sync: bool = typer.Option(False, help='Generate for sync or async.'), _: str = CONFIG_PARAM, out: str = typer.Option('schema_protocols.py', help='Path to a file to save the result.')) -> None -``` - -Export Python protocols corresponding to a schema. - -### `version` - -```python -version() -> None -``` - -Display the version of Python and the version of the Python SDK in use. - -### `info` - -```python -info(detail: bool = typer.Option(False, help='Display detailed information.'), _: str = CONFIG_PARAM) -> None -``` - -Display the status of the Python SDK. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/client.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/client.mdx deleted file mode 100644 index e61ca981..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/client.mdx +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: client -sidebarTitle: client ---- - -# `infrahub_sdk.ctl.client` - -## Functions - -### `initialize_client` - -```python -initialize_client(branch: str | None = None, identifier: str | None = None, timeout: int | None = None, max_concurrent_execution: int | None = None, retry_on_failure: bool | None = None) -> InfrahubClient -``` - -### `initialize_client_sync` - -```python -initialize_client_sync(branch: str | None = None, identifier: str | None = None, timeout: int | None = None, max_concurrent_execution: int | None = None, retry_on_failure: bool | None = None) -> InfrahubClientSync -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/config.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/config.mdx deleted file mode 100644 index 614bc1cf..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/config.mdx +++ /dev/null @@ -1,59 +0,0 @@ ---- -title: config -sidebarTitle: config ---- - -# `infrahub_sdk.ctl.config` - -Config Class. - -## Classes - -### `Settings` - -Main Settings Class for the project. - -**Methods:** - -#### `cleanup_server_address` - -```python -cleanup_server_address(cls, v: str) -> str -``` - -### `ConfiguredSettings` - -**Methods:** - -#### `active` - -```python -active(self) -> Settings -``` - -#### `load` - -```python -load(self, config_file: str | Path = 'infrahubctl.toml', config_data: dict | None = None) -> None -``` - -Load configuration. - -Configuration is loaded from a config file in toml format that contains the settings, -or from a dictionary of those settings passed in as "config_data" - -#### `load_and_exit` - -```python -load_and_exit(self, config_file: str | Path = 'infrahubctl.toml', config_data: dict | None = None) -> None -``` - -Calls load, but wraps it in a try except block. - -This is done to handle a ValidationErorr which is raised when settings are specified but invalid. -In such cases, a message is printed to the screen indicating the settings which don't pass validation. - -**Args:** - -- `config_file_name`: [description]. Defaults to "pyprojectctl.toml". -- `config_data`: [description]. Defaults to None. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exceptions.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exceptions.mdx deleted file mode 100644 index 5499dcff..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exceptions.mdx +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: exceptions -sidebarTitle: exceptions ---- - -# `infrahub_sdk.ctl.exceptions` - -## Classes - -### `Error` - -Infrahub CTL Base exception. - -### `QueryNotFoundError` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exporter.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exporter.mdx deleted file mode 100644 index 63335216..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/exporter.mdx +++ /dev/null @@ -1,22 +0,0 @@ ---- -title: exporter -sidebarTitle: exporter ---- - -# `infrahub_sdk.ctl.exporter` - -## Functions - -### `directory_name_with_timestamp` - -```python -directory_name_with_timestamp() -> str -``` - -### `dump` - -```python -dump(namespace: list[str] = typer.Option([], help='Namespace(s) to export'), directory: Path = typer.Option(directory_name_with_timestamp, help='Directory path to store export'), quiet: bool = typer.Option(False, help='No console output'), _: str = CONFIG_PARAM, branch: str = typer.Option(None, help='Branch from which to export'), concurrent: int = typer.Option(4, help='Maximum number of requests to execute at the same time.', envvar='INFRAHUB_MAX_CONCURRENT_EXECUTION'), timeout: int = typer.Option(60, help='Timeout in sec', envvar='INFRAHUB_TIMEOUT'), exclude: list[str] = typer.Option(['CoreAccount'], help='Prevent node kind(s) from being exported, CoreAccount is excluded by default')) -> None -``` - -Export nodes and their relationships out of the database. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/generator.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/generator.mdx deleted file mode 100644 index fad2698d..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/generator.mdx +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: generator -sidebarTitle: generator ---- - -# `infrahub_sdk.ctl.generator` - -## Functions - -### `run` - -```python -run(generator_name: str, path: str, debug: bool, list_available: bool, branch: str | None = None, variables: Optional[list[str]] = None) -> None -``` - -### `list_generators` - -```python -list_generators(repository_config: InfrahubRepositoryConfig) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/importer.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/importer.mdx deleted file mode 100644 index bbb99aea..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/importer.mdx +++ /dev/null @@ -1,22 +0,0 @@ ---- -title: importer -sidebarTitle: importer ---- - -# `infrahub_sdk.ctl.importer` - -## Functions - -### `local_directory` - -```python -local_directory() -> Path -``` - -### `load` - -```python -load(directory: Path = typer.Option(local_directory, help='Directory path of exported data'), continue_on_error: bool = typer.Option(False, help='Allow exceptions during loading and display them when complete'), quiet: bool = typer.Option(False, help='No console output'), _: str = CONFIG_PARAM, branch: str = typer.Option(None, help='Branch from which to export'), concurrent: Optional[int] = typer.Option(None, help='Maximum number of requests to execute at the same time.', envvar='INFRAHUB_MAX_CONCURRENT_EXECUTION'), timeout: int = typer.Option(60, help='Timeout in sec', envvar='INFRAHUB_TIMEOUT')) -> None -``` - -Import nodes and their relationships into the database. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/menu.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/menu.mdx deleted file mode 100644 index ad1c92d7..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/menu.mdx +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: menu -sidebarTitle: menu ---- - -# `infrahub_sdk.ctl.menu` - -## Functions - -### `callback` - -```python -callback() -> None -``` - -Manage the menu in a remote Infrahub instance. - -### `load` - -```python -load(menus: list[Path], debug: bool = False, branch: str = typer.Option(None, help='Branch on which to load the menu.'), _: str = CONFIG_PARAM) -> None -``` - -Load one or multiple menu files into Infrahub. - -### `validate` - -```python -validate(paths: list[Path], debug: bool = False, branch: str = typer.Option(None, help='Branch on which to validate the objects.'), _: str = CONFIG_PARAM) -> None -``` - -Validate one or multiple menu files. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/object.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/object.mdx deleted file mode 100644 index 7ed1aac9..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/object.mdx +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: object -sidebarTitle: object ---- - -# `infrahub_sdk.ctl.object` - -## Functions - -### `callback` - -```python -callback() -> None -``` - -Manage objects in a remote Infrahub instance. - -### `load` - -```python -load(paths: list[Path], debug: bool = False, branch: str = typer.Option(None, help='Branch on which to load the objects.'), _: str = CONFIG_PARAM) -> None -``` - -Load one or multiple objects files into Infrahub. - -### `validate` - -```python -validate(paths: list[Path], debug: bool = False, branch: str = typer.Option(None, help='Branch on which to validate the objects.'), _: str = CONFIG_PARAM) -> None -``` - -Validate one or multiple objects files. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/parameters.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/parameters.mdx deleted file mode 100644 index c3c927d7..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/parameters.mdx +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: parameters -sidebarTitle: parameters ---- - -# `infrahub_sdk.ctl.parameters` - -## Functions - -### `load_configuration` - -```python -load_configuration(value: str) -> str -``` - -Load the configuration file using default environment variables or from the specified configuration file diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/render.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/render.mdx deleted file mode 100644 index 918c47a1..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/render.mdx +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: render -sidebarTitle: render ---- - -# `infrahub_sdk.ctl.render` - -## Functions - -### `list_jinja2_transforms` - -```python -list_jinja2_transforms(config: InfrahubRepositoryConfig) -> None -``` - -### `print_template_errors` - -```python -print_template_errors(error: JinjaTemplateError, console: Console) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/repository.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/repository.mdx deleted file mode 100644 index 9d42debf..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/repository.mdx +++ /dev/null @@ -1,44 +0,0 @@ ---- -title: repository -sidebarTitle: repository ---- - -# `infrahub_sdk.ctl.repository` - -## Functions - -### `get_repository_config` - -```python -get_repository_config(repo_config_file: Path) -> InfrahubRepositoryConfig -``` - -### `load_repository_config_file` - -```python -load_repository_config_file(repo_config_file: Path) -> dict -``` - -### `callback` - -```python -callback() -> None -``` - -Manage the repositories in a remote Infrahub instance. - -List, create, delete .. - -### `add` - -```python -add(name: str, location: str, description: str = '', username: Optional[str] = None, password: str = '', ref: str = '', read_only: bool = False, debug: bool = False, _: str = CONFIG_PARAM) -> None -``` - -Add a new repository. - -### `list` - -```python -list(branch: Optional[str] = typer.Option(None, help='Branch on which to list repositories.'), debug: bool = False, _: str = CONFIG_PARAM) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/schema.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/schema.mdx deleted file mode 100644 index 667df63f..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/schema.mdx +++ /dev/null @@ -1,62 +0,0 @@ ---- -title: schema -sidebarTitle: schema ---- - -# `infrahub_sdk.ctl.schema` - -## Functions - -### `callback` - -```python -callback() -> None -``` - -Manage the schema in a remote Infrahub instance. - -### `validate_schema_content_and_exit` - -```python -validate_schema_content_and_exit(client: InfrahubClient, schemas: list[SchemaFile]) -> None -``` - -### `display_schema_load_errors` - -```python -display_schema_load_errors(response: dict[str, Any], schemas_data: list[dict]) -> None -``` - -### `handle_non_detail_errors` - -```python -handle_non_detail_errors(response: dict[str, Any]) -> None -``` - -### `valid_error_path` - -```python -valid_error_path(loc_path: list[Any]) -> bool -``` - -### `get_node` - -```python -get_node(schemas_data: list[dict], schema_index: int, node_index: int) -> dict | None -``` - -### `load` - -```python -load(schemas: list[Path], debug: bool = False, branch: str = typer.Option(None, help='Branch on which to load the schema.'), wait: int = typer.Option(0, help='Time in seconds to wait until the schema has converged across all workers'), _: str = CONFIG_PARAM) -> None -``` - -Load one or multiple schema files into Infrahub. - -### `check` - -```python -check(schemas: list[Path], debug: bool = False, branch: str = typer.Option(None, help='Branch on which to check the schema.'), _: str = CONFIG_PARAM) -> None -``` - -Check if schema files are valid and what would be the impact of loading them with Infrahub. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/transform.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/transform.mdx deleted file mode 100644 index 10181b92..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/transform.mdx +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: transform -sidebarTitle: transform ---- - -# `infrahub_sdk.ctl.transform` - -## Functions - -### `list_transforms` - -```python -list_transforms(config: InfrahubRepositoryConfig) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx deleted file mode 100644 index a8727bd3..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/utils.mdx +++ /dev/null @@ -1,86 +0,0 @@ ---- -title: utils -sidebarTitle: utils ---- - -# `infrahub_sdk.ctl.utils` - -## Functions - -### `init_logging` - -```python -init_logging(debug: bool = False) -> None -``` - -### `handle_exception` - -```python -handle_exception(exc: Exception, console: Console, exit_code: int) -> NoReturn -``` - -Handle exception in a different fashion based on its type. - -### `catch_exception` - -```python -catch_exception(console: Console | None = None, exit_code: int = 1) -> Callable[[Callable[..., T]], Callable[..., T | Coroutine[Any, Any, T]]] -``` - -Decorator to handle exception for commands. - -### `execute_graphql_query` - -```python -execute_graphql_query(query: str, variables_dict: dict[str, Any], repository_config: InfrahubRepositoryConfig, branch: str | None = None, debug: bool = False) -> dict -``` - -### `print_graphql_errors` - -```python -print_graphql_errors(console: Console, errors: list) -> None -``` - -### `parse_cli_vars` - -```python -parse_cli_vars(variables: Optional[list[str]]) -> dict[str, str] -``` - -### `find_graphql_query` - -```python -find_graphql_query(name: str, directory: str | Path = '.') -> str -``` - -### `render_action_rich` - -```python -render_action_rich(value: str) -> str -``` - -### `get_fixtures_dir` - -```python -get_fixtures_dir() -> Path -``` - -Get the directory which stores fixtures that are common to multiple unit/integration tests. - -### `load_yamlfile_from_disk_and_exit` - -```python -load_yamlfile_from_disk_and_exit(paths: list[Path], file_type: type[YamlFileVar], console: Console) -> list[YamlFileVar] -``` - -### `display_object_validate_format_success` - -```python -display_object_validate_format_success(file: ObjectFile, console: Console) -> None -``` - -### `display_object_validate_format_error` - -```python -display_object_validate_format_error(file: ObjectFile, error: ValidationError, console: Console) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/validate.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/validate.mdx deleted file mode 100644 index 2ffa3799..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/ctl/validate.mdx +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: validate -sidebarTitle: validate ---- - -# `infrahub_sdk.ctl.validate` - -## Functions - -### `callback` - -```python -callback() -> None -``` - -Helper to validate the format of various files. - -### `validate_schema` - -```python -validate_schema(schema: Path, _: str = CONFIG_PARAM) -> None -``` - -Validate the format of a schema file either in JSON or YAML - -### `validate_graphql` - -```python -validate_graphql(query: str, variables: Optional[list[str]] = typer.Argument(None, help='Variables to pass along with the query. Format key=value key=value.'), debug: bool = typer.Option(False, help='Display more troubleshooting information.'), branch: str = typer.Option(None, help='Branch on which to validate the GraphQL Query.'), _: str = CONFIG_PARAM, out: str = typer.Option(None, help='Path to a file to save the result.')) -> None -``` - -Validate the format of a GraphQL Query stored locally by executing it on a remote GraphQL endpoint diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/data.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/data.mdx deleted file mode 100644 index 6f6a6877..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/data.mdx +++ /dev/null @@ -1,20 +0,0 @@ ---- -title: data -sidebarTitle: data ---- - -# `infrahub_sdk.data` - -## Classes - -### `RepositoryBranchInfo` - -### `RepositoryData` - -**Methods:** - -#### `get_staging_branch` - -```python -get_staging_branch(self) -> str | None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/diff.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/diff.mdx deleted file mode 100644 index 0c25d3c0..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/diff.mdx +++ /dev/null @@ -1,30 +0,0 @@ ---- -title: diff -sidebarTitle: diff ---- - -# `infrahub_sdk.diff` - -## Functions - -### `get_diff_summary_query` - -```python -get_diff_summary_query() -> str -``` - -### `diff_tree_node_to_node_diff` - -```python -diff_tree_node_to_node_diff(node_dict: dict[str, Any], branch_name: str) -> NodeDiff -``` - -## Classes - -### `NodeDiff` - -### `NodeDiffElement` - -### `NodeDiffSummary` - -### `NodeDiffPeer` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/exceptions.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/exceptions.mdx deleted file mode 100644 index 7ebde17b..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/exceptions.mdx +++ /dev/null @@ -1,60 +0,0 @@ ---- -title: exceptions -sidebarTitle: exceptions ---- - -# `infrahub_sdk.exceptions` - -## Classes - -### `Error` - -### `JsonDecodeError` - -### `ServerNotReachableError` - -### `ServerNotResponsiveError` - -### `GraphQLError` - -### `BranchNotFoundError` - -### `SchemaNotFoundError` - -### `ModuleImportError` - -### `NodeNotFoundError` - -### `NodeInvalidError` - -### `ResourceNotDefinedError` - -Raised when trying to access a resource that hasn't been defined. - -### `InfrahubCheckNotFoundError` - -### `InfrahubTransformNotFoundError` - -### `ValidationError` - -### `ObjectValidationError` - -### `AuthenticationError` - -### `URLNotFoundError` - -### `FeatureNotSupportedError` - -Raised when trying to use a method on a node that doesn't support it. - -### `UninitializedError` - -Raised when an object requires an initialization step before use - -### `InvalidResponseError` - -Raised when an object requires an initialization step before use - -### `FileNotValidError` - -### `TimestampFormatError` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/generator.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/generator.mdx deleted file mode 100644 index e43498f6..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/generator.mdx +++ /dev/null @@ -1,64 +0,0 @@ ---- -title: generator -sidebarTitle: generator ---- - -# `infrahub_sdk.generator` - -## Classes - -### `InfrahubGenerator` - -Infrahub Generator class - -**Methods:** - -#### `subscribers` - -```python -subscribers(self) -> list[str] | None -``` - -#### `client` - -```python -client(self) -> InfrahubClient -``` - -#### `client` - -```python -client(self, value: InfrahubClient) -> None -``` - -#### `collect_data` - -```python -collect_data(self) -> dict -``` - -Query the result of the GraphQL Query defined in self.query and return the result - -#### `run` - -```python -run(self, identifier: str, data: dict | None = None) -> None -``` - -Execute the generator after collecting the data from the GraphQL query. - -#### `generate` - -```python -generate(self, data: dict) -> None -``` - -Code to run the generator - -Any child class of the InfrahubGenerator us expected to provide this method. The method is expected -to use the provided InfrahubClient contained in self.client to create or update any nodes in an idempotent -way as the method could be executed multiple times. Typically this would be done by using: - -await new_or_updated_object.save(allow_upsert=True) - -The tracking system will be responsible for deleting nodes that are no longer required. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/graphql.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/graphql.mdx deleted file mode 100644 index 437f8739..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/graphql.mdx +++ /dev/null @@ -1,68 +0,0 @@ ---- -title: graphql -sidebarTitle: graphql ---- - -# `infrahub_sdk.graphql` - -## Functions - -### `convert_to_graphql_as_string` - -```python -convert_to_graphql_as_string(value: str | bool | list | BaseModel | Enum | Any, convert_enum: bool = False) -> str -``` - -### `render_variables_to_string` - -```python -render_variables_to_string(data: dict[str, type[str | int | float | bool]]) -> str -``` - -Render a dict into a variable string that will be used in a GraphQL Query. - -The $ sign will be automatically added to the name of the query. - -### `render_query_block` - -```python -render_query_block(data: dict, offset: int = 4, indentation: int = 4, convert_enum: bool = False) -> list[str] -``` - -### `render_input_block` - -```python -render_input_block(data: dict, offset: int = 4, indentation: int = 4, convert_enum: bool = False) -> list[str] -``` - -## Classes - -### `BaseGraphQLQuery` - -**Methods:** - -#### `render_first_line` - -```python -render_first_line(self) -> str -``` - -### `Query` - -**Methods:** - -#### `render` - -```python -render(self, convert_enum: bool = False) -> str -``` - -### `Mutation` - -**Methods:** - -#### `render` - -```python -render(self, convert_enum: bool = False) -> str -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/groups.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/groups.mdx deleted file mode 100644 index ffe53eee..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/groups.mdx +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: groups -sidebarTitle: groups ---- - -# `infrahub_sdk.groups` - -## Functions - -### `group_add_subscriber` - -```python -group_add_subscriber(client: InfrahubClient, group: InfrahubNode, subscribers: list[str], branch: str) -> dict -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/jinja2.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/jinja2.mdx deleted file mode 100644 index 12f4b24c..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/jinja2.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: jinja2 -sidebarTitle: jinja2 ---- - -# `infrahub_sdk.jinja2` - -## Functions - -### `identify_faulty_jinja_code` - -```python -identify_faulty_jinja_code(traceback: Traceback, nbr_context_lines: int = 3) -> list[tuple[Frame, Syntax]] -``` - -This function identifies the faulty Jinja2 code and beautify it to provide meaningful information to the user. - -We use the rich's Traceback to parse the complete stack trace and extract Frames for each exception found in the trace. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/attribute.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/attribute.mdx deleted file mode 100644 index e0cbba24..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/attribute.mdx +++ /dev/null @@ -1,26 +0,0 @@ ---- -title: attribute -sidebarTitle: attribute ---- - -# `infrahub_sdk.node.attribute` - -## Classes - -### `Attribute` - -Represents an attribute of a Node, including its schema, value, and properties. - -**Methods:** - -#### `value` - -```python -value(self) -> Any -``` - -#### `value` - -```python -value(self, value: Any) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/constants.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/constants.mdx deleted file mode 100644 index 290f923e..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/constants.mdx +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: constants -sidebarTitle: constants ---- - -# `infrahub_sdk.node.constants` - -*This module is empty or contains only private/internal implementations.* diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx index 82ce44d3..5980aad0 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx @@ -7,91 +7,91 @@ sidebarTitle: node ## Classes -### `InfrahubNodeBase` +### `InfrahubNodeBase` Base class for InfrahubNode and InfrahubNodeSync **Methods:** -#### `get_branch` +#### `get_branch` ```python get_branch(self) -> str ``` -#### `get_path_value` +#### `get_path_value` ```python get_path_value(self, path: str) -> Any ``` -#### `get_human_friendly_id` +#### `get_human_friendly_id` ```python get_human_friendly_id(self) -> list[str] | None ``` -#### `get_human_friendly_id_as_string` +#### `get_human_friendly_id_as_string` ```python get_human_friendly_id_as_string(self, include_kind: bool = False) -> str | None ``` -#### `hfid` +#### `hfid` ```python hfid(self) -> list[str] | None ``` -#### `hfid_str` +#### `hfid_str` ```python hfid_str(self) -> str | None ``` -#### `get_kind` +#### `get_kind` ```python get_kind(self) -> str ``` -#### `get_all_kinds` +#### `get_all_kinds` ```python get_all_kinds(self) -> list[str] ``` -#### `is_ip_prefix` +#### `is_ip_prefix` ```python is_ip_prefix(self) -> bool ``` -#### `is_ip_address` +#### `is_ip_address` ```python is_ip_address(self) -> bool ``` -#### `is_resource_pool` +#### `is_resource_pool` ```python is_resource_pool(self) -> bool ``` -#### `get_raw_graphql_data` +#### `get_raw_graphql_data` ```python get_raw_graphql_data(self) -> dict | None ``` -#### `generate_query_data_init` +#### `generate_query_data_init` ```python generate_query_data_init(self, filters: dict[str, Any] | None = None, offset: int | None = None, limit: int | None = None, include: list[str] | None = None, exclude: list[str] | None = None, partial_match: bool = False, order: Order | None = None) -> dict[str, Any | dict] ``` -#### `extract` +#### `extract` ```python extract(self, params: dict[str, str]) -> dict[str, Any] @@ -99,55 +99,55 @@ extract(self, params: dict[str, str]) -> dict[str, Any] Extract some data points defined in a flat notation. -### `InfrahubNode` +### `InfrahubNode` Represents a Infrahub node in an asynchronous context. **Methods:** -#### `from_graphql` +#### `from_graphql` ```python from_graphql(cls, client: InfrahubClient, branch: str, data: dict, schema: MainSchemaTypesAPI | None = None, timeout: int | None = None) -> Self ``` -#### `generate` +#### `generate` ```python generate(self, nodes: list[str] | None = None) -> None ``` -#### `artifact_generate` +#### `artifact_generate` ```python artifact_generate(self, name: str) -> None ``` -#### `artifact_fetch` +#### `artifact_fetch` ```python artifact_fetch(self, name: str) -> str | dict[str, Any] ``` -#### `delete` +#### `delete` ```python delete(self, timeout: int | None = None, request_context: RequestContext | None = None) -> None ``` -#### `save` +#### `save` ```python save(self, allow_upsert: bool = False, update_group_context: bool | None = None, timeout: int | None = None, request_context: RequestContext | None = None) -> None ``` -#### `generate_query_data` +#### `generate_query_data` ```python generate_query_data(self, filters: dict[str, Any] | None = None, offset: int | None = None, limit: int | None = None, include: list[str] | None = None, exclude: list[str] | None = None, fragment: bool = False, prefetch_relationships: bool = False, partial_match: bool = False, property: bool = False, order: Order | None = None) -> dict[str, Any | dict] ``` -#### `generate_query_data_node` +#### `generate_query_data_node` ```python generate_query_data_node(self, include: list[str] | None = None, exclude: list[str] | None = None, inherited: bool = True, insert_alias: bool = False, prefetch_relationships: bool = False, property: bool = False) -> dict[str, Any | dict] @@ -168,31 +168,31 @@ Generate the node part of a GraphQL Query with attributes and nodes. - dict\[str, Union\[Any, Dict]]: GraphQL query in dictionary format -#### `add_relationships` +#### `add_relationships` ```python add_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None ``` -#### `remove_relationships` +#### `remove_relationships` ```python remove_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None ``` -#### `create` +#### `create` ```python create(self, allow_upsert: bool = False, timeout: int | None = None, request_context: RequestContext | None = None) -> None ``` -#### `update` +#### `update` ```python update(self, do_full_update: bool = False, timeout: int | None = None, request_context: RequestContext | None = None) -> None ``` -#### `get_pool_allocated_resources` +#### `get_pool_allocated_resources` ```python get_pool_allocated_resources(self, resource: InfrahubNode) -> list[InfrahubNode] @@ -208,7 +208,7 @@ Fetch all nodes that were allocated for the pool and a given resource. - list\[InfrahubNode]: The allocated nodes. -#### `get_pool_resources_utilization` +#### `get_pool_resources_utilization` ```python get_pool_resources_utilization(self) -> list[dict[str, Any]] @@ -220,55 +220,55 @@ Fetch the utilization of each resource for the pool. - list\[dict\[str, Any]]: A list containing the allocation numbers for each resource of the pool. -### `InfrahubNodeSync` +### `InfrahubNodeSync` Represents a Infrahub node in a synchronous context. **Methods:** -#### `from_graphql` +#### `from_graphql` ```python from_graphql(cls, client: InfrahubClientSync, branch: str, data: dict, schema: MainSchemaTypesAPI | None = None, timeout: int | None = None) -> Self ``` -#### `generate` +#### `generate` ```python generate(self, nodes: list[str] | None = None) -> None ``` -#### `artifact_generate` +#### `artifact_generate` ```python artifact_generate(self, name: str) -> None ``` -#### `artifact_fetch` +#### `artifact_fetch` ```python artifact_fetch(self, name: str) -> str | dict[str, Any] ``` -#### `delete` +#### `delete` ```python delete(self, timeout: int | None = None, request_context: RequestContext | None = None) -> None ``` -#### `save` +#### `save` ```python save(self, allow_upsert: bool = False, update_group_context: bool | None = None, timeout: int | None = None, request_context: RequestContext | None = None) -> None ``` -#### `generate_query_data` +#### `generate_query_data` ```python generate_query_data(self, filters: dict[str, Any] | None = None, offset: int | None = None, limit: int | None = None, include: list[str] | None = None, exclude: list[str] | None = None, fragment: bool = False, prefetch_relationships: bool = False, partial_match: bool = False, property: bool = False, order: Order | None = None) -> dict[str, Any | dict] ``` -#### `generate_query_data_node` +#### `generate_query_data_node` ```python generate_query_data_node(self, include: list[str] | None = None, exclude: list[str] | None = None, inherited: bool = True, insert_alias: bool = False, prefetch_relationships: bool = False, property: bool = False) -> dict[str, Any | dict] @@ -289,31 +289,31 @@ Generate the node part of a GraphQL Query with attributes and nodes. - dict\[str, Union\[Any, Dict]]: GraphQL query in dictionary format -#### `add_relationships` +#### `add_relationships` ```python add_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None ``` -#### `remove_relationships` +#### `remove_relationships` ```python remove_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None ``` -#### `create` +#### `create` ```python create(self, allow_upsert: bool = False, timeout: int | None = None, request_context: RequestContext | None = None) -> None ``` -#### `update` +#### `update` ```python update(self, do_full_update: bool = False, timeout: int | None = None, request_context: RequestContext | None = None) -> None ``` -#### `get_pool_allocated_resources` +#### `get_pool_allocated_resources` ```python get_pool_allocated_resources(self, resource: InfrahubNodeSync) -> list[InfrahubNodeSync] @@ -329,7 +329,7 @@ Fetch all nodes that were allocated for the pool and a given resource. - list\[InfrahubNodeSync]: The allocated nodes. -#### `get_pool_resources_utilization` +#### `get_pool_resources_utilization` ```python get_pool_resources_utilization(self) -> list[dict[str, Any]] diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/parsers.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/parsers.mdx deleted file mode 100644 index d058f8eb..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/parsers.mdx +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: parsers -sidebarTitle: parsers ---- - -# `infrahub_sdk.node.parsers` - -## Functions - -### `parse_human_friendly_id` - -```python -parse_human_friendly_id(hfid: str | list[str]) -> tuple[str | None, list[str]] -``` - -Parse a human friendly ID into a kind and an identifier. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/property.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/property.mdx deleted file mode 100644 index d7ad38b5..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/property.mdx +++ /dev/null @@ -1,12 +0,0 @@ ---- -title: property -sidebarTitle: property ---- - -# `infrahub_sdk.node.property` - -## Classes - -### `NodeProperty` - -Represents a property of a node, typically used for metadata like display labels. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/related_node.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/related_node.mdx deleted file mode 100644 index 1634208f..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/related_node.mdx +++ /dev/null @@ -1,110 +0,0 @@ ---- -title: related_node -sidebarTitle: related_node ---- - -# `infrahub_sdk.node.related_node` - -## Classes - -### `RelatedNodeBase` - -Base class for representing a related node in a relationship. - -**Methods:** - -#### `id` - -```python -id(self) -> str | None -``` - -#### `hfid` - -```python -hfid(self) -> list[Any] | None -``` - -#### `hfid_str` - -```python -hfid_str(self) -> str | None -``` - -#### `is_resource_pool` - -```python -is_resource_pool(self) -> bool -``` - -#### `initialized` - -```python -initialized(self) -> bool -``` - -#### `display_label` - -```python -display_label(self) -> str | None -``` - -#### `typename` - -```python -typename(self) -> str | None -``` - -#### `kind` - -```python -kind(self) -> str | None -``` - -### `RelatedNode` - -Represents a RelatedNodeBase in an asynchronous context. - -**Methods:** - -#### `fetch` - -```python -fetch(self, timeout: int | None = None) -> None -``` - -#### `peer` - -```python -peer(self) -> InfrahubNode -``` - -#### `get` - -```python -get(self) -> InfrahubNode -``` - -### `RelatedNodeSync` - -Represents a related node in a synchronous context. - -**Methods:** - -#### `fetch` - -```python -fetch(self, timeout: int | None = None) -> None -``` - -#### `peer` - -```python -peer(self) -> InfrahubNodeSync -``` - -#### `get` - -```python -get(self) -> InfrahubNodeSync -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx deleted file mode 100644 index 50d9a31c..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/relationship.mdx +++ /dev/null @@ -1,106 +0,0 @@ ---- -title: relationship -sidebarTitle: relationship ---- - -# `infrahub_sdk.node.relationship` - -## Classes - -### `RelationshipManagerBase` - -Base class for RelationshipManager and RelationshipManagerSync - -**Methods:** - -#### `peer_ids` - -```python -peer_ids(self) -> list[str] -``` - -#### `peer_hfids` - -```python -peer_hfids(self) -> list[list[Any]] -``` - -#### `peer_hfids_str` - -```python -peer_hfids_str(self) -> list[str] -``` - -#### `has_update` - -```python -has_update(self) -> bool -``` - -### `RelationshipManager` - -Manages relationships of a node in an asynchronous context. - -**Methods:** - -#### `fetch` - -```python -fetch(self) -> None -``` - -#### `add` - -```python -add(self, data: str | RelatedNode | dict) -> None -``` - -Add a new peer to this relationship. - -#### `extend` - -```python -extend(self, data: Iterable[str | RelatedNode | dict]) -> None -``` - -Add new peers to this relationship. - -#### `remove` - -```python -remove(self, data: str | RelatedNode | dict) -> None -``` - -### `RelationshipManagerSync` - -Manages relationships of a node in a synchronous context. - -**Methods:** - -#### `fetch` - -```python -fetch(self) -> None -``` - -#### `add` - -```python -add(self, data: str | RelatedNodeSync | dict) -> None -``` - -Add a new peer to this relationship. - -#### `extend` - -```python -extend(self, data: Iterable[str | RelatedNodeSync | dict]) -> None -``` - -Add new peers to this relationship. - -#### `remove` - -```python -remove(self, data: str | RelatedNodeSync | dict) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/object_store.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/object_store.mdx deleted file mode 100644 index 2f3cce09..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/object_store.mdx +++ /dev/null @@ -1,42 +0,0 @@ ---- -title: object_store -sidebarTitle: object_store ---- - -# `infrahub_sdk.object_store` - -## Classes - -### `ObjectStoreBase` - -### `ObjectStore` - -**Methods:** - -#### `get` - -```python -get(self, identifier: str, tracker: str | None = None) -> str -``` - -#### `upload` - -```python -upload(self, content: str, tracker: str | None = None) -> dict[str, str] -``` - -### `ObjectStoreSync` - -**Methods:** - -#### `get` - -```python -get(self, identifier: str, tracker: str | None = None) -> str -``` - -#### `upload` - -```python -upload(self, content: str, tracker: str | None = None) -> dict[str, str] -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/operation.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/operation.mdx deleted file mode 100644 index b1f96d2f..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/operation.mdx +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: operation -sidebarTitle: operation ---- - -# `infrahub_sdk.operation` - -## Classes - -### `InfrahubOperation` - -**Methods:** - -#### `branch_name` - -```python -branch_name(self) -> str -``` - -Return the name of the current git branch. - -#### `store` - -```python -store(self) -> NodeStore -``` - -The store will be populated with nodes based on the query during the collection of data if activated - -#### `nodes` - -```python -nodes(self) -> list[InfrahubNode] -``` - -Returns nodes collected and parsed during the data collection process if this feature is enabled - -#### `related_nodes` - -```python -related_nodes(self) -> list[InfrahubNode] -``` - -Returns nodes collected and parsed during the data collection process if this feature is enabled - -#### `process_nodes` - -```python -process_nodes(self, data: dict) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/playback.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/playback.mdx deleted file mode 100644 index e4687058..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/playback.mdx +++ /dev/null @@ -1,24 +0,0 @@ ---- -title: playback -sidebarTitle: playback ---- - -# `infrahub_sdk.playback` - -## Classes - -### `JSONPlayback` - -**Methods:** - -#### `async_request` - -```python -async_request(self, url: str, method: HTTPMethod, headers: dict[str, Any], timeout: int, payload: dict | None = None) -> httpx.Response -``` - -#### `sync_request` - -```python -sync_request(self, url: str, method: HTTPMethod, headers: dict[str, Any], timeout: int, payload: dict | None = None) -> httpx.Response -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols.mdx deleted file mode 100644 index 2368ba66..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols.mdx +++ /dev/null @@ -1,332 +0,0 @@ ---- -title: protocols -sidebarTitle: protocols ---- - -# `infrahub_sdk.protocols` - -## Classes - -### `BuiltinIPAddress` - -### `BuiltinIPNamespace` - -### `BuiltinIPPrefix` - -### `CoreAction` - -### `CoreArtifactTarget` - -### `CoreBasePermission` - -### `CoreCheck` - -### `CoreComment` - -### `CoreCredential` - -### `CoreGenericAccount` - -### `CoreGenericRepository` - -### `CoreGroup` - -### `CoreMenu` - -### `CoreNodeTriggerMatch` - -### `CoreObjectComponentTemplate` - -### `CoreObjectTemplate` - -### `CoreProfile` - -### `CoreResourcePool` - -### `CoreTaskTarget` - -### `CoreThread` - -### `CoreTransformation` - -### `CoreTriggerRule` - -### `CoreValidator` - -### `CoreWebhook` - -### `LineageOwner` - -### `LineageSource` - -### `BuiltinTag` - -### `CoreAccount` - -### `CoreAccountGroup` - -### `CoreAccountRole` - -### `CoreArtifact` - -### `CoreArtifactCheck` - -### `CoreArtifactDefinition` - -### `CoreArtifactThread` - -### `CoreArtifactValidator` - -### `CoreChangeComment` - -### `CoreChangeThread` - -### `CoreCheckDefinition` - -### `CoreCustomWebhook` - -### `CoreDataCheck` - -### `CoreDataValidator` - -### `CoreFileCheck` - -### `CoreFileThread` - -### `CoreGeneratorAction` - -### `CoreGeneratorCheck` - -### `CoreGeneratorDefinition` - -### `CoreGeneratorGroup` - -### `CoreGeneratorInstance` - -### `CoreGeneratorValidator` - -### `CoreGlobalPermission` - -### `CoreGraphQLQuery` - -### `CoreGraphQLQueryGroup` - -### `CoreGroupAction` - -### `CoreGroupTriggerRule` - -### `CoreIPAddressPool` - -### `CoreIPPrefixPool` - -### `CoreMenuItem` - -### `CoreNodeTriggerAttributeMatch` - -### `CoreNodeTriggerRelationshipMatch` - -### `CoreNodeTriggerRule` - -### `CoreNumberPool` - -### `CoreObjectPermission` - -### `CoreObjectThread` - -### `CorePasswordCredential` - -### `CoreProposedChange` - -### `CoreReadOnlyRepository` - -### `CoreRepository` - -### `CoreRepositoryGroup` - -### `CoreRepositoryValidator` - -### `CoreSchemaCheck` - -### `CoreSchemaValidator` - -### `CoreStandardCheck` - -### `CoreStandardGroup` - -### `CoreStandardWebhook` - -### `CoreThreadComment` - -### `CoreTransformJinja2` - -### `CoreTransformPython` - -### `CoreUserValidator` - -### `InternalAccountToken` - -### `InternalRefreshToken` - -### `IpamNamespace` - -### `BuiltinIPAddressSync` - -### `BuiltinIPNamespaceSync` - -### `BuiltinIPPrefixSync` - -### `CoreActionSync` - -### `CoreArtifactTargetSync` - -### `CoreBasePermissionSync` - -### `CoreCheckSync` - -### `CoreCommentSync` - -### `CoreCredentialSync` - -### `CoreGenericAccountSync` - -### `CoreGenericRepositorySync` - -### `CoreGroupSync` - -### `CoreMenuSync` - -### `CoreNodeTriggerMatchSync` - -### `CoreObjectComponentTemplateSync` - -### `CoreObjectTemplateSync` - -### `CoreProfileSync` - -### `CoreResourcePoolSync` - -### `CoreTaskTargetSync` - -### `CoreThreadSync` - -### `CoreTransformationSync` - -### `CoreTriggerRuleSync` - -### `CoreValidatorSync` - -### `CoreWebhookSync` - -### `LineageOwnerSync` - -### `LineageSourceSync` - -### `BuiltinTagSync` - -### `CoreAccountSync` - -### `CoreAccountGroupSync` - -### `CoreAccountRoleSync` - -### `CoreArtifactSync` - -### `CoreArtifactCheckSync` - -### `CoreArtifactDefinitionSync` - -### `CoreArtifactThreadSync` - -### `CoreArtifactValidatorSync` - -### `CoreChangeCommentSync` - -### `CoreChangeThreadSync` - -### `CoreCheckDefinitionSync` - -### `CoreCustomWebhookSync` - -### `CoreDataCheckSync` - -### `CoreDataValidatorSync` - -### `CoreFileCheckSync` - -### `CoreFileThreadSync` - -### `CoreGeneratorActionSync` - -### `CoreGeneratorCheckSync` - -### `CoreGeneratorDefinitionSync` - -### `CoreGeneratorGroupSync` - -### `CoreGeneratorInstanceSync` - -### `CoreGeneratorValidatorSync` - -### `CoreGlobalPermissionSync` - -### `CoreGraphQLQuerySync` - -### `CoreGraphQLQueryGroupSync` - -### `CoreGroupActionSync` - -### `CoreGroupTriggerRuleSync` - -### `CoreIPAddressPoolSync` - -### `CoreIPPrefixPoolSync` - -### `CoreMenuItemSync` - -### `CoreNodeTriggerAttributeMatchSync` - -### `CoreNodeTriggerRelationshipMatchSync` - -### `CoreNodeTriggerRuleSync` - -### `CoreNumberPoolSync` - -### `CoreObjectPermissionSync` - -### `CoreObjectThreadSync` - -### `CorePasswordCredentialSync` - -### `CoreProposedChangeSync` - -### `CoreReadOnlyRepositorySync` - -### `CoreRepositorySync` - -### `CoreRepositoryGroupSync` - -### `CoreRepositoryValidatorSync` - -### `CoreSchemaCheckSync` - -### `CoreSchemaValidatorSync` - -### `CoreStandardCheckSync` - -### `CoreStandardGroupSync` - -### `CoreStandardWebhookSync` - -### `CoreThreadCommentSync` - -### `CoreTransformJinja2Sync` - -### `CoreTransformPythonSync` - -### `CoreUserValidatorSync` - -### `InternalAccountTokenSync` - -### `InternalRefreshTokenSync` - -### `IpamNamespaceSync` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_base.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_base.mdx deleted file mode 100644 index 01665925..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_base.mdx +++ /dev/null @@ -1,272 +0,0 @@ ---- -title: protocols_base -sidebarTitle: protocols_base ---- - -# `infrahub_sdk.protocols_base` - -## Classes - -### `RelatedNodeBase` - -**Methods:** - -#### `id` - -```python -id(self) -> str | None -``` - -#### `hfid` - -```python -hfid(self) -> list[Any] | None -``` - -#### `hfid_str` - -```python -hfid_str(self) -> str | None -``` - -#### `is_resource_pool` - -```python -is_resource_pool(self) -> bool -``` - -#### `initialized` - -```python -initialized(self) -> bool -``` - -#### `display_label` - -```python -display_label(self) -> str | None -``` - -#### `typename` - -```python -typename(self) -> str | None -``` - -### `RelatedNode` - -### `RelatedNodeSync` - -### `Attribute` - -### `String` - -### `StringOptional` - -### `DateTime` - -### `DateTimeOptional` - -### `HashedPassword` - -### `HashedPasswordOptional` - -### `URL` - -### `URLOptional` - -### `MacAddress` - -### `MacAddressOptional` - -### `Dropdown` - -### `DropdownOptional` - -### `Enum` - -### `EnumOptional` - -### `Integer` - -### `IntegerOptional` - -### `IPHost` - -### `IPHostOptional` - -### `IPNetwork` - -### `IPNetworkOptional` - -### `Boolean` - -### `BooleanOptional` - -### `ListAttribute` - -### `ListAttributeOptional` - -### `JSONAttribute` - -### `JSONAttributeOptional` - -### `AnyAttribute` - -### `AnyAttributeOptional` - -### `CoreNodeBase` - -**Methods:** - -#### `hfid` - -```python -hfid(self) -> list[str] | None -``` - -#### `hfid_str` - -```python -hfid_str(self) -> str | None -``` - -#### `get_human_friendly_id` - -```python -get_human_friendly_id(self) -> list[str] | None -``` - -#### `get_human_friendly_id_as_string` - -```python -get_human_friendly_id_as_string(self, include_kind: bool = False) -> str | None -``` - -#### `get_kind` - -```python -get_kind(self) -> str -``` - -#### `get_all_kinds` - -```python -get_all_kinds(self) -> list[str] -``` - -#### `get_branch` - -```python -get_branch(self) -> str -``` - -#### `is_ip_prefix` - -```python -is_ip_prefix(self) -> bool -``` - -#### `is_ip_address` - -```python -is_ip_address(self) -> bool -``` - -#### `is_resource_pool` - -```python -is_resource_pool(self) -> bool -``` - -#### `get_raw_graphql_data` - -```python -get_raw_graphql_data(self) -> dict | None -``` - -#### `extract` - -```python -extract(self, params: dict[str, str]) -> dict[str, Any] -``` - -### `CoreNode` - -**Methods:** - -#### `save` - -```python -save(self, allow_upsert: bool = False, update_group_context: bool | None = None, timeout: int | None = None, request_context: RequestContext | None = None) -> None -``` - -#### `delete` - -```python -delete(self, timeout: int | None = None, request_context: RequestContext | None = None) -> None -``` - -#### `update` - -```python -update(self, do_full_update: bool, timeout: int | None = None, request_context: RequestContext | None = None) -> None -``` - -#### `create` - -```python -create(self, allow_upsert: bool = False, timeout: int | None = None, request_context: RequestContext | None = None) -> None -``` - -#### `add_relationships` - -```python -add_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None -``` - -#### `remove_relationships` - -```python -remove_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None -``` - -### `CoreNodeSync` - -**Methods:** - -#### `save` - -```python -save(self, allow_upsert: bool = False, update_group_context: bool | None = None, timeout: int | None = None, request_context: RequestContext | None = None) -> None -``` - -#### `delete` - -```python -delete(self, timeout: int | None = None, request_context: RequestContext | None = None) -> None -``` - -#### `update` - -```python -update(self, do_full_update: bool, timeout: int | None = None, request_context: RequestContext | None = None) -> None -``` - -#### `create` - -```python -create(self, allow_upsert: bool = False, timeout: int | None = None, request_context: RequestContext | None = None) -> None -``` - -#### `add_relationships` - -```python -add_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None -``` - -#### `remove_relationships` - -```python -remove_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/constants.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/constants.mdx deleted file mode 100644 index bdebeaff..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/constants.mdx +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: constants -sidebarTitle: constants ---- - -# `infrahub_sdk.protocols_generator.constants` - -*This module is empty or contains only private/internal implementations.* diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/generator.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/generator.mdx deleted file mode 100644 index b59c45c7..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/protocols_generator/generator.mdx +++ /dev/null @@ -1,34 +0,0 @@ ---- -title: generator -sidebarTitle: generator ---- - -# `infrahub_sdk.protocols_generator.generator` - -## Functions - -### `load_template` - -```python -load_template() -> str -``` - -### `move_to_end_of_list` - -```python -move_to_end_of_list(lst: list, item: str) -> list -``` - -Move an item to the end of a list if it exists in the list - -## Classes - -### `CodeGenerator` - -**Methods:** - -#### `render` - -```python -render(self, sync: bool = True) -> str -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/exceptions.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/exceptions.mdx deleted file mode 100644 index c8d85b8c..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/exceptions.mdx +++ /dev/null @@ -1,30 +0,0 @@ ---- -title: exceptions -sidebarTitle: exceptions ---- - -# `infrahub_sdk.pytest_plugin.exceptions` - -## Classes - -### `Error` - -pytest-infrahub Base exception. - -### `InvalidResourceConfigError` - -### `DirectoryNotFoundError` - -### `FileNotValidError` - -### `OutputMatchError` - -### `Jinja2TransformError` - -### `Jinja2TransformUndefinedError` - -### `CheckDefinitionError` - -### `CheckResultError` - -### `PythonTransformDefinitionError` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/base.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/base.mdx deleted file mode 100644 index 023020a2..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/base.mdx +++ /dev/null @@ -1,61 +0,0 @@ ---- -title: base -sidebarTitle: base ---- - -# `infrahub_sdk.pytest_plugin.items.base` - -## Classes - -### `InfrahubItem` - -**Methods:** - -#### `validate_resource_config` - -```python -validate_resource_config(self) -> None -``` - -Make sure that a test resource config is properly defined. - -#### `get_result_differences` - -```python -get_result_differences(self, computed: Any) -> str | None -``` - -Compute the differences between the computed result and the expected one. - -If the results are not JSON parsable, this method must be redefined to handle them. - -#### `runtest` - -```python -runtest(self) -> None -``` - -Run the test logic. - -#### `repr_failure` - -```python -repr_failure(self, excinfo: pytest.ExceptionInfo, style: str | None = None) -> str -``` - -#### `reportinfo` - -```python -reportinfo(self) -> tuple[Path | str, int | None, str] -``` - -#### `repository_base` - -```python -repository_base(self) -> str -``` - -Return the path to the root of the repository - -This will be an absolute path if --infrahub-config-path is an absolute path as happens when -tests are started from within Infrahub server. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/check.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/check.mdx deleted file mode 100644 index 1b30a8a7..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/check.mdx +++ /dev/null @@ -1,60 +0,0 @@ ---- -title: check -sidebarTitle: check ---- - -# `infrahub_sdk.pytest_plugin.items.check` - -## Classes - -### `InfrahubCheckItem` - -**Methods:** - -#### `instantiate_check` - -```python -instantiate_check(self) -> None -``` - -#### `run_check` - -```python -run_check(self, variables: dict[str, Any]) -> Any -``` - -#### `repr_failure` - -```python -repr_failure(self, excinfo: ExceptionInfo, style: str | None = None) -> str -``` - -### `InfrahubCheckSmokeItem` - -**Methods:** - -#### `runtest` - -```python -runtest(self) -> None -``` - -### `InfrahubCheckUnitProcessItem` - -**Methods:** - -#### `runtest` - -```python -runtest(self) -> None -``` - -### `InfrahubCheckIntegrationItem` - -**Methods:** - -#### `runtest` - -```python -runtest(self) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/graphql_query.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/graphql_query.mdx deleted file mode 100644 index dd3d9b58..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/graphql_query.mdx +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: graphql_query -sidebarTitle: graphql_query ---- - -# `infrahub_sdk.pytest_plugin.items.graphql_query` - -## Classes - -### `InfrahubGraphQLQueryItem` - -**Methods:** - -#### `validate_resource_config` - -```python -validate_resource_config(self) -> None -``` - -#### `execute_query` - -```python -execute_query(self) -> Any -``` - -#### `repr_failure` - -```python -repr_failure(self, excinfo: ExceptionInfo, style: str | None = None) -> str -``` - -### `InfrahubGraphQLQuerySmokeItem` - -**Methods:** - -#### `runtest` - -```python -runtest(self) -> None -``` - -### `InfrahubGraphQLQueryIntegrationItem` - -**Methods:** - -#### `runtest` - -```python -runtest(self) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/jinja2_transform.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/jinja2_transform.mdx deleted file mode 100644 index ca479c55..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/jinja2_transform.mdx +++ /dev/null @@ -1,78 +0,0 @@ ---- -title: jinja2_transform -sidebarTitle: jinja2_transform ---- - -# `infrahub_sdk.pytest_plugin.items.jinja2_transform` - -## Classes - -### `InfrahubJinja2Item` - -**Methods:** - -#### `get_jinja2_environment` - -```python -get_jinja2_environment(self) -> jinja2.Environment -``` - -#### `get_jinja2_template` - -```python -get_jinja2_template(self) -> jinja2.Template -``` - -#### `render_jinja2_template` - -```python -render_jinja2_template(self, variables: dict[str, Any]) -> str | None -``` - -#### `get_result_differences` - -```python -get_result_differences(self, computed: Any) -> str | None -``` - -#### `repr_failure` - -```python -repr_failure(self, excinfo: ExceptionInfo, style: str | None = None) -> str -``` - -### `InfrahubJinja2TransformSmokeItem` - -**Methods:** - -#### `runtest` - -```python -runtest(self) -> None -``` - -### `InfrahubJinja2TransformUnitRenderItem` - -**Methods:** - -#### `runtest` - -```python -runtest(self) -> None -``` - -#### `repr_failure` - -```python -repr_failure(self, excinfo: ExceptionInfo, style: str | None = None) -> str -``` - -### `InfrahubJinja2TransformIntegrationItem` - -**Methods:** - -#### `runtest` - -```python -runtest(self) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/python_transform.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/python_transform.mdx deleted file mode 100644 index 13dd67f3..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/items/python_transform.mdx +++ /dev/null @@ -1,60 +0,0 @@ ---- -title: python_transform -sidebarTitle: python_transform ---- - -# `infrahub_sdk.pytest_plugin.items.python_transform` - -## Classes - -### `InfrahubPythonTransformItem` - -**Methods:** - -#### `instantiate_transform` - -```python -instantiate_transform(self) -> None -``` - -#### `run_transform` - -```python -run_transform(self, variables: dict[str, Any]) -> Any -``` - -#### `repr_failure` - -```python -repr_failure(self, excinfo: ExceptionInfo, style: str | None = None) -> str -``` - -### `InfrahubPythonTransformSmokeItem` - -**Methods:** - -#### `runtest` - -```python -runtest(self) -> None -``` - -### `InfrahubPythonTransformUnitProcessItem` - -**Methods:** - -#### `runtest` - -```python -runtest(self) -> None -``` - -### `InfrahubPythonTransformIntegrationItem` - -**Methods:** - -#### `runtest` - -```python -runtest(self) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/loader.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/loader.mdx deleted file mode 100644 index fe591c02..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/loader.mdx +++ /dev/null @@ -1,34 +0,0 @@ ---- -title: loader -sidebarTitle: loader ---- - -# `infrahub_sdk.pytest_plugin.loader` - -## Classes - -### `InfrahubYamlFile` - -**Methods:** - -#### `get_resource_config` - -```python -get_resource_config(self, group: InfrahubTestGroup) -> Any | None -``` - -Retrieve the resource configuration to apply to all tests in a group. - -#### `collect_group` - -```python -collect_group(self, group: InfrahubTestGroup) -> Iterable[Item] -``` - -Collect all items for a group. - -#### `collect` - -```python -collect(self) -> Iterable[Item] -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/models.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/models.mdx deleted file mode 100644 index 9bd13d23..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/models.mdx +++ /dev/null @@ -1,93 +0,0 @@ ---- -title: models -sidebarTitle: models ---- - -# `infrahub_sdk.pytest_plugin.models` - -## Classes - -### `InfrahubTestExpectedResult` - -### `InfrahubTestResource` - -### `InfrahubBaseTest` - -Basic Infrahub test model used as a common ground for all tests. - -### `InfrahubInputOutputTest` - -**Methods:** - -#### `parse_user_provided_data` - -```python -parse_user_provided_data(path: Path | None) -> Any -``` - -Read and parse user provided data depending on a file extension. - -This function handles JSON and YAML as they can be used to achieve the same goal. However some users may be more used to one format or -another. If the file extension isn't known, assume the content is plain text. - -#### `update_paths` - -```python -update_paths(self, base_dir: Path) -> None -``` - -#### `get_input_data` - -```python -get_input_data(self) -> Any -``` - -#### `get_output_data` - -```python -get_output_data(self) -> Any -``` - -### `InfrahubIntegrationTest` - -**Methods:** - -#### `update_paths` - -```python -update_paths(self, base_dir: Path) -> None -``` - -#### `get_variables_data` - -```python -get_variables_data(self) -> dict[str, Any] -``` - -### `InfrahubCheckSmokeTest` - -### `InfrahubCheckUnitProcessTest` - -### `InfrahubCheckIntegrationTest` - -### `InfrahubGraphQLQuerySmokeTest` - -### `InfrahubGraphQLQueryIntegrationTest` - -### `InfrahubJinja2TransformSmokeTest` - -### `InfrahubJinja2TransformUnitRenderTest` - -### `InfrahubJinja2TransformIntegrationTest` - -### `InfrahubPythonTransformSmokeTest` - -### `InfrahubPythonTransformUnitProcessTest` - -### `InfrahubPythonTransformIntegrationTest` - -### `InfrahubTest` - -### `InfrahubTestGroup` - -### `InfrahubTestFileV1` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/plugin.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/plugin.mdx deleted file mode 100644 index ee76f8c1..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/plugin.mdx +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: plugin -sidebarTitle: plugin ---- - -# `infrahub_sdk.pytest_plugin.plugin` - -## Functions - -### `pytest_addoption` - -```python -pytest_addoption(parser: Parser) -> None -``` - -### `pytest_sessionstart` - -```python -pytest_sessionstart(session: Session) -> None -``` - -### `pytest_collect_file` - -```python -pytest_collect_file(parent: Collector | Item, file_path: Path) -> InfrahubYamlFile | None -``` - -### `pytest_configure` - -```python -pytest_configure(config: Config) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/utils.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/utils.mdx deleted file mode 100644 index ed904129..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/pytest_plugin/utils.mdx +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: utils -sidebarTitle: utils ---- - -# `infrahub_sdk.pytest_plugin.utils` - -## Functions - -### `load_repository_config` - -```python -load_repository_config(repo_config_file: Path) -> InfrahubRepositoryConfig -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/queries.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/queries.mdx deleted file mode 100644 index 394661ee..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/queries.mdx +++ /dev/null @@ -1,14 +0,0 @@ ---- -title: queries -sidebarTitle: queries ---- - -# `infrahub_sdk.queries` - -## Functions - -### `get_commit_update_mutation` - -```python -get_commit_update_mutation(is_read_only: bool = False) -> str -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/query_groups.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/query_groups.mdx deleted file mode 100644 index f5ac9516..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/query_groups.mdx +++ /dev/null @@ -1,131 +0,0 @@ ---- -title: query_groups -sidebarTitle: query_groups ---- - -# `infrahub_sdk.query_groups` - -## Classes - -### `InfrahubGroupContextBase` - -Base class for InfrahubGroupContext and InfrahubGroupContextSync - -**Methods:** - -#### `set_properties` - -```python -set_properties(self, identifier: str, params: dict[str, str] | None = None, delete_unused_nodes: bool = False, group_type: str | None = None, group_params: dict[str, Any] | None = None, branch: str | None = None) -> None -``` - -Setter method to set the values of identifier and params. - -**Args:** - -- `identifier`: The new value for the identifier. -- `params`: A dictionary with new values for the params. - -### `InfrahubGroupContext` - -Represents a Infrahub GroupContext in an asynchronous context. - -**Methods:** - -#### `get_group` - -```python -get_group(self, store_peers: bool = False) -> InfrahubNode | None -``` - -#### `delete_unused` - -```python -delete_unused(self) -> None -``` - -#### `add_related_nodes` - -```python -add_related_nodes(self, ids: list[str], update_group_context: bool | None = None) -> None -``` - -Add related Nodes IDs to the context. - -**Args:** - -- `ids`: List of node IDs to be added. -- `update_group_context`: Flag to control whether to update the group context. - -#### `add_related_groups` - -```python -add_related_groups(self, ids: list[str], update_group_context: bool | None = None) -> None -``` - -Add related Groups IDs to the context. - -**Args:** - -- `ids`: List of group IDs to be added. -- `update_group_context`: Flag to control whether to update the group context. - -#### `update_group` - -```python -update_group(self) -> None -``` - -Create or update (using upsert) a CoreStandardGroup to store all the Nodes and Groups used during an execution. - -### `InfrahubGroupContextSync` - -Represents a Infrahub GroupContext in an synchronous context. - -**Methods:** - -#### `get_group` - -```python -get_group(self, store_peers: bool = False) -> InfrahubNodeSync | None -``` - -#### `delete_unused` - -```python -delete_unused(self) -> None -``` - -#### `add_related_nodes` - -```python -add_related_nodes(self, ids: list[str], update_group_context: bool | None = None) -> None -``` - -Add related Nodes IDs to the context. - -**Args:** - -- `ids`: List of node IDs to be added. -- `update_group_context`: Flag to control whether to update the group context. - -#### `add_related_groups` - -```python -add_related_groups(self, ids: list[str], update_group_context: bool | None = None) -> None -``` - -Add related Groups IDs to the context. - -**Args:** - -- `ids`: List of group IDs to be added. -- `update_group_context`: Flag to control whether to update the group context. - -#### `update_group` - -```python -update_group(self) -> None -``` - -Create or update (using upsert) a CoreStandardGroup to store all the Nodes and Groups used during an execution. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/recorder.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/recorder.mdx deleted file mode 100644 index 94251b72..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/recorder.mdx +++ /dev/null @@ -1,50 +0,0 @@ ---- -title: recorder -sidebarTitle: recorder ---- - -# `infrahub_sdk.recorder` - -## Classes - -### `RecorderType` - -### `Recorder` - -**Methods:** - -#### `record` - -```python -record(self, response: httpx.Response) -> None -``` - -Record the response from Infrahub - -### `NoRecorder` - -**Methods:** - -#### `record` - -```python -record(response: httpx.Response) -> None -``` - -The NoRecorder just silently returns - -#### `default` - -```python -default(cls) -> NoRecorder -``` - -### `JSONRecorder` - -**Methods:** - -#### `record` - -```python -record(self, response: httpx.Response) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/repository.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/repository.mdx deleted file mode 100644 index 5546beda..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/repository.mdx +++ /dev/null @@ -1,24 +0,0 @@ ---- -title: repository -sidebarTitle: repository ---- - -# `infrahub_sdk.repository` - -## Classes - -### `GitRepoManager` - -**Methods:** - -#### `initialize_repo` - -```python -initialize_repo(self) -> Repo -``` - -#### `active_branch` - -```python -active_branch(self) -> str | None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/main.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/main.mdx deleted file mode 100644 index deedc99e..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/main.mdx +++ /dev/null @@ -1,204 +0,0 @@ ---- -title: main -sidebarTitle: main ---- - -# `infrahub_sdk.schema.main` - -## Classes - -### `RelationshipCardinality` - -### `BranchSupportType` - -### `RelationshipKind` - -### `RelationshipDirection` - -### `AttributeKind` - -### `SchemaState` - -### `AllowOverrideType` - -### `RelationshipDeleteBehavior` - -### `AttributeSchema` - -### `AttributeSchemaAPI` - -### `RelationshipSchema` - -### `RelationshipSchemaAPI` - -### `BaseSchemaAttrRel` - -### `BaseSchemaAttrRelAPI` - -**Methods:** - -#### `get_field` - -```python -get_field(self, name: str, raise_on_error: bool = True) -> AttributeSchemaAPI | RelationshipSchemaAPI | None -``` - -#### `get_attribute` - -```python -get_attribute(self, name: str) -> AttributeSchemaAPI -``` - -#### `get_attribute_or_none` - -```python -get_attribute_or_none(self, name: str) -> AttributeSchemaAPI | None -``` - -#### `get_relationship` - -```python -get_relationship(self, name: str) -> RelationshipSchemaAPI -``` - -#### `get_relationship_or_none` - -```python -get_relationship_or_none(self, name: str) -> RelationshipSchemaAPI | None -``` - -#### `get_relationship_by_identifier` - -```python -get_relationship_by_identifier(self, id: str, raise_on_error: bool = True) -> RelationshipSchemaAPI | None -``` - -#### `get_matching_relationship` - -```python -get_matching_relationship(self, id: str, direction: RelationshipDirection = RelationshipDirection.BIDIR) -> RelationshipSchemaAPI -``` - -#### `attribute_names` - -```python -attribute_names(self) -> list[str] -``` - -#### `relationship_names` - -```python -relationship_names(self) -> list[str] -``` - -#### `mandatory_input_names` - -```python -mandatory_input_names(self) -> list[str] -``` - -#### `mandatory_attribute_names` - -```python -mandatory_attribute_names(self) -> list[str] -``` - -#### `mandatory_relationship_names` - -```python -mandatory_relationship_names(self) -> list[str] -``` - -#### `local_attributes` - -```python -local_attributes(self) -> list[AttributeSchemaAPI] -``` - -#### `local_relationships` - -```python -local_relationships(self) -> list[RelationshipSchemaAPI] -``` - -#### `unique_attributes` - -```python -unique_attributes(self) -> list[AttributeSchemaAPI] -``` - -### `BaseSchema` - -**Methods:** - -#### `kind` - -```python -kind(self) -> str -``` - -### `GenericSchema` - -**Methods:** - -#### `convert_api` - -```python -convert_api(self) -> GenericSchemaAPI -``` - -### `GenericSchemaAPI` - -A Generic can be either an Interface or a Union depending if there are some Attributes or Relationships defined. - -### `BaseNodeSchema` - -### `NodeSchema` - -**Methods:** - -#### `convert_api` - -```python -convert_api(self) -> NodeSchemaAPI -``` - -### `NodeSchemaAPI` - -### `ProfileSchemaAPI` - -### `TemplateSchemaAPI` - -### `NodeExtensionSchema` - -### `SchemaRoot` - -**Methods:** - -#### `to_schema_dict` - -```python -to_schema_dict(self) -> dict[str, Any] -``` - -### `SchemaRootAPI` - -### `BranchSchema` - -**Methods:** - -#### `from_api_response` - -```python -from_api_response(cls, data: MutableMapping[str, Any]) -> Self -``` - -Convert an API response from /api/schema into a BranchSchema object. - -#### `from_schema_root_api` - -```python -from_schema_root_api(cls, data: SchemaRootAPI) -> Self -``` - -Convert a SchemaRootAPI object to a BranchSchema object. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/repository.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/repository.mdx deleted file mode 100644 index 4779ebb5..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/schema/repository.mdx +++ /dev/null @@ -1,156 +0,0 @@ ---- -title: repository -sidebarTitle: repository ---- - -# `infrahub_sdk.schema.repository` - -## Classes - -### `InfrahubRepositoryConfigElement` - -Class to regroup all elements of the infrahub configuration for a repository for typing purpose. - -### `InfrahubRepositoryArtifactDefinitionConfig` - -### `InfrahubJinja2TransformConfig` - -**Methods:** - -#### `template_path_value` - -```python -template_path_value(self) -> str -``` - -#### `payload` - -```python -payload(self) -> dict[str, str] -``` - -### `InfrahubCheckDefinitionConfig` - -**Methods:** - -#### `load_class` - -```python -load_class(self, import_root: str | None = None, relative_path: str | None = None) -> type[InfrahubCheck] -``` - -### `InfrahubGeneratorDefinitionConfig` - -**Methods:** - -#### `load_class` - -```python -load_class(self, import_root: str | None = None, relative_path: str | None = None) -> type[InfrahubGenerator] -``` - -### `InfrahubPythonTransformConfig` - -**Methods:** - -#### `load_class` - -```python -load_class(self, import_root: str | None = None, relative_path: str | None = None) -> type[InfrahubTransform] -``` - -### `InfrahubRepositoryGraphQLConfig` - -**Methods:** - -#### `load_query` - -```python -load_query(self, relative_path: str = '.') -> str -``` - -### `InfrahubObjectConfig` - -### `InfrahubMenuConfig` - -### `InfrahubRepositoryConfig` - -**Methods:** - -#### `unique_items` - -```python -unique_items(cls, v: list[Any]) -> list[Any] -``` - -#### `has_jinja2_transform` - -```python -has_jinja2_transform(self, name: str) -> bool -``` - -#### `get_jinja2_transform` - -```python -get_jinja2_transform(self, name: str) -> InfrahubJinja2TransformConfig -``` - -#### `has_check_definition` - -```python -has_check_definition(self, name: str) -> bool -``` - -#### `get_check_definition` - -```python -get_check_definition(self, name: str) -> InfrahubCheckDefinitionConfig -``` - -#### `has_artifact_definition` - -```python -has_artifact_definition(self, name: str) -> bool -``` - -#### `get_artifact_definition` - -```python -get_artifact_definition(self, name: str) -> InfrahubRepositoryArtifactDefinitionConfig -``` - -#### `has_generator_definition` - -```python -has_generator_definition(self, name: str) -> bool -``` - -#### `get_generator_definition` - -```python -get_generator_definition(self, name: str) -> InfrahubGeneratorDefinitionConfig -``` - -#### `has_python_transform` - -```python -has_python_transform(self, name: str) -> bool -``` - -#### `get_python_transform` - -```python -get_python_transform(self, name: str) -> InfrahubPythonTransformConfig -``` - -#### `has_query` - -```python -has_query(self, name: str) -> bool -``` - -#### `get_query` - -```python -get_query(self, name: str) -> InfrahubRepositoryGraphQLConfig -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/menu.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/menu.mdx deleted file mode 100644 index 89aabc9a..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/menu.mdx +++ /dev/null @@ -1,34 +0,0 @@ ---- -title: menu -sidebarTitle: menu ---- - -# `infrahub_sdk.spec.menu` - -## Classes - -### `InfrahubMenuFileData` - -**Methods:** - -#### `enrich_node` - -```python -enrich_node(cls, data: dict, context: dict) -> dict -``` - -### `MenuFile` - -**Methods:** - -#### `spec` - -```python -spec(self) -> InfrahubMenuFileData -``` - -#### `validate_content` - -```python -validate_content(self) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/object.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/object.mdx deleted file mode 100644 index 9efe0df3..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/spec/object.mdx +++ /dev/null @@ -1,170 +0,0 @@ ---- -title: object -sidebarTitle: object ---- - -# `infrahub_sdk.spec.object` - -## Functions - -### `validate_list_of_scalars` - -```python -validate_list_of_scalars(value: list[Any]) -> bool -``` - -### `validate_list_of_hfids` - -```python -validate_list_of_hfids(value: list[Any]) -> bool -``` - -### `validate_list_of_data_dicts` - -```python -validate_list_of_data_dicts(value: list[Any]) -> bool -``` - -### `validate_list_of_objects` - -```python -validate_list_of_objects(value: list[Any]) -> bool -``` - -### `get_relationship_info` - -```python -get_relationship_info(client: InfrahubClient, schema: MainSchemaTypesAPI, name: str, value: Any, branch: str | None = None) -> RelationshipInfo -``` - -Get the relationship info for a given relationship name. - -## Classes - -### `RelationshipDataFormat` - -### `RelationshipInfo` - -**Methods:** - -#### `is_bidirectional` - -```python -is_bidirectional(self) -> bool -``` - -Indicate if a relationship with the same identifier exists on the other side - -#### `is_mandatory` - -```python -is_mandatory(self) -> bool -``` - -#### `is_valid` - -```python -is_valid(self) -> bool -``` - -#### `is_reference` - -```python -is_reference(self) -> bool -``` - -#### `get_context` - -```python -get_context(self, value: Any) -> dict -``` - -Return a dict to insert to the context if the relationship is mandatory - -#### `find_matching_relationship` - -```python -find_matching_relationship(self, peer_schema: MainSchemaTypesAPI, force: bool = False) -> RelationshipSchema | None -``` - -Find the matching relationship on the other side of the relationship - -### `InfrahubObjectFileData` - -**Methods:** - -#### `validate_format` - -```python -validate_format(self, client: InfrahubClient, branch: str | None = None) -> list[ObjectValidationError] -``` - -#### `process` - -```python -process(self, client: InfrahubClient, branch: str | None = None) -> None -``` - -#### `validate_object` - -```python -validate_object(cls, client: InfrahubClient, schema: MainSchemaTypesAPI, data: dict, position: list[int | str], context: dict | None = None, branch: str | None = None, default_schema_kind: str | None = None) -> list[ObjectValidationError] -``` - -#### `validate_related_nodes` - -```python -validate_related_nodes(cls, client: InfrahubClient, position: list[int | str], rel_info: RelationshipInfo, data: dict | list[dict], context: dict | None = None, branch: str | None = None, default_schema_kind: str | None = None) -> list[ObjectValidationError] -``` - -#### `enrich_node` - -```python -enrich_node(cls, data: dict, context: dict) -> dict -``` - -#### `create_node` - -```python -create_node(cls, client: InfrahubClient, schema: MainSchemaTypesAPI, data: dict, position: list[int | str], context: dict | None = None, branch: str | None = None, default_schema_kind: str | None = None) -> InfrahubNode -``` - -#### `create_related_nodes` - -```python -create_related_nodes(cls, client: InfrahubClient, rel_info: RelationshipInfo, position: list[int | str], data: dict | list[dict], parent_node: InfrahubNode | None = None, context: dict | None = None, branch: str | None = None, default_schema_kind: str | None = None) -> list[InfrahubNode] -``` - -#### `get_peer_schema` - -```python -get_peer_schema(cls, client: InfrahubClient, peer_kind: str, branch: str | None = None, default_schema_kind: str | None = None) -> MainSchemaTypesAPI -``` - -### `ObjectFile` - -**Methods:** - -#### `spec` - -```python -spec(self) -> InfrahubObjectFileData -``` - -#### `validate_content` - -```python -validate_content(self) -> None -``` - -#### `validate_format` - -```python -validate_format(self, client: InfrahubClient, branch: str | None = None) -> None -``` - -#### `process` - -```python -process(self, client: InfrahubClient, branch: str | None = None) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/store.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/store.mdx deleted file mode 100644 index 681ddd5d..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/store.mdx +++ /dev/null @@ -1,193 +0,0 @@ ---- -title: store -sidebarTitle: store ---- - -# `infrahub_sdk.store` - -## Functions - -### `get_schema_name` - -```python -get_schema_name(schema: type[SchemaType | SchemaTypeSync] | str | None = None) -> str | None -``` - -## Classes - -### `NodeStoreBranch` - -**Methods:** - -#### `count` - -```python -count(self) -> int -``` - -#### `set` - -```python -set(self, node: InfrahubNode | InfrahubNodeSync | CoreNode | CoreNodeSync, key: str | None = None) -> None -``` - -#### `get` - -```python -get(self, key: str | list[str], kind: type[SchemaType | SchemaTypeSync] | str | None = None, raise_when_missing: bool = True) -> InfrahubNode | InfrahubNodeSync | CoreNode | CoreNodeSync | None -``` - -### `NodeStoreBase` - -Internal Store for InfrahubNode objects. - -Often while creating a lot of new objects, -we need to save them in order to reuse them later to associate them with another node for example. - -**Methods:** - -#### `count` - -```python -count(self, branch: str | None = None) -> int -``` - -### `NodeStore` - -**Methods:** - -#### `get` - -```python -get(self, key: str | list[str], kind: type[SchemaType], raise_when_missing: Literal[True] = True, branch: str | None = ...) -> SchemaType -``` - -#### `get` - -```python -get(self, key: str | list[str], kind: type[SchemaType], raise_when_missing: Literal[False] = False, branch: str | None = ...) -> SchemaType | None -``` - -#### `get` - -```python -get(self, key: str | list[str], kind: type[SchemaType], raise_when_missing: bool = ..., branch: str | None = ...) -> SchemaType -``` - -#### `get` - -```python -get(self, key: str | list[str], kind: str | None = ..., raise_when_missing: Literal[True] = True, branch: str | None = ...) -> InfrahubNode -``` - -#### `get` - -```python -get(self, key: str | list[str], kind: str | None = ..., raise_when_missing: Literal[False] = False, branch: str | None = ...) -> InfrahubNode | None -``` - -#### `get` - -```python -get(self, key: str | list[str], kind: str | None = ..., raise_when_missing: bool = ..., branch: str | None = ...) -> InfrahubNode -``` - -#### `get` - -```python -get(self, key: str | list[str], kind: str | type[SchemaType] | None = None, raise_when_missing: bool = True, branch: str | None = None) -> InfrahubNode | SchemaType | None -``` - -#### `get_by_hfid` - -```python -get_by_hfid(self, key: str | list[str], raise_when_missing: Literal[True] = True, branch: str | None = ...) -> InfrahubNode -``` - -#### `get_by_hfid` - -```python -get_by_hfid(self, key: str | list[str], raise_when_missing: Literal[False] = False, branch: str | None = ...) -> InfrahubNode | None -``` - -#### `get_by_hfid` - -```python -get_by_hfid(self, key: str | list[str], raise_when_missing: bool = True, branch: str | None = None) -> InfrahubNode | None -``` - -#### `set` - -```python -set(self, node: InfrahubNode | SchemaType, key: str | None = None, branch: str | None = None) -> None -``` - -### `NodeStoreSync` - -**Methods:** - -#### `get` - -```python -get(self, key: str | list[str], kind: type[SchemaTypeSync], raise_when_missing: Literal[True] = True, branch: str | None = ...) -> SchemaTypeSync -``` - -#### `get` - -```python -get(self, key: str | list[str], kind: type[SchemaTypeSync], raise_when_missing: Literal[False] = False, branch: str | None = ...) -> SchemaTypeSync | None -``` - -#### `get` - -```python -get(self, key: str | list[str], kind: type[SchemaTypeSync], raise_when_missing: bool = ..., branch: str | None = ...) -> SchemaTypeSync -``` - -#### `get` - -```python -get(self, key: str | list[str], kind: str | None = ..., raise_when_missing: Literal[True] = True, branch: str | None = ...) -> InfrahubNodeSync -``` - -#### `get` - -```python -get(self, key: str | list[str], kind: str | None = ..., raise_when_missing: Literal[False] = False, branch: str | None = ...) -> InfrahubNodeSync | None -``` - -#### `get` - -```python -get(self, key: str | list[str], kind: str | None = ..., raise_when_missing: bool = ..., branch: str | None = ...) -> InfrahubNodeSync -``` - -#### `get` - -```python -get(self, key: str | list[str], kind: str | type[SchemaTypeSync] | None = None, raise_when_missing: bool = True, branch: str | None = None) -> InfrahubNodeSync | SchemaTypeSync | None -``` - -#### `get_by_hfid` - -```python -get_by_hfid(self, key: str | list[str], raise_when_missing: Literal[True] = True, branch: str | None = ...) -> InfrahubNodeSync -``` - -#### `get_by_hfid` - -```python -get_by_hfid(self, key: str | list[str], raise_when_missing: Literal[False] = False, branch: str | None = ...) -> InfrahubNodeSync | None -``` - -#### `get_by_hfid` - -```python -get_by_hfid(self, key: str | list[str], raise_when_missing: bool = True, branch: str | None = None) -> InfrahubNodeSync | None -``` - -#### `set` - -```python -set(self, node: InfrahubNodeSync | SchemaTypeSync, key: str | None = None, branch: str | None = None) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/constants.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/constants.mdx deleted file mode 100644 index f20f01fd..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/constants.mdx +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: constants -sidebarTitle: constants ---- - -# `infrahub_sdk.task.constants` - -*This module is empty or contains only private/internal implementations.* diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/exceptions.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/exceptions.mdx deleted file mode 100644 index 27ca9ede..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/exceptions.mdx +++ /dev/null @@ -1,16 +0,0 @@ ---- -title: exceptions -sidebarTitle: exceptions ---- - -# `infrahub_sdk.task.exceptions` - -## Classes - -### `TaskError` - -### `TaskNotFoundError` - -### `TooManyTasksError` - -### `TaskNotCompletedError` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/manager.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/manager.mdx deleted file mode 100644 index c5ccf7e2..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/manager.mdx +++ /dev/null @@ -1,262 +0,0 @@ ---- -title: manager -sidebarTitle: manager ---- - -# `infrahub_sdk.task.manager` - -## Classes - -### `InfraHubTaskManagerBase` - -### `InfrahubTaskManager` - -**Methods:** - -#### `count` - -```python -count(self, filters: TaskFilter | None = None) -> int -``` - -Count the number of tasks. - -**Args:** - -- `filters`: The filter to apply to the tasks. Defaults to None. - -**Returns:** - -- The number of tasks. - -#### `all` - -```python -all(self, limit: int | None = None, offset: int | None = None, timeout: int | None = None, parallel: bool = False, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task] -``` - -Get all tasks. - -**Args:** - -- `limit`: The maximum number of tasks to return. Defaults to None. -- `offset`: The offset to start the tasks from. Defaults to None. -- `timeout`: The timeout to wait for the tasks to complete. Defaults to None. -- `parallel`: Whether to query the tasks in parallel. Defaults to False. -- `include_logs`: Whether to include the logs in the tasks. Defaults to False. -- `include_related_nodes`: Whether to include the related nodes in the tasks. Defaults to False. - -**Returns:** - -- A list of tasks. - -#### `filter` - -```python -filter(self, filter: TaskFilter | None = None, limit: int | None = None, offset: int | None = None, timeout: int | None = None, parallel: bool = False, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task] -``` - -Filter tasks. - -**Args:** - -- `filter`: The filter to apply to the tasks. Defaults to None. -- `limit`: The maximum number of tasks to return. Defaults to None. -- `offset`: The offset to start the tasks from. Defaults to None. -- `timeout`: The timeout to wait for the tasks to complete. Defaults to None. -- `parallel`: Whether to query the tasks in parallel. Defaults to False. -- `include_logs`: Whether to include the logs in the tasks. Defaults to False. -- `include_related_nodes`: Whether to include the related nodes in the tasks. Defaults to False. - -**Returns:** - -- A list of tasks. - -#### `get` - -```python -get(self, id: str, include_logs: bool = False, include_related_nodes: bool = False) -> Task -``` - -#### `wait_for_completion` - -```python -wait_for_completion(self, id: str, interval: int = 1, timeout: int = 60) -> Task -``` - -Wait for a task to complete. - -**Args:** - -- `id`: The id of the task to wait for. -- `interval`: The interval to check the task state. Defaults to 1. -- `timeout`: The timeout to wait for the task to complete. Defaults to 60. - -**Raises:** - -- `TaskNotCompletedError`: The task did not complete in the given timeout. - -**Returns:** - -- The task object. - -#### `process_page` - -```python -process_page(client: InfrahubClient, query: Query, page_number: int, timeout: int | None = None) -> tuple[list[Task], int | None] -``` - -Process a single page of results. - -**Args:** - -- `client`: The client to use to execute the query. -- `query`: The query to execute. -- `page_number`: The page number to process. -- `timeout`: The timeout to wait for the query to complete. Defaults to None. - -**Returns:** - -- A tuple containing a list of tasks and the count of tasks. - -#### `process_batch` - -```python -process_batch(self, filters: TaskFilter | None = None, timeout: int | None = None, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task] -``` - -Process queries in parallel mode. - -#### `process_non_batch` - -```python -process_non_batch(self, filters: TaskFilter | None = None, offset: int | None = None, limit: int | None = None, timeout: int | None = None, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task] -``` - -Process queries without parallel mode. - -### `InfrahubTaskManagerSync` - -**Methods:** - -#### `count` - -```python -count(self, filters: TaskFilter | None = None) -> int -``` - -Count the number of tasks. - -**Args:** - -- `filters`: The filter to apply to the tasks. Defaults to None. - -**Returns:** - -- The number of tasks. - -#### `all` - -```python -all(self, limit: int | None = None, offset: int | None = None, timeout: int | None = None, parallel: bool = False, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task] -``` - -Get all tasks. - -**Args:** - -- `limit`: The maximum number of tasks to return. Defaults to None. -- `offset`: The offset to start the tasks from. Defaults to None. -- `timeout`: The timeout to wait for the tasks to complete. Defaults to None. -- `parallel`: Whether to query the tasks in parallel. Defaults to False. -- `include_logs`: Whether to include the logs in the tasks. Defaults to False. -- `include_related_nodes`: Whether to include the related nodes in the tasks. Defaults to False. - -**Returns:** - -- A list of tasks. - -#### `filter` - -```python -filter(self, filter: TaskFilter | None = None, limit: int | None = None, offset: int | None = None, timeout: int | None = None, parallel: bool = False, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task] -``` - -Filter tasks. - -**Args:** - -- `filter`: The filter to apply to the tasks. Defaults to None. -- `limit`: The maximum number of tasks to return. Defaults to None. -- `offset`: The offset to start the tasks from. Defaults to None. -- `timeout`: The timeout to wait for the tasks to complete. Defaults to None. -- `parallel`: Whether to query the tasks in parallel. Defaults to False. -- `include_logs`: Whether to include the logs in the tasks. Defaults to False. -- `include_related_nodes`: Whether to include the related nodes in the tasks. Defaults to False. - -**Returns:** - -- A list of tasks. - -#### `get` - -```python -get(self, id: str, include_logs: bool = False, include_related_nodes: bool = False) -> Task -``` - -#### `wait_for_completion` - -```python -wait_for_completion(self, id: str, interval: int = 1, timeout: int = 60) -> Task -``` - -Wait for a task to complete. - -**Args:** - -- `id`: The id of the task to wait for. -- `interval`: The interval to check the task state. Defaults to 1. -- `timeout`: The timeout to wait for the task to complete. Defaults to 60. - -**Raises:** - -- `TaskNotCompletedError`: The task did not complete in the given timeout. - -**Returns:** - -- The task object. - -#### `process_page` - -```python -process_page(client: InfrahubClientSync, query: Query, page_number: int, timeout: int | None = None) -> tuple[list[Task], int | None] -``` - -Process a single page of results. - -**Args:** - -- `client`: The client to use to execute the query. -- `query`: The query to execute. -- `page_number`: The page number to process. -- `timeout`: The timeout to wait for the query to complete. Defaults to None. - -**Returns:** - -- A tuple containing a list of tasks and the count of tasks. - -#### `process_batch` - -```python -process_batch(self, filters: TaskFilter | None = None, timeout: int | None = None, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task] -``` - -Process queries in parallel mode. - -#### `process_non_batch` - -```python -process_non_batch(self, filters: TaskFilter | None = None, offset: int | None = None, limit: int | None = None, timeout: int | None = None, include_logs: bool = False, include_related_nodes: bool = False) -> list[Task] -``` - -Process queries without parallel mode. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/models.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/models.mdx deleted file mode 100644 index ea8f1211..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/task/models.mdx +++ /dev/null @@ -1,34 +0,0 @@ ---- -title: models -sidebarTitle: models ---- - -# `infrahub_sdk.task.models` - -## Classes - -### `TaskState` - -### `TaskLog` - -### `TaskRelatedNode` - -### `Task` - -**Methods:** - -#### `from_graphql` - -```python -from_graphql(cls, data: dict) -> Task -``` - -### `TaskFilter` - -**Methods:** - -#### `to_dict` - -```python -to_dict(self) -> dict -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/exceptions.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/exceptions.mdx deleted file mode 100644 index c13f8d2a..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/exceptions.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: exceptions -sidebarTitle: exceptions ---- - -# `infrahub_sdk.template.exceptions` - -## Classes - -### `JinjaTemplateError` - -### `JinjaTemplateNotFoundError` - -### `JinjaTemplateSyntaxError` - -### `JinjaTemplateUndefinedError` - -### `JinjaTemplateOperationViolationError` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/filters.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/filters.mdx deleted file mode 100644 index 4f93c7d1..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/filters.mdx +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: filters -sidebarTitle: filters ---- - -# `infrahub_sdk.template.filters` - -## Classes - -### `FilterDefinition` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/models.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/models.mdx deleted file mode 100644 index 1a15dc6e..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/template/models.mdx +++ /dev/null @@ -1,10 +0,0 @@ ---- -title: models -sidebarTitle: models ---- - -# `infrahub_sdk.template.models` - -## Classes - -### `UndefinedJinja2Error` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/docker.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/docker.mdx deleted file mode 100644 index c41bf7b9..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/docker.mdx +++ /dev/null @@ -1,34 +0,0 @@ ---- -title: docker -sidebarTitle: docker ---- - -# `infrahub_sdk.testing.docker` - -## Functions - -### `skip_version` - -```python -skip_version(min_infrahub_version: str | None = None, max_infrahub_version: str | None = None) -> bool -``` - -Check if a test should be skipped depending on infrahub version. - -## Classes - -### `TestInfrahubDockerClient` - -**Methods:** - -#### `client` - -```python -client(self, infrahub_port: int) -> InfrahubClient -``` - -#### `client_sync` - -```python -client_sync(self, infrahub_port: int) -> InfrahubClientSync -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/repository.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/repository.mdx deleted file mode 100644 index eeb5fa6f..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/repository.mdx +++ /dev/null @@ -1,46 +0,0 @@ ---- -title: repository -sidebarTitle: repository ---- - -# `infrahub_sdk.testing.repository` - -## Classes - -### `RepositorySyncStatus` - -### `GitRepoType` - -### `GitRepo` - -**Methods:** - -#### `repo` - -```python -repo(self) -> GitRepoManager -``` - -#### `path` - -```python -path(self) -> str -``` - -#### `init` - -```python -init(self) -> None -``` - -#### `add_to_infrahub` - -```python -add_to_infrahub(self, client: InfrahubClient, branch: str | None = None) -> dict -``` - -#### `wait_for_sync_to_complete` - -```python -wait_for_sync_to_complete(self, client: InfrahubClient, branch: str | None = None, interval: int = 5, retries: int = 6) -> bool -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/schemas/animal.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/schemas/animal.mdx deleted file mode 100644 index 4e0cf5e3..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/schemas/animal.mdx +++ /dev/null @@ -1,90 +0,0 @@ ---- -title: animal -sidebarTitle: animal ---- - -# `infrahub_sdk.testing.schemas.animal` - -## Classes - -### `SchemaAnimal` - -**Methods:** - -#### `schema_animal` - -```python -schema_animal(self) -> GenericSchema -``` - -#### `schema_dog` - -```python -schema_dog(self) -> NodeSchema -``` - -#### `schema_cat` - -```python -schema_cat(self) -> NodeSchema -``` - -#### `schema_person` - -```python -schema_person(self) -> NodeSchema -``` - -#### `schema_base` - -```python -schema_base(self, schema_animal: GenericSchema, schema_person: NodeSchema, schema_cat: NodeSchema, schema_dog: NodeSchema) -> SchemaRoot -``` - -#### `load_schema` - -```python -load_schema(self, client: InfrahubClient, schema_base: SchemaRoot) -> None -``` - -#### `person_liam` - -```python -person_liam(self, client: InfrahubClient) -> InfrahubNode -``` - -#### `person_sophia` - -```python -person_sophia(self, client: InfrahubClient) -> InfrahubNode -``` - -#### `person_ethan` - -```python -person_ethan(self, client: InfrahubClient) -> InfrahubNode -``` - -#### `cat_bella` - -```python -cat_bella(self, client: InfrahubClient, person_ethan: InfrahubNode) -> InfrahubNode -``` - -#### `cat_luna` - -```python -cat_luna(self, client: InfrahubClient, person_ethan: InfrahubNode) -> InfrahubNode -``` - -#### `dog_daisy` - -```python -dog_daisy(self, client: InfrahubClient, person_ethan: InfrahubNode) -> InfrahubNode -``` - -#### `dog_rocky` - -```python -dog_rocky(self, client: InfrahubClient, person_sophia: InfrahubNode) -> InfrahubNode -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/schemas/car_person.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/schemas/car_person.mdx deleted file mode 100644 index a411d340..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/testing/schemas/car_person.mdx +++ /dev/null @@ -1,138 +0,0 @@ ---- -title: car_person -sidebarTitle: car_person ---- - -# `infrahub_sdk.testing.schemas.car_person` - -## Classes - -### `TestingPersonData` - -### `TestingManufacturerData` - -### `TestingCarData` - -### `SchemaCarPerson` - -**Methods:** - -#### `schema_person_base` - -```python -schema_person_base(self) -> NodeSchema -``` - -#### `schema_car_base` - -```python -schema_car_base(self) -> NodeSchema -``` - -#### `schema_manufacturer_base` - -```python -schema_manufacturer_base(self) -> NodeSchema -``` - -#### `schema_base` - -```python -schema_base(self, schema_car_base: NodeSchema, schema_person_base: NodeSchema, schema_manufacturer_base: NodeSchema) -> SchemaRoot -``` - -#### `person_joe_data` - -```python -person_joe_data(self) -> TestingPersonData -``` - -#### `person_jane_data` - -```python -person_jane_data(self) -> TestingPersonData -``` - -#### `manufacturer_vw_data` - -```python -manufacturer_vw_data(self) -> TestingManufacturerData -``` - -#### `manufacturer_renault_data` - -```python -manufacturer_renault_data(self) -> TestingManufacturerData -``` - -#### `manufacturer_mercedes_data` - -```python -manufacturer_mercedes_data(self) -> TestingManufacturerData -``` - -#### `car_golf_data` - -```python -car_golf_data(self) -> TestingCarData -``` - -#### `person_joe` - -```python -person_joe(self, client: InfrahubClient, person_joe_data: TestingPersonData) -> InfrahubNode -``` - -#### `person_jane` - -```python -person_jane(self, client: InfrahubClient, person_jane_data: TestingPersonData) -> InfrahubNode -``` - -#### `manufacturer_mercedes` - -```python -manufacturer_mercedes(self, client: InfrahubClient, manufacturer_mercedes_data: TestingManufacturerData) -> InfrahubNode -``` - -#### `car_golf` - -```python -car_golf(self, client: InfrahubClient, car_golf_data: TestingCarData, manufacturer_mercedes: InfrahubNode, person_joe: InfrahubNode) -> InfrahubNode -``` - -#### `tag_blue` - -```python -tag_blue(self, client: InfrahubClient) -> InfrahubNode -``` - -#### `tag_red` - -```python -tag_red(self, client: InfrahubClient) -> InfrahubNode -``` - -#### `tag_green` - -```python -tag_green(self, client: InfrahubClient) -> InfrahubNode -``` - -#### `create_persons` - -```python -create_persons(self, client: InfrahubClient, branch: str) -> list[InfrahubNode] -``` - -#### `create_manufacturers` - -```python -create_manufacturers(self, client: InfrahubClient, branch: str) -> list[InfrahubNode] -``` - -#### `create_initial_data` - -```python -create_initial_data(self, client: InfrahubClient, branch: str) -> dict[str, list[InfrahubNode]] -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/timestamp.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/timestamp.mdx deleted file mode 100644 index d009eb55..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/timestamp.mdx +++ /dev/null @@ -1,60 +0,0 @@ ---- -title: timestamp -sidebarTitle: timestamp ---- - -# `infrahub_sdk.timestamp` - -## Classes - -### `Timestamp` - -**Methods:** - -#### `obj` - -```python -obj(self) -> ZonedDateTime -``` - -#### `to_string` - -```python -to_string(self, with_z: bool = True) -> str -``` - -#### `to_timestamp` - -```python -to_timestamp(self) -> int -``` - -#### `to_datetime` - -```python -to_datetime(self) -> datetime -``` - -#### `get_obj` - -```python -get_obj(self) -> ZonedDateTime -``` - -#### `add_delta` - -```python -add_delta(self, hours: int = 0, minutes: int = 0, seconds: int = 0, microseconds: int = 0) -> Timestamp -``` - -#### `add` - -```python -add(self, years: int = 0, months: int = 0, weeks: int = 0, days: int = 0, hours: float = 0, minutes: float = 0, seconds: float = 0, milliseconds: float = 0, microseconds: float = 0, nanoseconds: int = 0, disambiguate: Literal['compatible'] = 'compatible') -> Timestamp -``` - -#### `subtract` - -```python -subtract(self, years: int = 0, months: int = 0, weeks: int = 0, days: int = 0, hours: float = 0, minutes: float = 0, seconds: float = 0, milliseconds: float = 0, microseconds: float = 0, nanoseconds: int = 0, disambiguate: Literal['compatible'] = 'compatible') -> Timestamp -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/topological_sort.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/topological_sort.mdx deleted file mode 100644 index f4f753dc..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/topological_sort.mdx +++ /dev/null @@ -1,32 +0,0 @@ ---- -title: topological_sort -sidebarTitle: topological_sort ---- - -# `infrahub_sdk.topological_sort` - -## Functions - -### `topological_sort` - -```python -topological_sort(dependency_dict: Mapping[str, Iterable[str]]) -> list[set[str]] -``` - -### `get_cycles` - -```python -get_cycles(dependency_dict: Mapping[str, Iterable[str]]) -> list[list[str]] -``` - -## Classes - -### `DependencyCycleExistsError` - -**Methods:** - -#### `get_cycle_strings` - -```python -get_cycle_strings(self) -> list[str] -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/constants.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/constants.mdx deleted file mode 100644 index 621f23ed..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/constants.mdx +++ /dev/null @@ -1,8 +0,0 @@ ---- -title: constants -sidebarTitle: constants ---- - -# `infrahub_sdk.transfer.constants` - -*This module is empty or contains only private/internal implementations.* diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exceptions.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exceptions.mdx deleted file mode 100644 index 7a400c63..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exceptions.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: exceptions -sidebarTitle: exceptions ---- - -# `infrahub_sdk.transfer.exceptions` - -## Classes - -### `TransferError` - -### `FileAlreadyExistsError` - -### `TransferFileNotFoundError` - -### `InvalidNamespaceError` - -### `SchemaImportError` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exporter/interface.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exporter/interface.mdx deleted file mode 100644 index 62acfd98..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exporter/interface.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: interface -sidebarTitle: interface ---- - -# `infrahub_sdk.transfer.exporter.interface` - -## Classes - -### `ExporterInterface` - -**Methods:** - -#### `export` - -```python -export(self, export_directory: Path, namespaces: list[str], branch: str, exclude: list[str] | None = None) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exporter/json.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exporter/json.mdx deleted file mode 100644 index a160eb52..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/exporter/json.mdx +++ /dev/null @@ -1,36 +0,0 @@ ---- -title: json -sidebarTitle: json ---- - -# `infrahub_sdk.transfer.exporter.json` - -## Classes - -### `LineDelimitedJSONExporter` - -**Methods:** - -#### `wrapped_task_output` - -```python -wrapped_task_output(self, start: str, end: str = '[green]done') -> Generator -``` - -#### `identify_many_to_many_relationships` - -```python -identify_many_to_many_relationships(self, node_schema_map: dict[str, MainSchemaTypesAPI]) -> dict[tuple[str, str], str] -``` - -#### `retrieve_many_to_many_relationships` - -```python -retrieve_many_to_many_relationships(self, node_schema_map: dict[str, MainSchemaTypesAPI], branch: str) -> list[dict[str, Any]] -``` - -#### `export` - -```python -export(self, export_directory: Path, namespaces: list[str], branch: str, exclude: list[str] | None = None) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/importer/interface.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/importer/interface.mdx deleted file mode 100644 index 7211b6cd..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/importer/interface.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: interface -sidebarTitle: interface ---- - -# `infrahub_sdk.transfer.importer.interface` - -## Classes - -### `ImporterInterface` - -**Methods:** - -#### `import_data` - -```python -import_data(self, import_directory: Path, branch: str) -> None -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/importer/json.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/importer/json.mdx deleted file mode 100644 index 4604697d..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/importer/json.mdx +++ /dev/null @@ -1,48 +0,0 @@ ---- -title: json -sidebarTitle: json ---- - -# `infrahub_sdk.transfer.importer.json` - -## Classes - -### `LineDelimitedJSONImporter` - -**Methods:** - -#### `wrapped_task_output` - -```python -wrapped_task_output(self, start: str, end: str = '[green]done') -> Generator -``` - -#### `import_data` - -```python -import_data(self, import_directory: Path, branch: str) -> None -``` - -#### `remove_and_store_optional_relationships` - -```python -remove_and_store_optional_relationships(self) -> None -``` - -#### `update_optional_relationships` - -```python -update_optional_relationships(self) -> None -``` - -#### `update_many_to_many_relationships` - -```python -update_many_to_many_relationships(self, file: Path) -> None -``` - -#### `execute_batches` - -```python -execute_batches(self, batches: list[InfrahubBatch], progress_bar_message: str = 'Executing batches') -> Sequence[Any] -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/schema_sorter.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/schema_sorter.mdx deleted file mode 100644 index 919fb560..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transfer/schema_sorter.mdx +++ /dev/null @@ -1,18 +0,0 @@ ---- -title: schema_sorter -sidebarTitle: schema_sorter ---- - -# `infrahub_sdk.transfer.schema_sorter` - -## Classes - -### `InfrahubSchemaTopologicalSorter` - -**Methods:** - -#### `get_sorted_node_schema` - -```python -get_sorted_node_schema(self, schemas: Sequence[NodeSchema], required_relationships_only: bool = True, include: list[str] | None = None) -> list[set[str]] -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transforms.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transforms.mdx deleted file mode 100644 index bb80aab3..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/transforms.mdx +++ /dev/null @@ -1,48 +0,0 @@ ---- -title: transforms -sidebarTitle: transforms ---- - -# `infrahub_sdk.transforms` - -## Classes - -### `InfrahubTransform` - -**Methods:** - -#### `client` - -```python -client(self) -> InfrahubClient -``` - -#### `transform` - -```python -transform(self, data: dict) -> Any -``` - -#### `collect_data` - -```python -collect_data(self) -> dict -``` - -Query the result of the GraphQL Query defined in self.query and return the result - -#### `run` - -```python -run(self, data: dict | None = None) -> Any -``` - -Execute the transformation after collecting the data from the GraphQL query. - -The result of the check is determined based on the presence or not of ERROR log messages. - -**Args:** - -- `data`: The data on which to run the transform. Data will be queried from the API if not provided - -Returns: Transformed data diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/types.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/types.mdx deleted file mode 100644 index c263a0df..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/types.mdx +++ /dev/null @@ -1,70 +0,0 @@ ---- -title: types -sidebarTitle: types ---- - -# `infrahub_sdk.types` - -## Classes - -### `HTTPMethod` - -### `RequesterTransport` - -### `SyncRequester` - -### `AsyncRequester` - -### `InfrahubLogger` - -**Methods:** - -#### `debug` - -```python -debug(self, event: str | None = None, *args: Any, **kw: Any) -> Any -``` - -Send a debug event - -#### `info` - -```python -info(self, event: str | None = None, *args: Any, **kw: Any) -> Any -``` - -Send an info event - -#### `warning` - -```python -warning(self, event: str | None = None, *args: Any, **kw: Any) -> Any -``` - -Send a warning event - -#### `error` - -```python -error(self, event: str | None = None, *args: Any, **kw: Any) -> Any -``` - -Send an error event. - -#### `critical` - -```python -critical(self, event: str | None = None, *args: Any, **kw: Any) -> Any -``` - -Send a critical event. - -#### `exception` - -```python -exception(self, event: str | None = None, *args: Any, **kw: Any) -> Any -``` - -Send an exception event. - -### `Order` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/utils.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/utils.mdx deleted file mode 100644 index 5729b76d..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/utils.mdx +++ /dev/null @@ -1,228 +0,0 @@ ---- -title: utils -sidebarTitle: utils ---- - -# `infrahub_sdk.utils` - -## Functions - -### `generate_short_id` - -```python -generate_short_id() -> str -``` - -Generate a short unique ID - -### `base36encode` - -```python -base36encode(number: int) -> str -``` - -### `base36decode` - -```python -base36decode(data: str) -> int -``` - -### `base16decode` - -```python -base16decode(data: str) -> int -``` - -### `base16encode` - -```python -base16encode(number: int) -> str -``` - -### `get_fixtures_dir` - -```python -get_fixtures_dir() -> Path -``` - -Get the directory which stores fixtures that are common to multiple unit/integration tests. - -### `is_valid_uuid` - -```python -is_valid_uuid(value: Any) -> bool -``` - -Check if the input is a valid UUID. - -### `decode_json` - -```python -decode_json(response: httpx.Response) -> dict -``` - -### `generate_uuid` - -```python -generate_uuid() -> str -``` - -### `duplicates` - -```python -duplicates(input_list: list) -> list -``` - -Identify and return all the duplicates in a list. - -### `intersection` - -```python -intersection(list1: list[Any], list2: list[Any]) -> list -``` - -Calculate the intersection between 2 lists. - -### `compare_lists` - -```python -compare_lists(list1: list[Any], list2: list[Any]) -> tuple[list[Any], list[Any], list[Any]] -``` - -Compare 2 lists and return : - -- the intersection of both -- the item present only in list1 -- the item present only in list2 - -### `deep_merge_dict` - -```python -deep_merge_dict(dicta: dict, dictb: dict, path: list | None = None) -> dict -``` - -Deep Merge Dictionary B into Dictionary A. -Code is inspired by https://stackoverflow.com/a/7205107 - -### `str_to_bool` - -```python -str_to_bool(value: str) -> bool -``` - -Convert a String to a Boolean - -### `get_flat_value` - -```python -get_flat_value(obj: Any, key: str, separator: str = '__') -> Any -``` - -Query recursively an value defined in a flat notation (string), on a hierarchy of objects - -**Examples:** - -name__value -module.object.value - -### `generate_request_filename` - -```python -generate_request_filename(request: httpx.Request) -> str -``` - -Return a filename for a request sent to the Infrahub API - -This function is used when recording and playing back requests, as Infrahub is using a GraphQL -API it's not possible to rely on the URL endpoint alone to separate one request from another, -for this reason a hash of the payload is included in a filename. - -### `is_valid_url` - -```python -is_valid_url(url: str) -> bool -``` - -### `get_branch` - -```python -get_branch(branch: str | None = None, directory: str | Path = '.') -> str -``` - -If branch isn't provide, return the name of the local Git branch. - -### `dict_hash` - -```python -dict_hash(dictionary: dict[str, Any]) -> str -``` - -MD5 hash of a dictionary. - -### `calculate_dict_depth` - -```python -calculate_dict_depth(data: dict, level: int = 1) -> int -``` - -Calculate the depth of a nested Dictionary recursively. - -### `calculate_dict_height` - -```python -calculate_dict_height(data: dict, cnt: int = 0) -> int -``` - -Calculate the number of fields (height) in a nested Dictionary recursively. - -### `extract_fields` - -```python -extract_fields(selection_set: SelectionSetNode | None) -> dict[str, dict] | None -``` - -This function extract all the requested fields in a tree of Dict from a SelectionSetNode - -The goal of this function is to limit the fields that we need to query from the backend. - -Currently the function support Fields and InlineFragments but in a combined tree where the fragments are merged together -This implementation may seam counter intuitive but in the current implementation -it's better to have slightly more information at time passed to the query manager. - -In the future we'll probably need to redesign how we read GraphQL queries to generate better Database query. - -### `extract_fields_first_node` - -```python -extract_fields_first_node(info: GraphQLResolveInfo) -> dict[str, dict] -``` - -### `write_to_file` - -```python -write_to_file(path: Path, value: Any) -> bool -``` - -Write a given value into a file and return if the operation was successful. - -If the file does not exist, the function will attempt to create it. - -### `read_file` - -```python -read_file(file_path: Path) -> str -``` - -### `get_user_permissions` - -```python -get_user_permissions(data: list[dict]) -> dict -``` - -### `calculate_time_diff` - -```python -calculate_time_diff(value: str) -> str | None -``` - -Calculate the time in human format between a timedate in string format and now. diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/uuidt.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/uuidt.mdx deleted file mode 100644 index 47d3d8ae..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/uuidt.mdx +++ /dev/null @@ -1,44 +0,0 @@ ---- -title: uuidt -sidebarTitle: uuidt ---- - -# `infrahub_sdk.uuidt` - -## Functions - -### `generate_uuid` - -```python -generate_uuid() -> str -``` - -### `encode_number` - -```python -encode_number(number: int, min_length: int) -> str -``` - -Encode a number into a base16 string and ensure the result has a minimum size. -If the initial response produced doesn't match the min requirement, -random number will be used to fill the gap - -## Classes - -### `UUIDT` - -**Methods:** - -#### `short` - -```python -short(self) -> str -``` - -Return the last 8 digit of the UUID (the most random part) - -#### `new` - -```python -new(cls, namespace: str | None = None) -> UUID -``` diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/yaml.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/yaml.mdx deleted file mode 100644 index 40af0a2c..00000000 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/yaml.mdx +++ /dev/null @@ -1,88 +0,0 @@ ---- -title: yaml -sidebarTitle: yaml ---- - -# `infrahub_sdk.yaml` - -## Classes - -### `InfrahubFileApiVersion` - -### `InfrahubFileKind` - -### `InfrahubFileData` - -### `LocalFile` - -### `YamlFile` - -**Methods:** - -#### `load_content` - -```python -load_content(self) -> None -``` - -#### `validate_content` - -```python -validate_content(self) -> None -``` - -#### `init` - -```python -init(cls, location: Path, multiple_documents: bool, content: dict | None) -> Self -``` - -#### `load_file_from_disk` - -```python -load_file_from_disk(cls, path: Path) -> list[Self] -``` - -#### `load_from_disk` - -```python -load_from_disk(cls, paths: list[Path]) -> list[Self] -``` - -### `InfrahubFile` - -**Methods:** - -#### `data` - -```python -data(self) -> InfrahubFileData -``` - -#### `version` - -```python -version(self) -> InfrahubFileApiVersion -``` - -#### `kind` - -```python -kind(self) -> InfrahubFileKind -``` - -#### `validate_content` - -```python -validate_content(self) -> None -``` - -### `SchemaFile` - -**Methods:** - -#### `payload` - -```python -payload(self) -> dict[str, Any] -``` From a0a8686b72c9e8b3af6b2e33b3f2941b86625494 Mon Sep 17 00:00:00 2001 From: Antoine Delannoy Date: Fri, 1 Aug 2025 14:23:04 +0200 Subject: [PATCH 24/24] docs: update documentation --- .../sdk_ref/infrahub_sdk/node/node.mdx | 50 ++++++++++++++++--- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx index 5980aad0..3d826871 100644 --- a/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx +++ b/docs/docs/python-sdk/sdk_ref/infrahub_sdk/node/node.mdx @@ -91,14 +91,6 @@ get_raw_graphql_data(self) -> dict | None generate_query_data_init(self, filters: dict[str, Any] | None = None, offset: int | None = None, limit: int | None = None, include: list[str] | None = None, exclude: list[str] | None = None, partial_match: bool = False, order: Order | None = None) -> dict[str, Any | dict] ``` -#### `extract` - -```python -extract(self, params: dict[str, str]) -> dict[str, Any] -``` - -Extract some data points defined in a flat notation. - ### `InfrahubNode` Represents a Infrahub node in an asynchronous context. @@ -220,6 +212,27 @@ Fetch the utilization of each resource for the pool. - list\[dict\[str, Any]]: A list containing the allocation numbers for each resource of the pool. +#### `get_flat_value` + +```python +get_flat_value(self, key: str, separator: str = '__') -> Any +``` + +Query recursively a value defined in a flat notation (string), on a hierarchy of objects + +**Examples:** + +name__value +module.object.value + +#### `extract` + +```python +extract(self, params: dict[str, str]) -> dict[str, Any] +``` + +Extract some datapoints defined in a flat notation. + ### `InfrahubNodeSync` Represents a Infrahub node in a synchronous context. @@ -340,3 +353,24 @@ Fetch the utilization of each resource for the pool. **Returns:** - list\[dict\[str, Any]]: A list containing the allocation numbers for each resource of the pool. + +#### `get_flat_value` + +```python +get_flat_value(self, key: str, separator: str = '__') -> Any +``` + +Query recursively a value defined in a flat notation (string), on a hierarchy of objects + +**Examples:** + +name__value +module.object.value + +#### `extract` + +```python +extract(self, params: dict[str, str]) -> dict[str, Any] +``` + +Extract some datapoints defined in a flat notation.