Files
houston-be/model/incident/model.go
Vijay Joshi 804be01c2f INFRA-3467 : Private Houston Incidents (#445)
* INFRA-3467 : Private Houston Incidents

* INFRA-3627 : Minor self review

* INFRA-3627 : PR Review changes

INFRA-3627 : Minor changes

INFRA-3627 : UT fix

INFRA-3637 : Message changes

INFRA-3627 : Minor changes

INFRA-3627 : Constant fix

INFRA-3627 : Do not post SLA breach in public channels for private incidents
2024-08-08 19:20:04 +05:30

128 lines
4.7 KiB
Go

package incident
import (
"database/sql/driver"
"encoding/json"
"errors"
"fmt"
"github.com/lib/pq"
"houston/model/product"
"houston/model/severity"
"houston/model/team"
"time"
)
type JSON json.RawMessage
// Scan scan value into Jsonb, implements sql.Scanner interface
func (j *JSON) Scan(value interface{}) error {
bytes, ok := value.([]byte)
if !ok {
return errors.New(fmt.Sprint("Failed to unmarshal JSONB value:", value))
}
result := json.RawMessage{}
err := json.Unmarshal(bytes, &result)
*j = JSON(result)
return err
}
// Value return json value, implement driver.Valuer interface
func (j JSON) Value() (driver.Value, error) {
if len(j) == 0 {
return nil, nil
}
return json.RawMessage(j).MarshalJSON()
}
type CreateIncidentDTO struct {
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
Severity string `json:"severity,omitempty"`
Pagerduty string `json:"pagerduty,omitempty"`
Status IncidentStatus `json:"status,omitempty"`
IncidentName string `json:"incident_name,omitempty"`
SlackChannel string `json:"slack_channel,omitempty"`
DetectionTime *time.Time `json:"detection_time,omitempty"`
StartTime time.Time `json:"start_time,omitempty"`
EndTime *time.Time `json:"end_time,omitempty"`
TeamId string `json:"type,omitempty"`
JiraId *string `json:"jira_id,omitempty"`
ConfluenceId *string `json:"confluence_id,omitempty"`
SeverityTat *time.Time `json:"severity_tat,omitempty"`
RemindMeAt *time.Time `json:"remind_me_at,omitempty"`
EnableReminder bool `json:"enable_reminder,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
UpdatedBy string `json:"updated_by,omitempty"`
MetaData JSON `json:"meta_data,omitempty"`
ProductIds []uint `json:"product_ids,omitempty"`
ReportingTeamID *uint `json:"reporting_team_id,omitempty"`
IsPrivate bool `json:"is_private,omitempty"`
}
type IncidentSeverityTeamDTO struct {
Title string
Status IncidentStatus
SeverityName string
SlackChannel string
TeamName string
}
type AddIncidentRoleRequest struct {
UserId string `json:"users_select,omitempty"`
Role IncidentRole `json:"role_type,omitempty"`
IncidentId int
CreatedById string
}
type CreateIncidentChannelEntry struct {
SlackChannel string `gorm:"column:slack_channel"`
IncidentId uint `gorm:"column:incident_id"`
MessageTimeStamp string `gorm:"column:message_timestamp"`
}
type AddIncidentStatusRequest struct {
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
}
type TeamMetricDetailsOfIncident struct {
SlackChannel string `json:"slack_channel,omitempty"`
ResponderId string `json:"responder_id,omitempty"`
CreatedAt time.Time
Severity string
ManagerId string
}
type IncidentDTO struct {
ID uint `json:"id,omitempty"`
Title string `json:"title,omitempty"`
Description string `json:"description,omitempty"`
SeverityId uint `json:"severity_id,omitempty"`
Status uint `json:"status,omitempty"`
IncidentName string `json:"incident_name,omitempty"`
SlackChannel string `json:"slack_channel,omitempty"`
TeamId uint `json:"team_id,omitempty"`
JiraLinks pq.StringArray `json:"jira_links,omitempty"`
ConfluenceId *string `json:"confluence_id,omitempty"`
CreatedAt time.Time `json:"created_at,omitempty"`
CreatedBy string `json:"created_by,omitempty"`
RCA string `json:"rca,omitempty"`
ConferenceId string `json:"conference_id,omitempty"`
ConferenceLink string `json:"conference_link,omitempty"`
ReportingTeamId *uint `json:"reporting_team_id,omitempty"`
Products []product.ProductDTO `json:"products,omitempty"`
SeverityTat time.Time `json:"severity_tat,omitempty"`
Team team.TeamDTO `json:"team,omitempty"`
Severity severity.SeverityDTO `json:"severity,omitempty"`
ReportingTeam team.TeamDTO `json:"reporting_team,omitempty"`
IsPrivate bool `json:"is_private,omitempty"`
}
type IncidentRoleDTO struct {
IncidentId int `json:"incident_id,omitempty"`
Role IncidentRole `json:"role,omitempty"`
AssignedTo string `json:"assigned_to,omitempty"`
AssignedBy string `json:"assigned_by,omitempty"`
}