pycape.experimental.cli module#

pycape.experimental.cli.deploy(deploy_path, url=None, token_expiry=None)[source]#

Deploy a directory or a zip file containing a Cape function declared in an app.py script.

This method calls cape deploy and cape token from the Cape CLI to deploy a Cape function then returns a ~.function_ref.FunctionRef representing the deployed function. This ~.function_ref.FunctionRef will hold a function ID, a function token and a function checksum. Note that the deploy_path has to point to a directory or a zip file containing a Cape function declared in an app.py file and the size of its content is currently limited to 1GB.

Parameters:
  • deploy_path (Union[str, PathLike]) – A path pointing to a directory or a zip file containing a Cape function declared in an app.py script.

  • url (Optional[str]) – The Cape platform’s websocket URL, which is responsible for forwarding client requests to the proper enclave instances. If None, tries to load value from the CAPE_ENCLAVE_HOST environment variable. If no such variable value is supplied, defaults to "https://app.capeprivacy.com".

  • token_expriry – Amount of time in seconds until the function token expires.

Return type:

FunctionRef

Returns:

A FunctionRef representing the deployed Cape function.

Raises:

RuntimeError – if the websocket response or the enclave attestation doc is malformed, or if the function path is not pointing to a directory or a zip file or if folder size exceeds 1GB, or if the Cape CLI cannot be found on the device.

async pycape.experimental.cli.token(function_id, expiry=<class 'NoneType'>, function_checksum=None)[source]#

Generate a function token (JSON Web Token) based on a function ID.

This method calls cape token from the Cape CLI to generate a function token based on a function ID. Tokens can be created statically (long expiration and bundled with your application) or created dynamically (short-lived) and have an owner specified expiration. This function token is required in addition to the function ID when calling a Cape function.

Parameters:
  • function_id – A function ID string representing a deployed Cape function.

  • expiry – Amount of time in seconds until the function token expires.

Return type:

FunctionRef

Returns:

A FunctionRef representing the deployed Cape function.

Raises: RuntimeError: if the Cape CLI cannot be found on the device.