@@ -21,12 +21,21 @@ class CatalogWorkspace(Base):
2121 id : str = attr .field (init = False , default = attr .Factory (lambda self : self .workspace_id , takes_self = True ))
2222 name : str
2323 parent_id : Optional [str ] = attr .field (default = None )
24+ description : Optional [str ] = attr .field (default = None )
2425
2526 @classmethod
2627 def from_api (cls , entity : dict [str , Any ]) -> CatalogWorkspace :
2728 ea = entity ["attributes" ]
2829 er = entity .get ("relationships" )
29- return cls (workspace_id = entity ["id" ], name = ea ["name" ], parent_id = safeget (er , ["parent" , "data" , "id" ]))
30+ return cls (
31+ workspace_id = entity ["id" ],
32+ name = ea ["name" ],
33+ parent_id = safeget (
34+ er ,
35+ ["parent" , "data" , "id" ],
36+ ),
37+ description = ea .get ("description" ),
38+ )
3039
3140 def to_api (self ) -> JsonApiWorkspaceInDocument :
3241 kwargs = dict ()
@@ -36,12 +45,13 @@ def to_api(self) -> JsonApiWorkspaceInDocument:
3645 data = JsonApiWorkspaceToOneLinkage (id = self .parent_id , type = "workspace" )
3746 )
3847 )
48+ attributes_dict = {"name" : self .name }
49+ if self .description :
50+ attributes_dict ["description" ] = self .description
3951 return JsonApiWorkspaceInDocument (
4052 data = JsonApiWorkspaceIn (
4153 id = self .id ,
42- attributes = JsonApiWorkspaceInAttributes (
43- name = self .name ,
44- ),
54+ attributes = JsonApiWorkspaceInAttributes (** attributes_dict ),
4555 ** kwargs ,
4656 )
4757 )
0 commit comments