feat: implement service history view and tracking
This commit is contained in:
@@ -91,3 +91,23 @@ func UnlockService(serviceName, user string) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetHistory(serviceName string) ([]models.HistoryEntry, error) {
|
||||
req, err := http.NewRequest("GET", baseURL+"/history?service="+serviceName, nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Set("X-API-Key", apiToken)
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
var history []models.HistoryEntry
|
||||
if err := json.NewDecoder(resp.Body).Decode(&history); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return history, nil
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ import "time"
|
||||
|
||||
// Service represents a microservice that can be locked.
|
||||
type Service struct {
|
||||
Name string `json:"name"`
|
||||
IsLocked bool `json:"is_locked"`
|
||||
LockedBy string `json:"locked_by,omitempty"`
|
||||
LockedAt time.Time `json:"locked_at,omitempty"`
|
||||
Name string `json:"name"`
|
||||
IsLocked bool `json:"is_locked"`
|
||||
LockedBy string `json:"locked_by,omitempty"`
|
||||
LockedAt time.Time `json:"locked_at,omitempty"`
|
||||
}
|
||||
|
||||
// LockRequest is the payload to lock a service.
|
||||
@@ -21,3 +21,11 @@ type UnlockRequest struct {
|
||||
ServiceName string `json:"service_name"`
|
||||
User string `json:"user"`
|
||||
}
|
||||
|
||||
// HistoryEntry represents a historical event for a service.
|
||||
type HistoryEntry struct {
|
||||
ServiceName string `json:"service_name"`
|
||||
Action string `json:"action"` // "LOCK" or "UNLOCK"
|
||||
User string `json:"user"`
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user