pycape.function_ref module#

A structured set of metadata representing a deployed Cape function.

A FunctionRef is intended to capture any/all metadata related to a Cape function. The metadata is generally user-supplied, provided to them with the output of the Cape CLI’s deploy command.

Note: We recommend using the pycape.Cape.function() method to create a FunctionRef.


fid = "asdf231lkg1324afdg"
fchecksum = str(b"2l1h21jhgb2k1jh3".hex())
fref = FunctionRef(fid, fchecksum)
token = pycape.Token("eY12shd...")

cape = Cape()
cape.connect(fref, token)
class pycape.function_ref.FunctionRef(id=None, name=None, checksum=None)[source]#

Bases: object

A reference to a Cape function.

  • id (Optional[str]) – String denoting the function ID of the deployed Cape function. Typically given with the output of the Cape CLI’s deploy command.

  • name (Optional[str]) – String denoting the name of the deployed Cape function. Must be of the form USER/FUNC_NAME where USER is the Github username of the Cape user and FUNC_NAME is the name they gave for the function at deploy-time.

  • checksum (Optional[str]) – Optional string denoting the checksum of the deployed Cape function. If supplied as part of a FunctionRef, the Cape client will verify that enclave responses includes a matching checksum whenever the FunctionRef is included in Cape requests.

property checksum#
classmethod from_json(function_json)[source]#

Construct a FunctionRef from a JSON string or file.


function_json (Union[str, PathLike]) – a JSON string or filepath containing function ID and optional function checksum.

Return type:



A FunctionRef representing the deployed Cape function.

  • ValueError – if the json file doesn’t exist, or the json is missing a function_id key-value.

  • TypeError – if function_json is neither Path-like nor str.

property full_name#
property id#
property name#

Write this FunctionRef to a JSON string or file.


path (Union[str, PathLike, None]) – Optional file path to write the resulting JSON to.

Return type:



If path is None, a string with this FunctionRef as a JSON struct.

property user#