Skip to content

Commit

Permalink
Query optional in instance.search (#1905)
Browse files Browse the repository at this point in the history
  • Loading branch information
doctrino authored Sep 3, 2024
1 parent 9c16977 commit 929adcb
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Changes are grouped as follows
- `Fixed` for any bug fixes.
- `Security` in case of vulnerabilities.

## [7.58.3] - 2024-09-03
### Fixed
- The parameter `query` is now optional in `client.data_modeling.instances.search(...)`.

## [7.58.2] - 2024-09-03
### Added
- [Feature Preview - alpha] Support for `client.hosted_extractors.sources`.
Expand Down
20 changes: 13 additions & 7 deletions cognite/client/_api/data_modeling/instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,8 @@ def apply(
def search(
self,
view: ViewId,
query: str,
query: str | None = None,
*,
instance_type: Literal["node"] = "node",
properties: list[str] | None = None,
target_units: list[TargetUnit] | None = None,
Expand All @@ -988,7 +989,8 @@ def search(
def search(
self,
view: ViewId,
query: str,
query: str | None = None,
*,
instance_type: Literal["edge"],
properties: list[str] | None = None,
target_units: list[TargetUnit] | None = None,
Expand All @@ -1003,7 +1005,8 @@ def search(
def search(
self,
view: ViewId,
query: str,
query: str | None = None,
*,
instance_type: type[T_Node],
properties: list[str] | None = None,
target_units: list[TargetUnit] | None = None,
Expand All @@ -1018,7 +1021,8 @@ def search(
def search(
self,
view: ViewId,
query: str,
query: str | None = None,
*,
instance_type: type[T_Edge],
properties: list[str] | None = None,
target_units: list[TargetUnit] | None = None,
Expand All @@ -1032,7 +1036,7 @@ def search(
def search(
self,
view: ViewId,
query: str,
query: str | None = None,
instance_type: Literal["node", "edge"] | type[T_Node] | type[T_Edge] = "node",
properties: list[str] | None = None,
target_units: list[TargetUnit] | None = None,
Expand All @@ -1046,7 +1050,7 @@ def search(
Args:
view (ViewId): View to search in.
query (str): Query string that will be parsed and used for search.
query (str | None): Query string that will be parsed and used for search.
instance_type (Literal["node", "edge"] | type[T_Node] | type[T_Edge]): Whether to search for nodes or edges.
properties (list[str] | None): Optional array of properties you want to search through. If you do not specify one or more properties, the service will search all text fields within the view.
target_units (list[TargetUnit] | None): Properties to convert to another unit. The API can only convert to another unit if a unit has been defined as part of the type on the underlying container being queried.
Expand Down Expand Up @@ -1103,7 +1107,9 @@ def search(
else:
raise ValueError(f"Invalid instance type: {instance_type}")

body = {"view": view.dump(camel_case=True), "query": query, "instanceType": instance_type_str, "limit": limit}
body: dict[str, Any] = {"view": view.dump(camel_case=True), "instanceType": instance_type_str, "limit": limit}
if query:
body["query"] = query
if properties:
body["properties"] = properties
if include_typing:
Expand Down
2 changes: 1 addition & 1 deletion cognite/client/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from __future__ import annotations

__version__ = "7.58.2"
__version__ = "7.58.3"
__api_subversion__ = "20230101"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[tool.poetry]
name = "cognite-sdk"

version = "7.58.2"
version = "7.58.3"
description = "Cognite Python SDK"
readme = "README.md"
documentation = "https://cognite-sdk-python.readthedocs-hosted.com"
Expand Down

0 comments on commit 929adcb

Please sign in to comment.