client

module client

Global Variables

  • DEFAULT_API_VERSION

  • GIZA_TOKEN_VARIABLE

  • MODEL_URL_HEADER

  • API_KEY_HEADER


class ApiClient

Implementation of the API client to interact with core-services

method __init__

__init__(
    host: str,
    token: Optional[str] = None,
    api_key: Optional[str] = None,
    api_version: str = 'v1',
    verify: bool = True,
    debug: Optional[bool] = False
)None

method retrieve_api_key

retrieve_api_key()None

Retrieve the API key from the ~/.giza/.api_key.json file.

Raises:

  • Exception: if the file does not exist

Returns:

  • str: the API key


method retrieve_token

retrieve_token(
    user: Optional[str] = None,
    password: Optional[str] = None,
    renew: bool = False
)None

Get the JWT token.

First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials.json. And finally it will try to retrieve it from the API login the user in.

Args:

  • user: if provided it will be used to check against current credentials and if provided with password used to retrieve a new token.

  • password: if provided with user it will be used to retrieve a new token.

  • renew: for renewal of the JWT token by user login.

Raises:

  • Exception: if token could not be retrieved in any way


class UsersClient

Client to interact with users endpoint.

method __init__

__init__(
    host: str,
    token: Optional[str] = None,
    api_key: Optional[str] = None,
    api_version: str = 'v1',
    verify: bool = True,
    debug: Optional[bool] = False
)None

method create

create(user: UserCreate) → UserResponse

Call the API to create a new user

Args:

  • user (users.UserCreate): information used to create a new user

Returns:

  • users.UserResponse: the created user information


method create_api_key

create_api_key()

Call the API to create a new API key

Returns:

  • users.UserResponse: the created user information


method me

me() → UserResponse

Retrieve information about the current user. Must have a valid token to perform the operation, enforced by @auth

Returns:

  • users.UserResponse: User information from the server


method request_reset_password_token

request_reset_password_token(email: str) → Msg

Sends a request to the server to generate a password reset token. The token is sent to the user's email.

Args:

  • email (str): The email of the user who wants to reset their password.

Returns:

  • Msg: A message indicating the success or failure of the request.


method resend_email

resend_email(email: str) → Msg

Resend the verification email to the user.

Args:

  • email (EmailStr): The email of the user who wants to resend the verification email.

Returns:

  • Msg: A message indicating the success or failure of the request.


method reset_password

reset_password(token: str, new_password: str) → Msg

Resets the user's password using the provided token and new password.

Args:

  • token (str): The password reset token sent to the user's email.

  • new_password (str): The new password the user wants to set.

Returns:

  • Msg: A message indicating the success or failure of the password reset.


method retrieve_api_key

retrieve_api_key()None

Retrieve the API key from the ~/.giza/.api_key.json file.

Raises:

  • Exception: if the file does not exist

Returns:

  • str: the API key


method retrieve_token

retrieve_token(
    user: Optional[str] = None,
    password: Optional[str] = None,
    renew: bool = False
)None

Get the JWT token.

First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials.json. And finally it will try to retrieve it from the API login the user in.

Args:

  • user: if provided it will be used to check against current credentials and if provided with password used to retrieve a new token.

  • password: if provided with user it will be used to retrieve a new token.

  • renew: for renewal of the JWT token by user login.

Raises:

  • Exception: if token could not be retrieved in any way


class EndpointsClient

Client to interact with endpoints endpoint.

method __init__

__init__(
    host: str,
    token: Optional[str] = None,
    api_key: Optional[str] = None,
    api_version: str = 'v1',
    verify: bool = True,
    debug: Optional[bool] = False
)None

method create

create(
    model_id: int,
    version_id: int,
    endpoint_create: EndpointCreate,
    f: Optional[BufferedReader] = None
) → Endpoint

Create a new deployment.

Args:

  • endpoint_create: Endpoint information to create

Returns: The recently created deployment information


method delete

delete(endpoint_id: int)None

Delete an endpoint.

Args:

  • endpoint_id: Endpoint identifier


method download_proof

download_proof(endpoint_id: int, proof_id: Union[int, str])bytes

Download a proof.

Args:

  • proof_id: Proof identifier

Returns: The proof binary file


method get

get(endpoint_id: int) → Endpoint

Get a deployment.

Args:

  • endpoint_id: Endpoint identifier

Returns: The deployment information


method get_proof

get_proof(endpoint_id: int, proof_id: Union[int, str]) → Proof

Return information about a specific proof. proof_if is the identifier of the proof that can be a integer or the request id.

