Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def change_wdf_refs_id(self, mapping: dict[str, str]) -> None:
class CatalogDeclarativeWorkspace(Base):
id: str
name: str
description: Optional[str] = None
model: Optional[CatalogDeclarativeWorkspaceModel] = None
parent: Optional[CatalogWorkspaceIdentifier] = None
permissions: list[CatalogDeclarativeSingleWorkspacePermission] = attr.field(factory=list)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,21 @@ class CatalogWorkspace(Base):
id: str = attr.field(init=False, default=attr.Factory(lambda self: self.workspace_id, takes_self=True))
name: str
parent_id: Optional[str] = attr.field(default=None)
description: Optional[str] = attr.field(default=None)

@classmethod
def from_api(cls, entity: dict[str, Any]) -> CatalogWorkspace:
ea = entity["attributes"]
er = entity.get("relationships")
return cls(workspace_id=entity["id"], name=ea["name"], parent_id=safeget(er, ["parent", "data", "id"]))
return cls(
workspace_id=entity["id"],
name=ea["name"],
parent_id=safeget(
er,
["parent", "data", "id"],
),
description=ea.get("description"),
)

def to_api(self) -> JsonApiWorkspaceInDocument:
kwargs = dict()
Expand All @@ -36,12 +45,13 @@ def to_api(self) -> JsonApiWorkspaceInDocument:
data=JsonApiWorkspaceToOneLinkage(id=self.parent_id, type="workspace")
)
)
attributes_dict = {"name": self.name}
if self.description:
attributes_dict["description"] = self.description
return JsonApiWorkspaceInDocument(
data=JsonApiWorkspaceIn(
id=self.id,
attributes=JsonApiWorkspaceInAttributes(
name=self.name,
),
attributes=JsonApiWorkspaceInAttributes(**attributes_dict),
**kwargs,
)
)
Loading