def _get_organization_metadata_from_registry(self, org_id): rez = self._get_organization_registration(org_id) metadata_hash = bytesuri_to_hash(rez["orgMetadataURI"]) metadata = get_from_ipfs_and_checkhash( self._get_ipfs_client(), metadata_hash) metadata = metadata.decode("utf-8") return OrganizationMetadata.from_json(json.loads(metadata))
def _get_service_metadata_from_registry(self): rez = self._get_service_registration() metadata_hash = bytesuri_to_hash(rez["metadataURI"]) metadata = get_from_ipfs_and_checkhash(self._get_ipfs_client(), metadata_hash) metadata = metadata.decode("utf-8") metadata = mpe_service_metadata_from_json(metadata) return metadata
def get_service_metadata(self, org_id, service_id): (found, registration_id, metadata_uri, tags) = self.registry_contract.functions.getServiceRegistrationById( bytes(org_id, "utf-8"), bytes(service_id, "utf-8")).call() metadata_hash = bytesuri_to_hash(metadata_uri) metadata_json = get_from_ipfs_and_checkhash(self.ipfs_client, metadata_hash) metadata = mpe_service_metadata_from_json(metadata_json) return metadata
def fetch_org_metadata(self, org_id): (found, id, metadata_uri, owner, members, service_ids, repository_ids ) = self.registry_contract.functions.getOrganizationById( bytes(org_id, "utf-8")).call() if found is not True: raise Exception('No organization is foubd "{}"'.format(org_id)) metadata_hash = bytesuri_to_hash(metadata_uri) metadata_json = get_from_ipfs_and_checkhash(self._ipfs_client, metadata_hash) org_metadata = json.loads(metadata_json) return org_metadata
def fetch_service_metadata(self, org_id, service_id): (found, registration_id, metadata_uri, tags) = self.registry_contract.functions.getServiceRegistrationById( bytes(org_id, "utf-8"), bytes(service_id, "utf-8")).call() if found is not True: raise Exception( 'No service "{}" found in organization "{}"'.format( service_id, org_id)) metadata_hash = bytesuri_to_hash(metadata_uri) metadata_json = get_from_ipfs_and_checkhash(self._ipfs_client, metadata_hash) metadata = mpe_service_metadata_from_json(metadata_json) return metadata