Ejemplo n.º 1
0
 def get_all(self, dataset):
     dataset_id = self._get_id(dataset)
     resp = self._get(self._uri('/{dataset_id}/relationships', dataset_id=dataset_id), stream=True)
     for r in resp:
       r['dataset_id'] = r.get('dataset_id', dataset_id)
     relations = [RelationshipType.from_dict(r, api=self.session) for r in resp]
     return {r.type: r for r in relations}
Ejemplo n.º 2
0
 def create(self, dataset, relationship):
     assert isinstance(relationship, RelationshipType), "Must be of type Relationship"
     dataset_id = self._get_id(dataset)
     rel_dict = relationship.as_dict()
     r = self._post(self._uri('/{dataset_id}/relationships', dataset_id=dataset_id), json=rel_dict)
     r['dataset_id'] = r.get('dataset_id', dataset_id)
     return RelationshipType.from_dict(r, api=self.session)
Ejemplo n.º 3
0
 def get(self, dataset, relationship):
     dataset_id = self._get_id(dataset)
     relationship_id = self._get_id(relationship)
     r = self._get(
         self._uri(
             "/{dataset_id}/relationships/{r_id}",
             dataset_id=dataset_id,
             r_id=relationship_id,
         ))
     r["dataset_id"] = r.get("dataset_id", dataset_id)
     return RelationshipType.from_dict(r, api=self.session)
Ejemplo n.º 4
0
 def get(self, dataset, relationship):
     dataset_id = self._get_id(dataset)
     relationship_id = self._get_id(relationship)
     r = self._get(self._uri('/{dataset_id}/relationships/{r_id}', dataset_id=dataset_id, r_id=relationship_id))
     r['dataset_id'] = r.get('dataset_id', dataset_id)
     return RelationshipType.from_dict(r, api=self.session)