@@ -88,7 +88,7 @@ type DbtTask struct {
8888 WarehouseId string `json:"warehouse_id,omitempty"`
8989}
9090
91- // EmailNotifications contains the information for email notifications after job completion
91+ // EmailNotifications contains the information for email notifications after job or task run start or completion
9292type EmailNotifications struct {
9393 OnStart []string `json:"on_start,omitempty"`
9494 OnSuccess []string `json:"on_success,omitempty"`
@@ -97,6 +97,31 @@ type EmailNotifications struct {
9797 AlertOnLastAttempt bool `json:"alert_on_last_attempt,omitempty"`
9898}
9999
100+ // WebhookNotifications contains the information for webhook notifications sent after job start or completion.
101+ type WebhookNotifications struct {
102+ OnStart []Webhook `json:"on_start,omitempty"`
103+ OnSuccess []Webhook `json:"on_success,omitempty"`
104+ OnFailure []Webhook `json:"on_failure,omitempty"`
105+ }
106+
107+ func (wn * WebhookNotifications ) Sort () {
108+ if wn == nil {
109+ return
110+ }
111+
112+ notifs := [][]Webhook {wn .OnStart , wn .OnFailure , wn .OnSuccess }
113+ for _ , ns := range notifs {
114+ sort .Slice (ns , func (i , j int ) bool {
115+ return ns [i ].ID < ns [j ].ID
116+ })
117+ }
118+ }
119+
120+ // Webhook contains a reference by id to one of the centrally configured webhooks.
121+ type Webhook struct {
122+ ID string `json:"id"`
123+ }
124+
100125// CronSchedule contains the information for the quartz cron expression
101126type CronSchedule struct {
102127 QuartzCronExpression string `json:"quartz_cron_expression"`
@@ -179,10 +204,11 @@ type JobSettings struct {
179204 GitSource * GitSource `json:"git_source,omitempty"`
180205 // END Jobs + Repo integration preview
181206
182- Schedule * CronSchedule `json:"schedule,omitempty"`
183- MaxConcurrentRuns int32 `json:"max_concurrent_runs,omitempty"`
184- EmailNotifications * EmailNotifications `json:"email_notifications,omitempty" tf:"suppress_diff"`
185- Tags map [string ]string `json:"tags,omitempty"`
207+ Schedule * CronSchedule `json:"schedule,omitempty"`
208+ MaxConcurrentRuns int32 `json:"max_concurrent_runs,omitempty"`
209+ EmailNotifications * EmailNotifications `json:"email_notifications,omitempty" tf:"suppress_diff"`
210+ WebhookNotifications * WebhookNotifications `json:"webhook_notifications,omitempty" tf:"suppress_diff"`
211+ Tags map [string ]string `json:"tags,omitempty"`
186212}
187213
188214func (js * JobSettings ) isMultiTask () bool {
@@ -195,6 +221,10 @@ func (js *JobSettings) sortTasksByKey() {
195221 })
196222}
197223
224+ func (js * JobSettings ) sortWebhooksByID () {
225+ js .WebhookNotifications .Sort ()
226+ }
227+
198228// JobList returns a list of all jobs
199229type JobList struct {
200230 Jobs []Job `json:"jobs"`
@@ -381,6 +411,7 @@ func (a JobsAPI) Restart(id string, timeout time.Duration) error {
381411func (a JobsAPI ) Create (jobSettings JobSettings ) (Job , error ) {
382412 var job Job
383413 jobSettings .sortTasksByKey ()
414+ jobSettings .sortWebhooksByID ()
384415 var gitSource * GitSource = jobSettings .GitSource
385416 if gitSource != nil && gitSource .Provider == "" {
386417 gitSource .Provider = repos .GetGitProviderFromUrl (gitSource .Url )
@@ -418,6 +449,7 @@ func (a JobsAPI) Read(id string) (job Job, err error) {
418449 }, & job ), id )
419450 if job .Settings != nil {
420451 job .Settings .sortTasksByKey ()
452+ job .Settings .sortWebhooksByID ()
421453 }
422454 return
423455}
0 commit comments