Skip to content

Latest commit

 

History

History
203 lines (140 loc) · 22.8 KB

File metadata and controls

203 lines (140 loc) · 22.8 KB

Client.Documents

Overview

Available Operations

retrieve_permissions

Read the emails of all users who have access to the given document.

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:

    res = glean.client.documents.retrieve_permissions()

    # Handle response
    print(res)

Parameters

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.
document_id Optional[str] The Glean Document ID to retrieve permissions for.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetDocPermissionsResponse

Errors

Error Type Status Code Content Type
errors.GleanError 4XX, 5XX */*

retrieve

Read the documents including metadata (does not include enhanced metadata via /documentmetadata) for the given list of Glean Document IDs or URLs specified in the request.

Example Usage

from glean.api_client import Glean
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:

    res = glean.client.documents.retrieve()

    # Handle response
    print(res)

Parameters

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.
get_documents_request Optional[models.GetDocumentsRequest] Information about documents requested.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetDocumentsResponse

Errors

Error Type Status Code Content Type
errors.GleanError 4XX, 5XX */*

retrieve_by_facets

Read the documents including metadata (does not include enhanced metadata via /documentmetadata) macthing the given facet conditions.

Example Usage

from glean.api_client import Glean, models
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:

    res = glean.client.documents.retrieve_by_facets(get_documents_by_facets_request={
        "filter_sets": [
            {
                "filters": [
                    {
                        "field_name": "type",
                        "values": [
                            {
                                "value": "Spreadsheet",
                                "relation_type": models.RelationType.EQUALS,
                            },
                            {
                                "value": "Presentation",
                                "relation_type": models.RelationType.EQUALS,
                            },
                        ],
                    },
                ],
            },
        ],
    })

    # Handle response
    print(res)

Parameters

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.
get_documents_by_facets_request Optional[models.GetDocumentsByFacetsRequest] Information about facet conditions for documents to be retrieved.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetDocumentsByFacetsResponse

Errors

Error Type Status Code Content Type
errors.GleanError 4XX, 5XX */*

summarize

Generate an AI summary of the requested documents.

Example Usage

from glean.api_client import Glean, models
import os


with Glean(
    api_token=os.getenv("GLEAN_API_TOKEN", ""),
) as glean:

    res = glean.client.documents.summarize(document_specs=[
        {
            "ugc_type": models.DocumentSpecUgcType2.CHATS,
            "ugc_id": "<id>",
        },
    ])

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
document_specs List[models.DocumentSpecUnion] ✔️ Specifications of documents to summarize
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.
timestamp date The ISO 8601 timestamp associated with the client request.
query Optional[str] Optional query that the summary should be about
preferred_summary_length Optional[int] Optional length of summary output. If not given, defaults to 500 chars.
tracking_token Optional[str] An opaque token that represents this particular result. To be used for /feedback reporting.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.SummarizeResponse

Errors

Error Type Status Code Content Type
errors.GleanError 4XX, 5XX */*