Acquire.Service._function module¶
-
call_function(service_url, function=None, args=None, args_key=None, response_key=None, public_cert=None)[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(function=None, args=None, 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.
If is_return_value is True, then this will simply return the unpacked return valu
Otherwise, this will return a tuple containing
(function, args, keys)
where function is the name of the function to be called, args are the arguments to the function, and keys is a dictionary that may contain keys or additional instructions that will be used to package up the return value from calling the function.
This function is also called as unpack_return_value, in which case is_return_value is set as True, and only the dictionary is returned. 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.
Parameters: args (str) – should be a JSON encoded UTF-8
-
create_return_value(payload)[source]¶ Convenience function that creates a return value that can be passed back by a function. The ‘payload’ should either be a dictionary of return data, or it should be an exception.
-
pack_return_value(function=None, payload=None, key=None, response_key=None, public_cert=None, private_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