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.

Usage

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

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

Bases: object

A reference to a Cape function.

Parameters:
  • id (str) – Required string denoting the function ID of the deployed Cape function. Typically given with the output of the Cape CLI’s deploy command.

  • token (str) – Required string containing a Cape function token generated by the Cape CLI during cape token.

  • 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.

Parameters:

function_json (Union[str, PathLike]) – a JSON string or filepath containing function ID, token, and optional checksum, e.g. as generated by the Cape CLI token command.

Return type:

FunctionRef

Returns:

A FunctionRef representing the deployed Cape function.

Raises:

ValueError – if the json token file doesn’t exist or, the token file doesn’t contain a function_id or a function_token.

property id#
to_json(path=None)[source]#

Write this FunctionRef to a JSON string or file.

Parameters:

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

Return type:

Optional[str]

Returns:

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

property token#