Skip to content

Commit

Permalink
fix(specs): correct types for Tasks trigger (#1279)
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts committed Feb 3, 2023
1 parent e4b318b commit a1c7c24
Showing 1 changed file with 74 additions and 28 deletions.
102 changes: 74 additions & 28 deletions specs/ingestion/common/schemas/task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Task:
destinationID:
$ref: './common.yml#/destinationID'
trigger:
$ref: '#/TaskTrigger'
$ref: '#/Trigger'
enabled:
type: boolean
default: true
Expand All @@ -31,10 +31,11 @@ Task:
- action
- createdAt

TaskTrigger:
Trigger:
oneOf:
- $ref: '#/Trigger'
- $ref: '#/OnDemandTrigger'
- $ref: '#/ScheduleTrigger'
- $ref: '#/SubscriptionTrigger'

TaskCreate:
type: object
Expand Down Expand Up @@ -131,60 +132,105 @@ TriggerInput:
required:
- type

TriggerType:
type: string
description: >
The type of the task reflect how it can be used:
- on_demand: a task that runs manually
- schedule: a task that runs regularly, following a given cron expression
- subscription: a task that runs after a subscription event is received from an integration (e.g. Webhook).
enum: ['on_demand', 'schedule', 'subscription']

# schedule trigger

LastRun:
description: The last time the scheduled task ran.
type: string

Cron:
type: string
description: A cron expression that represent at which regularity the task should run.
example: '* * 1 * *'

ScheduleTriggerType:
type: string
description: A task which is triggered by a schedule (cron expression).
enum: ['schedule']

ScheduleTriggerInput:
type: object
additionalProperties: false
description: The trigger input for a task of type 'schedule'.
properties:
type:
$ref: '#/TriggerType'
$ref: '#/ScheduleTriggerType'
cron:
$ref: '#/Cron'
required:
- type
- cron

Trigger:
type: object
additionalProperties: false
description: The trigger information of a task.
properties:
type:
$ref: '#/TriggerType'
required:
- type

ScheduleTrigger:
type: object
additionalProperties: false
description: The trigger information for a task of type 'schedule'.
properties:
type:
$ref: '#/TriggerType'
$ref: '#/ScheduleTriggerType'
cron:
$ref: '#/Cron'
lastRun:
description: The last time the scheduled task ran.
type: string
$ref: '#/LastRun'
nextRun:
description: The next scheduled run of the task.
type: string
required:
- type
- cron
- lastRun
- nextRun

TriggerType:
# on demand trigger

OnDemandTriggerType:
type: string
description: >
The type of the task reflect how it can be used:
- on_demand: a task that runs manually
- schedule: a task that runs regularly, following a given cron expression
- subscription: a task that runs after a subscription event is received from an integration (e.g. Webhook).
enum: ['on_demand', 'schedule', 'subscription']
description: A task which is manually executed via the run task endpoint.
enum: ['on_demand']

Cron:
OnDemandTriggerInput:
type: object
additionalProperties: false
description: The trigger information of a task of type `on-demand`.
properties:
type:
$ref: '#/OnDemandTriggerType'
required:
- type

OnDemandTrigger:
type: object
additionalProperties: false
description: The trigger information of a task of type `on-demand`.
properties:
type:
$ref: '#/OnDemandTriggerType'
lastRun:
$ref: '#/LastRun'
required:
- type

# subscription trigger

SubscriptionTriggerType:
type: string
description: A cron expression that represent at which regularity the task should run.
example: '* * 1 * *'
description: A task which is triggered by an external subscription (e.g. Webhook).
enum: ['subscription']

SubscriptionTrigger:
type: object
additionalProperties: false
description: The trigger input for a task of type 'subscription'.
properties:
type:
$ref: '#/TriggerType'
required:
- type

0 comments on commit a1c7c24

Please sign in to comment.