Search

Organizations

Organizations

The Kodexa platform provides a powerful way to manage and organize your data processing workflows. One of the key concepts in Kodexa is the Organization, which serves as a container for various resources and settings. This article will explore the Organization concept and demonstrate how to interact with it using the Kodexa client.

What is a Kodexa Organization?

A Kodexa Organization is a logical grouping of resources, settings, and users within the Kodexa platform. It allows you to:

  • Manage access to resources
  • Configure settings for your team
  • Organize projects and workflows

Each Organization has a unique identifier (slug) and can have various properties such as a name, description, and associated image.

Interacting with Organizations using the Kodexa Client

The Kodexa client provides a convenient way to interact with Organizations programmatically. Let's explore some common operations you can perform using the client.

Accessing Organization Information

To work with an Organization, you typically use the OrganizationEndpoint class. This class provides methods to retrieve and modify Organization-related data.

from kodexa import KodexaClient, OrganizationEndpoint

# Assuming you have already initialized the KodexaClient
client = KodexaClient(...)

# Get the Organization endpoint
organization = client.organization("your-org-slug")

Retrieving Available Resources

Organizations have access to various resources such as templates, models, and assistants. You can retrieve these using the following methods:

# Get available templates
templates = organization.available_templates

# Get available models
models = organization.available_models

# Get available assistants
assistants = organization.available_assistants

Managing Products and Subscriptions

Organizations can subscribe to different products within the Kodexa platform. Here's how you can manage products and subscriptions:

# List available products
products = client.products.list()

# Add a subscription to a product
organization.add_subscription(product)

# Get current subscriptions
subscriptions = organization.get_subscriptions()

# Remove a subscription
organization.remove_subscription(subscription)

Example: Adding and Removing a Product Subscription

Let's walk through an example of adding and removing a product subscription for an Organization:

def manage_product_subscription(client: KodexaClient, organization: OrganizationEndpoint):
    # List available products
    products = client.products.list()

    if len(products.content) > 0:
        # Select the first product
        test_product = products.content[0]

        # Add subscription to the product
        organization.add_subscription(test_product)

        # Get current subscriptions
        subscriptions = organization.get_subscriptions()

        # Remove the subscription we just added
        for subscription in subscriptions.content:
            if subscription.organization.slug == organization.slug:
                organization.remove_subscription(subscription)

        # Verify that the subscription was removed
        updated_subscriptions = organization.get_subscriptions()
        assert len(updated_subscriptions.content) == 0

Conclusion

The Kodexa platform's Organization concept provides a flexible way to manage resources and settings for your team. By using the Kodexa client, you can easily interact with Organizations programmatically, allowing you to automate various tasks and integrate Kodexa functionality into your workflows.

Remember to refer to the Kodexa documentation for the most up-to-date information on available methods and best practices when working with Organizations and the Kodexa client.