本文整理汇总了Python中interface.services.coi.iresource_registry_service.ResourceRegistryServiceProcessClient.update方法的典型用法代码示例。如果您正苦于以下问题:Python ResourceRegistryServiceProcessClient.update方法的具体用法?Python ResourceRegistryServiceProcessClient.update怎么用?Python ResourceRegistryServiceProcessClient.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类interface.services.coi.iresource_registry_service.ResourceRegistryServiceProcessClient
的用法示例。
在下文中一共展示了ResourceRegistryServiceProcessClient.update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: resolve_org_negotiation
# 需要导入模块: from interface.services.coi.iresource_registry_service import ResourceRegistryServiceProcessClient [as 别名]
# 或者: from interface.services.coi.iresource_registry_service.ResourceRegistryServiceProcessClient import update [as 别名]
def resolve_org_negotiation():
try:
payload = request.form['payload']
json_params = json_loads(str(payload))
ion_actor_id, expiry = get_governance_info_from_request('serviceRequest', json_params)
ion_actor_id, expiry = validate_request(ion_actor_id, expiry)
headers = build_message_headers(ion_actor_id, expiry)
# extract negotiation-specific data (convert from unicode just in case - these are machine generated and unicode specific
# chars are unexpected)
verb = str(json_params['verb'])
originator = str(json_params['originator'])
negotiation_id = str(json_params['negotiation_id'])
reason = str(json_params.get('reason', ''))
proposal_status = None
if verb.lower() == "accept":
proposal_status = ProposalStatusEnum.ACCEPTED
elif verb.lower() == "reject":
proposal_status = ProposalStatusEnum.REJECTED
proposal_originator = None
if originator.lower() == "consumer":
proposal_originator = ProposalOriginatorEnum.CONSUMER
elif originator.lower() == "provider":
proposal_originator = ProposalOriginatorEnum.PROVIDER
rr_client = ResourceRegistryServiceProcessClient(process=service_gateway_instance)
negotiation = rr_client.read(negotiation_id, headers=headers)
new_negotiation_sap = Negotiation.create_counter_proposal(negotiation, proposal_status, proposal_originator)
org_client = OrgManagementServiceProcessClient(process=service_gateway_instance)
resp = org_client.negotiate(new_negotiation_sap, headers=headers)
# update reason if it exists
if reason:
# reload negotiation because it has changed
negotiation = rr_client.read(negotiation_id, headers=headers)
negotiation.reason = reason
rr_client.update(negotiation)
return gateway_json_response(resp)
except Exception as e:
return build_error_response(e)