incident.go 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. package types
  2. import "time"
  3. const URLParamIncidentID URLParam = "incident_id"
  4. type SeverityType string
  5. const (
  6. SeverityCritical SeverityType = "critical"
  7. SeverityNormal SeverityType = "normal"
  8. )
  9. type InvolvedObjectKind string
  10. const (
  11. InvolvedObjectDeployment InvolvedObjectKind = "deployment"
  12. InvolvedObjectJob InvolvedObjectKind = "job"
  13. InvolvedObjectPod InvolvedObjectKind = "pod"
  14. )
  15. type IncidentStatus string
  16. const (
  17. IncidentStatusResolved IncidentStatus = "resolved"
  18. IncidentStatusActive IncidentStatus = "active"
  19. )
  20. type IncidentMeta struct {
  21. ID string `json:"id" form:"required"`
  22. ReleaseName string `json:"release_name" form:"required"`
  23. ReleaseNamespace string `json:"release_namespace" form:"required"`
  24. ChartName string `json:"chart_name" form:"required"`
  25. CreatedAt time.Time `json:"created_at" form:"required"`
  26. UpdatedAt time.Time `json:"updated_at" form:"required"`
  27. LastSeen *time.Time `json:"last_seen" form:"required"`
  28. Status IncidentStatus `json:"status" form:"required"`
  29. Summary string `json:"summary" form:"required"`
  30. ShortSummary string `json:"short_summary"`
  31. Severity SeverityType `json:"severity" form:"required"`
  32. InvolvedObjectKind InvolvedObjectKind `json:"involved_object_kind" form:"required"`
  33. InvolvedObjectName string `json:"involved_object_name" form:"required"`
  34. InvolvedObjectNamespace string `json:"involved_object_namespace" form:"required"`
  35. ShouldViewLogs bool `json:"should_view_logs"`
  36. }
  37. type PaginationRequest struct {
  38. Page int64 `schema:"page"`
  39. }
  40. type PaginationResponse struct {
  41. NumPages int64 `json:"num_pages" form:"required"`
  42. CurrentPage int64 `json:"current_page" form:"required"`
  43. NextPage int64 `json:"next_page" form:"required"`
  44. }
  45. type ListIncidentsRequest struct {
  46. *PaginationRequest
  47. Status *IncidentStatus `schema:"status"`
  48. ReleaseName *string `schema:"release_name"`
  49. ReleaseNamespace *string `schema:"release_namespace"`
  50. }
  51. type ListIncidentsResponse struct {
  52. Incidents []*IncidentMeta `json:"incidents" form:"required"`
  53. Pagination *PaginationResponse `json:"pagination"`
  54. }
  55. type GetIncidentResponse *Incident
  56. type Incident struct {
  57. *IncidentMeta
  58. Pods []string `json:"pods" form:"required"`
  59. Detail string `json:"detail" form:"required"`
  60. }
  61. type IncidentEvent struct {
  62. ID string `json:"id" form:"required"`
  63. LastSeen *time.Time `json:"last_seen" form:"required"`
  64. PodName string `json:"pod_name" form:"required"`
  65. PodNamespace string `json:"pod_namespace" form:"required"`
  66. Summary string `json:"summary" form:"required"`
  67. Detail string `json:"detail" form:"required"`
  68. Revision string `json:"revision"`
  69. }
  70. type ListIncidentEventsRequest struct {
  71. *PaginationRequest
  72. PodName *string `schema:"pod_name"`
  73. PodNamespace *string `schema:"pod_namespace"`
  74. Summary *string `schema:"summary"`
  75. }
  76. type ListIncidentEventsResponse struct {
  77. Events []*IncidentEvent `json:"events" form:"required"`
  78. Pagination *PaginationResponse `json:"pagination"`
  79. }
  80. type GetLogRequest struct {
  81. Limit uint `schema:"limit"`
  82. StartRange *time.Time `schema:"start_range"`
  83. EndRange *time.Time `schema:"end_range"`
  84. SearchParam string `schema:"search_param"`
  85. Revision string `schema:"revision"`
  86. PodSelector string `schema:"pod_selector" form:"required"`
  87. Namespace string `schema:"namespace" form:"required"`
  88. Direction string `schema:"direction"`
  89. }
  90. type GetPodValuesRequest struct {
  91. StartRange *time.Time `schema:"start_range"`
  92. EndRange *time.Time `schema:"end_range"`
  93. MatchPrefix string `schema:"match_prefix"`
  94. Revision string `schema:"revision"`
  95. }
  96. type GetRevisionValuesRequest struct {
  97. StartRange *time.Time `schema:"start_range"`
  98. EndRange *time.Time `schema:"end_range"`
  99. MatchPrefix string `schema:"match_prefix"`
  100. }
  101. type LogLine struct {
  102. Timestamp *time.Time `json:"timestamp"`
  103. Line string `json:"line"`
  104. }
  105. type GetLogResponse struct {
  106. BackwardContinueTime *time.Time `json:"backward_continue_time"`
  107. ForwardContinueTime *time.Time `json:"forward_continue_time"`
  108. Logs []LogLine `json:"logs"`
  109. }
  110. type GetKubernetesEventRequest struct {
  111. Limit uint `schema:"limit"`
  112. StartRange *time.Time `schema:"start_range"`
  113. EndRange *time.Time `schema:"end_range"`
  114. Revision string `schema:"revision"`
  115. PodSelector string `schema:"pod_selector" form:"required"`
  116. Namespace string `schema:"namespace" form:"required"`
  117. }
  118. type KubernetesEventLine struct {
  119. Timestamp *time.Time `json:"timestamp"`
  120. Event string `json:"event"`
  121. }
  122. type GetKubernetesEventResponse struct {
  123. ContinueTime *time.Time `json:"continue_time"`
  124. Events []KubernetesEventLine `json:"events"`
  125. }
  126. type EventType string
  127. const (
  128. EventTypeIncident EventType = "incident"
  129. EventTypeIncidentResolved EventType = "incident_resolved"
  130. EventTypeDeploymentStarted EventType = "deployment_started"
  131. EventTypeDeploymentFinished EventType = "deployment_finished"
  132. EventTypeDeploymentErrored EventType = "deployment_errored"
  133. )
  134. type Event struct {
  135. Type EventType `json:"type"`
  136. Version string `json:"version"`
  137. ReleaseName string `json:"release_name"`
  138. ReleaseNamespace string `json:"release_namespace"`
  139. Timestamp *time.Time `json:"timestamp"`
  140. Data map[string]interface{} `json:"data"`
  141. }
  142. type ListEventsRequest struct {
  143. *PaginationRequest
  144. ReleaseName *string `schema:"release_name"`
  145. ReleaseNamespace *string `schema:"release_namespace"`
  146. Type *string `schema:"type"`
  147. }
  148. type ListEventsResponse struct {
  149. Events []*Event `json:"events" form:"required"`
  150. Pagination *PaginationResponse `json:"pagination"`
  151. }