Skip to main content

A python package to interact with Nimbella cloud services.

Project description

Nimbella SDK for Python

A Python package to interact with nimbella.com services.

Installation

pip install nimbella

Usage

This SDK provides access to the following cloud services on Nimbella.com:

Redis

The nimbella.redis() method returns a pre-configured Redis client for use in your application. See the Redis client library documentation for the methods provided.

import nimbella

# Redis
redis = nimbella.redis()
redis.set("key", "value")
value = redis.get("key")

Object Storage (GCP & S3)

The nimbella.storage() method returns a pre-configured object storage client. This client exposes a high-level storage API (details below) - which hides the underlying storage provider implementation. The storage client is automatically configured to use the storage service for the cloud it is running on - which is GCS on GCP and S3 on AWS.

import nimbella

# Storage
bucket = nimbella.storage()
filename = "test.txt"
file = bucket.file(filename)
file.save('Expected %s contents' % filename, 'text/plain')

The nimbella.storage() constructor takes a single parameter web to determine whether the storage bucket is for a website (nimbella.storage(web=True)) or files (nimbella.storage()). Website buckets can be used for store web content (e.g. HTML & JS files) to host static websites.

Object Storage API

# Storage API
class StorageProvider(web=False):    
    # External bucket URL
    @property
    def url() -> Union[str, None]:

    # Configure website for web storage buckets
    def setWebsite(mainPageSuffix, notFoundPage):

    # Remove all files from the bucket (using optional prefix)    
    def deleteFiles(force, prefix):

    # Upload new file from path to bucket destination.
    def upload(path, destination, contentType, cacheControl):

    # Return storage file instance from bucket
    def file(destination) -> StorageFile:

    # Return all storage files (with optional prefix) instance from bucket
    def getFiles(prefix) -> list:

# Storage File Class
class StorageFile():
    # Name of the bucket file
    @property
    def name() -> str:

    # key/value pairs for provider-specific object metadata
    @property
    def metadata() -> dict:

    # does file exist?
    def exists() -> bool:

    # delete file from bucket
    def delete() -> None:

    # update file contents from string or bytes with content-type
    def save(data: Union[str, bytes], contentType: str) -> None:

    # return file contents as bytes
    def download() -> bytes:

    # return pre-signed url from file for external access
    def signed_url(version: str, action: str, expires: int, contentType: str) -> str:

Support

We're always happy to help you with any issues you encounter. You may want to join our Slack community to engage with us for a more rapid response.

License

Apache-2.0. See LICENSE to learn more.

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

nimbella-2.0.0.tar.gz (8.7 kB view hashes)

Uploaded Source

Built Distribution

nimbella-2.0.0-py2.py3-none-any.whl (17.0 kB view hashes)

Uploaded Python 2 Python 3

Supported by

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