Skip to content

Latest commit

 

History

History
243 lines (167 loc) · 26.7 KB

File metadata and controls

243 lines (167 loc) · 26.7 KB

Client.Pins

Overview

Available Operations

update

Update an existing user-generated pin.

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.pins.update(audience_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.
queries List[str] The query strings for which the pinned result will show.
audience_filters List[models.FacetFilter] Filters which restrict who should see the pinned document. Values are taken from the corresponding filters in people search.
id Optional[str] The opaque id of the pin to be edited.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PinDocument

Errors

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

retrieve

Read pin details given its ID.

Example Usage

from glean.api_client import Glean
import os


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

    res = glean.client.pins.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.
id Optional[str] The opaque id of the pin to be fetched.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.GetPinResponse

Errors

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

list

Lists all pins.

Example Usage

from glean.api_client import Glean
import os


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

    res = glean.client.pins.list(request_body={})

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
request_body models.ListpinsRequestBody ✔️ List pins 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.

Response

models.ListPinsResponse

Errors

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

create

Pin a document as a result for a given search query.Pin results that are known to be a good match.

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.pins.create(audience_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.
queries List[str] The query strings for which the pinned result will show.
audience_filters List[models.FacetFilter] Filters which restrict who should see the pinned document. Values are taken from the corresponding filters in people search.
document_id Optional[str] The document to be pinned.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PinDocument

Errors

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

remove

Unpin a previously pinned result.

Example Usage

from glean.api_client import Glean
import os


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

    glean.client.pins.remove()

    # Use the SDK ...

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.
id Optional[str] The opaque id of the pin to be unpinned.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Errors

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