Skip to main content

Tiny client library for various Vimond APIs

Project description

pyvimond

Tiny Python client library for various Vimond APIs. Currently it provides clients for:

  • Vimond REST API
  • Vimond Image Service

Usage

The examples here can be found in the example files in the project root directory

Vimond REST API

from pyvimond.vimond_client import VimondClient

if __name__ == "__main__":
    # Create a client
    api_url = "https://vimond"
    user = "user"
    secret = "secret"
    vimond = VimondClient(api_url, user, secret)

    # Get an asset
    asset = vimond.get_asset(1334686)
    print(asset["uri"])

    # Get the asset's category
    category = vimond.get_category(asset["categoryId"])
    print(category["category"]["@uri"])

    # Get the metadata for the asset
    metadata = vimond.get_asset_metadata(1334686)
    print(metadata)

Vimond Image Service

The client uses HTTP Basic authentication when interfacing with Vimond Image Service

from pyvimond.vimond_image_service_client import VimondImageServiceClient

if __name__ == "__main__":
    # Create a client
    api_url = "https://image-service"
    username = "user"
    password = "secret"
    vimond_image_service = VimondImageServiceClient(api_url, username, password)

    # Create an image pack
    imagepack_id = vimond_image_service.create_image_pack()
    print(f"Created new imagepack with ID {imagepack_id}")

    # Update the "main" location with the image from a publicly accessible URL.
    # The function will return an ID consisting of the imagepack ID plus the current UNIX timestamp. This
    # can eventually be used to reference this version of the image (assuming it gets cached somewhere) even after
    # the image has been updated later on.
    public_url = "https://cdn.pixabay.com/photo/2020/12/03/12/35/sunset-5800386_960_720.jpg"
    timestamped_imagepack_id = vimond_image_service.send_image(imagepack_id, public_url, "main")

    # Get the URL to the timestamped version with location "main"
    url = vimond_image_service.create_image_url(timestamped_imagepack_id, location="main")
    print(url)

    # Get the URL to the untimestamped version and no location
    url_without_location = vimond_image_service.create_image_url(imagepack_id)
    print(url_without_location)

Testing

python3 -m unittest discover

Releasing

Before beginning, make sure you have the necessary tools installed:

pip install --user --upgrade setuptools wheel twine

To build a new distribution and publish it on PyPi:

  1. Update the version number in setup.py
  2. Run rm -rf build dist to remove any previous build artifacts
  3. Run python3 setup.py sdist bdist_wheel to build the new distribution
  4. Run twine upload dist/*. When asked for credentials, use __token__ as username and the output of vault -l pypi-pyvimond-api-token as password.

More information: https://packaging.python.org/tutorials/packaging-projects/

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

pyvimond-0.4.4.tar.gz (7.3 kB view details)

Uploaded Source

Built Distribution

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

pyvimond-0.4.4-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file pyvimond-0.4.4.tar.gz.

File metadata

  • Download URL: pyvimond-0.4.4.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.10

File hashes

Hashes for pyvimond-0.4.4.tar.gz
Algorithm Hash digest
SHA256 3318eac43a2c87cc0d2159c0c5ebe14cfd40900635f2d94167d15a92d83413e8
MD5 63a0a8f3407d09206157f2e2580cc276
BLAKE2b-256 18860a9792a3dfb19b1137b9e95f8da03230ec39437979d12cdb62985a4267a0

See more details on using hashes here.

File details

Details for the file pyvimond-0.4.4-py3-none-any.whl.

File metadata

  • Download URL: pyvimond-0.4.4-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.25.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.10

File hashes

Hashes for pyvimond-0.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 9dcb45310c75093b74052a68c2ee4f1995ec550628071e419ab73d14fd5559dd
MD5 7a0fac5398790f9cc0e3c07170def72b
BLAKE2b-256 1e9cf732bdb7162b53f47d2d04e2caed256d5d6f182058b3074c1b49c35bf002

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