TemplateVariablesCollectionsResource
TemplateVariablesCollectionsResource ¶
TemplateVariablesCollectionsResource(client: Client)
Bases: BaseResource
aupdate
async
¶
aupdate(collection_id: int, name: str, description: str | None = None, read_only: bool | None = None, columns: List[CollectionColumn] | None = None) -> TemplateVariablesCollection
Async version of update_collection.
create ¶
create(name: str, description: str = '', variables: List[Dict[str, str]] | None = None, columns: List[CollectionColumn] | None = None, read_only: bool = False) -> TemplateVariablesCollectionWithEntries
Creates a new collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name for the new collection. |
required |
description
|
str
|
Optional description for the collection. |
''
|
variables
|
list[dict[str, str]]
|
Optional list of variables to add to the collection. |
None
|
columns
|
list[CollectionColumn]
|
Optional list of column definitions for the collection. |
None
|
read_only
|
bool
|
Whether the collection should be read-only. |
False
|
Returns:
Type | Description |
---|---|
TemplateVariablesCollection
|
The newly created collection object. |
Raises:
Type | Description |
---|---|
HTTPStatusError
|
If collection with same name already exists (400 BAD REQUEST) |
get ¶
Get a collection by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the collection to get. |
required |
Returns:
Name | Type | Description |
---|---|---|
TemplateVariablesCollectionWithEntries |
TemplateVariablesCollectionWithEntries
|
The collection object. |
Raises:
Type | Description |
---|---|
ValueError
|
If no collection is found with the given name. |
get_by_id ¶
Get a collection by id.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id
|
int
|
The id of the collection. |
required |
Returns:
Type | Description |
---|---|
TemplateVariablesCollectionWithEntries
|
The requested collection. |
get_or_create ¶
get_or_create(name: str, description: str = '', variables: List[Dict[str, str]] | None = None, columns: List[CollectionColumn] | None = None, read_only: bool = False) -> tuple[TemplateVariablesCollectionWithEntries, bool]
Gets an existing collection by name or creates a new one if it doesn't exist. The existence check is only based on the name parameter - if a collection with the given name exists, it will be returned regardless of the other parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the collection to get or create. |
required |
description
|
str
|
Optional description for the collection if created. |
''
|
variables
|
List[Dict[str, str]] | None
|
Optional list of variables to add to the collection if created. |
None
|
columns
|
List[CollectionColumn] | None
|
Optional list of column definitions for the collection if created. |
None
|
read_only
|
bool
|
Whether the collection should be read-only if created. |
False
|
Returns:
Type | Description |
---|---|
tuple[TemplateVariablesCollectionWithEntries, bool]
|
tuple[TemplateVariablesCollectionWithEntries, bool]: A tuple containing: - Collection: The retrieved or created collection object - bool: True if a new collection was created, False if existing was found |
list ¶
list(filters: TemplateVariablesCollectionFilter | None = None, compatible_prompt_template: PromptTemplate | None = None, sort_options: TemplateVariablesCollectionSort | None = None) -> list[TemplateVariablesCollection]
Get a list of template variables collections.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filters
|
TemplateVariablesCollectionFilter | None
|
Filter for template variables collections. |
None
|
compatible_prompt_template
|
PromptTemplate | None
|
Filter collections compatible with a specific prompt template. |
None
|
sort_options
|
TemplateVariablesCollectionSort | None
|
Sort for template variables collections. |
None
|
Returns:
Type | Description |
---|---|
list[TemplateVariablesCollection]
|
list[TemplateVariablesCollection]: A list of template variables collections. |
update ¶
update(collection_id: int, name: str, description: str | None = None, read_only: bool | None = None, columns: List[CollectionColumn] | None = None) -> TemplateVariablesCollection
Update an existing collection.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
collection_id
|
int
|
The ID of the collection to update. |
required |
name
|
str
|
The new name for the collection. |
required |
description
|
str | None
|
Optional new description for the collection. |
None
|
read_only
|
bool | None
|
Optional new read-only status for the collection. |
None
|
columns
|
List[CollectionColumn] | None
|
Optional list of columns in the desired order. Missing columns are deleted, new columns are created as TEXT with default='', existing columns are reordered. |
None
|
Returns:
Name | Type | Description |
---|---|---|
TemplateVariablesCollection |
TemplateVariablesCollection
|
The updated collection object. |
Raises:
Type | Description |
---|---|
HTTPStatusError
|
If collection doesn't exist or validation fails. |