Skip to content

Latest commit

 

History

History
193 lines (130 loc) · 10.1 KB

File metadata and controls

193 lines (130 loc) · 10.1 KB

ClientDocuments

(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
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
request models.GetDocumentsRequest ✔️ The request object to use for the request.
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(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
request models.GetDocumentsByFacetsRequest ✔️ The request object to use for the request.
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
import os


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

    res = glean.client.documents.summarize(document_specs=[
        {},
    ])

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
document_specs List[models.DocumentSpecUnion] ✔️ Specifications of documents to summarize
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 */*