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

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for lockbox_sdk-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d8480e2dda45927fb35759e0bf10f91ffcbf33b464cbbb0e5263682a131f5ebe
MD5 7681a37559bf980457b7158eba3b43c9
BLAKE2b-256 69de0506abd127ffdfb3ce78a6590ee2f19b19820cb6f7b8859365637e356852

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