Esempio n. 1
0
    def update_metadata(self):
        metadata_file = self.args.metadata_file

        try:
            with open(metadata_file, 'r') as f:
                org_metadata = OrganizationMetadata.from_json(json.load(f))
        except Exception as e:
            print(
                "Organization metadata json file not found ,Please check --metadata-file path ")
            raise e
        # validate the metadata before updating

        org_id = self.args.org_id
        existing_registry_org_metadata = self._get_organization_metadata_from_registry(
            org_id)
        org_metadata.validate(existing_registry_org_metadata)

        # Check if Organization already exists
        found = self._get_organization_by_id(org_id)[0]
        if not found:
            raise Exception(
                "\nOrganization with id={} does not  exists!\n".format(org_id))

        ipfs_metadata_uri = publish_file_in_ipfs(
            self._get_ipfs_client(), metadata_file, False)
        params = [type_converter("bytes32")(
            org_id), hash_to_bytesuri(ipfs_metadata_uri)]
        self._printout(
            "Creating transaction to create organization name={} id={}\n".format(org_metadata.org_name, org_id))
        self.transact_contract_command(
            "Registry", "changeOrganizationMetadataURI", params)
        self._printout("id:\n%s" % org_id)
Esempio n. 2
0
 def publish_metadata_in_ipfs_and_update_registration(self):
     # first we check that we do not change payment_address or group_id in existed payment groups
     self._validate_service_group_with_org_group_and_update_group_id(
         self.args.org_id, self.args.metadata_file)
     metadata_uri = hash_to_bytesuri(
         self._publish_metadata_in_ipfs(self.args.metadata_file))
     params = [type_converter("bytes32")(self.args.org_id), type_converter(
         "bytes32")(self.args.service_id), metadata_uri]
     self.transact_contract_command(
         "Registry", "updateServiceRegistration", params)
Esempio n. 3
0
    def publish_service_with_metadata(self):

        self._validate_service_group_with_org_group_and_update_group_id(
            self.args.org_id, self.args.metadata_file)
        metadata_uri = hash_to_bytesuri(
            self._publish_metadata_in_ipfs(self.args.metadata_file))
        tags = self._get_converted_tags()
        params = [type_converter("bytes32")(self.args.org_id), type_converter(
            "bytes32")(self.args.service_id), metadata_uri, tags]
        self.transact_contract_command(
            "Registry", "createServiceRegistration", params)