Skip to main content

Python SDK for Lockbox API

Project description

Lockbox Python SDK

Static Badge

Python SDK for the Lockbox API.

Installation

pip install lockbox-sdk

Usage

import asyncio

from lockbox_sdk import AsyncLockboxSdk
from lockbox_sdk.v1.api_keys.dto import CreateApiKeyRequestDTO, IntrospectApiKeyRequestDTO


API_URL = "http://localhost:8087"

async def main():
    async with AsyncLockboxSdk(API_URL) as sdk:
        # Namespaces API
        namespaces = await sdk.v1.namespaces.find_namespaces(
            page=1,
            per_page=10,
            names=["namespace1", "namespace2"],
            tenant_id="my-tenant",
        )
        print(namespaces)

        namespace = await sdk.v1.namespaces.get_namespace(
            name="namespace3",
            tenant_id="my-tenant",
        )
        print(namespace)

        await sdk.v1.namespaces.delete_namespace(
            name="namespace2",
            tenant_id="my-tenant",
        )

        # Tags API
        tags = await sdk.v1.tags.find_tags(
            namespace="namespace2",
            page=1,
            per_page=10,
            names=["tag1", "tag2"],
            tenant_id="my-tenant",
        )
        print(tags)

        tag = await sdk.v1.tags.get_tag(
            namespace="namespace2",
            name="tag1",
            tenant_id="my-tenant",
        )
        print(tag)

        # API keys API
        api_key = await sdk.v1.api_keys.create_api_key(
            payload=CreateApiKeyRequestDTO(
                owner="user@example.com",
                scope="read:documents edit:posts",
                tag=tag.name,
                metadata={
                    "special": "sauce",
                }
            ),
            tenant_id="my-tenant"
        )
        print(api_key)

        introspection = await sdk.v1.api_keys.introspect_api_key(
            payload=IntrospectApiKeyRequestDTO(
                token=api_key.key,
                scope="read:documents",
                tag=tag.name,
            ),
            tenant_id="my-tenant"
        )
        print(introspection)

        new_api_key = await sdk.v1.api_keys.rotate_api_key(
            id=api_key.id,
            tenant_id="my-tenant"
        )
        print(new_api_key)

This library provides both an asynchronous and synchronous client. Simply use the LockboxSdk class for synchronous operations.

License

This project is licensed under MIT License.

Support & Feedback

If you encounter any issues or have feedback, please open an issue. We'd love to hear from you!

Made with ❤️ by Emergent Methods

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

lockbox_sdk-0.1.2-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file lockbox_sdk-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for lockbox_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9178d24e6734e9aad0a3bc2019b1072353c07f22e0782a65cd49672c6646669f
MD5 ed680010d13a3ecaa733030e8b1c8e75
BLAKE2b-256 6184e282b6b5683eb8c9065060cf0f59d52b66c9ec9dbc068f585e30064e0887

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