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.
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.
To work with an Organization, you typically use the OrganizationEndpoint class. This class provides methods to retrieve and modify Organization-related data.
Copy
Ask AI
from kodexa import KodexaClient, OrganizationEndpoint# Assuming you have already initialized the KodexaClientclient = KodexaClient(...)# Get the Organization endpointorganization = client.organization("your-org-slug")
Organizations have access to various resources such as templates, models, and assistants. You can retrieve these using the following methods:
Copy
Ask AI
# Get available templatestemplates = organization.available_templates# Get available modelsmodels = organization.available_models# Get available assistantsassistants = organization.available_assistants
Organizations can subscribe to different products within the Kodexa platform. Here’s how you can manage products and subscriptions:
Copy
Ask AI
# List available productsproducts = client.products.list()# Add a subscription to a productorganization.add_subscription(product)# Get current subscriptionssubscriptions = organization.get_subscriptions()# Remove a subscriptionorganization.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:
Copy
Ask AI
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
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.