Create a user-generated shortcut that contains an alias and destination URL.
from glean.api_client import Glean, models
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.client.shortcuts.create(data={
"added_roles": [
models.UserRoleSpecification(
person=models.Person(
name="George Clooney",
obfuscated_id="abc123",
),
role=models.UserRole.VERIFIER,
),
],
"removed_roles": [
models.UserRoleSpecification(
person=models.Person(
name="George Clooney",
obfuscated_id="abc123",
),
role=models.UserRole.VIEWER,
),
],
})
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
data |
models.ShortcutMutableProperties |
✔️ |
N/A |
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. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.CreateShortcutResponse
| Error Type |
Status Code |
Content Type |
| errors.GleanError |
4XX, 5XX |
*/* |
Delete an existing user-generated shortcut.
from glean.api_client import Glean
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
glean.client.shortcuts.delete(id=975862)
# Use the SDK ...
| Parameter |
Type |
Required |
Description |
id |
int |
✔️ |
The opaque id of the user generated content. |
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. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
| Error Type |
Status Code |
Content Type |
| errors.GleanError |
4XX, 5XX |
*/* |
Read a particular shortcut's details 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.shortcuts.retrieve(get_shortcut_request={
"alias": "<value>",
})
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
get_shortcut_request |
models.GetShortcutRequest |
✔️ |
GetShortcut request |
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. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.GetShortcutResponse
| Error Type |
Status Code |
Content Type |
| errors.GleanError |
4XX, 5XX |
*/* |
List shortcuts editable/owned by the currently authenticated user.
from glean.api_client import Glean, models
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.client.shortcuts.list(page_size=10, 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 |
Example |
page_size |
int |
✔️ |
N/A |
10 |
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_fields |
List[models.ListShortcutsPaginatedRequestIncludeField] |
➖ |
Array of fields/data to be included in response that are not included by default |
|
cursor |
Optional[str] |
➖ |
A token specifying the position in the overall results to start at. Received from the endpoint and iterated back. Currently being used as page no (as we implement offset pagination) |
|
filters |
List[models.FacetFilter] |
➖ |
A list of filters for the query. An AND is assumed between different filters. We support filters on Go Link name, author, department and type. |
|
sort |
Optional[models.SortOptions] |
➖ |
N/A |
|
query |
Optional[str] |
➖ |
Search query that should be a substring in atleast one of the fields (alias , inputAlias, destinationUrl, description). Empty query does not filter shortcuts. |
|
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
|
models.ListShortcutsPaginatedResponse
| Error Type |
Status Code |
Content Type |
| errors.GleanError |
4XX, 5XX |
*/* |
Updates the shortcut with the given ID.
from glean.api_client import Glean, models
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:
res = glean.client.shortcuts.update(id=268238, added_roles=[
models.UserRoleSpecification(
person=models.Person(
name="George Clooney",
obfuscated_id="abc123",
),
role=models.UserRole.ANSWER_MODERATOR,
),
], removed_roles=[
models.UserRoleSpecification(
person=models.Person(
name="George Clooney",
obfuscated_id="abc123",
),
role=models.UserRole.ANSWER_MODERATOR,
),
])
# Handle response
print(res)
| Parameter |
Type |
Required |
Description |
id |
int |
✔️ |
The opaque id of the user generated content. |
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. |
input_alias |
Optional[str] |
➖ |
Link text following go/ prefix as entered by the user. |
destination_url |
Optional[str] |
➖ |
Destination URL for the shortcut. |
destination_document_id |
Optional[str] |
➖ |
Glean Document ID for the URL, if known. |
description |
Optional[str] |
➖ |
A short, plain text blurb to help people understand the intent of the shortcut. |
unlisted |
Optional[bool] |
➖ |
Whether this shortcut is unlisted or not. Unlisted shortcuts are visible to author + admins only. |
url_template |
Optional[str] |
➖ |
For variable shortcuts, contains the URL template; note, destinationUrl contains default URL. |
added_roles |
List[models.UserRoleSpecification] |
➖ |
A list of user roles added for the Shortcut. |
removed_roles |
List[models.UserRoleSpecification] |
➖ |
A list of user roles removed for the Shortcut. |
retries |
Optional[utils.RetryConfig] |
➖ |
Configuration to override the default retry behavior of the client. |
models.UpdateShortcutResponse
| Error Type |
Status Code |
Content Type |
| errors.GleanError |
4XX, 5XX |
*/* |