Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(specs): correct types for Tasks trigger #1279

Merged
merged 1 commit into from
Feb 3, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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