Skip to content

Latest commit

 

History

History
474 lines (313 loc) · 31.5 KB

File metadata and controls

474 lines (313 loc) · 31.5 KB

Triggers

Overview

Available Operations

create

Create a trigger from a preset and return it with its signing secret.

Example Usage

from glean.api_client import Glean, models
import os


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

    res = glean.triggers.create(preset_id="GITHUB_1", delivery={
        "webhook_url": "https://customer.app/webhook",
        "auth": {
            "type": models.PlatformTriggerAuthType.BEARER,
            "secret": "secret_test_123",
        },
    }, description="Reviews I am tagged on, sent to my team's review channel", inputs={
        "repository": "acme/payments-api",
    })

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
preset_id str ✔️ ID of the preset to instantiate. GITHUB_1
delivery models.PlatformTriggerDelivery ✔️ N/A
description Optional[str] Optional note describing this trigger. Reviews I am tagged on, sent to my team's review channel
inputs Dict[str, Any] Values for the preset's inputs. {
"repository": "acme/payments-api"
}
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PlatformTriggerCreateResponse

Errors

Error Type Status Code Content Type
errors.PlatformProblemDetailError 400, 401, 403, 404, 408, 409, 413, 429 application/problem+json
errors.PlatformProblemDetailError 500, 503 application/problem+json
errors.GleanError 4XX, 5XX */*

list

List triggers owned by the authenticated caller.

Example Usage

from glean.api_client import Glean
import os


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

    res = glean.triggers.list(page_size=50)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
page_size Optional[int] Maximum number of triggers to return.
cursor Optional[str] Opaque pagination cursor from a previous response.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PlatformTriggerListResponse

Errors

Error Type Status Code Content Type
errors.PlatformProblemDetailError 400, 401, 403, 408, 429 application/problem+json
errors.PlatformProblemDetailError 500, 503 application/problem+json
errors.GleanError 4XX, 5XX */*

get

Retrieve a trigger owned by the authenticated caller.

Example Usage