Returns: A proof created by the user


method list

list(params: Optional[Dict[str, Any]] = None) → EndpointsList

List endpoints.

Returns: A list of endpoints created by the user


method list_jobs

list_jobs(endpoint_id: int) → JobList

List proofs.

Returns: A list of proofs created by the user


method list_proofs

list_proofs(endpoint_id: int) → ProofList

List proofs.

Returns: A list of proofs created by the user


method retrieve_api_key

retrieve_api_key()None

Retrieve the API key from the ~/.giza/.api_key.json file.

Raises:

  • Exception: if the file does not exist

Returns:

  • str: the API key


method retrieve_token

retrieve_token(
    user: Optional[str] = None,
    password: Optional[str] = None,
    renew: bool = False
)None

Get the JWT token.

First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials.json. And finally it will try to retrieve it from the API login the user in.

Args:

  • user: if provided it will be used to check against current credentials and if provided with password used to retrieve a new token.

  • password: if provided with user it will be used to retrieve a new token.

  • renew: for renewal of the JWT token by user login.

Raises:

  • Exception: if token could not be retrieved in any way


method verify_proof

verify_proof(endpoint_id: int, proof_id: Union[str, int]) → VerifyResponse

Verify a proof.

Args:

  • endpoint_id: Endpoint identifier

  • proof_id: Proof identifier

Returns: The verification response


class EndpointsClient

Client to interact with endpoints endpoint.

method __init__

__init__(
    host: str,
    token: Optional[str] = None,
    api_key: Optional[str] = None,
    api_version: str = 'v1',
    verify: bool = True,
    debug: Optional[bool] = False
)None

method create

create(
    model_id: int,
    version_id: int,
    endpoint_create: EndpointCreate,
    f: Optional[BufferedReader] = None
) → Endpoint

Create a new deployment.

Args:

  • endpoint_create: Endpoint information to create

Returns: The recently created deployment information


method delete

delete(endpoint_id: int)None

Delete an endpoint.

Args:

  • endpoint_id: Endpoint identifier


method download_proof

download_proof(endpoint_id: int, proof_id: Union[int, str])bytes

Download a proof.

Args:

  • proof_id: Proof identifier

Returns: The proof binary file


method get

get(endpoint_id: int) → Endpoint

Get a deployment.

Args:

  • endpoint_id: Endpoint identifier

Returns: The deployment information


method get_proof

get_proof(endpoint_id: int, proof_id: Union[int, str]) → Proof

Return information about a specific proof. proof_if is the identifier of the proof that can be a integer or the request id.

Returns: A proof created by the user


method list

list(params: Optional[Dict[str, Any]] = None) → EndpointsList

List endpoints.

Returns: A list of endpoints created by the user


method list_jobs

list_jobs(endpoint_id: int) → JobList

List proofs.

Returns: A list of proofs created by the user


method list_proofs

list_proofs(endpoint_id: int) → ProofList

List proofs.

Returns: A list of proofs created by the user


method retrieve_api_key

retrieve_api_key()None

Retrieve the API key from the ~/.giza/.api_key.json file.

Raises:

  • Exception: if the file does not exist

Returns:

  • str: the API key


method retrieve_token

retrieve_token(
    user: Optional[str] = None,
    password: Optional[str] = None,
    renew: bool = False
)None

Get the JWT token.

First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials.json. And finally it will try to retrieve it from the API login the user in.

Args:

  • user: if provided it will be used to check against current credentials and if provided with password used to retrieve a new token.

  • password: if provided with user it will be used to retrieve a new token.

  • renew: for renewal of the JWT token by user login.

Raises:

  • Exception: if token could not be retrieved in any way


method verify_proof

verify_proof(endpoint_id: int, proof_id: Union[str, int]) → VerifyResponse

Verify a proof.

Args:

  • endpoint_id: Endpoint identifier

  • proof_id: Proof identifier

Returns: The verification response


class TranspileClient

Client to interact with users endpoint.

method __init__

__init__(
    host: str,
    token: Optional[str] = None,
    api_key: Optional[str] = None,
    api_version: str = 'v1',
    verify: bool = True,
    debug: Optional[bool] = False
)None

method retrieve_api_key

retrieve_api_key()None

Retrieve the API key from the ~/.giza/.api_key.json file.

Raises:

  • Exception: if the file does not exist

Returns:

  • str: the API key


method retrieve_token

retrieve_token(
    user: Optional[str] = None,
    password: Optional[str] = None,
    renew: bool = False
)None

Get the JWT token.

