### Run an Example Script Source: https://github.com/gleanwork/api-client-python/blob/main/examples/README.md Follow these steps to navigate to the examples directory, install dependencies using poetry, and run an example Python script. ```bash # 1. cd into the examples repo cd api-client-python/examples # 2. Install dependencies poetry install # 3. Run the example file poetry run python ask_example.py ``` -------------------------------- ### Start Mock Server with Go Source: https://github.com/gleanwork/api-client-python/blob/main/tests/mockserver/README.md Use this command to start the mock server directly if you have the Go programming language toolchain installed. ```shell go run . ``` -------------------------------- ### Build and Start Mock Server with Docker Source: https://github.com/gleanwork/api-client-python/blob/main/tests/mockserver/README.md Build the mock server image and run it using Docker. Ensure Docker is installed. ```shell docker build -t mockserver . ``` ```shell docker run -i -p 18080:18080 -t --rm mockserver ``` -------------------------------- ### Example HypertextField Usage Source: https://github.com/gleanwork/api-client-python/blob/main/docs/models/additionalfielddefinition.md Illustrates how to format a HypertextField object. This example shows a simple key-value pair representing a hypertext link. ```json {"anchor":"Glean","hyperlink":"https://glean.com"} ``` -------------------------------- ### Install Glean API Client with PIP Source: https://github.com/gleanwork/api-client-python/blob/main/README.md Install the Glean API Client using pip, the standard package installer for Python. ```bash pip install glean-api-client ``` -------------------------------- ### Create Document Metadata Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Example of creating document metadata with various fields. ```python models.DocumentMetadata( datasource="datasource", object_type="Feature Request", container="container", parent_id="JIRA_EN-1337", mime_type="mimeType", document_id="documentId", create_time=parse_datetime("2000-01-23T04:56:07.000Z"), update_time=parse_datetime("2000-01-23T04:56:07.000Z"), author=models.Person( name="name", obfuscated_id="", ), components=[ "Backend", "Networking", ], status="[\"Done\"]", custom_data={ "someCustomField": models.CustomDataValue(), }, ) ``` -------------------------------- ### Create Shortcut Object Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Example of creating a Shortcut object with input_alias, created_by, updated_by, and destination_document. ```python models.Shortcut( input_alias="", created_by=models.Person( name="George Clooney", obfuscated_id="abc123", ), updated_by=models.Person( name="George Clooney", obfuscated_id="abc123", ), destination_document=models.Document( container_document=models.Document( ``` -------------------------------- ### Example Usage of Announcements SDK Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Demonstrates how to construct a complex object with nested metadata and person details for an announcement. ```python updated_by=models.Person( name="George Clooney", obfuscated_id="abc123", ), verification=models.Verification( state=models.State.DEPRECATED, metadata=models.VerificationMetadata( last_verifier=models.Person( name="George Clooney", obfuscated_id="abc123", ), document=models.Document( container_document=models.Document( metadata=models.DocumentMetadata( datasource="datasource", object_type="Feature Request", container="container", parent_id="JIRA_EN-1337", mime_type="mimeType", document_id="documentId", create_time=parse_datetime("2000-01-23T04:56:07.000Z"), update_time=parse_datetime("2000-01-23T04:56:07.000Z"), author=models.Person( name="name", obfuscated_id="", ), components=[ "Backend", "Networking", ], status="[\"Done\"]", custom_data={ "someCustomField": models.CustomDataValue(), }, ), ), parent_document=models.Document( metadata=models.DocumentMetadata( datasource="datasource", object_type="Feature Request", container="container", parent_id="JIRA_EN-1337", mime_type="mimeType", document_id="documentId", create_time=parse_datetime("2000-01-23T04:56:07.000Z"), update_time=parse_datetime("2000-01-23T04:56:07.000Z"), author=models.Person( name="name", obfuscated_id="", ), components=[ "Backend", "Networking", ], status="[\"Done\"]", custom_data={ "someCustomField": models.CustomDataValue(), }, ), ), metadata=models.DocumentMetadata( datasource="datasource", object_type="Feature Request", container="container", parent_id="JIRA_EN-1337", mime_type="mimeType", document_id="documentId", create_time=parse_datetime("2000-01-23T04:56:07.000Z"), update_time=parse_datetime("2000-01-23T04:56:07.000Z"), author=models.Person( name="name", obfuscated_id="", ), components=[ "Backend", "Networking", ], status="[\"Done\"]", custom_data={ "someCustomField": models.CustomDataValue(), }, ), ), ), ), ``` -------------------------------- ### Create Document with Metadata Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Example of creating a document with detailed metadata, including author, components, and custom data. Ensure all required fields are populated. ```python models.Document( parent_document=models.Document( metadata=models.DocumentMetadata( datasource="datasource", object_type="Feature Request", container="container", parent_id="JIRA_EN-1337", mime_type="mimeType", document_id="documentId", create_time=parse_datetime("2000-01-23T04:56:07.000Z"), update_time=parse_datetime("2000-01-23T04:56:07.000Z"), author=models.Person( name="name", obfuscated_id="", ), components=[ "Backend", "Networking", ], status="[\"Done\"]", custom_data={ "someCustomField": models.CustomDataValue(), }, ), ), metadata=models.DocumentMetadata( datasource="datasource", object_type="Feature Request", container="container", parent_id="JIRA_EN-1337", mime_type="mimeType", document_id="documentId", create_time=parse_datetime("2000-01-23T04:56:07.000Z"), update_time=parse_datetime("2000-01-23T04:56:07.000Z"), author=models.Person( name="name", obfuscated_id="", ), components=[ "Backend", "Networking", ], status="[\"Done\"]", custom_data={ "someCustomField": models.CustomDataValue(), }, ), ) ``` -------------------------------- ### Create Announcement with Collection and Document Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Example demonstrating how to construct an announcement with nested collections and document details. This is useful for setting up complex announcement structures. ```python status="[\"Done\"]", custom_data={ "someCustomField": models.CustomDataValue(), }, ), ), ), collection=models.Collection( name="", description="shy versus chunder monocle", audience_filters=[ models.FacetFilter( field_name="type", values=[ models.FacetFilterValue( value="Spreadsheet", relation_type=models.RelationType.EQUALS, ), models.FacetFilterValue( value="Presentation", relation_type=models.RelationType.EQUALS, ), ], ), ], id=455912, creator=models.Person( name="George Clooney", obfuscated_id="abc123", ), updated_by=models.Person( name="George Clooney", obfuscated_id="abc123", ), children=[ models.Collection( name="", description="though mismatch noisily jive worth meh following hmph analyse guidance", audience_filters=[ models.FacetFilter( field_name="type", values=[ models.FacetFilterValue( value="Spreadsheet", relation_type=models.RelationType.EQUALS, ), models.FacetFilterValue( value="Presentation", relation_type=models.RelationType.EQUALS, ), ], ), ], id=432713, creator=models.Person( name="George Clooney", obfuscated_id="abc123", ), updated_by=models.Person( name="George Clooney", obfuscated_id="abc123", ), ), ], ), item_type=models.CollectionItemItemType.URL, ), ], ), ], source_document=models.Document( container_document=models.Document( ``` -------------------------------- ### Parent Document Example Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Shows how to structure a parent document, referencing its metadata. ```python parent_document=models.Document( metadata=models.DocumentMetadata( datasource="datasource", object_type="Feature Request", container="container", parent_id="JIRA_EN-1337", mime_type="mimeType", document_id="documentId", create_time=parse_datetime("2000-01-23T04:56:07.000Z"), update_time=parse_datetime("2000-01-23T04:56:07.000Z"), author=models.Person( name="name", obfuscated_id="", ), components=[ "Backend", "Networking", ], status="[\"Done\"]", custom_data={ "someCustomField": models.CustomDataValue(), }, ), ), ``` -------------------------------- ### Create Query Suggestion List Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Example of creating a QuerySuggestionList object, including a Person object for suggestions. ```python query_suggestions=models.QuerySuggestionList( person=models.Person( name="George Clooney", obfuscated_id="abc123", ), ), ``` -------------------------------- ### Customize Mock Server Logging Level Source: https://github.com/gleanwork/api-client-python/blob/main/tests/mockserver/README.md Examples of how to enable debug logging for the mock server, shown for both `go run` and `docker run`. ```shell # via `go run` go run . -log-level=DEBUG ``` ```shell # via `docker run` docker run -i -p 18080:18080 -t --rm mockserver -log-level=DEBUG ``` -------------------------------- ### Create Chat - GPT Agent Example Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/clientchat/README.md Shows how to create a chat using the GPT agent configuration. Ensure the GLEAN_API_TOKEN environment variable is set. ```python from glean.api_client import Glean, models import os with Glean( api_token=os.getenv("GLEAN_API_TOKEN", ""), ) as glean: res = glean.client.chat.create(messages=[ { "fragments": [ models.ChatMessageFragment( text="Who was the first person to land on the moon?", ), ], }, ], agent_config={ "agent": models.AgentEnum.GPT, }, timeout_millis=30000) # Handle response print(res) ``` -------------------------------- ### Create Chat - Citation Response Example Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/clientchat/README.md Example of creating a chat with Glean AI, focusing on handling citation responses. Ensure the GLEAN_API_TOKEN environment variable is set. ```python from glean.api_client import Glean import os with Glean( api_token=os.getenv("GLEAN_API_TOKEN", ""), ) as glean: res = glean.client.chat.create(messages=[], timeout_millis=30000) # Handle response print(res) ``` -------------------------------- ### Extracted QnA Example Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Demonstrates the structure for ExtractedQnA, including question results with titles, URLs, and snippets. ```python extracted_qn_a=models.ExtractedQnA( question_result=models.SearchResult( title="title", url="https://example.com/foo/bar", native_app_url="slack://foo/bar", snippets=[ models.SearchResultSnippet( mime_type="mimeType", snippet="snippet", ), ], must_include_suggestions=models.QuerySuggestionList( suggestions=[ models.QuerySuggestion( query="app:github type:pull author:mortimer", label="Mortimer's PRs", datasource="github", ), ] ``` -------------------------------- ### Create Customer Object Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Example of creating a Customer object with ID, company details, POC, and merged customers. ```python models.Customer( id="", company=models.Company( name="", location="New York City", industry="Finances", about="Financial, software, data, and media company headquartered in Midtown Manhattan, New York City", ), poc=[ models.Person( name="George Clooney", obfuscated_id="abc123", ), ], merged_customers=[ models.Customer( id="", company=models.Company( name="", location="New York City", industry="Finances", about="Financial, software, data, and media company headquartered in Midtown Manhattan, New York City", ), notes="CIO is interested in trying out the product.", ), ], ) ``` -------------------------------- ### Create Document Object Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Example of creating a Document object with metadata and a parent document. ```python models.Document( metadata=models.DocumentMetadata( datasource="datasource", object_type="Feature Request", container="container", parent_id="JIRA_EN-1337", mime_type="mimeType", document_id="documentId", create_time=parse_datetime("2000-01-23T04:56:07.000Z"), update_time=parse_datetime("2000-01-23T04:56:07.000Z"), author=models.Person( name="name", obfuscated_id="", ), components=[ "Backend", "Networking", ], status="[\"Done\"]", custom_data={ "someCustomField": models.CustomDataValue(), }, ), parent_document=models.Document( metadata=models.DocumentMetadata( datasource="datasource", object_type="Feature Request", container="container", parent_id="JIRA_EN-1337", mime_type="mimeType", document_id="documentId", create_time=parse_datetime("2000-01-23T04:56:07.000Z"), update_time=parse_datetime("2000-01-23T04:56:07.000Z"), author=models.Person( name="name", obfuscated_id="", ), components=[ "Backend", "Networking", ], status="[\"Done\"]", custom_data={ "someCustomField": models.CustomDataValue(), }, ), ), metadata=models.DocumentMetadata( datasource="datasource", object_type="Feature Request", container="container", parent_id="JIRA_EN-1337", mime_type="mimeType", document_id="documentId", create_time=parse_datetime("2000-01-23T04:56:07.000Z"), update_time=parse_datetime("2000-01-23T04:56:07.000Z"), author=models.Person( name="name", obfuscated_id="", ), components=[ "Backend", "Networking", ], status="[\"Done\"]", custom_data={ "someCustomField": models.CustomDataValue(), }, ), ) ``` -------------------------------- ### Constructing a Search Query with Snippets and Suggestions Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Example of how to build a search query object, including specifying search snippets and mandatory suggestions for a person. ```python models.SearchRequest( query=models.Query( text="query", search_snippets=models.SearchSnippetList( snippets=[ models.SearchResultSnippet( mime_type="mimeType", snippet="snippet", ), ], must_include_suggestions=models.QuerySuggestionList( person=models.Person( name="George Clooney", obfuscated_id="abc123", ), ), ), ), ) ``` -------------------------------- ### Example Announcement Usage Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Demonstrates the construction of an announcement object with nested metadata and person details. This is useful for creating detailed announcement entries. ```python obfuscated_id="", ), components=[ "Backend", "Networking", ], status="[\"Done\"]", custom_data={ "someCustomField": models.CustomDataValue(), }, ), ), parent_document=models.Document( metadata=models.DocumentMetadata( datasource="datasource", object_type="Feature Request", container="container", parent_id="JIRA_EN-1337", mime_type="mimeType", document_id="documentId", create_time=parse_datetime("2000-01-23T04:56:07.000Z"), update_time=parse_datetime("2000-01-23T04:56:07.000Z"), author=models.Person( name="name", obfuscated_id="", ), components=[ "Backend", "Networking", ], status="[\"Done\"]", custom_data={ "someCustomField": models.CustomDataValue(), }, ), ), metadata=models.DocumentMetadata( datasource="datasource", object_type="Feature Request", container="container", parent_id="JIRA_EN-1337", mime_type="mimeType", document_id="documentId", create_time=parse_datetime("2000-01-23T04:56:07.000Z"), update_time=parse_datetime("2000-01-23T04:56:07.000Z"), author=models.Person( name="name", obfuscated_id="", ), components=[ "Backend", "Networking", ], status="[\"Done\"]", custom_data={ "someCustomField": models.CustomDataValue(), }, ), ), shortcut=models.Shortcut( input_alias="", created_by=models.Person( name="George Clooney", obfuscated_id="abc123", ), updated_by=models.Person( name="George Clooney", obfuscated_id="abc123", ), destination_document=models.Document( container_document=models.Document( ``` -------------------------------- ### Create Document with Parent Document Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Example demonstrating how to create a Document object that includes a parent Document, replicating metadata structure for both. ```python container_document=models.Document( metadata=models.DocumentMetadata( datasource="datasource", object_type="Feature Request", container="container", parent_id="JIRA_EN-1337", mime_type="mimeType", document_id="documentId", create_time=parse_datetime("2000-01-23T04:56:07.000Z"), update_time=parse_datetime("2000-01-23T04:56:07.000Z"), author=models.Person( name="name", obfuscated_id="", ), components=[ "Backend", "Networking", ], status="[\"Done\"]", custom_data={ "someCustomField": models.CustomDataValue(), }, ), ), parent_document=models.Document( metadata=models.DocumentMetadata( datasource="datasource", object_type="Feature Request", container="container", parent_id="JIRA_EN-1337", mime_type="mimeType", document_id="documentId", create_time=parse_datetime("2000-01-23T04:56:07.000Z"), update_time=parse_datetime("2000-01-23T04:56:07.000Z"), author=models.Person( name="name", obfuscated_id="", ), components=[ "Backend", "Networking", ], status="[\"Done\"]", custom_data={ "someCustomField": models.CustomDataValue(), }, ), ), metadata=models.DocumentMetadata( datasource="datasource", object_type="Feature Request", container="container", parent_id="JIRA_EN-1337", mime_type="mimeType", document_id="documentId", create_time=parse_datetime("2000-01-23T04:56:07.000Z"), update_time=parse_datetime("2000-01-23T04:56:07.000Z"), author=models.Person( name="name", obfuscated_id="", ), components=[ "Backend", "Networking", ], status="[\"Done\"]", custom_data={ "someCustomField": models.CustomDataValue(), }, ), ), ``` -------------------------------- ### Python AuthConfigType Example Source: https://github.com/gleanwork/api-client-python/blob/main/docs/models/authconfigtype.md Demonstrates how to import and use AuthConfigType in Python. Unrecognized values are captured as UnrecognizedStr. ```python from glean.api_client.models import AuthConfigType value = AuthConfigType.NONE # Open enum: unrecognized values are captured as UnrecognizedStr ``` -------------------------------- ### Constructing a Search Query with Snippets and Suggestions Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Example demonstrating how to build a search query object, including specifying a native app URL, search snippets with mime types, and must-include suggestions with person details. ```python models.SearchQuery( query="query", native_app_url="slack://foo/bar", snippets=[ models.SearchResultSnippet( mime_type="mimeType", snippet="snippet", ), ], must_include_suggestions=models.QuerySuggestionList( person=models.Person( name="George Clooney", obfuscated_id="abc123", ), ), ) ``` -------------------------------- ### Create Announcement with Custom Data and Reminders Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Example demonstrating how to create an announcement with custom data, reminders, and candidate verifiers. This is useful for setting up complex announcements with specific notification and verification requirements. ```python custom_data={ "someCustomField": models.CustomDataValue(), }, ), ), reminders=[ models.Reminder( assignee=models.Person( name="George Clooney", obfuscated_id="abc123", ), requestor=models.Person( name="George Clooney", obfuscated_id="abc123", ), remind_at=69479, ), ], last_reminder=models.Reminder( assignee=models.Person( name="George Clooney", obfuscated_id="abc123", ), requestor=models.Person( name="George Clooney", obfuscated_id="abc123", ), remind_at=877321, ), candidate_verifiers=[ models.Person( name="George Clooney", obfuscated_id="abc123", ), ], ), ), collections=[ models.Collection( name="", description="ew or every verbally", audience_filters=[ models.FacetFilter( field_name="type", values=[ models.FacetFilterValue( value="Spreadsheet", relation_type=models.RelationType.EQUALS, ), models.FacetFilterValue( value="Presentation", relation_type=models.RelationType.EQUALS, ), ], ), ], id=297273, creator=models.Person( name="George Clooney", obfuscated_id="abc123", ), updated_by=models.Person( name="George Clooney", obfuscated_id="abc123", ), items=[ models.CollectionItem( collection_id=896121, created_by=models.Person( name="George Clooney", obfuscated_id="abc123", ), document=models.Document( container_document=models.Document( metadata=models.DocumentMetadata( datasource="datasource", object_type="Feature Request", container="container", parent_id="JIRA_EN-1337", mime_type="mimeType", document_id="documentId", create_time=parse_datetime("2000-01-23T04:56:07.000Z"), update_time=parse_datetime("2000-01-23T04:56:07.000Z"), author=models.Person( name="name", ``` -------------------------------- ### CustomFieldValuePerson Example Source: https://github.com/gleanwork/api-client-python/blob/main/docs/models/customfieldvalue.md Example of how to assign a person type to a custom field value. ```python value: models.CustomFieldValuePerson = /* values here */ ``` -------------------------------- ### CustomFieldValueHyperlink Example Source: https://github.com/gleanwork/api-client-python/blob/main/docs/models/customfieldvalue.md Example of how to assign a hyperlink type to a custom field value. ```python value: models.CustomFieldValueHyperlink = /* values here */ ``` -------------------------------- ### Instantiate FeedbackChannel Source: https://github.com/gleanwork/api-client-python/blob/main/docs/models/feedbackchannel.md Import and use the FeedbackChannel model to specify a feedback source. ```python from glean.api_client.models import FeedbackChannel value = FeedbackChannel.COMPANY ``` -------------------------------- ### CustomFieldValueStr Example Source: https://github.com/gleanwork/api-client-python/blob/main/docs/models/customfieldvalue.md Example of how to assign a string type to a custom field value. ```python value: models.CustomFieldValueStr = /* values here */ ``` -------------------------------- ### Admin Search Request Example Source: https://github.com/gleanwork/api-client-python/blob/main/docs/models/adminsearchrequest.md An example of an admin search request object with facet filters for type and department. ```json { "trackingToken": "trackingToken", "query": "vacation policy", "pageSize": 10, "requestOptions": { "facetFilters": [ { "fieldName": "type", "values": [ { "value": "article", "relationType": "EQUALS" }, { "value": "document", "relationType": "EQUALS" } ] }, { "fieldName": "department", "values": [ { "value": "engineering", "relationType": "EQUALS" } ] } ] } } ``` -------------------------------- ### Configure SDK with Constructor Options Source: https://github.com/gleanwork/api-client-python/blob/main/README.md Initialize the Glean client with constructor options to enable experimental features and exclude deprecated endpoints. Note that environment variables take precedence if both are set. ```python import os from glean.api_client import Glean glean = Glean( api_token=os.environ.get("GLEAN_API_TOKEN", ""), server_url="https://mycompany-be.glean.com", exclude_deprecated_after="2026-10-15", include_experimental=True, ) ``` -------------------------------- ### Get Datasource Instance Configuration Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/datasources/README.md Retrieves the greenlisted configuration values for a specific datasource instance. Use this to get publicly exposed configuration keys. ```python from glean.api_client import Glean import os with Glean( api_token=os.getenv("GLEAN_API_TOKEN", ""), ) as glean: res = glean.datasources.get_datasource_instance_configuration(datasource_id="o365sharepoint", instance_id="o365sharepoint_abc123") # Handle response print(res) ``` -------------------------------- ### Client.Governance.Data.Policies - retrieve Source: https://github.com/gleanwork/api-client-python/blob/main/README.md Gets specified policy. ```APIDOC ## retrieve ### Description Gets specified policy. ### Method GET ### Endpoint /governance/data/policies/{policy_id} ### Parameters #### Path Parameters - **policy_id** (string) - Required - The ID of the policy to retrieve. ### Response #### Success Response (200) - **policy** (object) - The policy object. ``` -------------------------------- ### Instantiate UIOptions Source: https://github.com/gleanwork/api-client-python/blob/main/docs/models/uioptions.md Demonstrates how to import and use the UIOptions enum. Unrecognized values are handled as UnrecognizedStr. ```python from glean.api_client.models import UIOptions value = UIOptions.NONE # Open enum: unrecognized values are captured as UnrecognizedStr ``` -------------------------------- ### Indexing.Datasource Source: https://github.com/gleanwork/api-client-python/blob/main/README.md Method to get the status of a datasource (Beta). ```APIDOC ## Indexing.Datasource ### Description Provides status information for datasources (Beta). ### Method - **status**: Gets the datasource status. ``` -------------------------------- ### Get Agent Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/clientagents/README.md Retrieves information about a specific agent. ```APIDOC ## GET /agents/{agent_id} ### Description Retrieves information about a specific agent. ### Method GET ### Endpoint /agents/{agent_id} ### Parameters #### Path Parameters - **agent_id** (str) - Required - The ID of the agent. #### Query Parameters - **locale** (Optional[str]) - Optional - 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`. - **timezone_offset** (Optional[int]) - Optional - The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC. - **retries** (Optional[utils.RetryConfig]) - Optional - Configuration to override the default retry behavior of the client. ### Response #### Success Response (200) - **models.Agent** - The agent object. #### Response Example { "example": "response body" } ``` -------------------------------- ### retrieve_files Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/clientchat/README.md Get files uploaded by a user for Chat. ```APIDOC ## GET /rest/api/v1/chat/files ### Description Get files uploaded by a user for Chat. ### Method GET ### Endpoint /rest/api/v1/chat/files ### Response #### Success Response (200) - **files** (array) - An array of information about the uploaded files. - **file_id** (string) - The ID of the uploaded file. - **file_name** (string) - The name of the uploaded file. ``` -------------------------------- ### retrieve_application Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/clientchat/README.md Gets the metadata for a custom Chat application. ```APIDOC ## GET /rest/api/v1/chat/application ### Description Gets the metadata for a custom Chat application. ### Method GET ### Endpoint /rest/api/v1/chat/application ### Response #### Success Response (200) - **application** (object) - The metadata for the custom chat application. - **name** (string) - The name of the application. - **description** (string) - A description of the application. ``` -------------------------------- ### models.ResponseBody2 Type Source: https://github.com/gleanwork/api-client-python/blob/main/docs/models/createcollectionresponse.md Example of how to declare a variable of type models.ResponseBody2. ```python value: models.ResponseBody2 = /* values here */ ``` -------------------------------- ### Instantiate WorkflowFeedbackInfoSource Source: https://github.com/gleanwork/api-client-python/blob/main/docs/models/workflowfeedbackinfosource.md Demonstrates how to import and assign a value to WorkflowFeedbackInfoSource. Use this to specify the origin of feedback. ```python from glean.api_client.models import WorkflowFeedbackInfoSource value = WorkflowFeedbackInfoSource.ZERO_STATE ``` -------------------------------- ### Accessing Glean Client Namespace Source: https://github.com/gleanwork/api-client-python/blob/main/README.md Demonstrates how to initialize the Glean client and perform a search query. Ensure you have a valid client API token and server URL. ```python from glean.api_client import Glean import os with Glean(api_token="client-token", server_url="https://mycompany-be.glean.com") as glean: search_response = glean.client.search.query(query="search term") print(search_response) ``` -------------------------------- ### models.ResponseBody1 Type Source: https://github.com/gleanwork/api-client-python/blob/main/docs/models/createcollectionresponse.md Example of how to declare a variable of type models.ResponseBody1. ```python value: models.ResponseBody1 = /* values here */ ``` -------------------------------- ### create Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/clientshortcuts/README.md Create a user-generated shortcut that contains an alias and destination URL. ```APIDOC ## POST /rest/api/v1/createshortcut ### Description Create a user-generated shortcut that contains an alias and destination URL. ### Method POST ### Endpoint /rest/api/v1/createshortcut ### Request Body - **added_roles** (array) - Required - A list of user role specifications to add. - **person** (object) - Required - Information about the person. - **name** (string) - Required - The name of the person. - **obfuscated_id** (string) - Required - The obfuscated ID of the person. - **role** (string) - Required - The role to assign (e.g., VERIFIER, VIEWER). - **removed_roles** (array) - Required - A list of user role specifications to remove. - **person** (object) - Required - Information about the person. - **name** (string) - Required - The name of the person. - **obfuscated_id** (string) - Required - The obfuscated ID of the person. - **role** (string) - Required - The role to remove (e.g., VERIFIER, VIEWER). ### Request Example { "data": { "added_roles": [ { "person": { "name": "George Clooney", "obfuscated_id": "abc123" }, "role": "VERIFIER" } ], "removed_roles": [ { "person": { "name": "George Clooney", "obfuscated_id": "abc123" }, "role": "VIEWER" } ] } } ### Response #### Success Response (200) - **res** (object) - The response from the create shortcut operation. ``` -------------------------------- ### Client.Chat - retrieve_files Source: https://github.com/gleanwork/api-client-python/blob/main/README.md Get files uploaded by a user for Chat. ```APIDOC ## retrieve_files ### Description Get files uploaded by a user for Chat. ### Method GET ### Endpoint /chat/files ### Response #### Success Response (200) - **files** (array) - A list of uploaded files. ``` -------------------------------- ### Client.Chat - retrieve_application Source: https://github.com/gleanwork/api-client-python/blob/main/README.md Gets the metadata for a custom Chat application. ```APIDOC ## retrieve_application ### Description Gets the metadata for a custom Chat application. ### Method GET ### Endpoint /chat/application ### Response #### Success Response (200) - **application_metadata** (object) - The metadata for the chat application. ``` -------------------------------- ### Import and Use ActivityEnum Source: https://github.com/gleanwork/api-client-python/blob/main/docs/models/activityenum.md Demonstrates how to import and use the ActivityEnum, including assigning a value and noting how unrecognized values are handled. ```python from glean.api_client.models import ActivityEnum value = ActivityEnum.ALL # Open enum: unrecognized values are captured as UnrecognizedStr ``` -------------------------------- ### retrieve_application Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/clientchat/README.md Gets the Chat application details for the specified application ID. ```APIDOC ## retrieve_application ### Description Gets the Chat application details for the specified application ID. ### Method POST ### Endpoint /rest/api/v1/getchatapplication ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **id** (string) - Required - The ID of the application to retrieve. ### Request Example ```python { "id": "" } ``` ### Response #### Success Response (200) - **application_details** (object) - Description of the application details. #### Response Example ```json { "application_details": { "field1": "value1", "field2": "value2" } } ``` ``` -------------------------------- ### Initialize Glean Client with API Token and Report Activity Source: https://github.com/gleanwork/api-client-python/blob/main/README.md Initialize the Glean client using an API token from an environment variable and report activity events. Ensure the GLEAN_API_TOKEN environment variable is set. ```python from glean.api_client import Glean, models from glean.api_client.utils import parse_datetime import os with Glean( api_token=os.getenv("GLEAN_API_TOKEN", ""), ) as glean: glean.client.activity.report(events=[ { "action": models.ActivityEventAction.HISTORICAL_VIEW, "timestamp": parse_datetime("2000-01-23T04:56:07.000Z"), "url": "https://example.com/", }, { "action": models.ActivityEventAction.SEARCH, "params": { "query": "query", }, "timestamp": parse_datetime("2000-01-23T04:56:07.000Z"), "url": "https://example.com/search?q=query", }, { "action": models.ActivityEventAction.VIEW, "params": { "duration": 20, "referrer": "https://example.com/document", }, "timestamp": parse_datetime("2000-01-23T04:56:07.000Z"), "url": "https://example.com/", }, ]) # Use the SDK ... ``` -------------------------------- ### Create Person Object Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Example of creating a Person object with name and obfuscated_id. ```python models.Person( name="name", obfuscated_id="", ) ``` -------------------------------- ### Get Chat Application Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/clientchat/README.md Retrieves information about a specific chat application by its ID. ```APIDOC ## GET /chat/applications/{id} ### Description Retrieves details for a specific chat application. ### Method GET ### Endpoint /chat/applications/{id} ### Parameters #### Path Parameters - **id** (str) - Required - The id of the Chat application to be retrieved. #### Query Parameters - **locale** (Optional[str]) - Optional - The client's preferred locale in rfc56446 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`. - **timezone_offset** (Optional[int]) - Optional - The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC. - **retries** (Optional[utils.RetryConfig]) - Optional - Configuration to override the default retry behavior of the client. ### Response #### Success Response (200) - **GetChatApplicationResponse** (models.GetChatApplicationResponse) - Description of the response object. ``` -------------------------------- ### Create Person Object Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Example of creating a Person object with name and obfuscated ID. ```python models.Person( name="name", obfuscated_id="", ) ``` ```python models.Person( name="George Clooney", obfuscated_id="abc123", ) ``` -------------------------------- ### Import and Use ManualFeedbackInfoSource Source: https://github.com/gleanwork/api-client-python/blob/main/docs/models/manualfeedbackinfosource.md Demonstrates how to import and use the ManualFeedbackInfoSource enum to specify a feedback source. ```python from glean.api_client.models import ManualFeedbackInfoSource value = ManualFeedbackInfoSource.AUTOCOMPLETE ``` -------------------------------- ### Glean Client Initialization with Instance Variable Source: https://github.com/gleanwork/api-client-python/blob/main/README.md Initializes the Glean client using the `instance` variable to specify the deployment backend. This is useful when you need to target a specific Glean instance. ```APIDOC ## Glean Client Initialization with Instance Variable ### Description Initializes the Glean client using the `instance` variable to specify the deployment backend. This is useful when you need to target a specific Glean instance. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```python from glean.api_client import Glean, models from glean.api_client.utils import parse_datetime import os with Glean( server_idx=0, instance="instance-name", api_token=os.getenv("GLEAN_API_TOKEN", ""), ) as glean: glean.client.activity.report(events=[ { "action": models.ActivityEventAction.HISTORICAL_VIEW, "timestamp": parse_datetime("2000-01-23T04:56:07.000Z"), "url": "https://example.com/", }, { "action": models.ActivityEventAction.SEARCH, "params": { "query": "query", }, "timestamp": parse_datetime("2000-01-23T04:56:07.000Z"), "url": "https://example.com/search?q=query", }, { "action": models.ActivityEventAction.VIEW, "params": { "duration": 20, "referrer": "https://example.com/document", }, "timestamp": parse_datetime("2000-01-23T04:56:07.000Z"), "url": "https://example.com/", }, ]) # Use the SDK ... ``` ### Response #### Success Response (200) None explicitly documented. #### Response Example None explicitly documented. ``` -------------------------------- ### Create Related Documents Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Example of creating a RelatedDocuments object, which includes a QuerySuggestion and a list of SearchResults. ```python related_documents=[ models.RelatedDocuments( query_suggestion=models.QuerySuggestion( query="app:github type:pull author:mortimer", label="Mortimer's PRs", datasource="github", ), results=[ models.SearchResult( title="title", url="https://example.com/foo/bar", native_app_url="slack://foo/bar", ), ]) ], ``` -------------------------------- ### Create Company Object Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Example of creating a Company object with name, location, industry, and about information. ```python models.Company( name="", location="New York City", industry="Finances", about="Financial, software, data, and media company headquartered in Midtown Manhattan, New York City", ) ``` -------------------------------- ### Run a Tool Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/clienttools/README.md Execute the specified tool with provided parameters. ```APIDOC ## run /rest/api/v1/tools/call ### Description Execute the specified tool with provided parameters. ### Method POST ### Endpoint /rest/api/v1/tools/call ### Parameters #### Request Body - **name** (str) - Required - Required name of the tool to execute - **parameters** (Dict[str, models.ToolsCallParameter]) - Required - The parameters for the tool. Each key is the name of the parameter and the value is the parameter object. - **retries** (Optional[utils.RetryConfig]) - Optional - Configuration to override the default retry behavior of the client. ### Response #### Success Response (200) - **response** (models.ToolsCallResponse) - The response object containing the result of the tool execution. ### Errors - errors.GleanError (4XX, 5XX) - An error occurred while executing the tool. ``` -------------------------------- ### Create Announcement with Custom Data and Reminders Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/announcements/README.md Example of creating an announcement with custom data, reminders, and collections. This snippet demonstrates how to structure complex announcement objects. ```python custom_data={ "someCustomField": models.CustomDataValue(), }, ), ), reminders=[ models.Reminder( assignee=models.Person( name="George Clooney", obfuscated_id="abc123", ), requestor=models.Person( name="George Clooney", obfuscated_id="abc123", ), remind_at=627080, ), ], last_reminder=models.Reminder( assignee=models.Person( name="George Clooney", obfuscated_id="abc123", ), requestor=models.Person( name="George Clooney", obfuscated_id="abc123", ), remind_at=642543, ), candidate_verifiers=[ models.Person( name="George Clooney", obfuscated_id="abc123", ), ], ), ), collections=[ models.Collection( name="", description="minus mindless prudent better elderly", audience_filters=[ models.FacetFilter( field_name="type", values=[ models.FacetFilterValue( value="Spreadsheet", relation_type=models.RelationType.EQUALS, ), models.FacetFilterValue( value="Presentation", relation_type=models.RelationType.EQUALS, ), ], ), ], id=953622, creator=models.Person( name="George Clooney", obfuscated_id="abc123", ), updated_by=models.Person( name="George Clooney", obfuscated_id="abc123", ), items=[ models.CollectionItem( collection_id=164413, created_by=models.Person( name="George Clooney", obfuscated_id="abc123", ), document=models.Document( container_document=models.Document( metadata=models.DocumentMetadata( datasource="datasource", object_type="Feature Request", container="container", parent_id="JIRA_EN-1337", mime_type="mimeType", document_id="documentId", create_time=parse_datetime("2000-01-23T04:56:07.000Z"), update_time=parse_datetime("2000-01-23T04:56:07.000Z"), author=models.Person( name="name", ``` -------------------------------- ### Using UploadStatusEnum Source: https://github.com/gleanwork/api-client-python/blob/main/docs/models/uploadstatusenum.md Demonstrates how to import and use the UploadStatusEnum. Unrecognized values are handled by the UnrecognizedStr type. ```python from glean.api_client.models import UploadStatusEnum value = UploadStatusEnum.UPLOADED # Open enum: unrecognized values are captured as UnrecognizedStr ``` -------------------------------- ### Get Chat Source: https://github.com/gleanwork/api-client-python/blob/main/docs/sdks/clientchat/README.md Retrieves a specific chat by its ID. Allows for customization of locale, timezone, and retry behavior. ```APIDOC ## Get Chat ### Description Retrieves a specific chat using its unique identifier. This method supports optional parameters for locale, timezone offset, and custom retry configurations. ### Method (Assumed POST or GET based on typical SDK patterns, but not explicitly stated in source) ### Endpoint (Not explicitly stated in source) ### Parameters #### Path Parameters - **id** (str) - Required - The id of the Chat to be retrieved. #### Query Parameters - **locale** (Optional[str]) - Optional - The client's preferred locale in rfc56446 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`. - **timezone_offset** (Optional[int]) - Optional - The offset of the client's timezone in minutes from UTC. e.g. PDT is -420 because it's 7 hours behind UTC. #### Request Body (Not explicitly stated in source) ### Request Example (Not explicitly stated in source) ### Response #### Success Response - **models.GetChatResponse** - (Type is a reference to a model, actual fields not detailed in source) #### Response Example (Not explicitly stated in source) ```