Add items to a Collection.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.client.collections.add_items(collection_id=7742.68)
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
collection_id |
float |
✔️ |
The ID of the Collection to add items to. |
locale |
Optional[str] |
➖ |
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en. |
added_collection_item_descriptors |
List[models.CollectionItemDescriptor] |
➖ |
The CollectionItemDescriptors of the items being added. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.AddCollectionItemsResponse
| Error Type |
Status Code |
Content Type |
| errors.GleanError |
4XX, 5XX |
*/* |
Create a publicly visible (empty) Collection of documents.
from glean.api_client import Glean, models
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.client.collections.create(name="<value>", added_roles=[
models.UserRoleSpecification(
person=models.Person(
name="George Clooney",
obfuscated_id="abc123",
),
role=models.UserRole.OWNER,
),
], removed_roles=[
models.UserRoleSpecification(
person=models.Person(
name="George Clooney",
obfuscated_id="abc123",
),
role=models.UserRole.ANSWER_MODERATOR,
),
], audience_filters=[
{
"field_name": "type",
"values": [
{
"value": "Spreadsheet",
"relation_type": models.RelationType.EQUALS,
},
{
"value": "Presentation",
"relation_type": models.RelationType.EQUALS,
},
],
},
])
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
name |
str |
✔️ |
The unique name of the Collection. |
locale |
Optional[str] |
➖ |
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en. |
description |
Optional[str] |
➖ |
A brief summary of the Collection's contents. |
added_roles |
List[models.UserRoleSpecification] |
➖ |
A list of added user roles for the Collection. |
removed_roles |
List[models.UserRoleSpecification] |
➖ |
A list of removed user roles for the Collection. |
audience_filters |
List[models.FacetFilter] |
➖ |
Filters which restrict who should see this Collection. Values are taken from the corresponding filters in people search. |
icon |
Optional[str] |
➖ |
The emoji icon of this Collection. |
admin_locked |
Optional[bool] |
➖ |
Indicates whether edits are allowed for everyone or only admins. |
parent_id |
Optional[int] |
➖ |
The parent of this Collection, or 0 if it's a top-level Collection. |
thumbnail |
Optional[models.Thumbnail] |
➖ |
N/A |
allowed_datasource |
Optional[str] |
➖ |
The datasource type this Collection can hold. |
new_next_item_id |
Optional[str] |
➖ |
The (optional) ItemId of the next CollectionItem in sequence. If omitted, will be added to the end of the Collection. Only used if parentId is specified. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.CreatecollectionResponse
| Error Type |
Status Code |
Content Type |
| errors.CollectionError |
422 |
application/json |
| errors.GleanError |
4XX, 5XX |
*/* |
Delete a Collection given the Collection's ID.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
glean.client.collections.delete(ids=[
930352,
156719,
25102,
])
# Use the SDK ...
| Parameter |
Type |
Required |
Description |
ids |
List[int] |
✔️ |
The IDs of the Collections to delete. |
locale |
Optional[str] |
➖ |
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en. |
allowed_datasource |
Optional[str] |
➖ |
The datasource allowed in the Collection to be deleted. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
| Error Type |
Status Code |
Content Type |
| errors.CollectionError |
422 |
application/json |
| errors.GleanError |
4XX, 5XX |
*/* |
Delete a single item from a Collection.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.client.collections.delete_item(collection_id=6980.49, item_id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
collection_id |
float |
✔️ |
The ID of the Collection to remove an item in. |
item_id |
str |
✔️ |
The item ID of the CollectionItem to remove from this Collection. |
locale |
Optional[str] |
➖ |
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en. |
document_id |
Optional[str] |
➖ |
The (optional) Glean Document ID of the CollectionItem to remove from this Collection if this is an indexed document. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.DeleteCollectionItemResponse
| Error Type |
Status Code |
Content Type |
| errors.GleanError |
4XX, 5XX |
*/* |
Update the properties of an existing Collection.
from glean.api_client import Glean, models
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.client.collections.update(name="<value>", id=347152, added_roles=[
models.UserRoleSpecification(
person=models.Person(
name="George Clooney",
obfuscated_id="abc123",
),
role=models.UserRole.VIEWER,
),
], removed_roles=[
models.UserRoleSpecification(
person=models.Person(
name="George Clooney",
obfuscated_id="abc123",
),
role=models.UserRole.VERIFIER,
),
], audience_filters=[
{
"field_name": "type",
"values": [
{
"value": "Spreadsheet",
"relation_type": models.RelationType.EQUALS,
},
{
"value": "Presentation",
"relation_type": models.RelationType.EQUALS,
},
],
},
])
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
name |
str |
✔️ |
The unique name of the Collection. |
id |
int |
✔️ |
The ID of the Collection to modify. |
locale |
Optional[str] |
➖ |
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en. |
description |
Optional[str] |
➖ |
A brief summary of the Collection's contents. |
added_roles |
List[models.UserRoleSpecification] |
➖ |
A list of added user roles for the Collection. |
removed_roles |
List[models.UserRoleSpecification] |
➖ |
A list of removed user roles for the Collection. |
audience_filters |
List[models.FacetFilter] |
➖ |
Filters which restrict who should see this Collection. Values are taken from the corresponding filters in people search. |
icon |
Optional[str] |
➖ |
The emoji icon of this Collection. |
admin_locked |
Optional[bool] |
➖ |
Indicates whether edits are allowed for everyone or only admins. |
parent_id |
Optional[int] |
➖ |
The parent of this Collection, or 0 if it's a top-level Collection. |
thumbnail |
Optional[models.Thumbnail] |
➖ |
N/A |
allowed_datasource |
Optional[str] |
➖ |
The datasource type this Collection can hold. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.EditCollectionResponse
| Error Type |
Status Code |
Content Type |
| errors.CollectionError |
422 |
application/json |
| errors.GleanError |
4XX, 5XX |
*/* |
Update the URL, Glean Document ID, description of an item within a Collection given its ID.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.client.collections.update_item(collection_id=142375, item_id="<id>")
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
collection_id |
int |
✔️ |
The ID of the Collection to edit CollectionItems in. |
item_id |
str |
✔️ |
The ID of the CollectionItem to edit. |
locale |
Optional[str] |
➖ |
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en. |
name |
Optional[str] |
➖ |
The optional name of the Collection item. |
description |
Optional[str] |
➖ |
A helpful description of why this CollectionItem is in the Collection that it's in. |
icon |
Optional[str] |
➖ |
The emoji icon for this CollectionItem. Only used for Text type items. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.EditCollectionItemResponse
| Error Type |
Status Code |
Content Type |
| errors.GleanError |
4XX, 5XX |
*/* |
Read the details of a Collection given its ID. Does not fetch items in this Collection.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.client.collections.retrieve(id=425335)
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
id |
int |
✔️ |
The ID of the Collection to be retrieved. |
locale |
Optional[str] |
➖ |
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en. |
with_items |
Optional[bool] |
➖ |
Whether or not to include the Collection Items in this Collection. Only request if absolutely required, as this is expensive. |
with_hierarchy |
Optional[bool] |
➖ |
Whether or not to include the top level Collection in this Collection's hierarchy. |
allowed_datasource |
Optional[str] |
➖ |
The datasource allowed in the Collection returned. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.GetCollectionResponse
| Error Type |
Status Code |
Content Type |
| errors.GleanError |
4XX, 5XX |
*/* |
List all existing Collections.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.client.collections.list()
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
locale |
Optional[str] |
➖ |
The client's preferred locale in rfc5646 format (e.g. en, ja, pt-BR). If omitted, the Accept-Language will be used. If not present or not supported, defaults to the closest match or en. |
include_audience |
Optional[bool] |
➖ |
Whether to include the audience filters with the listed Collections. |
include_roles |
Optional[bool] |
➖ |
Whether to include the editor roles with the listed Collections. |
allowed_datasource |
Optional[str] |
➖ |
The datasource type this Collection can hold. ANSWERS - for Collections representing answer boards |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.ListCollectionsResponse
| Error Type |
Status Code |
Content Type |
| errors.GleanError |
4XX, 5XX |
*/* |