|
22 | 22 | InfrahubNodeSync, |
23 | 23 | RelatedNodeSync, |
24 | 24 | RelationshipManagerSync, |
25 | | - generate_relationship_property, |
26 | 25 | ) |
27 | 26 | from infrahub_sdk.schema import ( |
28 | 27 | GenericSchemaAPI, |
@@ -1092,29 +1091,35 @@ def _update_object(self, data: dict) -> tuple[InfrahubNodeSync, dict]: |
1092 | 1091 | # https://github.com/opsmill/infrahub-sdk-python/issues/272 |
1093 | 1092 | for attr_name in data: |
1094 | 1093 | if attr_name in tmp_obj._schema.attribute_names: |
1095 | | - attr_schema = next(attr for attr in tmp_obj._schema.attributes if attr.name == attr_name) |
| 1094 | + attr_schema = next(attr for attr in self.infrahub_node._schema.attributes if attr.name == attr_name) |
1096 | 1095 | attr_data = data.get(attr_name) |
1097 | 1096 | new_attr = Attribute(name=attr_name, schema=attr_schema, data=attr_data) |
1098 | 1097 | setattr(tmp_obj, attr_name, new_attr) |
1099 | 1098 | elif attr_name in tmp_obj._schema.relationship_names: |
1100 | | - rel_schema = next(rel for rel in self._schema.relationships if rel.name == attr_name) |
| 1099 | + rel_schema = next(rel for rel in self.infrahub_node._schema.relationships if rel.name == attr_name) |
1101 | 1100 | rel_data = data.get(attr_name) |
1102 | 1101 | if rel_schema.cardinality == RelationshipCardinality.ONE: |
1103 | 1102 | setattr(tmp_obj, f"_{attr_name}", None) |
1104 | 1103 | setattr( |
1105 | 1104 | tmp_obj, |
1106 | 1105 | attr_name, |
1107 | | - generate_relationship_property(name=attr_name, node=tmp_obj), |
| 1106 | + RelatedNodeSync( |
| 1107 | + name=attr_name, |
| 1108 | + client=self.infrahub_node._client, |
| 1109 | + branch=self.infrahub_node._branch, |
| 1110 | + schema=rel_schema, |
| 1111 | + data=rel_data, |
| 1112 | + ), |
1108 | 1113 | ) |
1109 | 1114 | elif rel_schema.cardinality == RelationshipCardinality.MANY: |
1110 | 1115 | setattr( |
1111 | 1116 | tmp_obj, |
1112 | 1117 | attr_name, |
1113 | 1118 | RelationshipManagerSync( |
1114 | 1119 | name=attr_name, |
1115 | | - client=tmp_obj._client, |
| 1120 | + client=self.infrahub_node._client, |
1116 | 1121 | node=tmp_obj, |
1117 | | - branch=tmp_obj._branch, |
| 1122 | + branch=self.infrahub_node._branch, |
1118 | 1123 | schema=rel_schema, |
1119 | 1124 | data=rel_data, |
1120 | 1125 | ), |
|
0 commit comments