Skip to content

Commit

Permalink
fix: query optional
Browse files Browse the repository at this point in the history
  • Loading branch information
doctrino committed Sep 3, 2024
1 parent 9c16977 commit 3247d19
Showing 1 changed file with 13 additions and 7 deletions.
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

0 comments on commit 3247d19

Please sign in to comment.