示例#1
0
    def insert(self, model: schema.RootEntity):
        """
        Inserts the given model into the database of the IPC server.

        Example
        -------
        ```
        import olca

        flow = olca.Flow()
        flow.name = 'CO2'
        flow.id = str(uuid.uuid4())
        prop = olca.FlowPropertyFactor()
        prop.flow_property = olca.ref(
            olca.FlowProperty,
            '93a60a56-a3c8-11da-a746-0800200b9a66',
            'Mass'
        )
        prop.conversion_factor = 1.0
        prop.reference_flow_property = True
        flow.flow_properties = [prop]
        response = olca.Client().insert(flow)
        print(response)
        ```

        """
        if model is None:
            return
        json = model.to_json()
        return self.__post('insert/model', json)
示例#2
0
 def delete(self, model: schema.RootEntity):
     """
     Delete the given model from the database of the IPC server.
     """
     if model is None:
         return
     json = model.to_json()
     return self.__post('delete/model', json)
示例#3
0
 def delete(self, model: schema.RootEntity):
     """
     Delete the given model from the database of the IPC server.
     """
     if model is None:
         return
     json = model.to_json()
     resp, err = self.__post('delete/model', json)
     if err:
         log.error('failed to delete model: %s', err)
         return err
     return resp
示例#4
0
 def delete(self, model: schema.RootEntity):
     if model is None:
         return
     json = model.to_json()
     return self.__post('delete/model', json)
示例#5
0
 def insert(self, model: schema.RootEntity):
     if model is None:
         return
     json = model.to_json()
     return self.__post('insert/model', json)