First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials.json. And finally it will try to retrieve it from the API login the user in.

Args:

  • user: if provided it will be used to check against current credentials and if provided with password used to retrieve a new token.

  • password: if provided with user it will be used to retrieve a new token.

  • renew: for renewal of the JWT token by user login.

Raises:

  • Exception: if token could not be retrieved in any way


method transpile

transpile(f: <class 'BinaryIO'>) → Response

Make a call to the API transpile endpoint with the model as a file.

Args:

  • f (BinaryIO): model to send for transpilation

Returns:

  • Response: raw response from the server with the transpiled model as a zip


method update_transpilation

update_transpilation(
    model_id: int,
    version_id: int,
    f: <class 'BinaryIO'>
)None

Make a call to the API transpile endpoint with the model as a file.

Args:

  • f (BinaryIO): model to send for transpilation

Returns:

  • Response: raw response from the server with the transpiled model as a zip


class ModelsClient

Client to interact with models endpoint.

method __init__

__init__(
    host: str,
    token: Optional[str] = None,
    api_key: Optional[str] = None,
    api_version: str = 'v1',
    verify: bool = True,
    debug: Optional[bool] = False
)None

method create

create(model_create: ModelCreate) → Model

Create a new model.

Args:

  • model_create: Model information to create

Raises:

  • Exception: if there is no upload Url

Returns:

  • Tuple[Model, str]: the recently created model and a url, used to upload the model.


method get

get(model_id: int, **kwargs) → Model

Make a call to the API to retrieve model information.

Args:

  • model_id: Model identfier to retrieve information

Returns:

  • Model: model entity with the retrieved information


method get_by_name

get_by_name(model_name: str, **kwargs) → Optional[Model]

Make a call to the API to retrieve model information by its name.

Args:

  • model_name: Model name to retrieve information

Returns:

  • Model: model entity with the retrieved information


method list

list(**kwargs) → ModelList

List all the models related to the user.

Returns: A list of models created by the user


method retrieve_api_key

retrieve_api_key()None

Retrieve the API key from the ~/.giza/.api_key.json file.

Raises:

  • Exception: if the file does not exist

Returns:

  • str: the API key


method retrieve_token

retrieve_token(
    user: Optional[str] = None,
    password: Optional[str] = None,
    renew: bool = False
)None

Get the JWT token.

First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials.json. And finally it will try to retrieve it from the API login the user in.

Args:

  • user: if provided it will be used to check against current credentials and if provided with password used to retrieve a new token.

  • password: if provided with user it will be used to retrieve a new token.

  • renew: for renewal of the JWT token by user login.

Raises:

  • Exception: if token could not be retrieved in any way


method update

update(model_id: int, model_update: ModelUpdate) → Model

Update a model.

Args:

  • model_id: Model identfier to retrieve information

  • model_update: body to partially update the model

Returns:

  • Model: the updated model


class JobsClient

Client to interact with jobs endpoint.

method __init__

__init__(
    host: str,
    token: Optional[str] = None,
    api_key: Optional[str] = None,
    api_version: str = 'v1',
    verify: bool = True,
    debug: Optional[bool] = False
) → None

method create

create(
    job_create: JobCreate,
    trace: Optional[BufferedReader, TextIOWrapper] = None,
    memory: Optional[BufferedReader, TextIOWrapper] = None
) → Job

Create a new job.

Args:

  • job_create: Job information to create

  • f: filed to upload, a CASM json

Raises:

  • Exception: if there is no upload Url

Returns:

  • Tuple[Model, str]: the recently created model and a url, used to upload the model.


method get

get(job_id: int, params: Optional[dict[str, str]] = None) → Job

Make a call to the API to retrieve job information.

Args:

  • job_id: Job identfier to retrieve information

Returns:

  • Job: job entity with the retrieved information


method list

list() → List[Job]

List jobs.

Returns: A list of jobs created by the user


method retrieve_api_key

retrieve_api_key() → None

Retrieve the API key from the ~/.giza/.api_key.json file.

Raises:

  • Exception: if the file does not exist

Returns:

  • str: the API key


method retrieve_token

retrieve_token(
    user: Optional[str] = None,
    password: Optional[str] = None,
    renew: bool = False
) → None

Get the JWT token.

First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials.json. And finally it will try to retrieve it from the API login the user in.

Args:

  • user: if provided it will be used to check against current credentials and if provided with password used to retrieve a new token.

  • password: if provided with user it will be used to retrieve a new token.

  • renew: for renewal of the JWT token by user login.

Raises:

  • Exception: if token could not be retrieved in any way


