-
Notifications
You must be signed in to change notification settings - Fork 8
/
events_structs.go
948 lines (794 loc) · 28.9 KB
/
events_structs.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
package scalingo
import (
"encoding/json"
"fmt"
"strings"
"time"
"golang.org/x/text/cases"
"golang.org/x/text/language"
)
type Event struct {
ID string `json:"id"`
AppID string `json:"app_id"`
CreatedAt time.Time `json:"created_at"`
User EventUser `json:"user"`
Type EventTypeName `json:"type"`
AppName string `json:"app_name"`
RawTypeData json.RawMessage `json:"type_data"`
TypeData map[string]interface{} `json:"-"`
}
type EventSecurityTypeData struct {
RemoteIP string `json:"remote_ip"`
}
func (ev *Event) GetEvent() *Event {
return ev
}
func (ev *Event) TypeDataPtr() interface{} {
return ev.TypeData
}
func (ev *Event) String() string {
return fmt.Sprintf("Unknown event %v on app %v", ev.Type, ev.AppName)
}
func (ev *Event) When() string {
return ev.CreatedAt.Format("Mon Jan 02 2006 15:04:05")
}
func (ev *Event) Who() string {
return fmt.Sprintf("%s (%s)", ev.User.Username, ev.User.Email)
}
func (ev *Event) PrintableType() string {
typeName := strings.ReplaceAll(string(ev.Type), "_", " ")
return cases.Title(language.English).String(typeName)
}
type DetailedEvent interface {
fmt.Stringer
GetEvent() *Event
PrintableType() string
When() string
Who() string
TypeDataPtr() interface{}
}
type Events []DetailedEvent
type EventUser struct {
Username string `json:"username"`
Email string `json:"email"`
ID string `json:"id"`
}
type EventTypeName string
const (
EventNewUser EventTypeName = "new_user"
EventNewApp EventTypeName = "new_app"
EventEditApp EventTypeName = "edit_app"
EventDeleteApp EventTypeName = "delete_app"
EventRenameApp EventTypeName = "rename_app"
EventTransferApp EventTypeName = "transfer_app"
EventRestart EventTypeName = "restart"
EventScale EventTypeName = "scale"
EventStopApp EventTypeName = "stop_app"
EventCrash EventTypeName = "crash"
EventRepeatedCrash EventTypeName = "repeated_crash"
EventDeployment EventTypeName = "deployment"
EventLinkSCM EventTypeName = "link_scm"
EventUpdateSCM EventTypeName = "update_scm"
EventUnlinkSCM EventTypeName = "unlink_scm"
EventNewIntegration EventTypeName = "new_integration"
EventDeleteIntegration EventTypeName = "delete_integration"
EventAuthorizeGithub EventTypeName = "authorize_github"
EventRevokeGithub EventTypeName = "revoke_github"
EventRun EventTypeName = "run"
EventNewDomain EventTypeName = "new_domain"
EventEditDomain EventTypeName = "edit_domain"
EventDeleteDomain EventTypeName = "delete_domain"
EventUpgradeDatabase EventTypeName = "upgrade_database"
EventNewAddon EventTypeName = "new_addon"
EventUpgradeAddon EventTypeName = "upgrade_addon"
EventDeleteAddon EventTypeName = "delete_addon"
EventResumeAddon EventTypeName = "resume_addon"
EventSuspendAddon EventTypeName = "suspend_addon"
EventDatabaseAddFeature EventTypeName = "database/add_feature"
EventDatabaseRemoveFeature EventTypeName = "database/remove_feature"
EventNewCollaborator EventTypeName = "new_collaborator"
EventAcceptCollaborator EventTypeName = "accept_collaborator"
EventDeleteCollaborator EventTypeName = "delete_collaborator"
EventNewVariable EventTypeName = "new_variable"
EventEditVariable EventTypeName = "edit_variable"
EventEditVariables EventTypeName = "edit_variables"
EventDeleteVariable EventTypeName = "delete_variable"
EventAddCredit EventTypeName = "add_credit"
EventAddPaymentMethod EventTypeName = "add_payment_method"
EventAddVoucher EventTypeName = "add_voucher"
EventNewKey EventTypeName = "new_key"
EventEditKey EventTypeName = "edit_key"
EventDeleteKey EventTypeName = "delete_key"
EventPaymentAttempt EventTypeName = "payment_attempt"
EventNewAlert EventTypeName = "new_alert"
EventAlert EventTypeName = "alert"
EventDeleteAlert EventTypeName = "delete_alert"
EventNewAutoscaler EventTypeName = "new_autoscaler"
EventEditAutoscaler EventTypeName = "edit_autoscaler"
EventDeleteAutoscaler EventTypeName = "delete_autoscaler"
EventAddonUpdated EventTypeName = "addon_updated"
EventStartRegionMigration EventTypeName = "start_region_migration"
EventNewLogDrain EventTypeName = "new_log_drain"
EventDeleteLogDrain EventTypeName = "delete_log_drain"
EventNewAddonLogDrain EventTypeName = "new_addon_log_drain"
EventDeleteAddonLogDrain EventTypeName = "delete_addon_log_drain"
EventNewNotifier EventTypeName = "new_notifier"
EventEditNotifier EventTypeName = "edit_notifier"
EventDeleteNotifier EventTypeName = "delete_notifier"
EventEditHDSContact EventTypeName = "edit_hds_contact"
EventCreateDataAccessConsent EventTypeName = "create_data_access_consent"
EventNewToken EventTypeName = "new_token"
EventRegenerateToken EventTypeName = "regenerate_token"
EventDeleteToken EventTypeName = "delete_token"
EventTfaEnabled EventTypeName = "tfa_enabled"
EventTfaDisabled EventTypeName = "tfa_disabled"
EventLoginSuccess EventTypeName = "login_success"
EventLoginFailure EventTypeName = "login_failure"
EventLoginLock EventTypeName = "login_lock"
EventLoginUnlockSuccess EventTypeName = "login_unlock_success"
EventPasswordResetQuery EventTypeName = "password_reset_query"
EventPasswordResetSuccess EventTypeName = "password_reset_success"
EventStackChanged EventTypeName = "stack_changed"
EventCreateReviewApp EventTypeName = "create_review_app"
EventDestroyReviewApp EventTypeName = "destroy_review_app"
EventPlanDatabaseMaintenance EventTypeName = "plan_database_maintenance"
EventStartDatabaseMaintenance EventTypeName = "start_database_maintenance"
EventCompleteDatabaseMaintenance EventTypeName = "complete_database_maintenance"
// EventLinkGithub and EventUnlinkGithub events are kept for
// retro-compatibility. They are replaced by SCM events.
EventLinkGithub EventTypeName = "link_github"
EventUnlinkGithub EventTypeName = "unlink_github"
)
type EventNewUserType struct {
Event
TypeData EventNewUserTypeData `json:"type_data"`
}
func (ev *EventNewUserType) String() string {
return "You joined Scalingo. Hooray!"
}
type EventCreateReviewAppTypeData struct {
AppID string `json:"app_id"`
ReviewAppName string `json:"review_app_name"`
ReviewAppURL string `json:"review_app_url"`
SourceRepoName string `json:"source_repo_name"`
SourceRepoURL string `json:"source_repo_url"`
PullRequestName string `json:"pr_name"`
PullRequestNumber int `json:"pr_number"`
PullRequestURL string `json:"pr_url"`
PullRequestComesFromFork bool `json:"pr_comes_from_a_fork"`
}
type EventCreateReviewAppType struct {
Event
TypeData EventCreateReviewAppTypeData `json:"type_data"`
}
func (ev *EventCreateReviewAppType) String() string {
return fmt.Sprintf("the review app %s has been created from the pull request %s #%d", ev.TypeData.ReviewAppName, ev.TypeData.PullRequestName, ev.TypeData.PullRequestNumber)
}
type EventDestroyReviewAppTypeData struct {
AppID string `json:"app_id"`
ReviewAppName string `json:"review_app_name"`
SourceRepoName string `json:"source_repo_name"`
SourceRepoURL string `json:"source_repo_url"`
PullRequestName string `json:"pr_name"`
PullRequestNumber int `json:"pr_number"`
PullRequestURL string `json:"pr_url"`
PullRequestComesFromFork bool `json:"pr_comes_from_a_fork"`
}
type EventDestroyReviewAppType struct {
Event
TypeData EventCreateReviewAppTypeData `json:"type_data"`
}
func (ev *EventDestroyReviewAppType) String() string {
return fmt.Sprintf("the review app %s has been destroyed", ev.TypeData.ReviewAppName)
}
type EventNewUserTypeData struct {
}
type EventLinkGithubType struct {
Event
TypeData EventLinkGithubTypeData `json:"type_data"`
}
func (ev *EventLinkGithubType) String() string {
return fmt.Sprintf("app has been linked to Github repository '%s'", ev.TypeData.RepoName)
}
type EventLinkGithubTypeData struct {
RepoName string `json:"repo_name"`
LinkerUsername string `json:"linker_username"`
GithubSource string `json:"github_source"`
}
type EventUnlinkGithubType struct {
Event
TypeData EventUnlinkGithubTypeData `json:"type_data"`
}
func (ev *EventUnlinkGithubType) String() string {
return fmt.Sprintf("app has been unlinked from Github repository '%s'", ev.TypeData.RepoName)
}
type EventUnlinkGithubTypeData struct {
RepoName string `json:"repo_name"`
UnlinkerUsername string `json:"unlinker_username"`
GithubSource string `json:"github_source"`
}
type EventLinkSCMType struct {
Event
TypeData EventLinkSCMTypeData `json:"type_data"`
}
func (ev *EventLinkSCMType) String() string {
return fmt.Sprintf("app has been linked to repository '%s'", ev.TypeData.RepoName)
}
type EventLinkSCMTypeData struct {
RepoName string `json:"repo_name"`
LinkerUsername string `json:"linker_username"`
Source string `json:"source"`
Branch string `json:"branch"`
AutoDeploy bool `json:"auto_deploy"`
AutoDeployReviewApps bool `json:"auto_deploy_review_apps"`
DeleteOnClose bool `json:"delete_on_close"`
DeleteStale bool `json:"delete_stale"`
HoursBeforeDeleteOnClose int `json:"hours_before_delete_on_close"`
HoursBeforeDeleteStale int `json:"hours_before_delete_stale"`
CreationFromForksAllowed bool `json:"creation_from_forks_allowed"`
}
type EventUpdateSCMType struct {
Event
TypeData EventLinkSCMTypeData `json:"type_data"`
}
func (ev *EventUpdateSCMType) String() string {
return fmt.Sprintf("the link between the app and the repository '%s' has been updated", ev.TypeData.RepoName)
}
type EventUnlinkSCMType struct {
Event
TypeData EventUnlinkSCMTypeData `json:"type_data"`
}
func (ev *EventUnlinkSCMType) String() string {
return fmt.Sprintf("app has been unlinked from repository '%s'", ev.TypeData.RepoName)
}
type EventUnlinkSCMTypeData struct {
RepoName string `json:"repo_name"`
UnlinkerUsername string `json:"unlinker_username"`
Source string `json:"source"`
}
type EventRunType struct {
Event
TypeData EventRunTypeData `json:"type_data"`
}
func (ev *EventRunType) String() string {
detached := ""
if ev.TypeData.Detached {
detached = "detached "
}
if ev.isEventRunFromOperator() {
// The command executed is not available to end user if it's executed by a Scalingo operator
return fmt.Sprintf("%sone-off container for maintenance/support purposes", detached)
}
return fmt.Sprintf("%sone-off container with command '%s'", detached, ev.TypeData.Command)
}
func (ev *EventRunType) Who() string {
if ev.User.Email == "[email protected]" {
return "Scalingo Operator"
}
return ev.Event.Who()
}
func (ev *EventRunType) isEventRunFromOperator() bool {
return ev.TypeData.Command == ""
}
type EventRunTypeData struct {
Command string `json:"command"`
AuditLogID string `json:"audit_log_id"`
Detached bool `json:"detached"`
}
type EventNewDomainType struct {
Event
TypeData EventNewDomainTypeData `json:"type_data"`
}
func (ev *EventNewDomainType) String() string {
return fmt.Sprintf("'%s' has been associated", ev.TypeData.Hostname)
}
type EventNewDomainTypeData struct {
Hostname string `json:"hostname"`
SSL bool `json:"ssl"`
}
type EventEditDomainType struct {
Event
TypeData EventEditDomainTypeData `json:"type_data"`
}
func (ev *EventEditDomainType) String() string {
t := ev.TypeData
res := fmt.Sprintf("'%s' modified", t.Hostname)
if !t.SSL && t.OldSSL {
res += ", TLS certificate has been removed"
} else if t.SSL && !t.OldSSL {
res += ", TLS certificate has been added"
} else if t.SSL && t.OldSSL {
res += ", TLS certificate has been changed"
}
return res
}
type EventEditDomainTypeData struct {
Hostname string `json:"hostname"`
SSL bool `json:"ssl"`
OldSSL bool `json:"old_ssl"`
}
type EventDeleteDomainType struct {
Event
TypeData EventDeleteDomainTypeData `json:"type_data"`
}
func (ev *EventDeleteDomainType) String() string {
return fmt.Sprintf("'%s' has been disassociated", ev.TypeData.Hostname)
}
type EventDeleteDomainTypeData struct {
Hostname string `json:"hostname"`
}
type EventCollaborator struct {
EventUser
Inviter EventUser `json:"inviter"`
}
type EventNewCollaboratorType struct {
Event
TypeData EventNewCollaboratorTypeData `json:"type_data"`
}
func (ev *EventNewCollaboratorType) String() string {
return fmt.Sprintf(
"'%s' has been invited",
ev.TypeData.Collaborator.Email,
)
}
type EventNewCollaboratorTypeData struct {
Collaborator EventCollaborator `json:"collaborator"`
}
type EventAcceptCollaboratorType struct {
Event
TypeData EventAcceptCollaboratorTypeData `json:"type_data"`
}
func (ev *EventAcceptCollaboratorType) String() string {
return fmt.Sprintf(
"'%s' (%s) has accepted the collaboration",
ev.TypeData.Collaborator.Username,
ev.TypeData.Collaborator.Email,
)
}
// Inviter is filled there
type EventAcceptCollaboratorTypeData struct {
Collaborator EventCollaborator `json:"collaborator"`
}
type EventDeleteCollaboratorType struct {
Event
TypeData EventDeleteCollaboratorTypeData `json:"type_data"`
}
func (ev *EventDeleteCollaboratorType) String() string {
return fmt.Sprintf(
"'%s' (%s) is not a collaborator anymore",
ev.TypeData.Collaborator.Username,
ev.TypeData.Collaborator.Email,
)
}
type EventDeleteCollaboratorTypeData struct {
Collaborator EventCollaborator `json:"collaborator"`
}
type EventUpgradeDatabaseType struct {
Event
TypeData EventUpgradeDatabaseTypeData `json:"type_data"`
}
type EventUpgradeDatabaseTypeData struct {
AddonName string `json:"addon_name"`
OldVersion string `json:"old_version"`
NewVersion string `json:"new_version"`
}
func (ev *EventUpgradeDatabaseType) String() string {
return fmt.Sprintf(
"'%s' upgraded from v%s to v%s",
ev.TypeData.AddonName, ev.TypeData.OldVersion, ev.TypeData.NewVersion,
)
}
func (ev *EventUpgradeDatabaseType) Who() string {
if ev.TypeData.AddonName != "" {
return fmt.Sprintf("Addon %s", ev.TypeData.AddonName)
}
return ev.Event.Who()
}
type EventVariable struct {
Name string `json:"name"`
Value string `json:"value"`
}
type EventNewVariableType struct {
Event
TypeData EventNewVariableTypeData `json:"type_data"`
}
func (ev *EventNewVariableType) String() string {
return fmt.Sprintf("'%s' added to the environment", ev.TypeData.Name)
}
func (ev *EventNewVariableType) Who() string {
if ev.TypeData.AddonName != "" {
return fmt.Sprintf("Addon %s", ev.TypeData.AddonName)
}
return ev.Event.Who()
}
type EventNewVariableTypeData struct {
AddonName string `json:"addon_name"`
EventVariable
}
type EventVariables []EventVariable
func (evs EventVariables) Names() string {
names := []string{}
for _, e := range evs {
names = append(names, e.Name)
}
return strings.Join(names, ", ")
}
type EventEditVariableType struct {
Event
TypeData EventEditVariableTypeData `json:"type_data"`
}
func (ev *EventEditVariableType) String() string {
return fmt.Sprintf("'%s' modified", ev.TypeData.Name)
}
type EventEditVariableTypeData struct {
EventVariable
OldValue string `json:"old_value"`
AddonName string `json:"addon_name"`
}
type EventEditVariablesType struct {
Event
TypeData EventEditVariablesTypeData `json:"type_data"`
}
func (ev *EventEditVariablesType) String() string {
res := "environment changes:"
if len(ev.TypeData.NewVars) > 0 {
res += fmt.Sprintf(" %s added", ev.TypeData.NewVars.Names())
}
if len(ev.TypeData.UpdatedVars) > 0 {
res += fmt.Sprintf(" %s modified", ev.TypeData.UpdatedVars.Names())
}
if len(ev.TypeData.DeletedVars) > 0 {
res += fmt.Sprintf(" %s removed", ev.TypeData.DeletedVars.Names())
}
return res
}
func (ev *EventEditVariableType) Who() string {
if ev.TypeData.AddonName != "" {
return fmt.Sprintf("Addon %s", ev.TypeData.AddonName)
}
return ev.Event.Who()
}
type EventEditVariablesTypeData struct {
NewVars EventVariables `json:"new_vars"`
UpdatedVars EventVariables `json:"updated_vars"`
DeletedVars EventVariables `json:"deleted_vars"`
}
type EventDeleteVariableType struct {
Event
TypeData EventDeleteVariableTypeData `json:"type_data"`
}
func (ev *EventDeleteVariableType) String() string {
return fmt.Sprintf("'%s' removed from environment", ev.TypeData.Name)
}
type EventDeleteVariableTypeData struct {
EventVariable
}
type EventPaymentAttemptTypeData struct {
Amount float32 `json:"amount"`
PaymentMethod string `json:"payment_method"`
Status string `json:"status"`
}
type EventPaymentAttemptType struct {
Event
TypeData EventPaymentAttemptTypeData `json:"type_data"`
}
func (ev *EventPaymentAttemptType) String() string {
res := "Payment attempt of "
res += fmt.Sprintf("%0.2f€", ev.TypeData.Amount)
res += " with your "
if ev.TypeData.PaymentMethod == "credit" {
res += "credits"
} else {
res += "card"
}
if ev.TypeData.Status == "new" {
res += " (pending)"
} else if ev.TypeData.Status == "paid" {
res += " (success)"
} else {
res += " (fail)"
}
return res
}
type EventNewAutoscalerTypeData struct {
ContainerType string `json:"container_type"`
MinContainers int `json:"min_containers,string"`
MaxContainers int `json:"max_containers,string"`
Metric string `json:"metric"`
Target float64 `json:"target"`
TargetText string `json:"target_text"`
}
type EventNewAutoscalerType struct {
Event
TypeData EventNewAutoscalerTypeData `json:"type_data"`
}
func (ev *EventNewAutoscalerType) String() string {
d := ev.TypeData
return fmt.Sprintf("Autoscaler created about %s on container %s (target: %s)", d.Metric, d.ContainerType, d.TargetText)
}
type EventEditAutoscalerTypeData struct {
ContainerType string `json:"container_type"`
MinContainers int `json:"min_containers,string"`
MaxContainers int `json:"max_containers,string"`
Metric string `json:"metric"`
Target float64 `json:"target"`
TargetText string `json:"target_text"`
}
type EventEditAutoscalerType struct {
Event
TypeData EventEditAutoscalerTypeData `json:"type_data"`
}
func (ev *EventEditAutoscalerType) String() string {
d := ev.TypeData
return fmt.Sprintf("Autoscaler edited about %s on container %s (target: %s)", d.Metric, d.ContainerType, d.TargetText)
}
type EventDeleteAutoscalerTypeData struct {
ContainerType string `json:"container_type"`
Metric string `json:"metric"`
}
type EventDeleteAutoscalerType struct {
Event
TypeData EventDeleteAutoscalerTypeData `json:"type_data"`
}
func (ev *EventDeleteAutoscalerType) String() string {
d := ev.TypeData
return fmt.Sprintf("Alert deleted about %s on container %s", d.Metric, d.ContainerType)
}
type EventStartRegionMigrationTypeData struct {
MigrationID string `json:"migration_id"`
Destination string `json:"destination"`
Source string `json:"source"`
DstAppName string `json:"dst_app_name"`
}
type EventStartRegionMigrationType struct {
Event
TypeData EventStartRegionMigrationTypeData `json:"type_data"`
}
func (ev *EventStartRegionMigrationType) String() string {
return fmt.Sprintf("Application region migration started from %s to %s/%s", ev.TypeData.Source, ev.TypeData.Destination, ev.TypeData.DstAppName)
}
// New log drain
type EventNewLogDrainTypeData struct {
URL string `json:"url"`
}
type EventNewLogDrainType struct {
Event
TypeData EventNewLogDrainTypeData `json:"type_data"`
}
func (ev *EventNewLogDrainType) String() string {
return fmt.Sprintf("Log drain added on %s app", ev.AppName)
}
// Delete log drain
type EventDeleteLogDrainTypeData struct {
URL string `json:"url"`
}
type EventDeleteLogDrainType struct {
Event
TypeData EventDeleteLogDrainTypeData `json:"type_data"`
}
func (ev *EventDeleteLogDrainType) String() string {
return fmt.Sprintf("Log drain deleted on %s app", ev.AppName)
}
// New addon log drain
type EventNewAddonLogDrainTypeData struct {
URL string `json:"url"`
AddonUUID string `json:"addon_uuid"`
AddonName string `json:"addon_name"`
}
type EventNewAddonLogDrainType struct {
Event
TypeData EventNewAddonLogDrainTypeData `json:"type_data"`
}
func (ev *EventNewAddonLogDrainType) String() string {
return fmt.Sprintf("Log drain added for %s addon on %s app", ev.TypeData.AddonName, ev.AppName)
}
// Delete addon log drain
type EventDeleteAddonLogDrainTypeData struct {
URL string `json:"url"`
AddonUUID string `json:"addon_uuid"`
AddonName string `json:"addon_name"`
}
type EventDeleteAddonLogDrainType struct {
Event
TypeData EventDeleteAddonLogDrainTypeData `json:"type_data"`
}
func (ev *EventDeleteAddonLogDrainType) String() string {
return fmt.Sprintf("Log drain deleted on %s addon for %s app", ev.TypeData.AddonName, ev.AppName)
}
// New notifier
type EventNewNotifierTypeData struct {
NotifierName string `json:"notifier_name"`
Active bool `json:"active"`
SendAllEvents bool `json:"send_all_events"`
SelectedEvents []string `json:"selected_events"`
NotifierType string `json:"notifier_type"`
NotifierTypeData map[string]interface{} `json:"notifier_type_data"`
PlatformName string `json:"platform_name"`
}
type EventNewNotifierType struct {
Event
TypeData EventNewNotifierTypeData `json:"type_data"`
}
var NotifierPlatformNames = map[string]string{
"email": "E-mail",
"rocker_chat": "Rocket Chat",
"slack": "Slack",
"webhook": "Webhook",
}
func (ev *EventNewNotifierType) String() string {
d := ev.TypeData
platformName, ok := NotifierPlatformNames[d.PlatformName]
if !ok {
platformName = "unknown"
}
return fmt.Sprintf("Notifier '%s' created for the platform '%s' on %s app", d.NotifierName, platformName, ev.AppName)
}
// Edit notifier
type EventEditNotifierTypeData struct {
NotifierName string `json:"notifier_name"`
Active bool `json:"active"`
SendAllEvents bool `json:"send_all_events"`
SelectedEvents []string `json:"selected_events"`
NotifierType string `json:"notifier_type"`
NotifierTypeData map[string]interface{} `json:"notifier_type_data"`
PlatformName string `json:"platform_name"`
}
type EventEditNotifierType struct {
Event
TypeData EventEditNotifierTypeData `json:"type_data"`
}
func (ev *EventEditNotifierType) String() string {
d := ev.TypeData
return fmt.Sprintf("Notifier '%s' edited on %s app", d.NotifierName, ev.AppName)
}
// Delete notifier
type EventDeleteNotifierTypeData struct {
NotifierName string `json:"notifier_name"`
Active bool `json:"active"`
SendAllEvents bool `json:"send_all_events"`
SelectedEvents []string `json:"selected_events"`
NotifierType string `json:"notifier_type"`
NotifierTypeData map[string]interface{} `json:"notifier_type_data"`
PlatformName string `json:"platform_name"`
}
type EventDeleteNotifierType struct {
Event
TypeData EventDeleteNotifierTypeData `json:"type_data"`
}
func (ev *EventDeleteNotifierType) String() string {
d := ev.TypeData
return fmt.Sprintf("Notifier '%s' deleted on %s app", d.NotifierName, ev.AppName)
}
// Edit hds_contact
type EventEditHDSContactTypeData struct {
Name string `json:"name"`
Email string `json:"email"`
PhoneNumber string `json:"phone_number"`
Company string `json:"company"`
AddressLine1 string `json:"address_line1"`
AddressLine2 string `json:"address_line2"`
AddressCity string `json:"address_city"`
AddressZip string `json:"address_zip"`
AddressCountry string `json:"address_country"`
Notes string `json:"notes"`
}
type EventEditHDSContactType struct {
Event
TypeData EventEditHDSContactTypeData `json:"type_data"`
}
func (ev *EventEditHDSContactType) String() string {
d := ev.TypeData
return fmt.Sprintf("Contact health Professional '%s' edited on %s app", d.Name, ev.AppName)
}
// Create data_access_consent
type EventCreateDataAccessConsentTypeData struct {
EndAt time.Time `json:"end_at"`
Databases bool `json:"databases"`
Containers bool `json:"containers"`
}
type EventCreateDataAccessConsentType struct {
Event
TypeData EventCreateDataAccessConsentTypeData `json:"type_data"`
}
func (ev *EventCreateDataAccessConsentType) String() string {
d := ev.TypeData
res := "Additional access "
if d.Containers {
res += "to application runtime environment, "
}
if d.Databases {
res += "to databases metadata and monitoring data, "
}
res += fmt.Sprintf("created on %s app", ev.AppName)
return res
}
// Enable Tfa
type EventTfaEnabledTypeData struct {
Provider string `json:"provider"`
}
type EventTfaEnabledType struct {
Event
TypeData EventTfaEnabledTypeData `json:"type_data"`
}
func (ev *EventTfaEnabledType) String() string {
return fmt.Sprintf("Two factor authentication enabled by %s", ev.TypeData.Provider)
}
// Disable Tfa
type EventTfaDisabledTypeData struct {
}
type EventTfaDisabledType struct {
Event
TypeData EventTfaDisabledTypeData `json:"type_data"`
}
func (ev *EventTfaDisabledType) String() string {
return "Two factor authentication disabled"
}
// Stack changed
type EventStackChangedTypeData struct {
PreviousStackID string `json:"previous_stack_id"`
CurrentStackID string `json:"current_stack_id"`
PreviousStackName string `json:"previous_stack_name"`
CurrentStackName string `json:"current_stack_name"`
}
type EventStackChangedType struct {
Event
TypeData EventStackChangedTypeData `json:"type_data"`
}
func (ev *EventStackChangedType) String() string {
d := ev.TypeData
return fmt.Sprintf("Stack changed from '%s' to %s", d.PreviousStackName, d.CurrentStackName)
}
// Database maintenance planned
type EventPlanDatabaseMaintenanceTypeData struct {
AddonName string `json:"addon_name"`
MaintenanceID string `json:"maintenance_id"`
MaintenanceWindowInHours int `json:"maintenance_window_in_hours"`
MaintenanceType string `json:"maintenance_type"`
NextMaintenanceWindow time.Time `json:"next_maintenance_window"`
}
type EventPlanDatabaseMaintenanceType struct {
Event
TypeData EventPlanDatabaseMaintenanceTypeData `json:"type_data"`
}
func (ev *EventPlanDatabaseMaintenanceType) String() string {
return fmt.Sprintf("A maintenance (ID: %s) has been scheduled on the %s database.", ev.TypeData.MaintenanceID, ev.TypeData.AddonName)
}
func (ev *EventPlanDatabaseMaintenanceType) Who() string {
return ev.Event.Who()
}
// Database maintenance started
type EventStartDatabaseMaintenanceTypeData struct {
AddonName string `json:"addon_name"`
MaintenanceID string `json:"maintenance_id"`
MaintenanceWindowInHours int `json:"maintenance_window_in_hours"`
MaintenanceType string `json:"maintenance_type"`
NextMaintenanceWindow time.Time `json:"next_maintenance_window"`
}
type EventStartDatabaseMaintenanceType struct {
Event
TypeData EventStartDatabaseMaintenanceTypeData `json:"type_data"`
}
func (ev *EventStartDatabaseMaintenanceType) String() string {
return fmt.Sprintf("A maintenance (ID: %s) has started on the %s database.", ev.TypeData.MaintenanceID, ev.TypeData.AddonName)
}
func (ev *EventStartDatabaseMaintenanceType) Who() string {
return ev.Event.Who()
}
// Database maintenance completed
type EventCompleteDatabaseMaintenanceTypeData struct {
AddonName string `json:"addon_name"`
MaintenanceID string `json:"maintenance_id"`
MaintenanceWindowInHours int `json:"maintenance_window_in_hours"`
MaintenanceType string `json:"maintenance_type"`
NextMaintenanceWindow time.Time `json:"next_maintenance_window"`
}
type EventCompleteDatabaseMaintenanceType struct {
Event
TypeData EventCompleteDatabaseMaintenanceTypeData `json:"type_data"`
}
func (ev *EventCompleteDatabaseMaintenanceType) String() string {
return fmt.Sprintf("A maintenance (ID: %s) has been completed on the %s database.", ev.TypeData.MaintenanceID, ev.TypeData.AddonName)
}
func (ev *EventCompleteDatabaseMaintenanceType) Who() string {
return ev.Event.Who()
}