From 3c25779c33fdbd3ad460130ba6112dcd5240fb86 Mon Sep 17 00:00:00 2001 From: Anders Albert <60234212+doctrino@users.noreply.github.com> Date: Tue, 12 Nov 2024 10:54:26 +0100 Subject: [PATCH] =?UTF-8?q?[PYG-284]=20=E2=86=A9=20Revert=200.99.34=20chan?= =?UTF-8?q?ge=20(#354)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * revert: time_series_type to type_ * refactro: regen + changelog * tests: updated tests to match type_ * build; bump * build: changelog bump * tests: updated tests --- cognite/pygen/_core/models/fields/base.py | 8 +-- cognite/pygen/_version.py | 2 +- docs/CHANGELOG.md | 6 +- docs/quickstart/cdf_streamlit.md | 2 +- examples/cognite_core/_api/__init__.py | 4 +- .../cognite_core/_api/cognite_3_d_object.py | 4 +- .../_api/cognite_3_d_object_images_360.py | 2 +- examples/cognite_core/_api/cognite_asset.py | 40 +++++------ .../cognite_core/_api/cognite_asset_query.py | 10 +-- .../_api/cognite_source_system.py | 72 +++++++++---------- examples/cognite_core/_api_client.py | 4 +- .../_cognite_360_image_collection.py | 22 +++--- .../data_classes/_cognite_360_image_model.py | 28 ++++---- .../data_classes/_cognite_3_d_model.py | 32 ++++----- .../data_classes/_cognite_3_d_revision.py | 26 +++---- .../data_classes/_cognite_asset.py | 69 ++++++++---------- .../data_classes/_cognite_cad_model.py | 28 ++++---- .../data_classes/_cognite_cad_revision.py | 22 +++--- .../_cognite_point_cloud_model.py | 28 ++++---- .../_cognite_point_cloud_revision.py | 22 +++--- .../data_classes/_cognite_source_system.py | 50 +++++++------ .../data_classes/_cognite_time_series.py | 26 +++---- .../equipment_unit/_api/equipment_module.py | 72 +++++++++---------- .../_api/equipment_module_sensor_value.py | 24 +++---- .../equipment_unit/_api/unit_procedure.py | 72 +++++++++---------- .../_api/unit_procedure_query.py | 24 +++---- examples/equipment_unit/_api/work_order.py | 72 +++++++++---------- examples/equipment_unit/_api_client.py | 4 +- .../data_classes/_equipment_module.py | 48 ++++++------- .../data_classes/_unit_procedure.py | 48 ++++++------- .../data_classes/_work_order.py | 48 ++++++------- examples/omni/_api_client.py | 4 +- examples/omni_multi/_api_client.py | 4 +- examples/omni_sub/_api_client.py | 4 +- .../scenario_instance/client/_api_client.py | 4 +- examples/windmill/_api_client.py | 4 +- pyproject.toml | 2 +- tests/test_integration/test_generate_sdks.py | 2 +- .../test_equipment_sdk/test_unit_procedure.py | 6 +- 39 files changed, 469 insertions(+), 480 deletions(-) diff --git a/cognite/pygen/_core/models/fields/base.py b/cognite/pygen/_core/models/fields/base.py index 56bbc5406..093165c31 100644 --- a/cognite/pygen/_core/models/fields/base.py +++ b/cognite/pygen/_core/models/fields/base.py @@ -4,7 +4,6 @@ import warnings from dataclasses import dataclass -from string import digits from typing import TYPE_CHECKING, Literal, TypeVar, cast from cognite.client.data_classes import data_modeling as dm @@ -67,12 +66,7 @@ def from_property( field_naming = config.naming.field name = create_name(prop_id, field_naming.name) - if name in {"type", "version"}: - # Special handling for reserved words - prop_view_id = _get_prop_view_id(prop_id, view_id, view_by_id) - prefix = prop_view_id.external_id.removeprefix("Cognite").removeprefix("3D").lstrip(digits) - name = create_name(f"{prefix}_{name}", field_naming.name) - elif is_reserved_word(name, "field", view_id, prop_id): + if is_reserved_word(name, "field", view_id, prop_id): name = f"{name}_" doc_name = to_words(name, singularize=True) diff --git a/cognite/pygen/_version.py b/cognite/pygen/_version.py index 5f290e986..7cf3264da 100644 --- a/cognite/pygen/_version.py +++ b/cognite/pygen/_version.py @@ -1 +1 @@ -__version__ = "0.99.46" +__version__ = "0.99.47" diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index cd3590ad4..dfa7c8564 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -13,9 +13,13 @@ Changes are grouped as follows - `Fixed` for any bug fixes. - `Security` in case of vulnerabilities. -## TBD +## [0.99.47] - 24-11-12 ### Fixed - Raised lower bound of dependency `inflect` to `6.2` when support for `pydantic` `v2` was added. +- Reverting change from `0.99.34`. For example, for `CogniteTimeSeries` the property `type` will + now be named `type_` and not `time_series_type`. This is to avoid conflicts if the view has a property + named `time_series_type`. This typically occurs when someone extends `CogniteTimeSeries` and introduces + custom `types`. ## [0.99.46] - 24-11-11 ### Fixed diff --git a/docs/quickstart/cdf_streamlit.md b/docs/quickstart/cdf_streamlit.md index 3df8447b0..f23321fa9 100644 --- a/docs/quickstart/cdf_streamlit.md +++ b/docs/quickstart/cdf_streamlit.md @@ -13,7 +13,7 @@ adding `cognite-pygen` to the installed packages under `settings`. pyodide-http==0.2.1 cognite-sdk==7.64.12 pydantic==1.10.7 -cognite-pygen==0.99.46 +cognite-pygen==0.99.47 ``` Note that we also set `pydantic` to a specific version. This is because `pygen` supports both `pydantic` `v1` and `v2`, but diff --git a/examples/cognite_core/_api/__init__.py b/examples/cognite_core/_api/__init__.py index 31afb28ac..e2658fbf9 100644 --- a/examples/cognite_core/_api/__init__.py +++ b/examples/cognite_core/_api/__init__.py @@ -9,7 +9,7 @@ from cognite_core._api.cognite_3_d_model import Cognite3DModelAPI from cognite_core._api.cognite_3_d_model_query import Cognite3DModelQueryAPI from cognite_core._api.cognite_3_d_object import Cognite3DObjectAPI -from cognite_core._api.cognite_3_d_object_images_360 import Cognite3DObjectImagesAPI +from cognite_core._api.cognite_3_d_object_images_360 import Cognite3DObjectImages360API from cognite_core._api.cognite_3_d_object_query import Cognite3DObjectQueryAPI from cognite_core._api.cognite_3_d_revision import Cognite3DRevisionAPI from cognite_core._api.cognite_3_d_revision_query import Cognite3DRevisionQueryAPI @@ -72,7 +72,7 @@ "Cognite3DModelAPI", "Cognite3DModelQueryAPI", "Cognite3DObjectAPI", - "Cognite3DObjectImagesAPI", + "Cognite3DObjectImages360API", "Cognite3DObjectQueryAPI", "Cognite3DRevisionAPI", "Cognite3DRevisionQueryAPI", diff --git a/examples/cognite_core/_api/cognite_3_d_object.py b/examples/cognite_core/_api/cognite_3_d_object.py index 09ae0a105..8d40fdd0c 100644 --- a/examples/cognite_core/_api/cognite_3_d_object.py +++ b/examples/cognite_core/_api/cognite_3_d_object.py @@ -45,7 +45,7 @@ NodeAPI, SequenceNotStr, ) -from cognite_core._api.cognite_3_d_object_images_360 import Cognite3DObjectImagesAPI +from cognite_core._api.cognite_3_d_object_images_360 import Cognite3DObjectImages360API from cognite_core._api.cognite_3_d_object_query import Cognite3DObjectQueryAPI @@ -59,7 +59,7 @@ class Cognite3DObjectAPI(NodeAPI[Cognite3DObject, Cognite3DObjectWrite, Cognite3 def __init__(self, client: CogniteClient): super().__init__(client=client) - self.images_360_edge = Cognite3DObjectImagesAPI(client) + self.images_360_edge = Cognite3DObjectImages360API(client) def __call__( self, diff --git a/examples/cognite_core/_api/cognite_3_d_object_images_360.py b/examples/cognite_core/_api/cognite_3_d_object_images_360.py index 5c4e450c6..3764cdeaf 100644 --- a/examples/cognite_core/_api/cognite_3_d_object_images_360.py +++ b/examples/cognite_core/_api/cognite_3_d_object_images_360.py @@ -15,7 +15,7 @@ from cognite_core.data_classes._core import DEFAULT_INSTANCE_SPACE -class Cognite3DObjectImagesAPI(EdgePropertyAPI): +class Cognite3DObjectImages360API(EdgePropertyAPI): _view_id = dm.ViewId("cdf_cdm", "Cognite360ImageAnnotation", "v1") _class_type = Cognite360ImageAnnotation _class_write_type = Cognite360ImageAnnotationWrite diff --git a/examples/cognite_core/_api/cognite_asset.py b/examples/cognite_core/_api/cognite_asset.py index 059afcc8a..815bbd024 100644 --- a/examples/cognite_core/_api/cognite_asset.py +++ b/examples/cognite_core/_api/cognite_asset.py @@ -127,7 +127,7 @@ def __call__( max_source_updated_time: datetime.datetime | None = None, source_updated_user: str | list[str] | None = None, source_updated_user_prefix: str | None = None, - asset_type: ( + type_: ( str | tuple[str, str] | dm.NodeId @@ -167,7 +167,7 @@ def __call__( max_source_updated_time: The maximum value of the source updated time to filter on. source_updated_user: The source updated user to filter on. source_updated_user_prefix: The prefix of the source updated user to filter on. - asset_type: The asset type to filter on. + type_: The type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of Cognite assets to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -204,7 +204,7 @@ def __call__( max_source_updated_time, source_updated_user, source_updated_user_prefix, - asset_type, + type_, external_id_prefix, space, (filter and dm.filters.And(filter, has_data)) or has_data, @@ -221,7 +221,7 @@ def apply( """Add or update (upsert) Cognite assets. Note: This method iterates through all nodes and timeseries linked to cognite_asset and creates them including the edges - between the nodes. For example, if any of `asset_class`, `object_3d`, `parent`, `path`, `root`, `source` or `asset_type` are set, then these + between the nodes. For example, if any of `asset_class`, `object_3d`, `parent`, `path`, `root`, `source` or `type_` are set, then these nodes as well as any nodes linked to them, and all the edges linking these nodes will be created. Args: @@ -392,7 +392,7 @@ def search( max_source_updated_time: datetime.datetime | None = None, source_updated_user: str | list[str] | None = None, source_updated_user_prefix: str | None = None, - asset_type: ( + type_: ( str | tuple[str, str] | dm.NodeId @@ -437,7 +437,7 @@ def search( max_source_updated_time: The maximum value of the source updated time to filter on. source_updated_user: The source updated user to filter on. source_updated_user_prefix: The prefix of the source updated user to filter on. - asset_type: The asset type to filter on. + type_: The type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of Cognite assets to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -486,7 +486,7 @@ def search( max_source_updated_time, source_updated_user, source_updated_user_prefix, - asset_type, + type_, external_id_prefix, space, filter, @@ -575,7 +575,7 @@ def aggregate( max_source_updated_time: datetime.datetime | None = None, source_updated_user: str | list[str] | None = None, source_updated_user_prefix: str | None = None, - asset_type: ( + type_: ( str | tuple[str, str] | dm.NodeId @@ -663,7 +663,7 @@ def aggregate( max_source_updated_time: datetime.datetime | None = None, source_updated_user: str | list[str] | None = None, source_updated_user_prefix: str | None = None, - asset_type: ( + type_: ( str | tuple[str, str] | dm.NodeId @@ -755,7 +755,7 @@ def aggregate( max_source_updated_time: datetime.datetime | None = None, source_updated_user: str | list[str] | None = None, source_updated_user_prefix: str | None = None, - asset_type: ( + type_: ( str | tuple[str, str] | dm.NodeId @@ -846,7 +846,7 @@ def aggregate( max_source_updated_time: datetime.datetime | None = None, source_updated_user: str | list[str] | None = None, source_updated_user_prefix: str | None = None, - asset_type: ( + type_: ( str | tuple[str, str] | dm.NodeId @@ -895,7 +895,7 @@ def aggregate( max_source_updated_time: The maximum value of the source updated time to filter on. source_updated_user: The source updated user to filter on. source_updated_user_prefix: The prefix of the source updated user to filter on. - asset_type: The asset type to filter on. + type_: The type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of Cognite assets to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -940,7 +940,7 @@ def aggregate( max_source_updated_time, source_updated_user, source_updated_user_prefix, - asset_type, + type_, external_id_prefix, space, filter, @@ -1027,7 +1027,7 @@ def histogram( max_source_updated_time: datetime.datetime | None = None, source_updated_user: str | list[str] | None = None, source_updated_user_prefix: str | None = None, - asset_type: ( + type_: ( str | tuple[str, str] | dm.NodeId @@ -1071,7 +1071,7 @@ def histogram( max_source_updated_time: The maximum value of the source updated time to filter on. source_updated_user: The source updated user to filter on. source_updated_user_prefix: The prefix of the source updated user to filter on. - asset_type: The asset type to filter on. + type_: The type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of Cognite assets to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -1107,7 +1107,7 @@ def histogram( max_source_updated_time, source_updated_user, source_updated_user_prefix, - asset_type, + type_, external_id_prefix, space, filter, @@ -1194,7 +1194,7 @@ def list( max_source_updated_time: datetime.datetime | None = None, source_updated_user: str | list[str] | None = None, source_updated_user_prefix: str | None = None, - asset_type: ( + type_: ( str | tuple[str, str] | dm.NodeId @@ -1238,7 +1238,7 @@ def list( max_source_updated_time: The maximum value of the source updated time to filter on. source_updated_user: The source updated user to filter on. source_updated_user_prefix: The prefix of the source updated user to filter on. - asset_type: The asset type to filter on. + type_: The type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of Cognite assets to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -1248,7 +1248,7 @@ def list( sort: (Advanced) If sort_by and direction are not sufficient, you can write your own sorting. This will override the sort_by and direction. This allowos you to sort by multiple fields and specify the direction for each field as well as how to handle null values. - retrieve_connections: Whether to retrieve `activities`, `asset_class`, `children`, `equipment`, `files`, `object_3d`, `parent`, `path`, `root`, `source`, `time_series` and `asset_type` for the Cognite assets. Defaults to 'skip'. + retrieve_connections: Whether to retrieve `activities`, `asset_class`, `children`, `equipment`, `files`, `object_3d`, `parent`, `path`, `root`, `source`, `time_series` and `type_` for the Cognite assets. Defaults to 'skip'. 'skip' will not retrieve any connections, 'identifier' will only retrieve the identifier of the connected items, and 'full' will retrieve the full connected items. Returns: @@ -1289,7 +1289,7 @@ def list( max_source_updated_time, source_updated_user, source_updated_user_prefix, - asset_type, + type_, external_id_prefix, space, filter, diff --git a/examples/cognite_core/_api/cognite_asset_query.py b/examples/cognite_core/_api/cognite_asset_query.py index 5f300c5cf..c3172f5e6 100644 --- a/examples/cognite_core/_api/cognite_asset_query.py +++ b/examples/cognite_core/_api/cognite_asset_query.py @@ -58,7 +58,7 @@ def query( retrieve_parent: bool = False, retrieve_root: bool = False, retrieve_source: bool = False, - retrieve_asset_type: bool = False, + retrieve_type_: bool = False, ) -> T_DomainModelList: """Execute query and return the result. @@ -68,7 +68,7 @@ def query( retrieve_parent: Whether to retrieve the parent for each Cognite asset or not. retrieve_root: Whether to retrieve the root for each Cognite asset or not. retrieve_source: Whether to retrieve the source for each Cognite asset or not. - retrieve_asset_type: Whether to retrieve the asset type for each Cognite asset or not. + retrieve_type_: Whether to retrieve the type for each Cognite asset or not. Returns: The list of the source nodes of the query. @@ -85,8 +85,8 @@ def query( self._query_append_root(from_) if retrieve_source: self._query_append_source(from_) - if retrieve_asset_type: - self._query_append_asset_type(from_) + if retrieve_type_: + self._query_append_type_(from_) return self._query() def _query_append_asset_class(self, from_: str) -> None: @@ -159,7 +159,7 @@ def _query_append_source(self, from_: str) -> None: ), ) - def _query_append_asset_type(self, from_: str) -> None: + def _query_append_type_(self, from_: str) -> None: self._builder.append( NodeQueryStep( name=self._builder.create_name(from_), diff --git a/examples/cognite_core/_api/cognite_source_system.py b/examples/cognite_core/_api/cognite_source_system.py index f7355b136..143108f94 100644 --- a/examples/cognite_core/_api/cognite_source_system.py +++ b/examples/cognite_core/_api/cognite_source_system.py @@ -60,8 +60,8 @@ def __call__( manufacturer_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - source_system_version: str | list[str] | None = None, - source_system_version_prefix: str | None = None, + version_: str | list[str] | None = None, + version_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_QUERY_LIMIT, @@ -76,8 +76,8 @@ def __call__( manufacturer_prefix: The prefix of the manufacturer to filter on. name: The name to filter on. name_prefix: The prefix of the name to filter on. - source_system_version: The source system version to filter on. - source_system_version_prefix: The prefix of the source system version to filter on. + version_: The version to filter on. + version_prefix: The prefix of the version to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of Cognite source systems to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -96,8 +96,8 @@ def __call__( manufacturer_prefix, name, name_prefix, - source_system_version, - source_system_version_prefix, + version_, + version_prefix, external_id_prefix, space, (filter and dm.filters.And(filter, has_data)) or has_data, @@ -221,8 +221,8 @@ def search( manufacturer_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - source_system_version: str | list[str] | None = None, - source_system_version_prefix: str | None = None, + version_: str | list[str] | None = None, + version_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -242,8 +242,8 @@ def search( manufacturer_prefix: The prefix of the manufacturer to filter on. name: The name to filter on. name_prefix: The prefix of the name to filter on. - source_system_version: The source system version to filter on. - source_system_version_prefix: The prefix of the source system version to filter on. + version_: The version to filter on. + version_prefix: The prefix of the version to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of Cognite source systems to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -274,8 +274,8 @@ def search( manufacturer_prefix, name, name_prefix, - source_system_version, - source_system_version_prefix, + version_, + version_prefix, external_id_prefix, space, filter, @@ -304,8 +304,8 @@ def aggregate( manufacturer_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - source_system_version: str | list[str] | None = None, - source_system_version_prefix: str | None = None, + version_: str | list[str] | None = None, + version_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -326,8 +326,8 @@ def aggregate( manufacturer_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - source_system_version: str | list[str] | None = None, - source_system_version_prefix: str | None = None, + version_: str | list[str] | None = None, + version_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -352,8 +352,8 @@ def aggregate( manufacturer_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - source_system_version: str | list[str] | None = None, - source_system_version_prefix: str | None = None, + version_: str | list[str] | None = None, + version_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -377,8 +377,8 @@ def aggregate( manufacturer_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - source_system_version: str | list[str] | None = None, - source_system_version_prefix: str | None = None, + version_: str | list[str] | None = None, + version_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -402,8 +402,8 @@ def aggregate( manufacturer_prefix: The prefix of the manufacturer to filter on. name: The name to filter on. name_prefix: The prefix of the name to filter on. - source_system_version: The source system version to filter on. - source_system_version_prefix: The prefix of the source system version to filter on. + version_: The version to filter on. + version_prefix: The prefix of the version to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of Cognite source systems to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -430,8 +430,8 @@ def aggregate( manufacturer_prefix, name, name_prefix, - source_system_version, - source_system_version_prefix, + version_, + version_prefix, external_id_prefix, space, filter, @@ -458,8 +458,8 @@ def histogram( manufacturer_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - source_system_version: str | list[str] | None = None, - source_system_version_prefix: str | None = None, + version_: str | list[str] | None = None, + version_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -478,8 +478,8 @@ def histogram( manufacturer_prefix: The prefix of the manufacturer to filter on. name: The name to filter on. name_prefix: The prefix of the name to filter on. - source_system_version: The source system version to filter on. - source_system_version_prefix: The prefix of the source system version to filter on. + version_: The version to filter on. + version_prefix: The prefix of the version to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of Cognite source systems to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -497,8 +497,8 @@ def histogram( manufacturer_prefix, name, name_prefix, - source_system_version, - source_system_version_prefix, + version_, + version_prefix, external_id_prefix, space, filter, @@ -525,8 +525,8 @@ def list( manufacturer_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - source_system_version: str | list[str] | None = None, - source_system_version_prefix: str | None = None, + version_: str | list[str] | None = None, + version_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -544,8 +544,8 @@ def list( manufacturer_prefix: The prefix of the manufacturer to filter on. name: The name to filter on. name_prefix: The prefix of the name to filter on. - source_system_version: The source system version to filter on. - source_system_version_prefix: The prefix of the source system version to filter on. + version_: The version to filter on. + version_prefix: The prefix of the version to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of Cognite source systems to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -576,8 +576,8 @@ def list( manufacturer_prefix, name, name_prefix, - source_system_version, - source_system_version_prefix, + version_, + version_prefix, external_id_prefix, space, filter, diff --git a/examples/cognite_core/_api_client.py b/examples/cognite_core/_api_client.py index 269f91a8e..25e63dd15 100644 --- a/examples/cognite_core/_api_client.py +++ b/examples/cognite_core/_api_client.py @@ -50,7 +50,7 @@ class CogniteCoreClient: CogniteCoreClient Generated with: - pygen = 0.99.46 + pygen = 0.99.47 cognite-sdk = 7.64.12 pydantic = 2.9.2 @@ -68,7 +68,7 @@ def __init__(self, config_or_client: CogniteClient | ClientConfig): else: raise ValueError(f"Expected CogniteClient or ClientConfig, got {type(config_or_client)}") # The client name is used for aggregated logging of Pygen Usage - client.config.client_name = "CognitePygen:0.99.46" + client.config.client_name = "CognitePygen:0.99.47" self._client = client diff --git a/examples/cognite_core/data_classes/_cognite_360_image_collection.py b/examples/cognite_core/data_classes/_cognite_360_image_collection.py index 579770210..15f9c235b 100644 --- a/examples/cognite_core/data_classes/_cognite_360_image_collection.py +++ b/examples/cognite_core/data_classes/_cognite_360_image_collection.py @@ -63,7 +63,7 @@ Cognite360ImageCollectionTextFields = Literal["external_id", "aliases", "description", "name", "tags"] Cognite360ImageCollectionFields = Literal[ - "external_id", "aliases", "description", "name", "published", "status", "tags", "revision_type" + "external_id", "aliases", "description", "name", "published", "status", "tags", "type_" ] _COGNITE360IMAGECOLLECTION_PROPERTIES_BY_FIELD = { @@ -74,7 +74,7 @@ "published": "published", "status": "status", "tags": "tags", - "revision_type": "type", + "type_": "type", } @@ -95,7 +95,7 @@ class Cognite360ImageCollectionGraphQL(GraphQLCore, protected_namespaces=()): published: The published field. status: The status field. tags: Text based labels for generic use, limited to 1000 - revision_type: The revision type field. + type_: The type field. """ view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "Cognite360ImageCollection", "v1") @@ -106,7 +106,7 @@ class Cognite360ImageCollectionGraphQL(GraphQLCore, protected_namespaces=()): published: Optional[bool] = None status: Optional[Literal["Done", "Failed", "Processing", "Queued"]] = None tags: Optional[list[str]] = None - revision_type: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") + type_: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") @model_validator(mode="before") def parse_data_record(cls, values: Any) -> Any: @@ -148,7 +148,7 @@ def as_read(self) -> Cognite360ImageCollection: published=self.published, status=self.status, tags=self.tags, - revision_type=self.revision_type, + type_=self.type_, ) # We do the ignore argument type as we let pydantic handle the type checking @@ -166,7 +166,7 @@ def as_write(self) -> Cognite360ImageCollectionWrite: published=self.published, status=self.status, tags=self.tags, - revision_type=self.revision_type, + type_=self.type_, ) @@ -186,7 +186,7 @@ class Cognite360ImageCollection(CogniteDescribableNode, Cognite3DRevision, prote published: The published field. status: The status field. tags: Text based labels for generic use, limited to 1000 - revision_type: The revision type field. + type_: The type field. """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "Cognite360ImageCollection", "v1") @@ -206,7 +206,7 @@ def as_write(self) -> Cognite360ImageCollectionWrite: published=self.published, status=self.status, tags=self.tags, - revision_type=self.revision_type, + type_=self.type_, ) def as_apply(self) -> Cognite360ImageCollectionWrite: @@ -252,7 +252,7 @@ class Cognite360ImageCollectionWrite(CogniteDescribableNodeWrite, Cognite3DRevis published: The published field. status: The status field. tags: Text based labels for generic use, limited to 1000 - revision_type: The revision type field. + type_: The type field. """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "Cognite360ImageCollection", "v1") @@ -295,8 +295,8 @@ def _to_instances_write( if self.tags is not None or write_none: properties["tags"] = self.tags - if self.revision_type is not None or write_none: - properties["type"] = self.revision_type + if self.type_ is not None or write_none: + properties["type"] = self.type_ if properties: this_node = dm.NodeApply( diff --git a/examples/cognite_core/data_classes/_cognite_360_image_model.py b/examples/cognite_core/data_classes/_cognite_360_image_model.py index 1d7bfc535..311449c83 100644 --- a/examples/cognite_core/data_classes/_cognite_360_image_model.py +++ b/examples/cognite_core/data_classes/_cognite_360_image_model.py @@ -67,7 +67,7 @@ Cognite360ImageModelTextFields = Literal["external_id", "aliases", "description", "name", "tags"] -Cognite360ImageModelFields = Literal["external_id", "aliases", "description", "name", "tags", "model_type"] +Cognite360ImageModelFields = Literal["external_id", "aliases", "description", "name", "tags", "type_"] _COGNITE360IMAGEMODEL_PROPERTIES_BY_FIELD = { "external_id": "externalId", @@ -75,11 +75,11 @@ "description": "description", "name": "name", "tags": "tags", - "model_type": "type", + "type_": "type", } -class Cognite360ImageModelGraphQL(GraphQLCore, protected_namespaces=()): +class Cognite360ImageModelGraphQL(GraphQLCore): """This represents the reading version of Cognite 360 image model, used when data is retrieved from CDF using GraphQL. @@ -95,7 +95,7 @@ class Cognite360ImageModelGraphQL(GraphQLCore, protected_namespaces=()): name: Name of the instance tags: Text based labels for generic use, limited to 1000 thumbnail: Thumbnail of the 3D model - model_type: CAD, PointCloud or Image360 + type_: CAD, PointCloud or Image360 """ view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "Cognite360ImageModel", "v1") @@ -105,7 +105,7 @@ class Cognite360ImageModelGraphQL(GraphQLCore, protected_namespaces=()): name: Optional[str] = None tags: Optional[list[str]] = None thumbnail: Optional[CogniteFileGraphQL] = Field(default=None, repr=False) - model_type: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") + type_: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") @model_validator(mode="before") def parse_data_record(cls, values: Any) -> Any: @@ -146,7 +146,7 @@ def as_read(self) -> Cognite360ImageModel: name=self.name, tags=self.tags, thumbnail=self.thumbnail.as_read() if isinstance(self.thumbnail, GraphQLCore) else self.thumbnail, - model_type=self.model_type, + type_=self.type_, ) # We do the ignore argument type as we let pydantic handle the type checking @@ -162,11 +162,11 @@ def as_write(self) -> Cognite360ImageModelWrite: name=self.name, tags=self.tags, thumbnail=self.thumbnail.as_write() if isinstance(self.thumbnail, GraphQLCore) else self.thumbnail, - model_type=self.model_type, + type_=self.type_, ) -class Cognite360ImageModel(Cognite3DModel, protected_namespaces=()): +class Cognite360ImageModel(Cognite3DModel): """This represents the reading version of Cognite 360 image model. It is used to when data is retrieved from CDF. @@ -181,7 +181,7 @@ class Cognite360ImageModel(Cognite3DModel, protected_namespaces=()): name: Name of the instance tags: Text based labels for generic use, limited to 1000 thumbnail: Thumbnail of the 3D model - model_type: CAD, PointCloud or Image360 + type_: CAD, PointCloud or Image360 """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "Cognite360ImageModel", "v1") @@ -200,7 +200,7 @@ def as_write(self) -> Cognite360ImageModelWrite: name=self.name, tags=self.tags, thumbnail=self.thumbnail.as_write() if isinstance(self.thumbnail, DomainModel) else self.thumbnail, - model_type=self.model_type, + type_=self.type_, ) def as_apply(self) -> Cognite360ImageModelWrite: @@ -240,7 +240,7 @@ def _update_connections( model_3d.collections.append(node) -class Cognite360ImageModelWrite(Cognite3DModelWrite, protected_namespaces=()): +class Cognite360ImageModelWrite(Cognite3DModelWrite): """This represents the writing version of Cognite 360 image model. It is used to when data is sent to CDF. @@ -254,7 +254,7 @@ class Cognite360ImageModelWrite(Cognite3DModelWrite, protected_namespaces=()): name: Name of the instance tags: Text based labels for generic use, limited to 1000 thumbnail: Thumbnail of the 3D model - model_type: CAD, PointCloud or Image360 + type_: CAD, PointCloud or Image360 """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "Cognite360ImageModel", "v1") @@ -291,8 +291,8 @@ def _to_instances_write( "externalId": self.thumbnail if isinstance(self.thumbnail, str) else self.thumbnail.external_id, } - if self.model_type is not None or write_none: - properties["type"] = self.model_type + if self.type_ is not None or write_none: + properties["type"] = self.type_ if properties: this_node = dm.NodeApply( diff --git a/examples/cognite_core/data_classes/_cognite_3_d_model.py b/examples/cognite_core/data_classes/_cognite_3_d_model.py index 52caa5835..7883630bf 100644 --- a/examples/cognite_core/data_classes/_cognite_3_d_model.py +++ b/examples/cognite_core/data_classes/_cognite_3_d_model.py @@ -60,7 +60,7 @@ Cognite3DModelTextFields = Literal["external_id", "aliases", "description", "name", "tags"] -Cognite3DModelFields = Literal["external_id", "aliases", "description", "name", "tags", "model_type"] +Cognite3DModelFields = Literal["external_id", "aliases", "description", "name", "tags", "type_"] _COGNITE3DMODEL_PROPERTIES_BY_FIELD = { "external_id": "externalId", @@ -68,11 +68,11 @@ "description": "description", "name": "name", "tags": "tags", - "model_type": "type", + "type_": "type", } -class Cognite3DModelGraphQL(GraphQLCore, protected_namespaces=()): +class Cognite3DModelGraphQL(GraphQLCore): """This represents the reading version of Cognite 3D model, used when data is retrieved from CDF using GraphQL. @@ -87,7 +87,7 @@ class Cognite3DModelGraphQL(GraphQLCore, protected_namespaces=()): name: Name of the instance tags: Text based labels for generic use, limited to 1000 thumbnail: Thumbnail of the 3D model - model_type: CAD, PointCloud or Image360 + type_: CAD, PointCloud or Image360 """ view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "Cognite3DModel", "v1") @@ -96,7 +96,7 @@ class Cognite3DModelGraphQL(GraphQLCore, protected_namespaces=()): name: Optional[str] = None tags: Optional[list[str]] = None thumbnail: Optional[CogniteFileGraphQL] = Field(default=None, repr=False) - model_type: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") + type_: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") @model_validator(mode="before") def parse_data_record(cls, values: Any) -> Any: @@ -136,7 +136,7 @@ def as_read(self) -> Cognite3DModel: name=self.name, tags=self.tags, thumbnail=self.thumbnail.as_read() if isinstance(self.thumbnail, GraphQLCore) else self.thumbnail, - model_type=self.model_type, + type_=self.type_, ) # We do the ignore argument type as we let pydantic handle the type checking @@ -152,11 +152,11 @@ def as_write(self) -> Cognite3DModelWrite: name=self.name, tags=self.tags, thumbnail=self.thumbnail.as_write() if isinstance(self.thumbnail, GraphQLCore) else self.thumbnail, - model_type=self.model_type, + type_=self.type_, ) -class Cognite3DModel(CogniteDescribableNode, protected_namespaces=()): +class Cognite3DModel(CogniteDescribableNode): """This represents the reading version of Cognite 3D model. It is used to when data is retrieved from CDF. @@ -170,14 +170,14 @@ class Cognite3DModel(CogniteDescribableNode, protected_namespaces=()): name: Name of the instance tags: Text based labels for generic use, limited to 1000 thumbnail: Thumbnail of the 3D model - model_type: CAD, PointCloud or Image360 + type_: CAD, PointCloud or Image360 """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "Cognite3DModel", "v1") node_type: Union[dm.DirectRelationReference, None] = None thumbnail: Union[CogniteFile, str, dm.NodeId, None] = Field(default=None, repr=False) - model_type: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") + type_: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") def as_write(self) -> Cognite3DModelWrite: """Convert this read version of Cognite 3D model to the writing version.""" @@ -190,7 +190,7 @@ def as_write(self) -> Cognite3DModelWrite: name=self.name, tags=self.tags, thumbnail=self.thumbnail.as_write() if isinstance(self.thumbnail, DomainModel) else self.thumbnail, - model_type=self.model_type, + type_=self.type_, ) def as_apply(self) -> Cognite3DModelWrite: @@ -220,7 +220,7 @@ def _update_connections( instance.thumbnail = thumbnail -class Cognite3DModelWrite(CogniteDescribableNodeWrite, protected_namespaces=()): +class Cognite3DModelWrite(CogniteDescribableNodeWrite): """This represents the writing version of Cognite 3D model. It is used to when data is sent to CDF. @@ -234,14 +234,14 @@ class Cognite3DModelWrite(CogniteDescribableNodeWrite, protected_namespaces=()): name: Name of the instance tags: Text based labels for generic use, limited to 1000 thumbnail: Thumbnail of the 3D model - model_type: CAD, PointCloud or Image360 + type_: CAD, PointCloud or Image360 """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "Cognite3DModel", "v1") node_type: Union[dm.DirectRelationReference, dm.NodeId, tuple[str, str], None] = None thumbnail: Union[CogniteFileWrite, str, dm.NodeId, None] = Field(default=None, repr=False) - model_type: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") + type_: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") @field_validator("thumbnail", mode="before") def as_node_id(cls, value: Any) -> Any: @@ -283,8 +283,8 @@ def _to_instances_write( "externalId": self.thumbnail if isinstance(self.thumbnail, str) else self.thumbnail.external_id, } - if self.model_type is not None or write_none: - properties["type"] = self.model_type + if self.type_ is not None or write_none: + properties["type"] = self.type_ if properties: this_node = dm.NodeApply( diff --git a/examples/cognite_core/data_classes/_cognite_3_d_revision.py b/examples/cognite_core/data_classes/_cognite_3_d_revision.py index f077a2365..2b8a870ed 100644 --- a/examples/cognite_core/data_classes/_cognite_3_d_revision.py +++ b/examples/cognite_core/data_classes/_cognite_3_d_revision.py @@ -59,13 +59,13 @@ Cognite3DRevisionTextFields = Literal["external_id",] -Cognite3DRevisionFields = Literal["external_id", "published", "status", "revision_type"] +Cognite3DRevisionFields = Literal["external_id", "published", "status", "type_"] _COGNITE3DREVISION_PROPERTIES_BY_FIELD = { "external_id": "externalId", "published": "published", "status": "status", - "revision_type": "type", + "type_": "type", } @@ -82,14 +82,14 @@ class Cognite3DRevisionGraphQL(GraphQLCore, protected_namespaces=()): model_3d: The model 3d field. published: The published field. status: The status field. - revision_type: The revision type field. + type_: The type field. """ view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "Cognite3DRevision", "v1") model_3d: Optional[Cognite3DModelGraphQL] = Field(default=None, repr=False, alias="model3D") published: Optional[bool] = None status: Optional[Literal["Done", "Failed", "Processing", "Queued"]] = None - revision_type: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") + type_: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") @model_validator(mode="before") def parse_data_record(cls, values: Any) -> Any: @@ -127,7 +127,7 @@ def as_read(self) -> Cognite3DRevision: model_3d=self.model_3d.as_read() if isinstance(self.model_3d, GraphQLCore) else self.model_3d, published=self.published, status=self.status, - revision_type=self.revision_type, + type_=self.type_, ) # We do the ignore argument type as we let pydantic handle the type checking @@ -141,7 +141,7 @@ def as_write(self) -> Cognite3DRevisionWrite: model_3d=self.model_3d.as_write() if isinstance(self.model_3d, GraphQLCore) else self.model_3d, published=self.published, status=self.status, - revision_type=self.revision_type, + type_=self.type_, ) @@ -157,7 +157,7 @@ class Cognite3DRevision(DomainModel, protected_namespaces=()): model_3d: The model 3d field. published: The published field. status: The status field. - revision_type: The revision type field. + type_: The type field. """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "Cognite3DRevision", "v1") @@ -167,7 +167,7 @@ class Cognite3DRevision(DomainModel, protected_namespaces=()): model_3d: Union[Cognite3DModel, str, dm.NodeId, None] = Field(default=None, repr=False, alias="model3D") published: Optional[bool] = None status: Optional[Literal["Done", "Failed", "Processing", "Queued"]] = None - revision_type: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") + type_: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") def as_write(self) -> Cognite3DRevisionWrite: """Convert this read version of Cognite 3D revision to the writing version.""" @@ -178,7 +178,7 @@ def as_write(self) -> Cognite3DRevisionWrite: model_3d=self.model_3d.as_write() if isinstance(self.model_3d, DomainModel) else self.model_3d, published=self.published, status=self.status, - revision_type=self.revision_type, + type_=self.type_, ) def as_apply(self) -> Cognite3DRevisionWrite: @@ -220,7 +220,7 @@ class Cognite3DRevisionWrite(DomainModelWrite, protected_namespaces=()): model_3d: The model 3d field. published: The published field. status: The status field. - revision_type: The revision type field. + type_: The type field. """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "Cognite3DRevision", "v1") @@ -230,7 +230,7 @@ class Cognite3DRevisionWrite(DomainModelWrite, protected_namespaces=()): model_3d: Union[Cognite3DModelWrite, str, dm.NodeId, None] = Field(default=None, repr=False, alias="model3D") published: Optional[bool] = None status: Optional[Literal["Done", "Failed", "Processing", "Queued"]] = None - revision_type: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") + type_: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") @field_validator("model_3d", mode="before") def as_node_id(cls, value: Any) -> Any: @@ -266,8 +266,8 @@ def _to_instances_write( if self.status is not None or write_none: properties["status"] = self.status - if self.revision_type is not None or write_none: - properties["type"] = self.revision_type + if self.type_ is not None or write_none: + properties["type"] = self.type_ if properties: this_node = dm.NodeApply( diff --git a/examples/cognite_core/data_classes/_cognite_asset.py b/examples/cognite_core/data_classes/_cognite_asset.py index da1c6dfa6..eed9525ca 100644 --- a/examples/cognite_core/data_classes/_cognite_asset.py +++ b/examples/cognite_core/data_classes/_cognite_asset.py @@ -186,7 +186,7 @@ class CogniteAssetGraphQL(GraphQLCore): source_updated_user: User identifier from the source system on who last updated the source data. This identifier is not guaranteed to match the user identifiers in CDF tags: Text based labels for generic use, limited to 1000 time_series: An automatically updated list of time series related to the asset. - asset_type: Specifies the type of the asset. It's a direct relation to CogniteAssetType. + type_: Specifies the type of the asset. It's a direct relation to CogniteAssetType. """ view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "CogniteAsset", "v1") @@ -212,7 +212,7 @@ class CogniteAssetGraphQL(GraphQLCore): source_updated_user: Optional[str] = Field(None, alias="sourceUpdatedUser") tags: Optional[list[str]] = None time_series: Optional[list[CogniteTimeSeriesGraphQL]] = Field(default=None, repr=False, alias="timeSeries") - asset_type: Optional[CogniteAssetTypeGraphQL] = Field(default=None, repr=False, alias="type") + type_: Optional[CogniteAssetTypeGraphQL] = Field(default=None, repr=False, alias="type") @model_validator(mode="before") def parse_data_record(cls, values: Any) -> Any: @@ -237,7 +237,7 @@ def parse_data_record(cls, values: Any) -> Any: "root", "source", "time_series", - "asset_type", + "type_", mode="before", ) def parse_graphql(cls, value: Any) -> Any: @@ -283,7 +283,7 @@ def as_read(self) -> CogniteAsset: source_updated_user=self.source_updated_user, tags=self.tags, time_series=[time_series.as_read() for time_series in self.time_series or []], - asset_type=self.asset_type.as_read() if isinstance(self.asset_type, GraphQLCore) else self.asset_type, + type_=self.type_.as_read() if isinstance(self.type_, GraphQLCore) else self.type_, ) # We do the ignore argument type as we let pydantic handle the type checking @@ -311,7 +311,7 @@ def as_write(self) -> CogniteAssetWrite: source_updated_time=self.source_updated_time, source_updated_user=self.source_updated_user, tags=self.tags, - asset_type=self.asset_type.as_write() if isinstance(self.asset_type, GraphQLCore) else self.asset_type, + type_=self.type_.as_write() if isinstance(self.type_, GraphQLCore) else self.type_, ) @@ -346,7 +346,7 @@ class CogniteAsset(CogniteVisualizable, CogniteDescribableNode, CogniteSourceabl source_updated_user: User identifier from the source system on who last updated the source data. This identifier is not guaranteed to match the user identifiers in CDF tags: Text based labels for generic use, limited to 1000 time_series: An automatically updated list of time series related to the asset. - asset_type: Specifies the type of the asset. It's a direct relation to CogniteAssetType. + type_: Specifies the type of the asset. It's a direct relation to CogniteAssetType. """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "CogniteAsset", "v1") @@ -362,7 +362,7 @@ class CogniteAsset(CogniteVisualizable, CogniteDescribableNode, CogniteSourceabl path_last_updated_time: Optional[datetime.datetime] = Field(None, alias="pathLastUpdatedTime") root: Union[CogniteAsset, str, dm.NodeId, None] = Field(default=None, repr=False) time_series: Optional[list[CogniteTimeSeries]] = Field(default=None, repr=False, alias="timeSeries") - asset_type: Union[CogniteAssetType, str, dm.NodeId, None] = Field(default=None, repr=False, alias="type") + type_: Union[CogniteAssetType, str, dm.NodeId, None] = Field(default=None, repr=False, alias="type") def as_write(self) -> CogniteAssetWrite: """Convert this read version of Cognite asset to the writing version.""" @@ -387,7 +387,7 @@ def as_write(self) -> CogniteAssetWrite: source_updated_time=self.source_updated_time, source_updated_user=self.source_updated_user, tags=self.tags, - asset_type=self.asset_type.as_write() if isinstance(self.asset_type, DomainModel) else self.asset_type, + type_=self.type_.as_write() if isinstance(self.type_, DomainModel) else self.type_, ) def as_apply(self) -> CogniteAssetWrite: @@ -447,11 +447,11 @@ def _update_connections( ): instance.source = source if ( - isinstance(instance.asset_type, (dm.NodeId, str)) - and (asset_type := nodes_by_id.get(instance.asset_type)) - and isinstance(asset_type, CogniteAssetType) + isinstance(instance.type_, (dm.NodeId, str)) + and (type_ := nodes_by_id.get(instance.type_)) + and isinstance(type_, CogniteAssetType) ): - instance.asset_type = asset_type + instance.type_ = type_ if instance.path: new_path: list[CogniteAsset | str | dm.NodeId] = [] for relation in instance.path: @@ -532,7 +532,7 @@ class CogniteAssetWrite(CogniteVisualizableWrite, CogniteDescribableNodeWrite, C source_updated_time: When the instance was last updated in the source system (if available) source_updated_user: User identifier from the source system on who last updated the source data. This identifier is not guaranteed to match the user identifiers in CDF tags: Text based labels for generic use, limited to 1000 - asset_type: Specifies the type of the asset. It's a direct relation to CogniteAssetType. + type_: Specifies the type of the asset. It's a direct relation to CogniteAssetType. """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "CogniteAsset", "v1") @@ -545,9 +545,9 @@ class CogniteAssetWrite(CogniteVisualizableWrite, CogniteDescribableNodeWrite, C path: Optional[list[Union[CogniteAssetWrite, str, dm.NodeId]]] = Field(default=None, repr=False) path_last_updated_time: Optional[datetime.datetime] = Field(None, alias="pathLastUpdatedTime") root: Union[CogniteAssetWrite, str, dm.NodeId, None] = Field(default=None, repr=False) - asset_type: Union[CogniteAssetTypeWrite, str, dm.NodeId, None] = Field(default=None, repr=False, alias="type") + type_: Union[CogniteAssetTypeWrite, str, dm.NodeId, None] = Field(default=None, repr=False, alias="type") - @field_validator("asset_class", "parent", "path", "root", "asset_type", mode="before") + @field_validator("asset_class", "parent", "path", "root", "type_", mode="before") def as_node_id(cls, value: Any) -> Any: if isinstance(value, dm.DirectRelationReference): return dm.NodeId(value.space, value.external_id) @@ -647,10 +647,10 @@ def _to_instances_write( if self.tags is not None or write_none: properties["tags"] = self.tags - if self.asset_type is not None: + if self.type_ is not None: properties["type"] = { - "space": self.space if isinstance(self.asset_type, str) else self.asset_type.space, - "externalId": self.asset_type if isinstance(self.asset_type, str) else self.asset_type.external_id, + "space": self.space if isinstance(self.type_, str) else self.type_.space, + "externalId": self.type_ if isinstance(self.type_, str) else self.type_.external_id, } if properties: @@ -689,8 +689,8 @@ def _to_instances_write( other_resources = self.source._to_instances_write(cache) resources.extend(other_resources) - if isinstance(self.asset_type, DomainModelWrite): - other_resources = self.asset_type._to_instances_write(cache) + if isinstance(self.type_, DomainModelWrite): + other_resources = self.type_._to_instances_write(cache) resources.extend(other_resources) for path in self.path or []: @@ -808,12 +808,10 @@ def time_series(self) -> CogniteTimeSeriesList: ) @property - def asset_type(self) -> CogniteAssetTypeList: + def type_(self) -> CogniteAssetTypeList: from ._cognite_asset_type import CogniteAssetType, CogniteAssetTypeList - return CogniteAssetTypeList( - [item.asset_type for item in self.data if isinstance(item.asset_type, CogniteAssetType)] - ) + return CogniteAssetTypeList([item.type_ for item in self.data if isinstance(item.type_, CogniteAssetType)]) class CogniteAssetWriteList(DomainModelWriteList[CogniteAssetWrite]): @@ -860,11 +858,11 @@ def source(self) -> CogniteSourceSystemWriteList: ) @property - def asset_type(self) -> CogniteAssetTypeWriteList: + def type_(self) -> CogniteAssetTypeWriteList: from ._cognite_asset_type import CogniteAssetTypeWrite, CogniteAssetTypeWriteList return CogniteAssetTypeWriteList( - [item.asset_type for item in self.data if isinstance(item.asset_type, CogniteAssetTypeWrite)] + [item.type_ for item in self.data if isinstance(item.type_, CogniteAssetTypeWrite)] ) @@ -939,7 +937,7 @@ def _create_cognite_asset_filter( max_source_updated_time: datetime.datetime | None = None, source_updated_user: str | list[str] | None = None, source_updated_user_prefix: str | None = None, - asset_type: ( + type_: ( str | tuple[str, str] | dm.NodeId @@ -1067,16 +1065,11 @@ def _create_cognite_asset_filter( filters.append( dm.filters.Prefix(view_id.as_property_ref("sourceUpdatedUser"), value=source_updated_user_prefix) ) - if isinstance(asset_type, str | dm.NodeId | dm.DirectRelationReference) or is_tuple_id(asset_type): - filters.append(dm.filters.Equals(view_id.as_property_ref("type"), value=as_instance_dict_id(asset_type))) - if ( - asset_type - and isinstance(asset_type, Sequence) - and not isinstance(asset_type, str) - and not is_tuple_id(asset_type) - ): + if isinstance(type_, str | dm.NodeId | dm.DirectRelationReference) or is_tuple_id(type_): + filters.append(dm.filters.Equals(view_id.as_property_ref("type"), value=as_instance_dict_id(type_))) + if type_ and isinstance(type_, Sequence) and not isinstance(type_, str) and not is_tuple_id(type_): filters.append( - dm.filters.In(view_id.as_property_ref("type"), values=[as_instance_dict_id(item) for item in asset_type]) + dm.filters.In(view_id.as_property_ref("type"), values=[as_instance_dict_id(item) for item in type_]) ) if external_id_prefix is not None: filters.append(dm.filters.Prefix(["node", "externalId"], value=external_id_prefix)) @@ -1273,7 +1266,7 @@ def __init__( ) if _CogniteAssetTypeQuery not in created_types: - self.asset_type = _CogniteAssetTypeQuery( + self.type_ = _CogniteAssetTypeQuery( created_types.copy(), self._creation_path, client, @@ -1282,7 +1275,7 @@ def __init__( through=self._view_id.as_property_ref("type"), direction="outwards", ), - connection_name="asset_type", + connection_name="type_", ) self.space = StringFilter(self, ["node", "space"]) diff --git a/examples/cognite_core/data_classes/_cognite_cad_model.py b/examples/cognite_core/data_classes/_cognite_cad_model.py index a62686fbd..9214d4acd 100644 --- a/examples/cognite_core/data_classes/_cognite_cad_model.py +++ b/examples/cognite_core/data_classes/_cognite_cad_model.py @@ -67,7 +67,7 @@ CogniteCADModelTextFields = Literal["external_id", "aliases", "description", "name", "tags"] -CogniteCADModelFields = Literal["external_id", "aliases", "description", "name", "tags", "model_type"] +CogniteCADModelFields = Literal["external_id", "aliases", "description", "name", "tags", "type_"] _COGNITECADMODEL_PROPERTIES_BY_FIELD = { "external_id": "externalId", @@ -75,11 +75,11 @@ "description": "description", "name": "name", "tags": "tags", - "model_type": "type", + "type_": "type", } -class CogniteCADModelGraphQL(GraphQLCore, protected_namespaces=()): +class CogniteCADModelGraphQL(GraphQLCore): """This represents the reading version of Cognite cad model, used when data is retrieved from CDF using GraphQL. @@ -95,7 +95,7 @@ class CogniteCADModelGraphQL(GraphQLCore, protected_namespaces=()): revisions: List of revisions for this CAD model tags: Text based labels for generic use, limited to 1000 thumbnail: Thumbnail of the 3D model - model_type: CAD, PointCloud or Image360 + type_: CAD, PointCloud or Image360 """ view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "CogniteCADModel", "v1") @@ -105,7 +105,7 @@ class CogniteCADModelGraphQL(GraphQLCore, protected_namespaces=()): revisions: Optional[list[CogniteCADRevisionGraphQL]] = Field(default=None, repr=False) tags: Optional[list[str]] = None thumbnail: Optional[CogniteFileGraphQL] = Field(default=None, repr=False) - model_type: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") + type_: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") @model_validator(mode="before") def parse_data_record(cls, values: Any) -> Any: @@ -146,7 +146,7 @@ def as_read(self) -> CogniteCADModel: revisions=[revision.as_read() for revision in self.revisions or []], tags=self.tags, thumbnail=self.thumbnail.as_read() if isinstance(self.thumbnail, GraphQLCore) else self.thumbnail, - model_type=self.model_type, + type_=self.type_, ) # We do the ignore argument type as we let pydantic handle the type checking @@ -162,11 +162,11 @@ def as_write(self) -> CogniteCADModelWrite: name=self.name, tags=self.tags, thumbnail=self.thumbnail.as_write() if isinstance(self.thumbnail, GraphQLCore) else self.thumbnail, - model_type=self.model_type, + type_=self.type_, ) -class CogniteCADModel(Cognite3DModel, protected_namespaces=()): +class CogniteCADModel(Cognite3DModel): """This represents the reading version of Cognite cad model. It is used to when data is retrieved from CDF. @@ -181,7 +181,7 @@ class CogniteCADModel(Cognite3DModel, protected_namespaces=()): revisions: List of revisions for this CAD model tags: Text based labels for generic use, limited to 1000 thumbnail: Thumbnail of the 3D model - model_type: CAD, PointCloud or Image360 + type_: CAD, PointCloud or Image360 """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "CogniteCADModel", "v1") @@ -200,7 +200,7 @@ def as_write(self) -> CogniteCADModelWrite: name=self.name, tags=self.tags, thumbnail=self.thumbnail.as_write() if isinstance(self.thumbnail, DomainModel) else self.thumbnail, - model_type=self.model_type, + type_=self.type_, ) def as_apply(self) -> CogniteCADModelWrite: @@ -240,7 +240,7 @@ def _update_connections( model_3d.revisions.append(node) -class CogniteCADModelWrite(Cognite3DModelWrite, protected_namespaces=()): +class CogniteCADModelWrite(Cognite3DModelWrite): """This represents the writing version of Cognite cad model. It is used to when data is sent to CDF. @@ -254,7 +254,7 @@ class CogniteCADModelWrite(Cognite3DModelWrite, protected_namespaces=()): name: Name of the instance tags: Text based labels for generic use, limited to 1000 thumbnail: Thumbnail of the 3D model - model_type: CAD, PointCloud or Image360 + type_: CAD, PointCloud or Image360 """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "CogniteCADModel", "v1") @@ -291,8 +291,8 @@ def _to_instances_write( "externalId": self.thumbnail if isinstance(self.thumbnail, str) else self.thumbnail.external_id, } - if self.model_type is not None or write_none: - properties["type"] = self.model_type + if self.type_ is not None or write_none: + properties["type"] = self.type_ if properties: this_node = dm.NodeApply( diff --git a/examples/cognite_core/data_classes/_cognite_cad_revision.py b/examples/cognite_core/data_classes/_cognite_cad_revision.py index 4e1f8d5a6..1f7e02c09 100644 --- a/examples/cognite_core/data_classes/_cognite_cad_revision.py +++ b/examples/cognite_core/data_classes/_cognite_cad_revision.py @@ -61,14 +61,14 @@ CogniteCADRevisionTextFields = Literal["external_id",] -CogniteCADRevisionFields = Literal["external_id", "published", "revision_id", "status", "revision_type"] +CogniteCADRevisionFields = Literal["external_id", "published", "revision_id", "status", "type_"] _COGNITECADREVISION_PROPERTIES_BY_FIELD = { "external_id": "externalId", "published": "published", "revision_id": "revisionId", "status": "status", - "revision_type": "type", + "type_": "type", } @@ -86,7 +86,7 @@ class CogniteCADRevisionGraphQL(GraphQLCore, protected_namespaces=()): published: The published field. revision_id: The 3D API revision identifier for this CAD model status: The status field. - revision_type: The revision type field. + type_: The type field. """ view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "CogniteCADRevision", "v1") @@ -94,7 +94,7 @@ class CogniteCADRevisionGraphQL(GraphQLCore, protected_namespaces=()): published: Optional[bool] = None revision_id: Optional[int] = Field(None, alias="revisionId") status: Optional[Literal["Done", "Failed", "Processing", "Queued"]] = None - revision_type: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") + type_: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") @model_validator(mode="before") def parse_data_record(cls, values: Any) -> Any: @@ -133,7 +133,7 @@ def as_read(self) -> CogniteCADRevision: published=self.published, revision_id=self.revision_id, status=self.status, - revision_type=self.revision_type, + type_=self.type_, ) # We do the ignore argument type as we let pydantic handle the type checking @@ -148,7 +148,7 @@ def as_write(self) -> CogniteCADRevisionWrite: published=self.published, revision_id=self.revision_id, status=self.status, - revision_type=self.revision_type, + type_=self.type_, ) @@ -165,7 +165,7 @@ class CogniteCADRevision(Cognite3DRevision, protected_namespaces=()): published: The published field. revision_id: The 3D API revision identifier for this CAD model status: The status field. - revision_type: The revision type field. + type_: The type field. """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "CogniteCADRevision", "v1") @@ -183,7 +183,7 @@ def as_write(self) -> CogniteCADRevisionWrite: published=self.published, revision_id=self.revision_id, status=self.status, - revision_type=self.revision_type, + type_=self.type_, ) def as_apply(self) -> CogniteCADRevisionWrite: @@ -226,7 +226,7 @@ class CogniteCADRevisionWrite(Cognite3DRevisionWrite, protected_namespaces=()): published: The published field. revision_id: The 3D API revision identifier for this CAD model status: The status field. - revision_type: The revision type field. + type_: The type field. """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "CogniteCADRevision", "v1") @@ -261,8 +261,8 @@ def _to_instances_write( if self.status is not None or write_none: properties["status"] = self.status - if self.revision_type is not None or write_none: - properties["type"] = self.revision_type + if self.type_ is not None or write_none: + properties["type"] = self.type_ if properties: this_node = dm.NodeApply( diff --git a/examples/cognite_core/data_classes/_cognite_point_cloud_model.py b/examples/cognite_core/data_classes/_cognite_point_cloud_model.py index a49b0daca..90ce51eb4 100644 --- a/examples/cognite_core/data_classes/_cognite_point_cloud_model.py +++ b/examples/cognite_core/data_classes/_cognite_point_cloud_model.py @@ -67,7 +67,7 @@ CognitePointCloudModelTextFields = Literal["external_id", "aliases", "description", "name", "tags"] -CognitePointCloudModelFields = Literal["external_id", "aliases", "description", "name", "tags", "model_type"] +CognitePointCloudModelFields = Literal["external_id", "aliases", "description", "name", "tags", "type_"] _COGNITEPOINTCLOUDMODEL_PROPERTIES_BY_FIELD = { "external_id": "externalId", @@ -75,11 +75,11 @@ "description": "description", "name": "name", "tags": "tags", - "model_type": "type", + "type_": "type", } -class CognitePointCloudModelGraphQL(GraphQLCore, protected_namespaces=()): +class CognitePointCloudModelGraphQL(GraphQLCore): """This represents the reading version of Cognite point cloud model, used when data is retrieved from CDF using GraphQL. @@ -95,7 +95,7 @@ class CognitePointCloudModelGraphQL(GraphQLCore, protected_namespaces=()): revisions: List of revisions for this PointCloud model tags: Text based labels for generic use, limited to 1000 thumbnail: Thumbnail of the 3D model - model_type: CAD, PointCloud or Image360 + type_: CAD, PointCloud or Image360 """ view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "CognitePointCloudModel", "v1") @@ -105,7 +105,7 @@ class CognitePointCloudModelGraphQL(GraphQLCore, protected_namespaces=()): revisions: Optional[list[CognitePointCloudRevisionGraphQL]] = Field(default=None, repr=False) tags: Optional[list[str]] = None thumbnail: Optional[CogniteFileGraphQL] = Field(default=None, repr=False) - model_type: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") + type_: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") @model_validator(mode="before") def parse_data_record(cls, values: Any) -> Any: @@ -146,7 +146,7 @@ def as_read(self) -> CognitePointCloudModel: revisions=[revision.as_read() for revision in self.revisions or []], tags=self.tags, thumbnail=self.thumbnail.as_read() if isinstance(self.thumbnail, GraphQLCore) else self.thumbnail, - model_type=self.model_type, + type_=self.type_, ) # We do the ignore argument type as we let pydantic handle the type checking @@ -162,11 +162,11 @@ def as_write(self) -> CognitePointCloudModelWrite: name=self.name, tags=self.tags, thumbnail=self.thumbnail.as_write() if isinstance(self.thumbnail, GraphQLCore) else self.thumbnail, - model_type=self.model_type, + type_=self.type_, ) -class CognitePointCloudModel(Cognite3DModel, protected_namespaces=()): +class CognitePointCloudModel(Cognite3DModel): """This represents the reading version of Cognite point cloud model. It is used to when data is retrieved from CDF. @@ -181,7 +181,7 @@ class CognitePointCloudModel(Cognite3DModel, protected_namespaces=()): revisions: List of revisions for this PointCloud model tags: Text based labels for generic use, limited to 1000 thumbnail: Thumbnail of the 3D model - model_type: CAD, PointCloud or Image360 + type_: CAD, PointCloud or Image360 """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "CognitePointCloudModel", "v1") @@ -200,7 +200,7 @@ def as_write(self) -> CognitePointCloudModelWrite: name=self.name, tags=self.tags, thumbnail=self.thumbnail.as_write() if isinstance(self.thumbnail, DomainModel) else self.thumbnail, - model_type=self.model_type, + type_=self.type_, ) def as_apply(self) -> CognitePointCloudModelWrite: @@ -240,7 +240,7 @@ def _update_connections( model_3d.revisions.append(node) -class CognitePointCloudModelWrite(Cognite3DModelWrite, protected_namespaces=()): +class CognitePointCloudModelWrite(Cognite3DModelWrite): """This represents the writing version of Cognite point cloud model. It is used to when data is sent to CDF. @@ -254,7 +254,7 @@ class CognitePointCloudModelWrite(Cognite3DModelWrite, protected_namespaces=()): name: Name of the instance tags: Text based labels for generic use, limited to 1000 thumbnail: Thumbnail of the 3D model - model_type: CAD, PointCloud or Image360 + type_: CAD, PointCloud or Image360 """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "CognitePointCloudModel", "v1") @@ -291,8 +291,8 @@ def _to_instances_write( "externalId": self.thumbnail if isinstance(self.thumbnail, str) else self.thumbnail.external_id, } - if self.model_type is not None or write_none: - properties["type"] = self.model_type + if self.type_ is not None or write_none: + properties["type"] = self.type_ if properties: this_node = dm.NodeApply( diff --git a/examples/cognite_core/data_classes/_cognite_point_cloud_revision.py b/examples/cognite_core/data_classes/_cognite_point_cloud_revision.py index 703769663..0ce719b98 100644 --- a/examples/cognite_core/data_classes/_cognite_point_cloud_revision.py +++ b/examples/cognite_core/data_classes/_cognite_point_cloud_revision.py @@ -61,14 +61,14 @@ CognitePointCloudRevisionTextFields = Literal["external_id",] -CognitePointCloudRevisionFields = Literal["external_id", "published", "revision_id", "status", "revision_type"] +CognitePointCloudRevisionFields = Literal["external_id", "published", "revision_id", "status", "type_"] _COGNITEPOINTCLOUDREVISION_PROPERTIES_BY_FIELD = { "external_id": "externalId", "published": "published", "revision_id": "revisionId", "status": "status", - "revision_type": "type", + "type_": "type", } @@ -86,7 +86,7 @@ class CognitePointCloudRevisionGraphQL(GraphQLCore, protected_namespaces=()): published: The published field. revision_id: The 3D API revision identifier for this PointCloud model status: The status field. - revision_type: The revision type field. + type_: The type field. """ view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "CognitePointCloudRevision", "v1") @@ -94,7 +94,7 @@ class CognitePointCloudRevisionGraphQL(GraphQLCore, protected_namespaces=()): published: Optional[bool] = None revision_id: Optional[int] = Field(None, alias="revisionId") status: Optional[Literal["Done", "Failed", "Processing", "Queued"]] = None - revision_type: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") + type_: Optional[Literal["CAD", "Image360", "PointCloud"]] = Field(None, alias="type") @model_validator(mode="before") def parse_data_record(cls, values: Any) -> Any: @@ -133,7 +133,7 @@ def as_read(self) -> CognitePointCloudRevision: published=self.published, revision_id=self.revision_id, status=self.status, - revision_type=self.revision_type, + type_=self.type_, ) # We do the ignore argument type as we let pydantic handle the type checking @@ -148,7 +148,7 @@ def as_write(self) -> CognitePointCloudRevisionWrite: published=self.published, revision_id=self.revision_id, status=self.status, - revision_type=self.revision_type, + type_=self.type_, ) @@ -165,7 +165,7 @@ class CognitePointCloudRevision(Cognite3DRevision, protected_namespaces=()): published: The published field. revision_id: The 3D API revision identifier for this PointCloud model status: The status field. - revision_type: The revision type field. + type_: The type field. """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "CognitePointCloudRevision", "v1") @@ -183,7 +183,7 @@ def as_write(self) -> CognitePointCloudRevisionWrite: published=self.published, revision_id=self.revision_id, status=self.status, - revision_type=self.revision_type, + type_=self.type_, ) def as_apply(self) -> CognitePointCloudRevisionWrite: @@ -226,7 +226,7 @@ class CognitePointCloudRevisionWrite(Cognite3DRevisionWrite, protected_namespace published: The published field. revision_id: The 3D API revision identifier for this PointCloud model status: The status field. - revision_type: The revision type field. + type_: The type field. """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "CognitePointCloudRevision", "v1") @@ -261,8 +261,8 @@ def _to_instances_write( if self.status is not None or write_none: properties["status"] = self.status - if self.revision_type is not None or write_none: - properties["type"] = self.revision_type + if self.type_ is not None or write_none: + properties["type"] = self.type_ if properties: this_node = dm.NodeApply( diff --git a/examples/cognite_core/data_classes/_cognite_source_system.py b/examples/cognite_core/data_classes/_cognite_source_system.py index 896686178..22aa6abc0 100644 --- a/examples/cognite_core/data_classes/_cognite_source_system.py +++ b/examples/cognite_core/data_classes/_cognite_source_system.py @@ -51,11 +51,9 @@ CogniteSourceSystemTextFields = Literal[ - "external_id", "aliases", "description", "manufacturer", "name", "tags", "source_system_version" -] -CogniteSourceSystemFields = Literal[ - "external_id", "aliases", "description", "manufacturer", "name", "tags", "source_system_version" + "external_id", "aliases", "description", "manufacturer", "name", "tags", "version_" ] +CogniteSourceSystemFields = Literal["external_id", "aliases", "description", "manufacturer", "name", "tags", "version_"] _COGNITESOURCESYSTEM_PROPERTIES_BY_FIELD = { "external_id": "externalId", @@ -64,7 +62,7 @@ "manufacturer": "manufacturer", "name": "name", "tags": "tags", - "source_system_version": "version", + "version_": "version", } @@ -83,7 +81,7 @@ class CogniteSourceSystemGraphQL(GraphQLCore): manufacturer: Manufacturer of the source system name: Name of the instance tags: Text based labels for generic use, limited to 1000 - source_system_version: Version identifier for the source system + version_: Version identifier for the source system """ view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "CogniteSourceSystem", "v1") @@ -92,7 +90,7 @@ class CogniteSourceSystemGraphQL(GraphQLCore): manufacturer: Optional[str] = None name: Optional[str] = None tags: Optional[list[str]] = None - source_system_version: Optional[str] = Field(None, alias="version") + version_: Optional[str] = Field(None, alias="version") @model_validator(mode="before") def parse_data_record(cls, values: Any) -> Any: @@ -124,7 +122,7 @@ def as_read(self) -> CogniteSourceSystem: manufacturer=self.manufacturer, name=self.name, tags=self.tags, - source_system_version=self.source_system_version, + version_=self.version_, ) # We do the ignore argument type as we let pydantic handle the type checking @@ -140,7 +138,7 @@ def as_write(self) -> CogniteSourceSystemWrite: manufacturer=self.manufacturer, name=self.name, tags=self.tags, - source_system_version=self.source_system_version, + version_=self.version_, ) @@ -158,14 +156,14 @@ class CogniteSourceSystem(CogniteDescribableNode): manufacturer: Manufacturer of the source system name: Name of the instance tags: Text based labels for generic use, limited to 1000 - source_system_version: Version identifier for the source system + version_: Version identifier for the source system """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "CogniteSourceSystem", "v1") node_type: Union[dm.DirectRelationReference, None] = None manufacturer: Optional[str] = None - source_system_version: Optional[str] = Field(None, alias="version") + version_: Optional[str] = Field(None, alias="version") def as_write(self) -> CogniteSourceSystemWrite: """Convert this read version of Cognite source system to the writing version.""" @@ -178,7 +176,7 @@ def as_write(self) -> CogniteSourceSystemWrite: manufacturer=self.manufacturer, name=self.name, tags=self.tags, - source_system_version=self.source_system_version, + version_=self.version_, ) def as_apply(self) -> CogniteSourceSystemWrite: @@ -205,14 +203,14 @@ class CogniteSourceSystemWrite(CogniteDescribableNodeWrite): manufacturer: Manufacturer of the source system name: Name of the instance tags: Text based labels for generic use, limited to 1000 - source_system_version: Version identifier for the source system + version_: Version identifier for the source system """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("cdf_cdm", "CogniteSourceSystem", "v1") node_type: Union[dm.DirectRelationReference, dm.NodeId, tuple[str, str], None] = None manufacturer: Optional[str] = None - source_system_version: Optional[str] = Field(None, alias="version") + version_: Optional[str] = Field(None, alias="version") def _to_instances_write( self, @@ -241,8 +239,8 @@ def _to_instances_write( if self.tags is not None or write_none: properties["tags"] = self.tags - if self.source_system_version is not None or write_none: - properties["version"] = self.source_system_version + if self.version_ is not None or write_none: + properties["version"] = self.version_ if properties: this_node = dm.NodeApply( @@ -311,8 +309,8 @@ def _create_cognite_source_system_filter( manufacturer_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - source_system_version: str | list[str] | None = None, - source_system_version_prefix: str | None = None, + version_: str | list[str] | None = None, + version_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, filter: dm.Filter | None = None, @@ -336,12 +334,12 @@ def _create_cognite_source_system_filter( filters.append(dm.filters.In(view_id.as_property_ref("name"), values=name)) if name_prefix is not None: filters.append(dm.filters.Prefix(view_id.as_property_ref("name"), value=name_prefix)) - if isinstance(source_system_version, str): - filters.append(dm.filters.Equals(view_id.as_property_ref("version"), value=source_system_version)) - if source_system_version and isinstance(source_system_version, list): - filters.append(dm.filters.In(view_id.as_property_ref("version"), values=source_system_version)) - if source_system_version_prefix is not None: - filters.append(dm.filters.Prefix(view_id.as_property_ref("version"), value=source_system_version_prefix)) + if isinstance(version_, str): + filters.append(dm.filters.Equals(view_id.as_property_ref("version"), value=version_)) + if version_ and isinstance(version_, list): + filters.append(dm.filters.In(view_id.as_property_ref("version"), values=version_)) + if version_prefix is not None: + filters.append(dm.filters.Prefix(view_id.as_property_ref("version"), value=version_prefix)) if external_id_prefix is not None: filters.append(dm.filters.Prefix(["node", "externalId"], value=external_id_prefix)) if isinstance(space, str): @@ -387,7 +385,7 @@ def __init__( self.description = StringFilter(self, self._view_id.as_property_ref("description")) self.manufacturer = StringFilter(self, self._view_id.as_property_ref("manufacturer")) self.name = StringFilter(self, self._view_id.as_property_ref("name")) - self.source_system_version = StringFilter(self, self._view_id.as_property_ref("version")) + self.version_ = StringFilter(self, self._view_id.as_property_ref("version")) self._filter_classes.extend( [ self.space, @@ -395,7 +393,7 @@ def __init__( self.description, self.manufacturer, self.name, - self.source_system_version, + self.version_, ] ) diff --git a/examples/cognite_core/data_classes/_cognite_time_series.py b/examples/cognite_core/data_classes/_cognite_time_series.py index adf083f0f..87381d263 100644 --- a/examples/cognite_core/data_classes/_cognite_time_series.py +++ b/examples/cognite_core/data_classes/_cognite_time_series.py @@ -117,7 +117,7 @@ "source_updated_time", "source_updated_user", "tags", - "time_series_type", + "type_", ] _COGNITETIMESERIES_PROPERTIES_BY_FIELD = { @@ -134,7 +134,7 @@ "source_updated_time": "sourceUpdatedTime", "source_updated_user": "sourceUpdatedUser", "tags": "tags", - "time_series_type": "type", + "type_": "type", } @@ -164,7 +164,7 @@ class CogniteTimeSeriesGraphQL(GraphQLCore): source_updated_time: When the instance was last updated in the source system (if available) source_updated_user: User identifier from the source system on who last updated the source data. This identifier is not guaranteed to match the user identifiers in CDF tags: Text based labels for generic use, limited to 1000 - time_series_type: Specifies the data type of the data points. + type_: Specifies the data type of the data points. unit: The unit of the time series. """ @@ -185,7 +185,7 @@ class CogniteTimeSeriesGraphQL(GraphQLCore): source_updated_time: Optional[datetime.datetime] = Field(None, alias="sourceUpdatedTime") source_updated_user: Optional[str] = Field(None, alias="sourceUpdatedUser") tags: Optional[list[str]] = None - time_series_type: Optional[Literal["numeric", "string"]] = Field(None, alias="type") + type_: Optional[Literal["numeric", "string"]] = Field(None, alias="type") unit: Optional[CogniteUnitGraphQL] = Field(default=None, repr=False) @model_validator(mode="before") @@ -237,7 +237,7 @@ def as_read(self) -> CogniteTimeSeries: source_updated_time=self.source_updated_time, source_updated_user=self.source_updated_user, tags=self.tags, - time_series_type=self.time_series_type, + type_=self.type_, unit=self.unit.as_read() if isinstance(self.unit, GraphQLCore) else self.unit, ) @@ -264,7 +264,7 @@ def as_write(self) -> CogniteTimeSeriesWrite: source_updated_time=self.source_updated_time, source_updated_user=self.source_updated_user, tags=self.tags, - time_series_type=self.time_series_type, + type_=self.type_, unit=self.unit.as_write() if isinstance(self.unit, GraphQLCore) else self.unit, ) @@ -294,7 +294,7 @@ class CogniteTimeSeries(CogniteDescribableNode, CogniteSourceableNode): source_updated_time: When the instance was last updated in the source system (if available) source_updated_user: User identifier from the source system on who last updated the source data. This identifier is not guaranteed to match the user identifiers in CDF tags: Text based labels for generic use, limited to 1000 - time_series_type: Specifies the data type of the data points. + type_: Specifies the data type of the data points. unit: The unit of the time series. """ @@ -306,7 +306,7 @@ class CogniteTimeSeries(CogniteDescribableNode, CogniteSourceableNode): equipment: Optional[list[Union[CogniteEquipment, str, dm.NodeId]]] = Field(default=None, repr=False) is_step: bool = Field(alias="isStep") source_unit: Optional[str] = Field(None, alias="sourceUnit") - time_series_type: Literal["numeric", "string"] = Field(alias="type") + type_: Literal["numeric", "string"] = Field(alias="type") unit: Union[CogniteUnit, str, dm.NodeId, None] = Field(default=None, repr=False) def as_write(self) -> CogniteTimeSeriesWrite: @@ -333,7 +333,7 @@ def as_write(self) -> CogniteTimeSeriesWrite: source_updated_time=self.source_updated_time, source_updated_user=self.source_updated_user, tags=self.tags, - time_series_type=self.time_series_type, + type_=self.type_, unit=self.unit.as_write() if isinstance(self.unit, DomainModel) else self.unit, ) @@ -426,7 +426,7 @@ class CogniteTimeSeriesWrite(CogniteDescribableNodeWrite, CogniteSourceableNodeW source_updated_time: When the instance was last updated in the source system (if available) source_updated_user: User identifier from the source system on who last updated the source data. This identifier is not guaranteed to match the user identifiers in CDF tags: Text based labels for generic use, limited to 1000 - time_series_type: Specifies the data type of the data points. + type_: Specifies the data type of the data points. unit: The unit of the time series. """ @@ -437,7 +437,7 @@ class CogniteTimeSeriesWrite(CogniteDescribableNodeWrite, CogniteSourceableNodeW equipment: Optional[list[Union[CogniteEquipmentWrite, str, dm.NodeId]]] = Field(default=None, repr=False) is_step: bool = Field(alias="isStep") source_unit: Optional[str] = Field(None, alias="sourceUnit") - time_series_type: Literal["numeric", "string"] = Field(alias="type") + type_: Literal["numeric", "string"] = Field(alias="type") unit: Union[CogniteUnitWrite, str, dm.NodeId, None] = Field(default=None, repr=False) @field_validator("assets", "equipment", "unit", mode="before") @@ -526,8 +526,8 @@ def _to_instances_write( if self.tags is not None or write_none: properties["tags"] = self.tags - if self.time_series_type is not None: - properties["type"] = self.time_series_type + if self.type_ is not None: + properties["type"] = self.type_ if self.unit is not None: properties["unit"] = { diff --git a/examples/equipment_unit/_api/equipment_module.py b/examples/equipment_unit/_api/equipment_module.py index 35eafe63f..f7b6c7db6 100644 --- a/examples/equipment_unit/_api/equipment_module.py +++ b/examples/equipment_unit/_api/equipment_module.py @@ -59,8 +59,8 @@ def __call__( description_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - equipment_module_type: str | list[str] | None = None, - equipment_module_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_QUERY_LIMIT, @@ -73,8 +73,8 @@ def __call__( description_prefix: The prefix of the description to filter on. name: The name to filter on. name_prefix: The prefix of the name to filter on. - equipment_module_type: The equipment module type to filter on. - equipment_module_type_prefix: The prefix of the equipment module type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of equipment modules to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -91,8 +91,8 @@ def __call__( description_prefix, name, name_prefix, - equipment_module_type, - equipment_module_type_prefix, + type_, + type_prefix, external_id_prefix, space, (filter and dm.filters.And(filter, has_data)) or has_data, @@ -214,8 +214,8 @@ def search( description_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - equipment_module_type: str | list[str] | None = None, - equipment_module_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -233,8 +233,8 @@ def search( description_prefix: The prefix of the description to filter on. name: The name to filter on. name_prefix: The prefix of the name to filter on. - equipment_module_type: The equipment module type to filter on. - equipment_module_type_prefix: The prefix of the equipment module type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of equipment modules to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -263,8 +263,8 @@ def search( description_prefix, name, name_prefix, - equipment_module_type, - equipment_module_type_prefix, + type_, + type_prefix, external_id_prefix, space, filter, @@ -291,8 +291,8 @@ def aggregate( description_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - equipment_module_type: str | list[str] | None = None, - equipment_module_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -311,8 +311,8 @@ def aggregate( description_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - equipment_module_type: str | list[str] | None = None, - equipment_module_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -335,8 +335,8 @@ def aggregate( description_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - equipment_module_type: str | list[str] | None = None, - equipment_module_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -358,8 +358,8 @@ def aggregate( description_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - equipment_module_type: str | list[str] | None = None, - equipment_module_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -381,8 +381,8 @@ def aggregate( description_prefix: The prefix of the description to filter on. name: The name to filter on. name_prefix: The prefix of the name to filter on. - equipment_module_type: The equipment module type to filter on. - equipment_module_type_prefix: The prefix of the equipment module type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of equipment modules to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -407,8 +407,8 @@ def aggregate( description_prefix, name, name_prefix, - equipment_module_type, - equipment_module_type_prefix, + type_, + type_prefix, external_id_prefix, space, filter, @@ -433,8 +433,8 @@ def histogram( description_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - equipment_module_type: str | list[str] | None = None, - equipment_module_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -451,8 +451,8 @@ def histogram( description_prefix: The prefix of the description to filter on. name: The name to filter on. name_prefix: The prefix of the name to filter on. - equipment_module_type: The equipment module type to filter on. - equipment_module_type_prefix: The prefix of the equipment module type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of equipment modules to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -468,8 +468,8 @@ def histogram( description_prefix, name, name_prefix, - equipment_module_type, - equipment_module_type_prefix, + type_, + type_prefix, external_id_prefix, space, filter, @@ -494,8 +494,8 @@ def list( description_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - equipment_module_type: str | list[str] | None = None, - equipment_module_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -511,8 +511,8 @@ def list( description_prefix: The prefix of the description to filter on. name: The name to filter on. name_prefix: The prefix of the name to filter on. - equipment_module_type: The equipment module type to filter on. - equipment_module_type_prefix: The prefix of the equipment module type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of equipment modules to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -541,8 +541,8 @@ def list( description_prefix, name, name_prefix, - equipment_module_type, - equipment_module_type_prefix, + type_, + type_prefix, external_id_prefix, space, filter, diff --git a/examples/equipment_unit/_api/equipment_module_sensor_value.py b/examples/equipment_unit/_api/equipment_module_sensor_value.py index cdd6f5845..466b428b8 100644 --- a/examples/equipment_unit/_api/equipment_module_sensor_value.py +++ b/examples/equipment_unit/_api/equipment_module_sensor_value.py @@ -367,8 +367,8 @@ def __call__( description_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - equipment_module_type: str | list[str] | None = None, - equipment_module_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -381,8 +381,8 @@ def __call__( description_prefix: The prefix of the description to filter on. name: The name to filter on. name_prefix: The prefix of the name to filter on. - equipment_module_type: The equipment module type to filter on. - equipment_module_type_prefix: The prefix of the equipment module type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of equipment modules to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -407,8 +407,8 @@ def __call__( description_prefix, name, name_prefix, - equipment_module_type, - equipment_module_type_prefix, + type_, + type_prefix, external_id_prefix, space, filter, @@ -427,8 +427,8 @@ def list( description_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - equipment_module_type: str | list[str] | None = None, - equipment_module_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -441,8 +441,8 @@ def list( description_prefix: The prefix of the description to filter on. name: The name to filter on. name_prefix: The prefix of the name to filter on. - equipment_module_type: The equipment module type to filter on. - equipment_module_type_prefix: The prefix of the equipment module type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of equipment modules to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -466,8 +466,8 @@ def list( description_prefix, name, name_prefix, - equipment_module_type, - equipment_module_type_prefix, + type_, + type_prefix, external_id_prefix, space, filter, diff --git a/examples/equipment_unit/_api/unit_procedure.py b/examples/equipment_unit/_api/unit_procedure.py index 27ea1ae25..25a044d32 100644 --- a/examples/equipment_unit/_api/unit_procedure.py +++ b/examples/equipment_unit/_api/unit_procedure.py @@ -65,8 +65,8 @@ def __call__( self, name: str | list[str] | None = None, name_prefix: str | None = None, - unit_procedure_type: str | list[str] | None = None, - unit_procedure_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_QUERY_LIMIT, @@ -77,8 +77,8 @@ def __call__( Args: name: The name to filter on. name_prefix: The prefix of the name to filter on. - unit_procedure_type: The unit procedure type to filter on. - unit_procedure_type_prefix: The prefix of the unit procedure type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of unit procedures to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -93,8 +93,8 @@ def __call__( self._view_id, name, name_prefix, - unit_procedure_type, - unit_procedure_type_prefix, + type_, + type_prefix, external_id_prefix, space, (filter and dm.filters.And(filter, has_data)) or has_data, @@ -238,8 +238,8 @@ def search( properties: UnitProcedureTextFields | SequenceNotStr[UnitProcedureTextFields] | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - unit_procedure_type: str | list[str] | None = None, - unit_procedure_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -255,8 +255,8 @@ def search( properties: The property to search, if nothing is passed all text fields will be searched. name: The name to filter on. name_prefix: The prefix of the name to filter on. - unit_procedure_type: The unit procedure type to filter on. - unit_procedure_type_prefix: The prefix of the unit procedure type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of unit procedures to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -283,8 +283,8 @@ def search( self._view_id, name, name_prefix, - unit_procedure_type, - unit_procedure_type_prefix, + type_, + type_prefix, external_id_prefix, space, filter, @@ -309,8 +309,8 @@ def aggregate( search_property: UnitProcedureTextFields | SequenceNotStr[UnitProcedureTextFields] | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - unit_procedure_type: str | list[str] | None = None, - unit_procedure_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -327,8 +327,8 @@ def aggregate( search_property: UnitProcedureTextFields | SequenceNotStr[UnitProcedureTextFields] | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - unit_procedure_type: str | list[str] | None = None, - unit_procedure_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -349,8 +349,8 @@ def aggregate( search_property: UnitProcedureTextFields | SequenceNotStr[UnitProcedureTextFields] | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - unit_procedure_type: str | list[str] | None = None, - unit_procedure_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -370,8 +370,8 @@ def aggregate( search_property: UnitProcedureTextFields | SequenceNotStr[UnitProcedureTextFields] | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - unit_procedure_type: str | list[str] | None = None, - unit_procedure_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -391,8 +391,8 @@ def aggregate( search_property: The text field to search in. name: The name to filter on. name_prefix: The prefix of the name to filter on. - unit_procedure_type: The unit procedure type to filter on. - unit_procedure_type_prefix: The prefix of the unit procedure type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of unit procedures to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -415,8 +415,8 @@ def aggregate( self._view_id, name, name_prefix, - unit_procedure_type, - unit_procedure_type_prefix, + type_, + type_prefix, external_id_prefix, space, filter, @@ -439,8 +439,8 @@ def histogram( search_property: UnitProcedureTextFields | SequenceNotStr[UnitProcedureTextFields] | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - unit_procedure_type: str | list[str] | None = None, - unit_procedure_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -455,8 +455,8 @@ def histogram( search_property: The text field to search in. name: The name to filter on. name_prefix: The prefix of the name to filter on. - unit_procedure_type: The unit procedure type to filter on. - unit_procedure_type_prefix: The prefix of the unit procedure type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of unit procedures to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -470,8 +470,8 @@ def histogram( self._view_id, name, name_prefix, - unit_procedure_type, - unit_procedure_type_prefix, + type_, + type_prefix, external_id_prefix, space, filter, @@ -494,8 +494,8 @@ def list( self, name: str | list[str] | None = None, name_prefix: str | None = None, - unit_procedure_type: str | list[str] | None = None, - unit_procedure_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -510,8 +510,8 @@ def list( Args: name: The name to filter on. name_prefix: The prefix of the name to filter on. - unit_procedure_type: The unit procedure type to filter on. - unit_procedure_type_prefix: The prefix of the unit procedure type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of unit procedures to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -540,8 +540,8 @@ def list( self._view_id, name, name_prefix, - unit_procedure_type, - unit_procedure_type_prefix, + type_, + type_prefix, external_id_prefix, space, filter, diff --git a/examples/equipment_unit/_api/unit_procedure_query.py b/examples/equipment_unit/_api/unit_procedure_query.py index 3dbc59e1b..35ed70a98 100644 --- a/examples/equipment_unit/_api/unit_procedure_query.py +++ b/examples/equipment_unit/_api/unit_procedure_query.py @@ -68,8 +68,8 @@ def work_orders( description_prefix: str | None = None, performed_by: str | list[str] | None = None, performed_by_prefix: str | None = None, - work_order_type: str | list[str] | None = None, - work_order_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, min_end_time_edge: datetime.datetime | None = None, @@ -88,8 +88,8 @@ def work_orders( description_prefix: The prefix of the description to filter on. performed_by: The performed by to filter on. performed_by_prefix: The prefix of the performed by to filter on. - work_order_type: The work order type to filter on. - work_order_type_prefix: The prefix of the work order type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. min_end_time_edge: The minimum value of the end time to filter on. @@ -141,8 +141,8 @@ def work_orders( description_prefix, performed_by, performed_by_prefix, - work_order_type, - work_order_type_prefix, + type_, + type_prefix, external_id_prefix, space, (filter and dm.filters.And(filter, has_data)) or has_data, @@ -155,8 +155,8 @@ def work_units( description_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - equipment_module_type: str | list[str] | None = None, - equipment_module_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, min_end_time_edge: datetime.datetime | None = None, @@ -175,8 +175,8 @@ def work_units( description_prefix: The prefix of the description to filter on. name: The name to filter on. name_prefix: The prefix of the name to filter on. - equipment_module_type: The equipment module type to filter on. - equipment_module_type_prefix: The prefix of the equipment module type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. min_end_time_edge: The minimum value of the end time to filter on. @@ -228,8 +228,8 @@ def work_units( description_prefix, name, name_prefix, - equipment_module_type, - equipment_module_type_prefix, + type_, + type_prefix, external_id_prefix, space, (filter and dm.filters.And(filter, has_data)) or has_data, diff --git a/examples/equipment_unit/_api/work_order.py b/examples/equipment_unit/_api/work_order.py index 62b4b37ab..d16b9249c 100644 --- a/examples/equipment_unit/_api/work_order.py +++ b/examples/equipment_unit/_api/work_order.py @@ -56,8 +56,8 @@ def __call__( description_prefix: str | None = None, performed_by: str | list[str] | None = None, performed_by_prefix: str | None = None, - work_order_type: str | list[str] | None = None, - work_order_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_QUERY_LIMIT, @@ -70,8 +70,8 @@ def __call__( description_prefix: The prefix of the description to filter on. performed_by: The performed by to filter on. performed_by_prefix: The prefix of the performed by to filter on. - work_order_type: The work order type to filter on. - work_order_type_prefix: The prefix of the work order type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of work orders to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -88,8 +88,8 @@ def __call__( description_prefix, performed_by, performed_by_prefix, - work_order_type, - work_order_type_prefix, + type_, + type_prefix, external_id_prefix, space, (filter and dm.filters.And(filter, has_data)) or has_data, @@ -211,8 +211,8 @@ def search( description_prefix: str | None = None, performed_by: str | list[str] | None = None, performed_by_prefix: str | None = None, - work_order_type: str | list[str] | None = None, - work_order_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -230,8 +230,8 @@ def search( description_prefix: The prefix of the description to filter on. performed_by: The performed by to filter on. performed_by_prefix: The prefix of the performed by to filter on. - work_order_type: The work order type to filter on. - work_order_type_prefix: The prefix of the work order type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of work orders to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -260,8 +260,8 @@ def search( description_prefix, performed_by, performed_by_prefix, - work_order_type, - work_order_type_prefix, + type_, + type_prefix, external_id_prefix, space, filter, @@ -288,8 +288,8 @@ def aggregate( description_prefix: str | None = None, performed_by: str | list[str] | None = None, performed_by_prefix: str | None = None, - work_order_type: str | list[str] | None = None, - work_order_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -308,8 +308,8 @@ def aggregate( description_prefix: str | None = None, performed_by: str | list[str] | None = None, performed_by_prefix: str | None = None, - work_order_type: str | list[str] | None = None, - work_order_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -332,8 +332,8 @@ def aggregate( description_prefix: str | None = None, performed_by: str | list[str] | None = None, performed_by_prefix: str | None = None, - work_order_type: str | list[str] | None = None, - work_order_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -355,8 +355,8 @@ def aggregate( description_prefix: str | None = None, performed_by: str | list[str] | None = None, performed_by_prefix: str | None = None, - work_order_type: str | list[str] | None = None, - work_order_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -378,8 +378,8 @@ def aggregate( description_prefix: The prefix of the description to filter on. performed_by: The performed by to filter on. performed_by_prefix: The prefix of the performed by to filter on. - work_order_type: The work order type to filter on. - work_order_type_prefix: The prefix of the work order type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of work orders to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -404,8 +404,8 @@ def aggregate( description_prefix, performed_by, performed_by_prefix, - work_order_type, - work_order_type_prefix, + type_, + type_prefix, external_id_prefix, space, filter, @@ -430,8 +430,8 @@ def histogram( description_prefix: str | None = None, performed_by: str | list[str] | None = None, performed_by_prefix: str | None = None, - work_order_type: str | list[str] | None = None, - work_order_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -448,8 +448,8 @@ def histogram( description_prefix: The prefix of the description to filter on. performed_by: The performed by to filter on. performed_by_prefix: The prefix of the performed by to filter on. - work_order_type: The work order type to filter on. - work_order_type_prefix: The prefix of the work order type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of work orders to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -465,8 +465,8 @@ def histogram( description_prefix, performed_by, performed_by_prefix, - work_order_type, - work_order_type_prefix, + type_, + type_prefix, external_id_prefix, space, filter, @@ -491,8 +491,8 @@ def list( description_prefix: str | None = None, performed_by: str | list[str] | None = None, performed_by_prefix: str | None = None, - work_order_type: str | list[str] | None = None, - work_order_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, limit: int = DEFAULT_LIMIT_READ, @@ -508,8 +508,8 @@ def list( description_prefix: The prefix of the description to filter on. performed_by: The performed by to filter on. performed_by_prefix: The prefix of the performed by to filter on. - work_order_type: The work order type to filter on. - work_order_type_prefix: The prefix of the work order type to filter on. + type_: The type to filter on. + type_prefix: The prefix of the type to filter on. external_id_prefix: The prefix of the external ID to filter on. space: The space to filter on. limit: Maximum number of work orders to return. Defaults to 25. Set to -1, float("inf") or None to return all items. @@ -538,8 +538,8 @@ def list( description_prefix, performed_by, performed_by_prefix, - work_order_type, - work_order_type_prefix, + type_, + type_prefix, external_id_prefix, space, filter, diff --git a/examples/equipment_unit/_api_client.py b/examples/equipment_unit/_api_client.py index a26dee084..d9d891496 100644 --- a/examples/equipment_unit/_api_client.py +++ b/examples/equipment_unit/_api_client.py @@ -23,7 +23,7 @@ class EquipmentUnitClient: EquipmentUnitClient Generated with: - pygen = 0.99.46 + pygen = 0.99.47 cognite-sdk = 7.64.12 pydantic = 2.9.2 @@ -41,7 +41,7 @@ def __init__(self, config_or_client: CogniteClient | ClientConfig): else: raise ValueError(f"Expected CogniteClient or ClientConfig, got {type(config_or_client)}") # The client name is used for aggregated logging of Pygen Usage - client.config.client_name = "CognitePygen:0.99.46" + client.config.client_name = "CognitePygen:0.99.47" self._client = client diff --git a/examples/equipment_unit/data_classes/_equipment_module.py b/examples/equipment_unit/data_classes/_equipment_module.py index f140ff774..30b9a04bc 100644 --- a/examples/equipment_unit/data_classes/_equipment_module.py +++ b/examples/equipment_unit/data_classes/_equipment_module.py @@ -59,15 +59,15 @@ ] -EquipmentModuleTextFields = Literal["external_id", "description", "name", "sensor_value", "equipment_module_type"] -EquipmentModuleFields = Literal["external_id", "description", "name", "sensor_value", "equipment_module_type"] +EquipmentModuleTextFields = Literal["external_id", "description", "name", "sensor_value", "type_"] +EquipmentModuleFields = Literal["external_id", "description", "name", "sensor_value", "type_"] _EQUIPMENTMODULE_PROPERTIES_BY_FIELD = { "external_id": "externalId", "description": "description", "name": "name", "sensor_value": "sensor_value", - "equipment_module_type": "type", + "type_": "type", } @@ -84,14 +84,14 @@ class EquipmentModuleGraphQL(GraphQLCore): description: The description field. name: The name field. sensor_value: The sensor value field. - equipment_module_type: The equipment module type field. + type_: The type field. """ view_id: ClassVar[dm.ViewId] = dm.ViewId("IntegrationTestsImmutable", "EquipmentModule", "b1cd4bf14a7a33") description: Optional[str] = None name: Optional[str] = None sensor_value: Optional[TimeSeriesGraphQL] = None - equipment_module_type: Optional[str] = Field(None, alias="type") + type_: Optional[str] = Field(None, alias="type") @model_validator(mode="before") def parse_data_record(cls, values: Any) -> Any: @@ -121,7 +121,7 @@ def as_read(self) -> EquipmentModule: description=self.description, name=self.name, sensor_value=self.sensor_value.as_read() if self.sensor_value else None, - equipment_module_type=self.equipment_module_type, + type_=self.type_, ) # We do the ignore argument type as we let pydantic handle the type checking @@ -135,7 +135,7 @@ def as_write(self) -> EquipmentModuleWrite: description=self.description, name=self.name, sensor_value=self.sensor_value.as_write() if self.sensor_value else None, - equipment_module_type=self.equipment_module_type, + type_=self.type_, ) @@ -151,7 +151,7 @@ class EquipmentModule(DomainModel): description: The description field. name: The name field. sensor_value: The sensor value field. - equipment_module_type: The equipment module type field. + type_: The type field. """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("IntegrationTestsImmutable", "EquipmentModule", "b1cd4bf14a7a33") @@ -161,7 +161,7 @@ class EquipmentModule(DomainModel): description: Optional[str] = None name: Optional[str] = None sensor_value: Union[TimeSeries, str, None] = None - equipment_module_type: Optional[str] = Field(None, alias="type") + type_: Optional[str] = Field(None, alias="type") def as_write(self) -> EquipmentModuleWrite: """Convert this read version of equipment module to the writing version.""" @@ -174,7 +174,7 @@ def as_write(self) -> EquipmentModuleWrite: sensor_value=( self.sensor_value.as_write() if isinstance(self.sensor_value, CogniteTimeSeries) else self.sensor_value ), - equipment_module_type=self.equipment_module_type, + type_=self.type_, ) def as_apply(self) -> EquipmentModuleWrite: @@ -199,7 +199,7 @@ class EquipmentModuleWrite(DomainModelWrite): description: The description field. name: The name field. sensor_value: The sensor value field. - equipment_module_type: The equipment module type field. + type_: The type field. """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("IntegrationTestsImmutable", "EquipmentModule", "b1cd4bf14a7a33") @@ -209,7 +209,7 @@ class EquipmentModuleWrite(DomainModelWrite): description: Optional[str] = None name: Optional[str] = None sensor_value: Union[TimeSeriesWrite, str, None] = None - equipment_module_type: Optional[str] = Field(None, alias="type") + type_: Optional[str] = Field(None, alias="type") def _to_instances_write( self, @@ -236,8 +236,8 @@ def _to_instances_write( else self.sensor_value.external_id ) - if self.equipment_module_type is not None or write_none: - properties["type"] = self.equipment_module_type + if self.type_ is not None or write_none: + properties["type"] = self.type_ if properties: this_node = dm.NodeApply( @@ -307,8 +307,8 @@ def _create_equipment_module_filter( description_prefix: str | None = None, name: str | list[str] | None = None, name_prefix: str | None = None, - equipment_module_type: str | list[str] | None = None, - equipment_module_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, filter: dm.Filter | None = None, @@ -326,12 +326,12 @@ def _create_equipment_module_filter( filters.append(dm.filters.In(view_id.as_property_ref("name"), values=name)) if name_prefix is not None: filters.append(dm.filters.Prefix(view_id.as_property_ref("name"), value=name_prefix)) - if isinstance(equipment_module_type, str): - filters.append(dm.filters.Equals(view_id.as_property_ref("type"), value=equipment_module_type)) - if equipment_module_type and isinstance(equipment_module_type, list): - filters.append(dm.filters.In(view_id.as_property_ref("type"), values=equipment_module_type)) - if equipment_module_type_prefix is not None: - filters.append(dm.filters.Prefix(view_id.as_property_ref("type"), value=equipment_module_type_prefix)) + if isinstance(type_, str): + filters.append(dm.filters.Equals(view_id.as_property_ref("type"), value=type_)) + if type_ and isinstance(type_, list): + filters.append(dm.filters.In(view_id.as_property_ref("type"), values=type_)) + if type_prefix is not None: + filters.append(dm.filters.Prefix(view_id.as_property_ref("type"), value=type_prefix)) if external_id_prefix is not None: filters.append(dm.filters.Prefix(["node", "externalId"], value=external_id_prefix)) if isinstance(space, str): @@ -376,14 +376,14 @@ def __init__( self.external_id = StringFilter(self, ["node", "externalId"]) self.description = StringFilter(self, self._view_id.as_property_ref("description")) self.name = StringFilter(self, self._view_id.as_property_ref("name")) - self.equipment_module_type = StringFilter(self, self._view_id.as_property_ref("type")) + self.type_ = StringFilter(self, self._view_id.as_property_ref("type")) self._filter_classes.extend( [ self.space, self.external_id, self.description, self.name, - self.equipment_module_type, + self.type_, ] ) diff --git a/examples/equipment_unit/data_classes/_unit_procedure.py b/examples/equipment_unit/data_classes/_unit_procedure.py index 91c738aad..975a40de0 100644 --- a/examples/equipment_unit/data_classes/_unit_procedure.py +++ b/examples/equipment_unit/data_classes/_unit_procedure.py @@ -58,13 +58,13 @@ ] -UnitProcedureTextFields = Literal["external_id", "name", "unit_procedure_type"] -UnitProcedureFields = Literal["external_id", "name", "unit_procedure_type"] +UnitProcedureTextFields = Literal["external_id", "name", "type_"] +UnitProcedureFields = Literal["external_id", "name", "type_"] _UNITPROCEDURE_PROPERTIES_BY_FIELD = { "external_id": "externalId", "name": "name", - "unit_procedure_type": "type", + "type_": "type", } @@ -79,14 +79,14 @@ class UnitProcedureGraphQL(GraphQLCore): external_id: The external id of the unit procedure. data_record: The data record of the unit procedure node. name: The name field. - unit_procedure_type: The unit procedure type field. + type_: The type field. work_orders: The work order field. work_units: The work unit field. """ view_id: ClassVar[dm.ViewId] = dm.ViewId("IntegrationTestsImmutable", "UnitProcedure", "a6e2fea1e1c664") name: Optional[str] = None - unit_procedure_type: Optional[str] = Field(None, alias="type") + type_: Optional[str] = Field(None, alias="type") work_orders: Optional[list[StartEndTimeGraphQL]] = Field(default=None, repr=False) work_units: Optional[list[StartEndTimeGraphQL]] = Field(default=None, repr=False) @@ -124,7 +124,7 @@ def as_read(self) -> UnitProcedure: created_time=self.data_record.created_time, ), name=self.name, - unit_procedure_type=self.unit_procedure_type, + type_=self.type_, work_orders=[work_order.as_read() for work_order in self.work_orders or []], work_units=[work_unit.as_read() for work_unit in self.work_units or []], ) @@ -138,7 +138,7 @@ def as_write(self) -> UnitProcedureWrite: external_id=self.external_id, data_record=DataRecordWrite(existing_version=0), name=self.name, - unit_procedure_type=self.unit_procedure_type, + type_=self.type_, work_orders=[work_order.as_write() for work_order in self.work_orders or []], work_units=[work_unit.as_write() for work_unit in self.work_units or []], ) @@ -154,7 +154,7 @@ class UnitProcedure(DomainModel): external_id: The external id of the unit procedure. data_record: The data record of the unit procedure node. name: The name field. - unit_procedure_type: The unit procedure type field. + type_: The type field. work_orders: The work order field. work_units: The work unit field. """ @@ -164,7 +164,7 @@ class UnitProcedure(DomainModel): space: str = DEFAULT_INSTANCE_SPACE node_type: Union[dm.DirectRelationReference, None] = None name: Optional[str] = None - unit_procedure_type: Optional[str] = Field(None, alias="type") + type_: Optional[str] = Field(None, alias="type") work_orders: Optional[list[StartEndTime]] = Field(default=None, repr=False) work_units: Optional[list[StartEndTime]] = Field(default=None, repr=False) @@ -175,7 +175,7 @@ def as_write(self) -> UnitProcedureWrite: external_id=self.external_id, data_record=DataRecordWrite(existing_version=self.data_record.version), name=self.name, - unit_procedure_type=self.unit_procedure_type, + type_=self.type_, work_orders=[work_order.as_write() for work_order in self.work_orders or []], work_units=[work_unit.as_write() for work_unit in self.work_units or []], ) @@ -251,7 +251,7 @@ class UnitProcedureWrite(DomainModelWrite): external_id: The external id of the unit procedure. data_record: The data record of the unit procedure node. name: The name field. - unit_procedure_type: The unit procedure type field. + type_: The type field. work_orders: The work order field. work_units: The work unit field. """ @@ -261,7 +261,7 @@ class UnitProcedureWrite(DomainModelWrite): space: str = DEFAULT_INSTANCE_SPACE node_type: Union[dm.DirectRelationReference, dm.NodeId, tuple[str, str], None] = None name: Optional[str] = None - unit_procedure_type: Optional[str] = Field(None, alias="type") + type_: Optional[str] = Field(None, alias="type") work_orders: Optional[list[StartEndTimeWrite]] = Field(default=None, repr=False) work_units: Optional[list[StartEndTimeWrite]] = Field(default=None, repr=False) @@ -290,8 +290,8 @@ def _to_instances_write( if self.name is not None or write_none: properties["name"] = self.name - if self.unit_procedure_type is not None or write_none: - properties["type"] = self.unit_procedure_type + if self.type_ is not None or write_none: + properties["type"] = self.type_ if properties: this_node = dm.NodeApply( @@ -406,8 +406,8 @@ def _create_unit_procedure_filter( view_id: dm.ViewId, name: str | list[str] | None = None, name_prefix: str | None = None, - unit_procedure_type: str | list[str] | None = None, - unit_procedure_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, filter: dm.Filter | None = None, @@ -419,12 +419,12 @@ def _create_unit_procedure_filter( filters.append(dm.filters.In(view_id.as_property_ref("name"), values=name)) if name_prefix is not None: filters.append(dm.filters.Prefix(view_id.as_property_ref("name"), value=name_prefix)) - if isinstance(unit_procedure_type, str): - filters.append(dm.filters.Equals(view_id.as_property_ref("type"), value=unit_procedure_type)) - if unit_procedure_type and isinstance(unit_procedure_type, list): - filters.append(dm.filters.In(view_id.as_property_ref("type"), values=unit_procedure_type)) - if unit_procedure_type_prefix is not None: - filters.append(dm.filters.Prefix(view_id.as_property_ref("type"), value=unit_procedure_type_prefix)) + if isinstance(type_, str): + filters.append(dm.filters.Equals(view_id.as_property_ref("type"), value=type_)) + if type_ and isinstance(type_, list): + filters.append(dm.filters.In(view_id.as_property_ref("type"), values=type_)) + if type_prefix is not None: + filters.append(dm.filters.Prefix(view_id.as_property_ref("type"), value=type_prefix)) if external_id_prefix is not None: filters.append(dm.filters.Prefix(["node", "externalId"], value=external_id_prefix)) if isinstance(space, str): @@ -499,13 +499,13 @@ def __init__( self.space = StringFilter(self, ["node", "space"]) self.external_id = StringFilter(self, ["node", "externalId"]) self.name = StringFilter(self, self._view_id.as_property_ref("name")) - self.unit_procedure_type = StringFilter(self, self._view_id.as_property_ref("type")) + self.type_ = StringFilter(self, self._view_id.as_property_ref("type")) self._filter_classes.extend( [ self.space, self.external_id, self.name, - self.unit_procedure_type, + self.type_, ] ) diff --git a/examples/equipment_unit/data_classes/_work_order.py b/examples/equipment_unit/data_classes/_work_order.py index 79e108a51..81b49d59c 100644 --- a/examples/equipment_unit/data_classes/_work_order.py +++ b/examples/equipment_unit/data_classes/_work_order.py @@ -49,14 +49,14 @@ ] -WorkOrderTextFields = Literal["external_id", "description", "performed_by", "work_order_type"] -WorkOrderFields = Literal["external_id", "description", "performed_by", "work_order_type"] +WorkOrderTextFields = Literal["external_id", "description", "performed_by", "type_"] +WorkOrderFields = Literal["external_id", "description", "performed_by", "type_"] _WORKORDER_PROPERTIES_BY_FIELD = { "external_id": "externalId", "description": "description", "performed_by": "performedBy", - "work_order_type": "type", + "type_": "type", } @@ -72,13 +72,13 @@ class WorkOrderGraphQL(GraphQLCore): data_record: The data record of the work order node. description: The description field. performed_by: The performed by field. - work_order_type: The work order type field. + type_: The type field. """ view_id: ClassVar[dm.ViewId] = dm.ViewId("IntegrationTestsImmutable", "WorkOrder", "c5543fb2b1bc81") description: Optional[str] = None performed_by: Optional[str] = Field(None, alias="performedBy") - work_order_type: Optional[str] = Field(None, alias="type") + type_: Optional[str] = Field(None, alias="type") @model_validator(mode="before") def parse_data_record(cls, values: Any) -> Any: @@ -107,7 +107,7 @@ def as_read(self) -> WorkOrder: ), description=self.description, performed_by=self.performed_by, - work_order_type=self.work_order_type, + type_=self.type_, ) # We do the ignore argument type as we let pydantic handle the type checking @@ -120,7 +120,7 @@ def as_write(self) -> WorkOrderWrite: data_record=DataRecordWrite(existing_version=0), description=self.description, performed_by=self.performed_by, - work_order_type=self.work_order_type, + type_=self.type_, ) @@ -135,7 +135,7 @@ class WorkOrder(DomainModel): data_record: The data record of the work order node. description: The description field. performed_by: The performed by field. - work_order_type: The work order type field. + type_: The type field. """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("IntegrationTestsImmutable", "WorkOrder", "c5543fb2b1bc81") @@ -144,7 +144,7 @@ class WorkOrder(DomainModel): node_type: Union[dm.DirectRelationReference, None] = None description: Optional[str] = None performed_by: Optional[str] = Field(None, alias="performedBy") - work_order_type: Optional[str] = Field(None, alias="type") + type_: Optional[str] = Field(None, alias="type") def as_write(self) -> WorkOrderWrite: """Convert this read version of work order to the writing version.""" @@ -154,7 +154,7 @@ def as_write(self) -> WorkOrderWrite: data_record=DataRecordWrite(existing_version=self.data_record.version), description=self.description, performed_by=self.performed_by, - work_order_type=self.work_order_type, + type_=self.type_, ) def as_apply(self) -> WorkOrderWrite: @@ -178,7 +178,7 @@ class WorkOrderWrite(DomainModelWrite): data_record: The data record of the work order node. description: The description field. performed_by: The performed by field. - work_order_type: The work order type field. + type_: The type field. """ _view_id: ClassVar[dm.ViewId] = dm.ViewId("IntegrationTestsImmutable", "WorkOrder", "c5543fb2b1bc81") @@ -187,7 +187,7 @@ class WorkOrderWrite(DomainModelWrite): node_type: Union[dm.DirectRelationReference, dm.NodeId, tuple[str, str], None] = None description: Optional[str] = None performed_by: Optional[str] = Field(None, alias="performedBy") - work_order_type: Optional[str] = Field(None, alias="type") + type_: Optional[str] = Field(None, alias="type") def _to_instances_write( self, @@ -207,8 +207,8 @@ def _to_instances_write( if self.performed_by is not None or write_none: properties["performedBy"] = self.performed_by - if self.work_order_type is not None or write_none: - properties["type"] = self.work_order_type + if self.type_ is not None or write_none: + properties["type"] = self.type_ if properties: this_node = dm.NodeApply( @@ -275,8 +275,8 @@ def _create_work_order_filter( description_prefix: str | None = None, performed_by: str | list[str] | None = None, performed_by_prefix: str | None = None, - work_order_type: str | list[str] | None = None, - work_order_type_prefix: str | None = None, + type_: str | list[str] | None = None, + type_prefix: str | None = None, external_id_prefix: str | None = None, space: str | list[str] | None = None, filter: dm.Filter | None = None, @@ -294,12 +294,12 @@ def _create_work_order_filter( filters.append(dm.filters.In(view_id.as_property_ref("performedBy"), values=performed_by)) if performed_by_prefix is not None: filters.append(dm.filters.Prefix(view_id.as_property_ref("performedBy"), value=performed_by_prefix)) - if isinstance(work_order_type, str): - filters.append(dm.filters.Equals(view_id.as_property_ref("type"), value=work_order_type)) - if work_order_type and isinstance(work_order_type, list): - filters.append(dm.filters.In(view_id.as_property_ref("type"), values=work_order_type)) - if work_order_type_prefix is not None: - filters.append(dm.filters.Prefix(view_id.as_property_ref("type"), value=work_order_type_prefix)) + if isinstance(type_, str): + filters.append(dm.filters.Equals(view_id.as_property_ref("type"), value=type_)) + if type_ and isinstance(type_, list): + filters.append(dm.filters.In(view_id.as_property_ref("type"), values=type_)) + if type_prefix is not None: + filters.append(dm.filters.Prefix(view_id.as_property_ref("type"), value=type_prefix)) if external_id_prefix is not None: filters.append(dm.filters.Prefix(["node", "externalId"], value=external_id_prefix)) if isinstance(space, str): @@ -344,14 +344,14 @@ def __init__( self.external_id = StringFilter(self, ["node", "externalId"]) self.description = StringFilter(self, self._view_id.as_property_ref("description")) self.performed_by = StringFilter(self, self._view_id.as_property_ref("performedBy")) - self.work_order_type = StringFilter(self, self._view_id.as_property_ref("type")) + self.type_ = StringFilter(self, self._view_id.as_property_ref("type")) self._filter_classes.extend( [ self.space, self.external_id, self.description, self.performed_by, - self.work_order_type, + self.type_, ] ) diff --git a/examples/omni/_api_client.py b/examples/omni/_api_client.py index 7c9525a02..eeef10c57 100644 --- a/examples/omni/_api_client.py +++ b/examples/omni/_api_client.py @@ -41,7 +41,7 @@ class OmniClient: OmniClient Generated with: - pygen = 0.99.46 + pygen = 0.99.47 cognite-sdk = 7.64.12 pydantic = 2.9.2 @@ -59,7 +59,7 @@ def __init__(self, config_or_client: CogniteClient | ClientConfig): else: raise ValueError(f"Expected CogniteClient or ClientConfig, got {type(config_or_client)}") # The client name is used for aggregated logging of Pygen Usage - client.config.client_name = "CognitePygen:0.99.46" + client.config.client_name = "CognitePygen:0.99.47" self._client = client diff --git a/examples/omni_multi/_api_client.py b/examples/omni_multi/_api_client.py index 68769d210..f6b98e5d2 100644 --- a/examples/omni_multi/_api_client.py +++ b/examples/omni_multi/_api_client.py @@ -111,7 +111,7 @@ class OmniMultiClient: OmniMultiClient Generated with: - pygen = 0.99.46 + pygen = 0.99.47 cognite-sdk = 7.64.12 pydantic = 2.9.2 @@ -125,7 +125,7 @@ def __init__(self, config_or_client: CogniteClient | ClientConfig): else: raise ValueError(f"Expected CogniteClient or ClientConfig, got {type(config_or_client)}") # The client name is used for aggregated logging of Pygen Usage - client.config.client_name = "CognitePygen:0.99.46" + client.config.client_name = "CognitePygen:0.99.47" self.omni_multi_a = OmniMultiAAPIs(client) self.omni_multi_b = OmniMultiBAPIs(client) diff --git a/examples/omni_sub/_api_client.py b/examples/omni_sub/_api_client.py index 663951841..c58de7b47 100644 --- a/examples/omni_sub/_api_client.py +++ b/examples/omni_sub/_api_client.py @@ -23,7 +23,7 @@ class OmniSubClient: OmniSubClient Generated with: - pygen = 0.99.46 + pygen = 0.99.47 cognite-sdk = 7.64.12 pydantic = 2.9.2 @@ -41,7 +41,7 @@ def __init__(self, config_or_client: CogniteClient | ClientConfig): else: raise ValueError(f"Expected CogniteClient or ClientConfig, got {type(config_or_client)}") # The client name is used for aggregated logging of Pygen Usage - client.config.client_name = "CognitePygen:0.99.46" + client.config.client_name = "CognitePygen:0.99.47" self._client = client diff --git a/examples/scenario_instance/client/_api_client.py b/examples/scenario_instance/client/_api_client.py index 831d658c6..06c7f5a48 100644 --- a/examples/scenario_instance/client/_api_client.py +++ b/examples/scenario_instance/client/_api_client.py @@ -21,7 +21,7 @@ class ScenarioInstanceClient: ScenarioInstanceClient Generated with: - pygen = 0.99.46 + pygen = 0.99.47 cognite-sdk = 7.64.12 pydantic = 2.9.2 @@ -39,7 +39,7 @@ def __init__(self, config_or_client: CogniteClient | ClientConfig): else: raise ValueError(f"Expected CogniteClient or ClientConfig, got {type(config_or_client)}") # The client name is used for aggregated logging of Pygen Usage - client.config.client_name = "CognitePygen:0.99.46" + client.config.client_name = "CognitePygen:0.99.47" self._client = client diff --git a/examples/windmill/_api_client.py b/examples/windmill/_api_client.py index ca57308bc..bcbb08b3b 100644 --- a/examples/windmill/_api_client.py +++ b/examples/windmill/_api_client.py @@ -31,7 +31,7 @@ class WindmillClient: WindmillClient Generated with: - pygen = 0.99.46 + pygen = 0.99.47 cognite-sdk = 7.64.12 pydantic = 2.9.2 @@ -49,7 +49,7 @@ def __init__(self, config_or_client: CogniteClient | ClientConfig): else: raise ValueError(f"Expected CogniteClient or ClientConfig, got {type(config_or_client)}") # The client name is used for aggregated logging of Pygen Usage - client.config.client_name = "CognitePygen:0.99.46" + client.config.client_name = "CognitePygen:0.99.47" self._client = client diff --git a/pyproject.toml b/pyproject.toml index 5134d8483..93037b20b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cognite-pygen" -version = "0.99.46" +version = "0.99.47" description = "Cognite Python SDK Generator" readme = "README.md" authors = ["Cognite "] diff --git a/tests/test_integration/test_generate_sdks.py b/tests/test_integration/test_generate_sdks.py index ac8d8de98..897cf75fb 100644 --- a/tests/test_integration/test_generate_sdks.py +++ b/tests/test_integration/test_generate_sdks.py @@ -23,4 +23,4 @@ def test_generate_process_industries(cognite_client: CogniteClient, tmp_path: Pa df = client.cognite_time_series.list(limit=1).to_pandas() - assert {"space", "external_id", "name", "time_series_type", "is_step"} <= set(df.columns) + assert {"space", "external_id", "name", "type_", "is_step"} <= set(df.columns) diff --git a/tests/test_integration/test_sdks/test_equipment_sdk/test_unit_procedure.py b/tests/test_integration/test_sdks/test_equipment_sdk/test_unit_procedure.py index 11b3a6cef..cafbeb676 100644 --- a/tests/test_integration/test_sdks/test_equipment_sdk/test_unit_procedure.py +++ b/tests/test_integration/test_sdks/test_equipment_sdk/test_unit_procedure.py @@ -58,10 +58,10 @@ def test_filter_start_end_time_edges(start_end_time_edges: StartEndTimeList, wor def test_filter_unit_procedure_through_edge(workorder: EquipmentUnitClient) -> None: - unit_procedures = workorder.unit_procedure(unit_procedure_type="red", limit=3).work_units(limit=5).query() + unit_procedures = workorder.unit_procedure(type_="red", limit=3).work_units(limit=5).query() assert 1 <= len(unit_procedures) <= 3 - assert all(procedure.unit_procedure_type == "red" for procedure in unit_procedures) + assert all(procedure.type_ == "red" for procedure in unit_procedures) for unit_procedure in unit_procedures: for work_unit in unit_procedure.work_units: assert isinstance(work_unit, StartEndTime) @@ -72,7 +72,7 @@ def test_apply_unit_procedure_with_edge(workorder: EquipmentUnitClient, cognite_ new_procedure = UnitProcedureWrite( external_id="procedure:new_procedure", name="New procedure", - unit_procedure_type="New type", + type_="New type", work_units=[ StartEndTimeWrite( start_time="2021-01-01T00:00:00Z",