Acquire.Service._function module¶
-
call_function(service_url, function=None, args_key=None, response_key=None, public_cert=None, args=None, **kwargs)[source]¶ Call the remote function called ‘function’ at ‘service_url’ passing in named function arguments in ‘kwargs’. If ‘args_key’ is supplied, then encrypt the arguments using ‘args’. If ‘response_key’ is supplied, then tell the remote server to encrypt the response using the public version of ‘response_key’, so that we can decrypt it in the response. If ‘public_cert’ is supplied then we will ask the service to sign their response using their service signing certificate, and we will validate the signature using ‘public_cert’
-
pack_arguments(args, key=None, response_key=None, public_cert=None)[source]¶ Pack the passed arguments, optionally encrypted using the passed key
-
unpack_arguments(args, key=None, public_cert=None, is_return_value=False, function=None, service=None)[source]¶ Call this to unpack the passed arguments that have been encoded as a json string, packed using pack_arguments. This will always return a dictionary. If there are no arguments, then an empty dictionary will be returned. If ‘public_cert’ is supplied then a signature of the result will be verified using ‘public_cert’
This function is also called as unpack_return_value, in which case is_return_value is set as True. The ‘function’ on ‘service’ that was called (or to be called) can also be passed. These are used to help provide more context for error messages.
-
create_return_value(status=0, message='success', log=None, error=None)[source]¶ Convenience functiont that creates the start of the return_value dictionary, setting the “status” key to the value of ‘status’, the “message” key to the value of ‘message’ and the “log” key to the value of ‘log’. If ‘error’ is passed, then this signifies an exception, which will be packed and returned. This returns a simple dictionary, which is ready to be packed into a json string
-
pack_return_value(result, key=None, response_key=None, public_cert=None)[source]¶ Pack the passed result into a json string, optionally encrypting the result with the passed key, and optionally supplying a public response key, with which the function being called should encrypt the response. If public_cert is provided then we will ask the service to sign their response. Note that you can only ask the service to sign their response if you provide a ‘reponse_key’ for them to encrypt it with too
-
unpack_return_value(return_value, key=None, public_cert=None, function=None, service=None)[source]¶ Call this to unpack the passed arguments that have been encoded as a json string, packed using pack_arguments