def get_upstream(self, id, search_depth=1): if self._gremlin_endpoint is not None: if id is None: raise InvalidArgumentsException( "Must have ID to run lineage search") else: try: return self._gremlin_endpoint.get_inbound( id=utils.get_arn(id, self._table_name, self._deployed_account), search_depth=search_depth) except ResourceNotFoundException: return None except Exception as e: raise DetailedException(e) else: raise UnimplementedFeatureException(params.NO_GREMLIN)
def _put_references(self, id: str, reference_doc: list): g = self._gremlin_endpoint if g is not None: from_id = utils.get_arn(id, self._table_name, self._deployed_account) ctr = 0 exceptions = [] for r in reference_doc: if params.RESOURCE not in r: raise InvalidArgumentsException( f"Malformed Reference: {r}. Must Contain a {params.RESOURCE}" ) else: to_id = r[params.RESOURCE] # remove the resource and ID keys so we can use the rest of the document for extra properties del r[params.RESOURCE] try: g.create_relationship(label=params.REFERENCES, from_id=from_id, to_id=to_id, extra_properties=r) ctr += 1 except Exception as e: exceptions.append({"ID": to_id, "Message": e.message}) response = {"ReferenceCount": ctr} if len(exceptions) > 0: response["Exceptions"] = exceptions return response else: raise UnimplementedFeatureException(NO_GREMLIN)