import { WorkspaceScopedResource, extractData } from './base.js';
export class TriggersResource extends WorkspaceScopedResource {
    async list(params) {
        return extractData(await this.client.GET('/v1/{workspace_id}/triggers', {
            params: { path: { workspace_id: this.workspaceId }, query: params },
        }));
    }
    listAutoPaging(params) {
        return this.iteratePaginatedList((pageParams) => this.list(pageParams), params);
    }
    async create(body) {
        return extractData(await this.client.POST('/v1/{workspace_id}/triggers', {
            params: { path: { workspace_id: this.workspaceId } },
            body,
        }));
    }
    async get(triggerId) {
        return extractData(await this.client.GET('/v1/{workspace_id}/triggers/{trigger_id}', {
            params: { path: { workspace_id: this.workspaceId, trigger_id: triggerId } },
        }));
    }
    async update(triggerId, body) {
        return extractData(await this.client.PUT('/v1/{workspace_id}/triggers/{trigger_id}', {
            params: { path: { workspace_id: this.workspaceId, trigger_id: triggerId } },
            body,
        }));
    }
    async delete(triggerId) {
        await this.client.DELETE('/v1/{workspace_id}/triggers/{trigger_id}', {
            params: { path: { workspace_id: this.workspaceId, trigger_id: triggerId } },
        });
    }
    async fire(triggerId) {
        return extractData(await this.client.POST('/v1/{workspace_id}/triggers/{trigger_id}/fire', {
            params: { path: { workspace_id: this.workspaceId, trigger_id: triggerId } },
        }));
    }
    async pause(triggerId) {
        return extractData(await this.client.POST('/v1/{workspace_id}/triggers/{trigger_id}/pause', {
            params: { path: { workspace_id: this.workspaceId, trigger_id: triggerId } },
        }));
    }
    async resume(triggerId) {
        return extractData(await this.client.POST('/v1/{workspace_id}/triggers/{trigger_id}/resume', {
            params: { path: { workspace_id: this.workspaceId, trigger_id: triggerId } },
        }));
    }
    async listRuns(triggerId, params) {
        return extractData(await this.client.GET('/v1/{workspace_id}/triggers/{trigger_id}/runs', {
            params: { path: { workspace_id: this.workspaceId, trigger_id: triggerId }, query: params },
        }));
    }
    listRunsAutoPaging(triggerId, params) {
        return this.iteratePaginatedList((pageParams) => this.listRuns(triggerId, pageParams), params);
    }
}
//# sourceMappingURL=triggers.js.map