pycape.experimental.cli module#

pycape.experimental.cli.deploy(deploy_path, url=None, public=False)[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 or function name, 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".

  • public (bool) – Boolean determining if the function should be publicly accessible or not.

Return type:

FunctionRef

Returns:

A FunctionRef representing the deployed Cape function.

Raises:

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

pycape.experimental.cli.token(name=None, description=None, expiry=None)[source]#

Generate a Personal Access Token.

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

Parameters:
  • name (Optional[str]) – Optional name for the token.

  • description (Optional[str]) – Optional description for the token.

  • expiry (Optional[str]) – Amount of time in seconds until the function token expires. Defaults to 1h.

Return type:

Token

Returns:

A Token representing the PAT.

Raises:

RuntimeError – if the Cape CLI cannot be found on the device, if the CLI failed to generate the token, or if PyCape failed to parse the token from the CLI’s output.