Skip to content

Commit ebc6b6f

Browse files
committed
[feat] Added support include_relationship_attributes support to fluent search
1 parent 7d81c20 commit ebc6b6f

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

pyatlan/model/assets/relations/user_def_relationship.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ class UserDefRelationship(RelationshipAttributes):
2424
class Attributes(AtlanObject):
2525
from_type_label: Optional[str] = Field(
2626
default=None,
27-
alias="fromTypeLabel",
2827
description="Name for the relationship when referring from endDef2 asset to endDef1 asset.",
2928
)
3029
to_type_label: Optional[str] = Field(
3130
default=None,
32-
alias="toTypeLabel",
3331
description="Name for the relationship when referring from endDef1 asset to endDef2 asset.",
3432
)
3533

@@ -46,7 +44,6 @@ class UserDefRelationshipFrom(Asset):
4644
)
4745
relationship_type: str = Field(
4846
default="UserDefRelationship",
49-
const=True,
5047
description="Fixed typeName for UserDefRelationship.",
5148
)
5249
relationship_attributes: UserDefRelationship = Field(

pyatlan/model/fluent_search.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,15 @@ def __init__(
381381
_page_size: Optional[int] = None,
382382
_includes_on_results: Optional[List[str]] = None,
383383
_includes_on_relations: Optional[List[str]] = None,
384+
_include_relationship_attributes: Optional[bool] = False,
384385
):
385386
super().__init__(wheres, where_nots, where_somes, _min_somes)
386387
self.sorts = sorts
387388
self.aggregations = aggregations
388389
self._page_size = _page_size
389390
self._includes_on_results = _includes_on_results
390391
self._includes_on_relations = _includes_on_relations
392+
self._include_relationship_attributes = _include_relationship_attributes
391393

392394
def _clone(self) -> "FluentSearch":
393395
"""
@@ -468,6 +470,22 @@ def include_on_relations(self, field: Union[str, AtlanField]) -> "FluentSearch":
468470
clone._includes_on_relations.append(field)
469471
return clone
470472

473+
def include_relationship_attributes(self, include: bool) -> "FluentSearch":
474+
"""
475+
Add an attribute to include relationship attributes on each relationship in the results.
476+
477+
:param include: include relationship attributes on each relationship in the results
478+
:returns: the fluent search with this parameter added
479+
"""
480+
clone = self._clone()
481+
# When enabling `include_relationship_attributes`
482+
# it's mandatory to include the "name" field
483+
# to ensure relationship names are included in the response.
484+
# Omitting "name" will result in a 500 error from the metastore.
485+
clone = self.include_on_relations("name")
486+
clone._include_relationship_attributes = include
487+
return clone
488+
471489
def _dsl(self) -> DSL:
472490
"""
473491
Translate the Atlan fluent search into an Atlan search DSL.
@@ -495,6 +513,10 @@ def to_request(self) -> IndexSearchRequest:
495513
request.attributes = self._includes_on_results
496514
if self._includes_on_relations:
497515
request.relation_attributes = self._includes_on_relations
516+
if self._include_relationship_attributes:
517+
request.include_relationship_attributes = (
518+
self._include_relationship_attributes
519+
)
498520
return request
499521

500522
def count(self, client: AtlanClient) -> int:

pyatlan/model/search.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2024,6 +2024,16 @@ class IndexSearchRequest(SearchRequest):
20242024
default=None,
20252025
description="Qualified name of the purpose eg: default/zL6uqsrZGuf1hz9XFYnw9x",
20262026
)
2027+
include_relationship_attributes: Optional[bool] = Field(
2028+
default=False,
2029+
alias="includeRelationshipAttributes",
2030+
description=(
2031+
"Whether to include relationship-level attributes "
2032+
"for any relationships to each asset (True) or not (False). "
2033+
"By default, this is `False` and therefore "
2034+
"relationship-level attributes are not included."
2035+
),
2036+
)
20272037
request_metadata: Optional[IndexSearchRequestMetadata] = Field(
20282038
default_factory=lambda: IndexSearchRequestMetadata(
20292039
# Set this to `False` to prevent the frequent

0 commit comments

Comments
 (0)