Skip to main content

Python SDK for the ZiCON Cloud API

Project description

zicon-cloud

Python SDK for the ZiCON Cloud API.

Installation

pip install zicon-cloud

Quickstart

from zicon_cloud import ZiconClient

# Public endpoints work without an API key
client = ZiconClient()

# Authenticated endpoints require an api_key
client = ZiconClient(api_key="YOUR_ZICON_API_KEY")

Usage

List datasets (no auth required)

from zicon_cloud import ZiconClient

client = ZiconClient()
datasets = client.list_datasets()
print(datasets)

Get a single dataset (no auth required)

dataset = client.get_dataset("dataset-id")
print(dataset)

List projects (requires API key)

from zicon_cloud import ZiconClient

client = ZiconClient(api_key="YOUR_ZICON_API_KEY")
projects = client.list_projects()
print(projects)

Get files for a project (requires API key)

files = client.get_project_files("project-id")
print(files)

Get a file download URL (requires API key)

download_url = client.get_download_url("file-id")
print(download_url)

List endpoints (no auth required)

endpoints = client.list_endpoints()
print(endpoints)

List tools (no auth required)

tools = client.list_tools()
print(tools)

Download a dataset (no auth required)

download = client.download_dataset("dataset-id")
print(download)

Delete a project (requires API key)

client = ZiconClient(api_key="YOUR_ZICON_API_KEY")
client.delete_project("project-id")

Create a project (requires an access token)

create_project authenticates differently from the other methods above: it takes an access_token argument and sends it as an Authorization: Bearer header, instead of using the client's api_key.

from zicon_cloud import ZiconClient

client = ZiconClient()
project = client.create_project(
    name="My Project",
    category="research",
    description="A project created via the SDK",
    access_token="YOUR_ACCESS_TOKEN",
)
print(project)

Error handling

The SDK raises typed exceptions based on the API response:

from zicon_cloud import (
    ZiconClient,
    ZiconAuthError,
    ZiconPermissionError,
    ZiconNotFoundError,
    ZiconServerError,
)

client = ZiconClient(api_key="YOUR_ZICON_API_KEY")

try:
    projects = client.list_projects()
except ZiconAuthError:
    print("Invalid or missing API key")
except ZiconPermissionError:
    print("Your API key doesn't have permission for this")
except ZiconNotFoundError:
    print("Resource not found")
except ZiconServerError:
    print("ZiCON Cloud is having server issues, try again later")

Calling an authenticated method (list_projects, get_project_files, get_download_url, delete_project) without an api_key set on the client raises ZiconAuthError immediately, without making a network request. Likewise, calling create_project without an access_token raises ZiconAuthError immediately.

Development

pip install -e ".[test]"
pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zicon_cloud-0.2.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zicon_cloud-0.2.0-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file zicon_cloud-0.2.0.tar.gz.

File metadata

  • Download URL: zicon_cloud-0.2.0.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for zicon_cloud-0.2.0.tar.gz
Algorithm Hash digest
SHA256 53824a6a87d807a23193d115688a3d4542bb0289c4ea773604cc243ea45c2a29
MD5 e1457d70362f9495a80b36515c91c4bf
BLAKE2b-256 a4caeb84aec0c6bd995d29768ab85877c3b7b3a3810526c2833add3f5f205f1e

See more details on using hashes here.

File details

Details for the file zicon_cloud-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: zicon_cloud-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for zicon_cloud-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eeba4d61297f4e7d037189791f20d0959abd0043ed59a72d916cf83f66adf79e
MD5 9142d251acefa6565f396258123c5290
BLAKE2b-256 c1003d4cc63df17b34d9c61768988f16457b01dc6c9e4942f359ecd0106185fb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page