package model import ( "encoding/json" "time" ) // Changeset statuses. const ( ChangesetOpen = "open" ChangesetApplied = "applied" ChangesetDiscarded = "discarded" ) // Changeset is a list of changes, staged to be reviewed and applied // together (or discarded). Applied, it is one history entry. type Changeset struct { ID int64 `json:"id"` UserID int64 `json:"user_id,omitempty"` Username string `json:"username"` Via string `json:"via"` Description string `json:"description"` Status string `json:"status"` Ops []Op `json:"ops"` CreatedAt time.Time `json:"created_at"` UpdatedAt time.Time `json:"updated_at"` // HistoryID is the history entry an applied changeset became. HistoryID int64 `json:"history_id,omitempty"` } // Operations. const ( OpCreate = "create" OpUpdate = "update" OpDelete = "delete" OpMove = "move" OpSettings = "settings" ) // Op is one change, as the API received it, so it can be stored and // replayed on whatever the configuration is when it is applied. type Op struct { Seq int `json:"seq"` Op string `json:"op"` // create, update, delete, move, settings Kind string `json:"kind,omitempty"` // Ref names the object (ID, or name) for update, delete and move. Ref string `json:"ref,omitempty"` // ID is the object a create makes, given when it is staged so later // operations can name it. ID int64 `json:"id,omitempty"` // Data is the object (create), the fields to change (update, // settings) or where to move it (move). Data json.RawMessage `json:"data,omitempty"` Summary string `json:"summary"` AddedAt time.Time `json:"added_at"` }