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