from glean.api_client import Glean
import os


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

    res = glean.triggers.get(trigger_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
trigger_id str ✔️ ID of the trigger to retrieve.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PlatformTriggerGetResponse

Errors

Error Type Status Code Content Type
errors.PlatformProblemDetailError 400, 401, 403, 404, 408, 429 application/problem+json
errors.PlatformProblemDetailError 500, 503 application/problem+json
errors.GleanError 4XX, 5XX */*

update

Update a trigger.

Example Usage

from glean.api_client import Glean, models
import os


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

    res = glean.triggers.update(trigger_id="<id>", status=models.PlatformTriggerStatus.ENABLED, description="Reviews I am tagged on, sent to my team's review channel", inputs={
        "repository": "acme/payments-api",
    }, delivery={
        "webhook_url": "https://customer.app/webhook",
        "auth": {
            "type": models.PlatformTriggerAuthType.BEARER,
            "secret": "secret_test_123",
        },
    })

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
trigger_id str ✔️ ID of the trigger to update.
status Optional[models.PlatformTriggerStatus] Current trigger lifecycle state. ENABLED
description Optional[str] Optional note describing this trigger. Reviews I am tagged on, sent to my team's review channel
inputs Dict[str, Any] Values for the preset's inputs. {
"repository": "acme/payments-api"
}
delivery Optional[models.PlatformTriggerDelivery] N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PlatformTriggerGetResponse

Errors

Error Type Status Code Content Type
errors.PlatformProblemDetailError 400, 401, 403, 404, 408, 413, 429 application/problem+json
errors.PlatformProblemDetailError 500, 503 application/problem+json
errors.GleanError 4XX, 5XX */*

delete

Delete a trigger.

Example Usage

from glean.api_client import Glean
import os


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

    glean.triggers.delete(trigger_id="<id>")

    # Use the SDK ...

Parameters

Parameter Type Required Description
trigger_id str ✔️ ID of the trigger to delete.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Errors

Error Type Status Code Content Type
errors.PlatformProblemDetailError 400, 401, 403, 404, 408, 429 application/problem+json
errors.PlatformProblemDetailError 500, 503 application/problem+json
errors.GleanError 4XX, 5XX */*

search_events

Search recent content events an existing trigger matches. Read-only — no webhook delivery is made. Covers the last seven days.

Example Usage

from glean.api_client import Glean
import os


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

    res = glean.triggers.search_events(trigger_id="<id>", page_size=10)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
trigger_id str ✔️ ID of the trigger whose events to search.
page_size Optional[int] Maximum number of events to return.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PlatformTriggerEventSearchResponse

Errors

Error Type Status Code Content Type
errors.PlatformProblemDetailError 400, 401, 403, 404, 408, 413, 429 application/problem+json
errors.PlatformProblemDetailError 500, 503 application/problem+json
errors.GleanError 4XX, 5XX */*

list_presets

List the trigger presets available to the caller. A preset is a curated content-trigger template (e.g. a new Jira ticket) which is passed when creating a trigger.

Example Usage

from glean.api_client import Glean
import os


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

    res = glean.triggers.list_presets(page_size=50)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
datasource Optional[str] Restrict results to presets for a single datasource (e.g. github).
page_size Optional[int] Maximum number of presets to return.
cursor Optional[str] Opaque pagination cursor from a previous response.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PlatformTriggerPresetListResponse

Errors

Error Type Status Code Content Type
errors.PlatformProblemDetailError 400, 401, 403, 408, 429 application/problem+json
errors.PlatformProblemDetailError 500, 503 application/problem+json
errors.GleanError 4XX, 5XX */*

get_preset

Retrieve a single trigger preset by id.

Example Usage

from glean.api_client import Glean
import os


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

    res = glean.triggers.get_preset(preset_id="<id>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
preset_id str ✔️ ID of the preset to retrieve.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PlatformTriggerPresetGetResponse

Errors

Error Type Status Code Content Type
errors.PlatformProblemDetailError 400, 401, 403, 404, 408, 429 application/problem+json
errors.PlatformProblemDetailError 500, 503 application/problem+json
errors.GleanError 4XX, 5XX */*

list_preset_input_values

Return up to 300 selectable values for a single picklist input on a preset. Results are intended for typeahead selection and are not cursor-paginated. When is_truncated is true, refine query to narrow the result set.

Example Usage

from glean.api_client import Glean
import os


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

    res = glean.triggers.list_preset_input_values(preset_id="<id>", field="<value>")

    # Handle response
    print(res)

Parameters

Parameter Type Required Description
preset_id str ✔️ ID of the preset the input belongs to.
field str ✔️ Field identifier of the input whose values to list.
query Optional[str] Prefix filter over the input's option values, for typeahead. Matching is on the option value, not its display name.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PlatformTriggerPresetInputValueListResponse

Errors

Error Type Status Code Content Type
errors.PlatformProblemDetailError 400, 401, 403, 404, 408, 429 application/problem+json
errors.PlatformProblemDetailError 500, 503 application/problem+json
errors.GleanError 4XX, 5XX */*

search_preset_events

Search recent content events an unsaved trigger built from this preset would match, to preview it before creating the trigger. Read-only — no trigger is created and no webhook delivery is made. Covers the last seven days.

Example Usage

from glean.api_client import Glean
import os


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

    res = glean.triggers.search_preset_events(preset_id="<id>", inputs={
        "repository": "acme/payments-api",
    }, page_size=10)

    # Handle response
    print(res)

Parameters

Parameter Type Required Description Example
preset_id str ✔️ ID of the preset to preview.
inputs Dict[str, str] Values for the preset's input fields, keyed by field name.
{
"repository": "acme/payments-api"
}
page_size Optional[int] Maximum number of events to return.
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.PlatformTriggerEventSearchResponse

Errors

Error Type Status Code Content Type
errors.PlatformProblemDetailError 400, 401, 403, 404, 408, 413, 429 application/problem+json
errors.PlatformProblemDetailError 500, 503 application/problem+json
errors.GleanError 4XX, 5XX */*