All checks were successful
release-tag / release-image (push) Successful in 1m33s
184 lines
6.6 KiB
Go
184 lines
6.6 KiB
Go
package model
|
|
|
|
import "time"
|
|
|
|
type LinkedItem struct {
|
|
ItemType string `json:"item_type"`
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name,omitempty"`
|
|
}
|
|
|
|
type Ticket struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Content string `json:"content"`
|
|
DateMod string `json:"date_mod"`
|
|
StatusID int64 `json:"status_id"`
|
|
CategoryID int64 `json:"category_id"`
|
|
RequesterIDs []int64 `json:"requester_ids,omitempty"`
|
|
Items []LinkedItem `json:"items,omitempty"`
|
|
}
|
|
|
|
type Followup struct {
|
|
ID int64 `json:"id"`
|
|
Content string `json:"content"`
|
|
IsPrivate bool `json:"is_private"`
|
|
UserID int64 `json:"user_id"`
|
|
Date string `json:"date"`
|
|
}
|
|
|
|
type Category struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
CompleteName string `json:"completename"`
|
|
}
|
|
|
|
type KnowledgeDoc struct {
|
|
ID string `json:"id"`
|
|
Title string `json:"title"`
|
|
Text string `json:"text"`
|
|
Answer string `json:"answer"`
|
|
AutoReply bool `json:"auto_reply"`
|
|
MinScore float64 `json:"min_score"`
|
|
Categories []int64 `json:"categories"`
|
|
Keywords []string `json:"keywords"`
|
|
Source string `json:"source"`
|
|
SourceURI string `json:"source_uri,omitempty"`
|
|
Language string `json:"language"`
|
|
CommunicationStyle string `json:"communication_style"`
|
|
}
|
|
|
|
type KnowledgeHit struct {
|
|
Doc KnowledgeDoc `json:"doc"`
|
|
Score float64 `json:"score"`
|
|
}
|
|
|
|
// ChangeContext is a normalized, read-only view of a GLPI Change. Only fields
|
|
// useful for ticket triage are passed to the model.
|
|
type ChangeContext struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Content string `json:"content,omitempty"`
|
|
StatusID int64 `json:"status_id,omitempty"`
|
|
CategoryID int64 `json:"category_id,omitempty"`
|
|
PlannedBegin string `json:"planned_begin,omitempty"`
|
|
PlannedEnd string `json:"planned_end,omitempty"`
|
|
DateMod string `json:"date_mod,omitempty"`
|
|
Relevance float64 `json:"relevance"`
|
|
Source string `json:"source"`
|
|
}
|
|
|
|
type MajorIncidentContext struct {
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name"`
|
|
Content string `json:"content,omitempty"`
|
|
StatusID int64 `json:"status_id,omitempty"`
|
|
CategoryID int64 `json:"category_id,omitempty"`
|
|
Priority int64 `json:"priority,omitempty"`
|
|
Impact int64 `json:"impact,omitempty"`
|
|
Urgency int64 `json:"urgency,omitempty"`
|
|
DateMod string `json:"date_mod,omitempty"`
|
|
Relevance float64 `json:"relevance"`
|
|
Source string `json:"source"`
|
|
}
|
|
|
|
type ServiceIssueContext struct {
|
|
Source string `json:"source"`
|
|
StatusPage string `json:"status_page"`
|
|
Kind string `json:"kind"` // monitor | pinned_incident | maintenance
|
|
MonitorID int64 `json:"monitor_id,omitempty"`
|
|
MonitorName string `json:"monitor_name,omitempty"`
|
|
Status string `json:"status"`
|
|
Message string `json:"message,omitempty"`
|
|
LastHeartbeat string `json:"last_heartbeat,omitempty"`
|
|
Uptime24h float64 `json:"uptime_24h,omitempty"`
|
|
IncidentTitle string `json:"incident_title,omitempty"`
|
|
IncidentContent string `json:"incident_content,omitempty"`
|
|
Relevance float64 `json:"relevance"`
|
|
}
|
|
|
|
type UserDeviceContext struct {
|
|
UserID int64 `json:"user_id,omitempty"`
|
|
ItemType string `json:"item_type"`
|
|
ID int64 `json:"id"`
|
|
Name string `json:"name,omitempty"`
|
|
Serial string `json:"serial,omitempty"`
|
|
InventoryNumber string `json:"inventory_number,omitempty"`
|
|
Status string `json:"status,omitempty"`
|
|
Location string `json:"location,omitempty"`
|
|
LastInventoryDate string `json:"last_inventory_date,omitempty"`
|
|
Source string `json:"source"`
|
|
}
|
|
|
|
type ContextSnapshot struct {
|
|
FetchedAt time.Time `json:"fetched_at"`
|
|
Changes []ChangeContext `json:"changes,omitempty"`
|
|
MajorIncidents []MajorIncidentContext `json:"major_incidents,omitempty"`
|
|
ServiceIssues []ServiceIssueContext `json:"service_issues,omitempty"`
|
|
UserDevices []UserDeviceContext `json:"user_devices,omitempty"`
|
|
Warnings []string `json:"warnings,omitempty"`
|
|
Incomplete bool `json:"incomplete"`
|
|
}
|
|
|
|
func (c ContextSnapshot) HasRelevantIncident(minScore float64) bool {
|
|
for _, incident := range c.MajorIncidents {
|
|
if incident.Relevance >= minScore {
|
|
return true
|
|
}
|
|
}
|
|
for _, issue := range c.ServiceIssues {
|
|
if issue.Relevance >= minScore && (issue.Status == "down" || issue.Status == "pending" || issue.Kind == "pinned_incident") {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
type Decision struct {
|
|
Category struct {
|
|
ID int64 `json:"id"`
|
|
Change bool `json:"change"`
|
|
Confidence float64 `json:"confidence"`
|
|
} `json:"category"`
|
|
Reply struct {
|
|
Allowed bool `json:"allowed"`
|
|
Confidence float64 `json:"confidence"`
|
|
KnowledgeID string `json:"knowledge_id"`
|
|
} `json:"reply"`
|
|
Reason string `json:"reason"`
|
|
}
|
|
|
|
type PolicyResult struct {
|
|
ChangeCategory bool `json:"change_category"`
|
|
CategoryID int64 `json:"category_id"`
|
|
Reply bool `json:"reply"`
|
|
ReplyText string `json:"reply_text,omitempty"`
|
|
KnowledgeID string `json:"knowledge_id,omitempty"`
|
|
Reason string `json:"reason"`
|
|
}
|
|
|
|
type RunRecord struct {
|
|
RunID string `json:"run_id"`
|
|
TicketID int64 `json:"ticket_id"`
|
|
TicketName string `json:"ticket_name"`
|
|
SourceVersion string `json:"source_version"`
|
|
StartedAt time.Time `json:"started_at"`
|
|
FinishedAt time.Time `json:"finished_at"`
|
|
Outcome string `json:"outcome"`
|
|
Reason string `json:"reason"`
|
|
CategoryBefore int64 `json:"category_before"`
|
|
CategoryProposed int64 `json:"category_proposed"`
|
|
CategoryChanged bool `json:"category_changed"`
|
|
ReplyProposed bool `json:"reply_proposed"`
|
|
ReplyWritten bool `json:"reply_written"`
|
|
KnowledgeID string `json:"knowledge_id,omitempty"`
|
|
KnowledgeScore float64 `json:"knowledge_score,omitempty"`
|
|
ContextChanges int `json:"context_changes,omitempty"`
|
|
ContextIncidents int `json:"context_incidents,omitempty"`
|
|
ContextIssues int `json:"context_issues,omitempty"`
|
|
ContextDevices int `json:"context_devices,omitempty"`
|
|
ContextWarnings []string `json:"context_warnings,omitempty"`
|
|
DryRun bool `json:"dry_run"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|