Skip to content
Snippets Groups Projects
Commit 0bd565bc authored by Dan Lorenc's avatar Dan Lorenc
Browse files

Add the integrated timestamp in GetEntry.

parent d72fba08
No related branches found
No related tags found
No related merge requests found
......@@ -31,13 +31,15 @@ import (
)
type getCmdOutput struct {
Body []byte
LogIndex int
Body []byte
LogIndex int
IntegratedTime int64
}
func (g *getCmdOutput) String() string {
s := fmt.Sprintf("%d\n", g.LogIndex)
s += fmt.Sprintf("%s\n", g.Body)
s := fmt.Sprintf("Index: %d\n", g.LogIndex)
s += fmt.Sprintf("IntegratedTime: %d\n", g.IntegratedTime)
s += fmt.Sprintf("Body: %s\n", g.Body)
return s
}
......@@ -108,6 +110,7 @@ func parseEntry(e models.LogEntryAnon) (interface{}, error) {
if err := json.Unmarshal(bytes, &obj); err != nil {
return nil, err
}
obj.IntegratedTime = e.IntegratedTime
return &obj, nil
}
......
......@@ -270,6 +270,8 @@ definitions:
body:
type: object
additionalProperties: true
integratedTime:
type: integer
required:
- "body"
......
......@@ -68,8 +68,9 @@ func GetLogEntryByIndexHandler(params entries.GetLogEntryByIndexParams) middlewa
logEntry := models.LogEntry{
hex.EncodeToString(leaf.MerkleLeafHash): models.LogEntryAnon{
LogIndex: &leaf.LeafIndex,
Body: leaf.LeafValue,
LogIndex: &leaf.LeafIndex,
Body: leaf.LeafValue,
IntegratedTime: leaf.IntegrateTimestamp.AsTime().Unix(),
},
}
return entries.NewGetLogEntryByIndexOK().WithPayload(logEntry)
......@@ -158,8 +159,9 @@ func GetLogEntryByUUIDHandler(params entries.GetLogEntryByUUIDParams) middleware
logEntry := models.LogEntry{
uuid: models.LogEntryAnon{
LogIndex: swag.Int64(leaf.GetLeafIndex()),
Body: leaf.LeafValue,
LogIndex: swag.Int64(leaf.GetLeafIndex()),
Body: leaf.LeafValue,
IntegratedTime: leaf.IntegrateTimestamp.AsTime().Unix(),
},
}
return entries.NewGetLogEntryByUUIDOK().WithPayload(logEntry)
......
......@@ -66,6 +66,9 @@ type LogEntryAnon struct {
// Required: true
Body interface{} `json:"body"`
// integrated time
IntegratedTime int64 `json:"integratedTime,omitempty"`
// log index
// Minimum: 0
LogIndex *int64 `json:"logIndex,omitempty"`
......
......@@ -441,6 +441,9 @@ func init() {
"type": "object",
"additionalProperties": true
},
"integratedTime": {
"type": "integer"
},
"logIndex": {
"type": "integer"
}
......@@ -1071,6 +1074,9 @@ func init() {
"type": "object",
"additionalProperties": true
},
"integratedTime": {
"type": "integer"
},
"logIndex": {
"type": "integer",
"minimum": 0
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment