|
| 1 | +from __future__ import annotations |
| 2 | + |
| 3 | +from typing import List |
| 4 | + |
1 | 5 | from conductor.asyncio_client.adapters.api.event_resource_api import ( |
2 | 6 | EventResourceApiAdapter, |
3 | 7 | ) |
| 8 | +from conductor.asyncio_client.adapters.models.tag_adapter import TagAdapter |
4 | 9 | from conductor.asyncio_client.adapters import ApiClient |
5 | 10 | from conductor.shared.event.configuration import QueueConfiguration |
6 | 11 |
|
@@ -34,3 +39,91 @@ async def put_queue_configuration(self, queue_configuration: QueueConfiguration) |
34 | 39 | queue_name=queue_configuration.queue_name, |
35 | 40 | queue_type=queue_configuration.queue_type, |
36 | 41 | ) |
| 42 | + |
| 43 | + async def get_event_handler_tags(self, name: str) -> List[TagAdapter]: |
| 44 | + """Get tags for an event handler. |
| 45 | +
|
| 46 | + Retrieves all tags associated with a specific event handler. |
| 47 | + Tags are used for organizing and categorizing event handlers. |
| 48 | +
|
| 49 | + Parameters: |
| 50 | + ----------- |
| 51 | + name : str |
| 52 | + The name of the event handler |
| 53 | +
|
| 54 | + Returns: |
| 55 | + -------- |
| 56 | + List[TagAdapter] |
| 57 | + List of tags associated with the event handler |
| 58 | +
|
| 59 | + Example: |
| 60 | + -------- |
| 61 | + ```python |
| 62 | + # Get tags for an event handler |
| 63 | + tags = await event_client.get_event_handler_tags("workflow_trigger") |
| 64 | + for tag in tags: |
| 65 | + print(f"Tag: {tag.key} = {tag.value}") |
| 66 | + ``` |
| 67 | + """ |
| 68 | + return await self.client.get_tags_for_event_handler(name=name) |
| 69 | + |
| 70 | + async def add_event_handler_tag(self, name: str, tags: List[TagAdapter]) -> None: |
| 71 | + """Add tags to an event handler. |
| 72 | +
|
| 73 | + Associates one or more tags with an event handler for organization and categorization. |
| 74 | +
|
| 75 | + Parameters: |
| 76 | + ----------- |
| 77 | + name : str |
| 78 | + The name of the event handler |
| 79 | + tags : List[TagAdapter] |
| 80 | + List of tags to add to the event handler |
| 81 | +
|
| 82 | + Example: |
| 83 | + -------- |
| 84 | + ```python |
| 85 | + from conductor.asyncio_client.adapters.models.tag_adapter import TagAdapter |
| 86 | +
|
| 87 | + # Add tags to an event handler |
| 88 | + tags = [ |
| 89 | + TagAdapter(key="environment", value="production"), |
| 90 | + TagAdapter(key="team", value="platform"), |
| 91 | + TagAdapter(key="priority", value="high") |
| 92 | + ] |
| 93 | +
|
| 94 | + await event_client.add_event_handler_tag("workflow_trigger", tags) |
| 95 | + ``` |
| 96 | + """ |
| 97 | + # Note: Async API uses (name=name, tag=tags) keyword args to match the server signature. |
| 98 | + # Sync API uses (tags, name) positional args due to swagger-codegen parameter ordering. |
| 99 | + return await self.client.put_tag_for_event_handler(name=name, tag=tags) |
| 100 | + |
| 101 | + async def remove_event_handler_tag(self, name: str, tags: List[TagAdapter]) -> None: |
| 102 | + """Remove tags from an event handler. |
| 103 | +
|
| 104 | + Removes one or more tags from an event handler. |
| 105 | +
|
| 106 | + Parameters: |
| 107 | + ----------- |
| 108 | + name : str |
| 109 | + The name of the event handler |
| 110 | + tags : List[TagAdapter] |
| 111 | + List of tags to remove from the event handler |
| 112 | +
|
| 113 | + Example: |
| 114 | + -------- |
| 115 | + ```python |
| 116 | + from conductor.asyncio_client.adapters.models.tag_adapter import TagAdapter |
| 117 | +
|
| 118 | + # Remove specific tags from an event handler |
| 119 | + tags_to_remove = [ |
| 120 | + TagAdapter(key="environment", value="production"), |
| 121 | + TagAdapter(key="priority", value="high") |
| 122 | + ] |
| 123 | +
|
| 124 | + await event_client.remove_event_handler_tag("workflow_trigger", tags_to_remove) |
| 125 | + ``` |
| 126 | + """ |
| 127 | + # Note: Async API uses (name=name, tag=tags) keyword args to match the server signature. |
| 128 | + # Sync API uses (tags, name) positional args due to swagger-codegen parameter ordering. |
| 129 | + return await self.client.delete_tag_for_event_handler(name=name, tag=tags) |
0 commit comments