// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../resource'; import * as Core from '../../core'; import * as CountByAPI from './count-by'; import * as EventsAPI from './events'; export class CountBy extends APIResource { /** * Returns distinct objects and the count of events associated with them. Objects * that can be counted include the day the event occurred, the type of event, or * the IDs of the resources associated with the event. */ create( countable: 'day' | 'time' | 'event' | 'resource', params: CountByCreateParams, options?: Core.RequestOptions, ): Core.APIPromise { const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.post(`/api/events/count-by/${countable}`, { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } } export type CountByCreateResponse = Array; export interface CountByCreateParams { /** * Body param: */ filter: CountByCreateParams.Filter; /** * Body param: */ time_interval?: number; /** * Body param: */ time_unit?: 'week' | 'day' | 'hour' | 'minute' | 'second'; /** * Header param: */ 'x-prefect-api-version'?: string; } export namespace CountByCreateParams { export interface Filter { /** * Filter criteria for the events' ID */ id?: Filter.ID; /** * Filter criteria for any resource involved in the event */ any_resource?: Filter.AnyResource | null; /** * Filter criteria for the event name */ event?: Filter.Event | null; /** * Filter criteria for when the events occurred */ occurred?: Filter.Occurred; /** * The order to return filtered events */ order?: 'ASC' | 'DESC'; /** * Filter criteria for the related resources of the event */ related?: Filter.Related | null; /** * Filter criteria for the resource of the event */ resource?: Filter.Resource | null; } export namespace Filter { /** * Filter criteria for the events' ID */ export interface ID { /** * Only include events with one of these IDs */ id?: Array | null; } /** * Filter criteria for any resource involved in the event */ export interface AnyResource { /** * Only include events for resources with these IDs */ id?: Array | null; /** * Only include events for resources with IDs starting with these prefixes */ id_prefix?: Array | null; /** * Only include events for related resources with these labels */ labels?: Record> | null; } /** * Filter criteria for the event name */ export interface Event { /** * Exclude events matching one of these names exactly */ exclude_name?: Array | null; /** * Exclude events matching one of these prefixes */ exclude_prefix?: Array | null; /** * Only include events matching one of these names exactly */ name?: Array | null; /** * Only include events matching one of these prefixes */ prefix?: Array | null; } /** * Filter criteria for when the events occurred */ export interface Occurred { /** * Only include events after this time (inclusive) */ since?: string; /** * Only include events prior to this time (inclusive) */ until?: string; } /** * Filter criteria for the related resources of the event */ export interface Related { /** * Only include events for related resources with these IDs */ id?: Array | null; /** * Only include events for related resources with these labels */ labels?: Record> | null; /** * Only include events with specific related resources in specific roles */ resources_in_roles?: Array> | null; /** * Only include events for related resources in these roles */ role?: Array | null; } /** * Filter criteria for the resource of the event */ export interface Resource { /** * Only include events for resources with these IDs */ id?: Array | null; /** * Only include events for distinct resources */ distinct?: boolean; /** * Only include events for resources with IDs starting with these prefixes. */ id_prefix?: Array | null; /** * Only include events for resources with these labels */ labels?: Record> | null; } } } export namespace CountBy { export import CountByCreateResponse = CountByAPI.CountByCreateResponse; export import CountByCreateParams = CountByAPI.CountByCreateParams; }