class VersionJobsClient

Client to interact with jobs endpoint.

method __init__

__init__(
    host: str,
    token: Optional[str] = None,
    api_key: Optional[str] = None,
    api_version: str = 'v1',
    verify: bool = True,
    debug: Optional[bool] = False
) → None

method create

create(
    model_id: int,
    version_id: int,
    job_create: JobCreate,
    f: TextIOWrapper
) → Job

Create a new job.

Args:

  • job_create: Job information to create

  • f: filed to upload, a CASM json

Raises:

  • Exception: if there is no upload Url

Returns:

  • Tuple[Model, str]: the recently created model and a url, used to upload the model.


method get

get(model_id: int, version_id: int, job_id: int) → Job

Make a call to the API to retrieve job information.

Args:

  • job_id: Job identfier to retrieve information

Returns:

  • Job: job entity with the retrieved information


method list

list(model_id: int, version_id: int) → List[Job]

List jobs.

Returns: A list of jobs created by the user


method retrieve_api_key

retrieve_api_key() → None

Retrieve the API key from the ~/.giza/.api_key.json file.

Raises:

  • Exception: if the file does not exist

Returns:

  • str: the API key


method retrieve_token

retrieve_token(
    user: Optional[str] = None,
    password: Optional[str] = None,
    renew: bool = False
) → None

Get the JWT token.

First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials.json. And finally it will try to retrieve it from the API login the user in.

Args:

  • user: if provided it will be used to check against current credentials and if provided with password used to retrieve a new token.

  • password: if provided with user it will be used to retrieve a new token.

  • renew: for renewal of the JWT token by user login.

Raises:

  • Exception: if token could not be retrieved in any way


class ProofsClient

Client to interact with proofs endpoint.

method __init__

__init__(
    host: str,
    token: Optional[str] = None,
    api_key: Optional[str] = None,
    api_version: str = 'v1',
    verify: bool = True,
    debug: Optional[bool] = False
) → None

method download

download(proof_id: int) → bytes

Download a proof.

Args:

  • proof_id: Proof identifier

Returns: The proof binary file


method get

get(proof_id: int) → Proof

Make a call to the API to retrieve proof information.

Args:

  • proof_id: Proof identfier to retrieve information

Returns:

  • Proof: proof entity with the desired information


method get_by_job_id

get_by_job_id(job_id: int) → Proof

Make a call to the API to retrieve proof information based on the job id.

Args:

  • job_id: Job identifier to query by.

Returns:

  • Proof: proof entity with the desired information


method list

list() → List[Proof]

List all the proofs related to the user.

Returns: A list of proofs created by the user


method retrieve_api_key

retrieve_api_key() → None

Retrieve the API key from the ~/.giza/.api_key.json file.

Raises:

  • Exception: if the file does not exist

Returns:

  • str: the API key


method retrieve_token

retrieve_token(
    user: Optional[str] = None,
    password: Optional[str] = None,
    renew: bool = False
) → None

Get the JWT token.

First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials.json. And finally it will try to retrieve it from the API login the user in.

Args:

  • user: if provided it will be used to check against current credentials and if provided with password used to retrieve a new token.

  • password: if provided with user it will be used to retrieve a new token.

  • renew: for renewal of the JWT token by user login.

Raises:

  • Exception: if token could not be retrieved in any way


method verify_proof

verify_proof(proof_id: int) → VerifyResponse

Verify a proof.

Args:

  • proof_id: Proof identifier

Returns: The verification response


class VersionsClient

Client to interact with versions endpoint.

method __init__

__init__(
    host: str,
    token: Optional[str] = None,
    api_key: Optional[str] = None,
    api_version: str = 'v1',
    verify: bool = True,
    debug: Optional[bool] = False
) → None

method create

create(
    model_id: int,
    version_create: VersionCreate,
    filename: Optional[str] = None
) → Tuple[Version, str]

Create a new version.

Args:

  • model_id: Model identifier

  • version_create: Version information to create

Returns: The recently created version information


method download

download(model_id: int, version_id: int, params: Dict) → Dict[str, bytes]

Download a version.

Args:

  • model_id: Model identifier

  • version_id: Version identifier

  • params: Additional parameters to pass to the request

Returns: The version binary file


method download_original

download_original(model_id: int, version_id: int) → bytes

Download the original version.

Args:

  • model_id: Model identifier

  • version_id: Version identifier

Returns: The version binary file


method get

get(model_id: int, version_id: int) → Version

Get a version.

Args:

  • model_id: Model identifier

  • version_id: Version identifier

