// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../resource'; import { isRequestOptions } from '../../core'; import * as Core from '../../core'; import * as FlowRunNotificationPoliciesAPI from './flow-run-notification-policies'; import * as FilterAPI from './filter'; export class FlowRunNotificationPolicies extends APIResource { filter: FilterAPI.Filter = new FilterAPI.Filter(this._client); /** * Creates a new flow run notification policy. */ create( params: FlowRunNotificationPolicyCreateParams, options?: Core.RequestOptions, ): Core.APIPromise { const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.post('/api/flow_run_notification_policies/', { body, ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Get a flow run notification policy by id. */ retrieve( id: string, params?: FlowRunNotificationPolicyRetrieveParams, options?: Core.RequestOptions, ): Core.APIPromise; retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise; retrieve( id: string, params: FlowRunNotificationPolicyRetrieveParams | Core.RequestOptions = {}, options?: Core.RequestOptions, ): Core.APIPromise { if (isRequestOptions(params)) { return this.retrieve(id, {}, params); } const { 'x-prefect-api-version': xPrefectAPIVersion } = params; return this._client.get(`/api/flow_run_notification_policies/${id}`, { ...options, headers: { ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Updates an existing flow run notification policy. */ update( id: string, params: FlowRunNotificationPolicyUpdateParams, options?: Core.RequestOptions, ): Core.APIPromise { const { 'x-prefect-api-version': xPrefectAPIVersion, ...body } = params; return this._client.patch(`/api/flow_run_notification_policies/${id}`, { body, ...options, headers: { Accept: '*/*', ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } /** * Delete a flow run notification policy by id. */ delete( id: string, params?: FlowRunNotificationPolicyDeleteParams, options?: Core.RequestOptions, ): Core.APIPromise; delete(id: string, options?: Core.RequestOptions): Core.APIPromise; delete( id: string, params: FlowRunNotificationPolicyDeleteParams | Core.RequestOptions = {}, options?: Core.RequestOptions, ): Core.APIPromise { if (isRequestOptions(params)) { return this.delete(id, {}, params); } const { 'x-prefect-api-version': xPrefectAPIVersion } = params; return this._client.delete(`/api/flow_run_notification_policies/${id}`, { ...options, headers: { Accept: '*/*', ...(xPrefectAPIVersion != null ? { 'x-prefect-api-version': xPrefectAPIVersion } : undefined), ...options?.headers, }, }); } } /** * An ORM representation of a flow run notification. */ export interface FlowRunNotificationPolicy { /** * The block document ID used for sending notifications */ block_document_id: string; /** * The flow run states that trigger notifications */ state_names: Array; /** * The flow run tags that trigger notifications (set [] to disable) */ tags: Array; id?: string; created?: string | null; /** * Whether the policy is currently active */ is_active?: boolean; /** * A templatable notification message. Use {braces} to add variables. Valid * variables include: 'flow_id', 'flow_name', 'flow_run_id', 'flow_run_name', * 'flow_run_notification_policy_id', 'flow_run_parameters', * 'flow_run_state_message', 'flow_run_state_name', 'flow_run_state_timestamp', * 'flow_run_state_type', 'flow_run_url' */ message_template?: string | null; updated?: string | null; } export interface FlowRunNotificationPolicyCreateParams { /** * Body param: The block document ID used for sending notifications */ block_document_id: string; /** * Body param: The flow run states that trigger notifications */ state_names: Array; /** * Body param: The flow run tags that trigger notifications (set [] to disable) */ tags: Array; /** * Body param: Whether the policy is currently active */ is_active?: boolean; /** * Body param: A templatable notification message. Use {braces} to add variables. * Valid variables include: 'flow_id', 'flow_name', 'flow_run_id', 'flow_run_name', * 'flow_run_notification_policy_id', 'flow_run_parameters', * 'flow_run_state_message', 'flow_run_state_name', 'flow_run_state_timestamp', * 'flow_run_state_type', 'flow_run_url' */ message_template?: string | null; /** * Header param: */ 'x-prefect-api-version'?: string; } export interface FlowRunNotificationPolicyRetrieveParams { 'x-prefect-api-version'?: string; } export interface FlowRunNotificationPolicyUpdateParams { /** * Body param: */ block_document_id?: string | null; /** * Body param: */ is_active?: boolean | null; /** * Body param: */ message_template?: string | null; /** * Body param: */ state_names?: Array | null; /** * Body param: */ tags?: Array | null; /** * Header param: */ 'x-prefect-api-version'?: string; } export interface FlowRunNotificationPolicyDeleteParams { 'x-prefect-api-version'?: string; } export namespace FlowRunNotificationPolicies { export import FlowRunNotificationPolicy = FlowRunNotificationPoliciesAPI.FlowRunNotificationPolicy; export import FlowRunNotificationPolicyCreateParams = FlowRunNotificationPoliciesAPI.FlowRunNotificationPolicyCreateParams; export import FlowRunNotificationPolicyRetrieveParams = FlowRunNotificationPoliciesAPI.FlowRunNotificationPolicyRetrieveParams; export import FlowRunNotificationPolicyUpdateParams = FlowRunNotificationPoliciesAPI.FlowRunNotificationPolicyUpdateParams; export import FlowRunNotificationPolicyDeleteParams = FlowRunNotificationPoliciesAPI.FlowRunNotificationPolicyDeleteParams; export import Filter = FilterAPI.Filter; export import FilterCreateResponse = FilterAPI.FilterCreateResponse; export import FilterCreateParams = FilterAPI.FilterCreateParams; }