当前位置: 首页>>代码示例>>Python>>正文


Python IonObject._rev方法代码示例

本文整理汇总了Python中pyon.public.IonObject._rev方法的典型用法代码示例。如果您正苦于以下问题:Python IonObject._rev方法的具体用法?Python IonObject._rev怎么用?Python IonObject._rev使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyon.public.IonObject的用法示例。


在下文中一共展示了IonObject._rev方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_createDataProduct_and_DataProducer_with_rev_BadRequest

# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import _rev [as 别名]
 def test_createDataProduct_and_DataProducer_with_rev_BadRequest(self):
     # setup
     self.resource_registry.find_resources.return_value = ([], 'do not care')
     self.resource_registry.create.return_value = ('SOME_RR_ID1', 'Version_1')
     self.data_acquisition_management.create_data_producer.side_effect = BadRequest("Create cannot create document with Rev: ")
     # Data Product
     dpt_obj = IonObject(RT.DataProduct, 
                         name='DPT_X', 
                         description='some new data product')
     # Data Producer
     dpr_obj = IonObject(RT.DataProducer, 
                         name='DP_X', 
                         description='some new data producer')
     dpr_obj._rev = "SOME_REV"
     
     # test call
     with self.assertRaises(BadRequest) as cm:
         dp_id = self.data_product_management_service.create_data_product(dpt_obj, dpr_obj)
     
     # check results
     self.resource_registry.find_resources.assert_called_once_with(RT.DataProduct, None, dpt_obj.name, True)
     self.resource_registry.create.assert_called_once_with(dpt_obj)
     self.data_acquisition_management.create_data_producer.assert_called_once_with(dpr_obj)
     ex = cm.exception
     self.assertEqual(ex.message, "Create cannot create document with Rev: ")
开发者ID:tgiguere,项目名称:coi-services,代码行数:27,代码来源:test_data_product_management_service.py

示例2: acquire_resource

# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import _rev [as 别名]
    def acquire_resource(self, sap=None):
        """Creates a Commitment Resource for the specified resource for a specified user withing the specified Org as defined in the
        proposal. Once shared, the resource is committed to the user. Throws a NotFound exception if none of the ids are found.

        @param proposal    AcquireResourceProposal
        @retval commitment_id    str
        @throws NotFound    object with specified id does not exist
        """
        param_objects = self._validate_parameters(org_id=sap.provider, user_id=sap.consumer, resource_id=sap.resource)

        if sap.type_ == OT.AcquireResourceExclusiveProposal:
            exclusive = True
        else:
            exclusive = False

        res_commitment = IonObject(OT.ResourceCommitment, resource_id=sap.resource, exclusive=exclusive)

        commitment = IonObject(RT.Commitment, name='', provider=sap.provider, consumer=sap.consumer, commitment=res_commitment,
             description='Resource Commitment', expiration=sap.expiration)

        commitment_id, commitment_rev = self.clients.resource_registry.create(commitment)
        commitment._id = commitment_id
        commitment._rev = commitment_rev

        #Creating associations to all objects
        self.clients.resource_registry.create_association(sap.provider, PRED.hasCommitment, commitment_id)
        self.clients.resource_registry.create_association(sap.consumer, PRED.hasCommitment, commitment_id)
        self.clients.resource_registry.create_association(sap.resource, PRED.hasCommitment, commitment_id)
        self.clients.resource_registry.create_association(sap.negotiation_id, PRED.hasContract, commitment_id)

        #TODO - publish some kind of event for creating a commitment

        return commitment_id
开发者ID:tomoreilly,项目名称:coi-services,代码行数:35,代码来源:org_management_service.py

示例3: acquire_resource

# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import _rev [as 别名]
    def acquire_resource(self, org_id='', user_id='', resource_id=''):
        """Acquire the specified resource for a specified user withing the specified Org. Once shared, the resource is
        committed to the user. Throws a NotFound exception if none of the ids are found.

        @param org_id    str
        @param user_id    str
        @param resource_id    str
        @retval success    bool
        @throws NotFound    object with specified id does not exist
        """
        param_objects = self._validate_parameters(org_id=org_id, user_id=user_id, resource_id=resource_id)

        commitment = IonObject(RT.ResourceCommitment, name='', org_id=org_id, user_id=user_id, resource_id=resource_id,
            description='Resource Commitment')

        commitment_id, commitment_rev = self.clients.resource_registry.create(commitment)
        commitment._id = commitment_id
        commitment._rev = commitment_rev
        self.clients.resource_registry.create_association(user_id, PRED.hasCommitment, commitment)
        self.clients.resource_registry.create_association(resource_id, PRED.hasCommitment, commitment)

        return True
开发者ID:seman,项目名称:coi-services,代码行数:24,代码来源:org_management_service.py

示例4: create_resource_commitment

# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import _rev [as 别名]
    def create_resource_commitment(self, org_id='', actor_id='', resource_id='', exclusive=False, expiration=0):
        """Creates a Commitment Resource for the specified resource for a specified actor withing the specified Org. Once shared,
        the resource is committed to the actor. Throws a NotFound exception if none of the ids are found.

        @param org_id    str
        @param actor_id    str
        @param resource_id    str
        @param exclusive    bool
        @param expiration    int
        @retval commitment_id    str
        @throws NotFound    object with specified id does not exist
        """
        param_objects = self._validate_parameters(org_id=org_id, actor_id=actor_id, resource_id=resource_id)
        org = param_objects['org']
        actor = param_objects['actor']
        resource = param_objects['resource']

        res_commitment = IonObject(OT.ResourceCommitment, resource_id=resource_id, exclusive=exclusive)

        commitment = IonObject(RT.Commitment, name='', provider=org_id, consumer=actor_id, commitment=res_commitment,
             description='Resource Commitment', expiration=str(expiration))

        commitment_id, commitment_rev = self.clients.resource_registry.create(commitment)
        commitment._id = commitment_id
        commitment._rev = commitment_rev

        #Creating associations to all related objects
        self.clients.resource_registry.create_association(org_id, PRED.hasCommitment, commitment_id)
        self.clients.resource_registry.create_association(actor_id, PRED.hasCommitment, commitment_id)
        self.clients.resource_registry.create_association(resource_id, PRED.hasCommitment, commitment_id)

        self.event_pub.publish_event(event_type=OT.ResourceCommitmentCreatedEvent, origin=org_id, origin_type='Org', sub_type=resource.type_,
            description='The resource has been committed by the Org', resource_id=resource_id, org_name=org.name,
            commitment_id=commitment._id, commitment_type=commitment.commitment.type_)

        return commitment_id
开发者ID:MauriceManning,项目名称:coi-services,代码行数:38,代码来源:org_management_service.py


注:本文中的pyon.public.IonObject._rev方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。