forked from holochain/holochain-proto
/
entry_agent.go
58 lines (52 loc) · 1.34 KB
/
entry_agent.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package holochain
import (
"encoding/json"
)
const (
AgentEntryType = SysEntryTypePrefix + "agent"
AgentEntrySchema = `
{
"$id": "http://example.com/example.json",
"type": "object",
"definitions": {},
"$schema": "http://json-schema.org/draft-07/schema#",
"properties": {
"Identity": {
"$id": "/properties/Identity",
"type": "string",
"title": "The Identity Schema ",
"default": ""
},
"Revocation": {
"$id": "/properties/Revocation",
"type": "string",
"title": "The Revocation Schema ",
"default": ""
},
"PublicKey": {
"$id": "/properties/PublicKey",
"type": "string",
"title": "The Publickey Schema ",
"default": ""
}
},
"required": ["Identity", "PublicKey"]
}`
)
// AgentEntry structure for building AgentEntryType entries
type AgentEntry struct {
Identity AgentIdentity
Revocation string // marshaled revocation
PublicKey string // marshaled public key
}
var AgentEntryDef = &EntryDef{Name: AgentEntryType, DataFormat: DataFormatJSON, Sharing: Public, Schema: AgentEntrySchema}
func (ae *AgentEntry) ToJSON() (encodedEntry string, err error) {
var j []byte
j, err = json.Marshal(ae)
encodedEntry = string(j)
return
}
func AgentEntryFromJSON(j string) (entry AgentEntry, err error) {
err = json.Unmarshal([]byte(j), &entry)
return
}