Indexing API
- Documents
- Permissions
- Troubleshooting
- Datasources
- Authentication
- People
- Shortcuts
Client API
- Activity
- Announcements
- Answers
- Authentication
- Chat
- Agents
- Collections
- Documents
- Insights
- Messages
- Pins
- Search
- Entities
- Shortcuts
- Summarize
- Verification
Shortcuts
Create shortcut
Shortcuts
Create shortcut
Create a user-generated shortcut that contains an alias and destination URL.
from datetime import date
from glean import Glean, models
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as g_client:
res = g_client.client.shortcuts.create(data={
"added_roles": [
models.UserRoleSpecification(
person=models.Person(
name="George Clooney",
obfuscated_id="abc123",
related_documents=[],
metadata=models.PersonMetadata(
type=models.PersonMetadataType.FULL_TIME,
title="Actor",
department="Movies",
email="george@example.com",
location="Hollywood, CA",
phone="6505551234",
photo_url="https://example.com/george.jpg",
start_date=date.fromisoformat("2000-01-23"),
datasource_profile=[
models.DatasourceProfile(
datasource="github",
handle="<value>",
),
],
query_suggestions=models.QuerySuggestionList(
suggestions=[],
),
invite_info=models.InviteInfo(
invites=[],
),
custom_fields=[],
badges=[
models.Badge(
key="deployment_name_new_hire",
display_name="New hire",
icon_config=models.IconConfig(
color="#343CED",
key="person_icon",
icon_type=models.IconType.GLYPH,
name="user",
),
),
],
),
),
role=models.UserRole.OWNER,
),
models.UserRoleSpecification(
role=models.UserRole.VERIFIER,
),
],
"removed_roles": [
models.UserRoleSpecification(
role=models.UserRole.VERIFIER,
),
models.UserRoleSpecification(
role=models.UserRole.ANSWER_MODERATOR,
),
models.UserRoleSpecification(
role=models.UserRole.OWNER,
),
],
})
# Handle response
print(res)
{
"shortcut": {
"id": 123,
"permissions": {
"write": {
"scopeType": "GLOBAL",
"create": true,
"update": true,
"delete": true
}
},
"createdBy": {
"name": "George Clooney",
"obfuscatedId": "abc123"
},
"createTime": "2023-11-07T05:31:56Z",
"updatedBy": {
"name": "George Clooney",
"obfuscatedId": "abc123"
},
"updateTime": "2023-11-07T05:31:56Z",
"destinationDocument": {},
"intermediateUrl": "<string>",
"viewPrefix": "<string>",
"isExternal": true,
"editUrl": "<string>",
"alias": "<string>",
"title": "<string>",
"roles": [
{}
]
},
"error": {
"errorType": "NO_PERMISSION"
}
}
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Headers
Email address of a user on whose behalf the request is intended to be made (should be non-empty only for global tokens).
Auth type being used to access the endpoint (should be non-empty only for global tokens).
Body
application/json
CreateShortcut request
The body is of type object
.
Response
200
application/json
OK
The response is of type object
.
from datetime import date
from glean import Glean, models
import os
with Glean(
api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as g_client:
res = g_client.client.shortcuts.create(data={
"added_roles": [
models.UserRoleSpecification(
person=models.Person(
name="George Clooney",
obfuscated_id="abc123",
related_documents=[],
metadata=models.PersonMetadata(
type=models.PersonMetadataType.FULL_TIME,
title="Actor",
department="Movies",
email="george@example.com",
location="Hollywood, CA",
phone="6505551234",
photo_url="https://example.com/george.jpg",
start_date=date.fromisoformat("2000-01-23"),
datasource_profile=[
models.DatasourceProfile(
datasource="github",
handle="<value>",
),
],
query_suggestions=models.QuerySuggestionList(
suggestions=[],
),
invite_info=models.InviteInfo(
invites=[],
),
custom_fields=[],
badges=[
models.Badge(
key="deployment_name_new_hire",
display_name="New hire",
icon_config=models.IconConfig(
color="#343CED",
key="person_icon",
icon_type=models.IconType.GLYPH,
name="user",
),
),
],
),
),
role=models.UserRole.OWNER,
),
models.UserRoleSpecification(
role=models.UserRole.VERIFIER,
),
],
"removed_roles": [
models.UserRoleSpecification(
role=models.UserRole.VERIFIER,
),
models.UserRoleSpecification(
role=models.UserRole.ANSWER_MODERATOR,
),
models.UserRoleSpecification(
role=models.UserRole.OWNER,
),
],
})
# Handle response
print(res)
{
"shortcut": {
"id": 123,
"permissions": {
"write": {
"scopeType": "GLOBAL",
"create": true,
"update": true,
"delete": true
}
},
"createdBy": {
"name": "George Clooney",
"obfuscatedId": "abc123"
},
"createTime": "2023-11-07T05:31:56Z",
"updatedBy": {
"name": "George Clooney",
"obfuscatedId": "abc123"
},
"updateTime": "2023-11-07T05:31:56Z",
"destinationDocument": {},
"intermediateUrl": "<string>",
"viewPrefix": "<string>",
"isExternal": true,
"editUrl": "<string>",
"alias": "<string>",
"title": "<string>",
"roles": [
{}
]
},
"error": {
"errorType": "NO_PERMISSION"
}
}