Skip to content

Latest commit

 

History

History
584 lines (410 loc) · 36 KB

File metadata and controls

584 lines (410 loc) · 36 KB

Triggers

Overview

Available Operations

create

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

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.PlatformTriggerCreateRequest;
import com.glean.api_client.glean_api_client.models.components.PlatformTriggerDelivery;
import com.glean.api_client.glean_api_client.models.errors.PlatformProblemDetailException;
import com.glean.api_client.glean_api_client.models.operations.PlatformTriggersCreateResponse;
import java.lang.Exception;
import java.util.Map;

public class Application {

    public static void main(String[] args) throws PlatformProblemDetailException, Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        PlatformTriggerCreateRequest req = PlatformTriggerCreateRequest.builder()
                .presetId("GITHUB_1")
                .delivery(PlatformTriggerDelivery.builder()
                    .webhookUrl("https://example.com/webhook")
                    .build())
                .inputs(Map.ofEntries(
                    Map.entry("repository", "{repository}")))
                .build();

        PlatformTriggersCreateResponse res = sdk.triggers().create()
                .request(req)
                .call();

        if (res.platformTriggerCreateResponse().isPresent()) {
            System.out.println(res.platformTriggerCreateResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description
request PlatformTriggerCreateRequest ✔️ The request object to use for the request.

Response

PlatformTriggersCreateResponse

Errors

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

list

List triggers owned by the authenticated caller.

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.errors.PlatformProblemDetailException;
import com.glean.api_client.glean_api_client.models.operations.PlatformTriggersListResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws PlatformProblemDetailException, Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        PlatformTriggersListResponse res = sdk.triggers().list()
                .pageSize(50L)
                .call();

        if (res.platformTriggerListResponse().isPresent()) {
            System.out.println(res.platformTriggerListResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description
pageSize Optional<Long> ➖ Maximum number of triggers to return.
cursor Optional<String> ➖ Opaque pagination cursor from a previous response.

Response

PlatformTriggersListResponse

Errors

Error Type Status Code Content Type
models/errors/PlatformProblemDetailException 400, 401, 403, 408, 429 application/problem+json
models/errors/PlatformProblemDetailException 500, 503 application/problem+json
models/errors/APIException 4XX, 5XX */*

get

Retrieve a trigger owned by the authenticated caller.

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.errors.PlatformProblemDetailException;
import com.glean.api_client.glean_api_client.models.operations.PlatformTriggersGetResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws PlatformProblemDetailException, Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        PlatformTriggersGetResponse res = sdk.triggers().get()
                .triggerId("{trigger_id}")
                .call();

        if (res.platformTriggerGetResponse().isPresent()) {
            System.out.println(res.platformTriggerGetResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description Example
triggerId String ✔️ ID of the trigger to retrieve. {trigger_id}

Response

PlatformTriggersGetResponse

Errors

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

update

Update a trigger.

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.PlatformTriggerDelivery;
import com.glean.api_client.glean_api_client.models.components.PlatformTriggerUpdateRequest;
import com.glean.api_client.glean_api_client.models.errors.PlatformProblemDetailException;
import com.glean.api_client.glean_api_client.models.operations.PlatformTriggersUpdateResponse;
import java.lang.Exception;
import java.util.Map;

public class Application {

    public static void main(String[] args) throws PlatformProblemDetailException, Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        PlatformTriggersUpdateResponse res = sdk.triggers().update()
                .triggerId("{trigger_id}")
                .platformTriggerUpdateRequest(PlatformTriggerUpdateRequest.builder()
                    .inputs(Map.ofEntries(
                        Map.entry("repository", "{repository}")))
                    .delivery(PlatformTriggerDelivery.builder()
                        .webhookUrl("https://example.com/webhook")
                        .build())
                    .build())
                .call();

        if (res.platformTriggerGetResponse().isPresent()) {
            System.out.println(res.platformTriggerGetResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description Example
triggerId String ✔️ ID of the trigger to update. {trigger_id}
platformTriggerUpdateRequest PlatformTriggerUpdateRequest ✔️ N/A {
"inputs": {
"repository": "{repository}"
},
"delivery": {
"webhook_url": "https://example.com/webhook"
}
}

Response

PlatformTriggersUpdateResponse

Errors

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

delete

Delete a trigger.

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.errors.PlatformProblemDetailException;
import com.glean.api_client.glean_api_client.models.operations.PlatformTriggersDeleteResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws PlatformProblemDetailException, Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        PlatformTriggersDeleteResponse res = sdk.triggers().delete()
                .triggerId("{trigger_id}")
                .call();

        // handle response
    }
}

Parameters

Parameter Type Required Description Example
triggerId String ✔️ ID of the trigger to delete. {trigger_id}

Response

PlatformTriggersDeleteResponse

Errors

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

searchEvents

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

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.PlatformTriggerEventSearchRequest;
import com.glean.api_client.glean_api_client.models.errors.PlatformProblemDetailException;
import com.glean.api_client.glean_api_client.models.operations.PlatformTriggersEventsSearchResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws PlatformProblemDetailException, Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        PlatformTriggersEventsSearchResponse res = sdk.triggers().searchEvents()
                .triggerId("{trigger_id}")
                .platformTriggerEventSearchRequest(PlatformTriggerEventSearchRequest.builder()
                    .build())
                .call();

        if (res.platformTriggerEventSearchResponse().isPresent()) {
            System.out.println(res.platformTriggerEventSearchResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description Example
triggerId String ✔️ ID of the trigger whose events to search. {trigger_id}
platformTriggerEventSearchRequest Optional<PlatformTriggerEventSearchRequest> ➖ N/A {
"page_size": 10
}

Response

PlatformTriggersEventsSearchResponse

Errors

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

listPresets

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

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.errors.PlatformProblemDetailException;
import com.glean.api_client.glean_api_client.models.operations.PlatformTriggerPresetsListResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws PlatformProblemDetailException, Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        PlatformTriggerPresetsListResponse res = sdk.triggers().listPresets()
                .pageSize(50L)
                .call();

        if (res.platformTriggerPresetListResponse().isPresent()) {
            System.out.println(res.platformTriggerPresetListResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description
datasource Optional<String> ➖ Restrict results to presets for a single datasource (e.g. github).
pageSize Optional<Long> ➖ Maximum number of presets to return.
cursor Optional<String> ➖ Opaque pagination cursor from a previous response.

Response

PlatformTriggerPresetsListResponse

Errors

Error Type Status Code Content Type
models/errors/PlatformProblemDetailException 400, 401, 403, 408, 429 application/problem+json
models/errors/PlatformProblemDetailException 500, 503 application/problem+json
models/errors/APIException 4XX, 5XX */*

getPreset

Retrieve a single trigger preset by id.

Example Usage

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.errors.PlatformProblemDetailException;
import com.glean.api_client.glean_api_client.models.operations.PlatformTriggerPresetsGetResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws PlatformProblemDetailException, Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        PlatformTriggerPresetsGetResponse res = sdk.triggers().getPreset()
                .presetId("{preset_id}")
                .call();

        if (res.platformTriggerPresetGetResponse().isPresent()) {
            System.out.println(res.platformTriggerPresetGetResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description Example
presetId String ✔️ ID of the preset to retrieve. {preset_id}

Response

PlatformTriggerPresetsGetResponse

Errors

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

listPresetInputValues

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

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.errors.PlatformProblemDetailException;
import com.glean.api_client.glean_api_client.models.operations.PlatformTriggerPresetsInputValuesListResponse;
import java.lang.Exception;

public class Application {

    public static void main(String[] args) throws PlatformProblemDetailException, Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        PlatformTriggerPresetsInputValuesListResponse res = sdk.triggers().listPresetInputValues()
                .presetId("{preset_id}")
                .field("{field}")
                .call();

        if (res.platformTriggerPresetInputValueListResponse().isPresent()) {
            System.out.println(res.platformTriggerPresetInputValueListResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description Example
presetId String ✔️ ID of the preset the input belongs to. {preset_id}
field String ✔️ Field identifier of the input whose values to list. {field}
query Optional<String> ➖ Prefix filter over the input's option values, for typeahead. Matching is on the option value, not its display name.

Response

PlatformTriggerPresetsInputValuesListResponse

Errors

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

searchPresetEvents

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

package hello.world;

import com.glean.api_client.glean_api_client.Glean;
import com.glean.api_client.glean_api_client.models.components.PlatformTriggerPresetEventSearchRequest;
import com.glean.api_client.glean_api_client.models.errors.PlatformProblemDetailException;
import com.glean.api_client.glean_api_client.models.operations.PlatformTriggerPresetsEventsSearchResponse;
import java.lang.Exception;
import java.util.Map;

public class Application {

    public static void main(String[] args) throws PlatformProblemDetailException, Exception {

        Glean sdk = Glean.builder()
                .apiToken(System.getenv().getOrDefault("GLEAN_API_TOKEN", ""))
            .build();

        PlatformTriggerPresetsEventsSearchResponse res = sdk.triggers().searchPresetEvents()
                .presetId("{preset_id}")
                .platformTriggerPresetEventSearchRequest(PlatformTriggerPresetEventSearchRequest.builder()
                    .inputs(Map.ofEntries(
                        Map.entry("repository", "{repository}")))
                    .build())
                .call();

        if (res.platformTriggerEventSearchResponse().isPresent()) {
            System.out.println(res.platformTriggerEventSearchResponse().get());
        }
    }
}

Parameters

Parameter Type Required Description Example
presetId String ✔️ ID of the preset to preview. {preset_id}
platformTriggerPresetEventSearchRequest Optional<PlatformTriggerPresetEventSearchRequest> ➖ N/A {
"inputs": {
"repository": "{repository}"
},
"page_size": 10
}

Response

PlatformTriggerPresetsEventsSearchResponse

Errors

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