Returns: The version information


method list

list(model_id: int) → VersionList

List all the versions related to a model.

Args:

  • model_id: Model identifier

Returns: A list of versions related to the model


method retrieve_api_key

retrieve_api_key() → None

Retrieve the API key from the ~/.giza/.api_key.json file.

Raises:

  • Exception: if the file does not exist

Returns:

  • str: the API key


method retrieve_token

retrieve_token(
    user: Optional[str] = None,
    password: Optional[str] = None,
    renew: bool = False
) → None

Get the JWT token.

First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials.json. And finally it will try to retrieve it from the API login the user in.

Args:

  • user: if provided it will be used to check against current credentials and if provided with password used to retrieve a new token.

  • password: if provided with user it will be used to retrieve a new token.

  • renew: for renewal of the JWT token by user login.

Raises:

  • Exception: if token could not be retrieved in any way


method update

update(model_id: int, version_id: int, version_update: VersionUpdate) → Version

Update a specific version.

Args:

  • model_id: Model identifier

  • version_id: Version identifier

  • version_update: Version information to update

Returns: The updated version information


method upload_cairo

upload_cairo(model_id: int, version_id: int, file_path: str) → Version

Get the Cairo model URL.

Args:

  • model_id: Model identifier

  • version_id: Version identifier

Returns: The Cairo model URL


class WorkspaceClient

Client to interact with workspaces endpoint.

method __init__

__init__(
    host: str,
    token: Optional[str] = None,
    api_key: Optional[str] = None,
    api_version: str = 'v1',
    verify: bool = True,
    debug: Optional[bool] = False
) → None

method create

create() → Workspace

Call the API to create a new workspace. If the workspace already exists it will return a 400.

Returns:

  • Workspace: the created workspace information


method delete

delete() → None

Call the API to delete the workspace. If the workspace does not exist it will return a 404.

Returns: None


method get

get() → Workspace

Make a call to the API to retrieve workspace information. Only one should exist.

Returns:

  • Workspace: workspace information


method retrieve_api_key

retrieve_api_key() → None

Retrieve the API key from the ~/.giza/.api_key.json file.

Raises:

  • Exception: if the file does not exist

Returns:

  • str: the API key


method retrieve_token

retrieve_token(
    user: Optional[str] = None,
    password: Optional[str] = None,
    renew: bool = False
) → None

Get the JWT token.

First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials.json. And finally it will try to retrieve it from the API login the user in.

Args:

  • user: if provided it will be used to check against current credentials and if provided with password used to retrieve a new token.

  • password: if provided with user it will be used to retrieve a new token.

  • renew: for renewal of the JWT token by user login.

Raises:

  • Exception: if token could not be retrieved in any way


class AgentsClient

Client to interact with agents endpoint.

method __init__

__init__(
    host: str,
    token: Optional[str] = None,
    api_key: Optional[str] = None,
    api_version: str = 'v1',
    verify: bool = True,
    debug: Optional[bool] = False
) → None

method create

create(agent_create: AgentCreate) → Agent

Create a new agent.

Args:

  • agent_create: Agent information to create

Returns: The recently created agent


method delete

delete(agent_id: int) → None

Delete an agent.

Args:

  • agent_id: Agent identifier


method get

get(agent_id: int, params: Optional[Dict[str, Any]] = None) → Agent

Get an agent.

Args:

  • agent_id: Agent identifier

Returns: The agent information


method list

list(params: Optional[Dict[str, Any]] = None) → AgentList

List endpoints.

Returns: A list of endpoints created by the user


method patch

patch(agent_id: int, agent_update: AgentUpdate) → Agent

Update an agent.

Args:

  • agent_id: Agent identifier

  • agent_update: Agent information to update

Returns: The updated agent information


method retrieve_api_key

retrieve_api_key() → None

Retrieve the API key from the ~/.giza/.api_key.json file.

Raises:

  • Exception: if the file does not exist

Returns:

  • str: the API key


method retrieve_token

retrieve_token(
    user: Optional[str] = None,
    password: Optional[str] = None,
    renew: bool = False
) → None

Get the JWT token.

First, it will try to get it from GIZA_TOKEN. Second, from ~/.giza/.credentials.json. And finally it will try to retrieve it from the API login the user in.

Args:

  • user: if provided it will be used to check against current credentials and if provided with password used to retrieve a new token.

  • password: if provided with user it will be used to retrieve a new token.

  • renew: for renewal of the JWT token by user login.

Raises:

  • Exception: if token could not be retrieved in any way

Last updated