Skip to main content

infrahub_sdk.node.node

Classes

InfrahubNodeBase

Base class for InfrahubNode and InfrahubNodeSync

Methods:

get_branch

get_branch(self) -> str

get_path_value

get_path_value(self, path: str) -> Any

get_human_friendly_id

get_human_friendly_id(self) -> list[str] | None

get_human_friendly_id_as_string

get_human_friendly_id_as_string(self, include_kind: bool = False) -> str | None

hfid

hfid(self) -> list[str] | None

hfid_str

hfid_str(self) -> str | None

get_kind

get_kind(self) -> str

get_all_kinds

get_all_kinds(self) -> list[str]

is_ip_prefix

is_ip_prefix(self) -> bool

is_ip_address

is_ip_address(self) -> bool

is_resource_pool

is_resource_pool(self) -> bool

get_raw_graphql_data

get_raw_graphql_data(self) -> dict | None

generate_query_data_init

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(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

from_graphql(cls, client: InfrahubClient, branch: str, data: dict, schema: MainSchemaTypesAPI | None = None, timeout: int | None = None) -> Self

generate

generate(self, nodes: list[str] | None = None) -> None

artifact_generate

artifact_generate(self, name: str) -> None

artifact_fetch

artifact_fetch(self, name: str) -> str | dict[str, Any]

delete

delete(self, timeout: int | None = None, request_context: RequestContext | None = None) -> None

save

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(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(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

add_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None

remove_relationships

remove_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None

create

create(self, allow_upsert: bool = False, timeout: int | None = None, request_context: RequestContext | None = None) -> None

update

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(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

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

from_graphql(cls, client: InfrahubClientSync, branch: str, data: dict, schema: MainSchemaTypesAPI | None = None, timeout: int | None = None) -> Self

generate

generate(self, nodes: list[str] | None = None) -> None

artifact_generate

artifact_generate(self, name: str) -> None

artifact_fetch

artifact_fetch(self, name: str) -> str | dict[str, Any]

delete

delete(self, timeout: int | None = None, request_context: RequestContext | None = None) -> None

save

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(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(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

add_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None

remove_relationships

remove_relationships(self, relation_to_update: str, related_nodes: list[str]) -> None

create

create(self, allow_upsert: bool = False, timeout: int | None = None, request_context: RequestContext | None = None) -> None

update

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(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

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.