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.0-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for lockbox_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3924ae6699710c42ac2eae472d047dbe42d51e1d0970685eb032b398d321e77
MD5 edf3b3b56bb3657a07d0faf650247d0f
BLAKE2b-256 b9db3c74c5cda7b0710ca76253bf36e945ae7c23a428d09ca19d67274ccacbe5

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