nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 113 lines 3.0 kB view raw
1// Code generated by github.com/atombender/go-jsonschema, DO NOT EDIT. 2 3package schema 4 5import "encoding/json" 6import "fmt" 7 8type Config struct { 9 // List of addresses to listen on for libp2p traffic. 10 ListenAddresses []string `json:"listenAddresses,omitempty"` 11 12 // Trusted peers in the network. 13 Peers []ConfigPeersElem `json:"peers,omitempty"` 14 15 // This node's private key. 16 PrivateKey string `json:"privateKey"` 17 18 // The services this node provides via the Service Network. 19 Services ConfigServices `json:"services,omitempty"` 20} 21 22type ConfigPeersElem struct { 23 // PeerID of this peer. 24 Id string `json:"id"` 25 26 // Friendly name for this peer. (optional) 27 Name string `json:"name,omitempty"` 28 29 // Networks to route to this peer. (optional) 30 Routes []ConfigPeersElemRoutesElem `json:"routes,omitempty"` 31} 32 33type ConfigPeersElemRoutesElem struct { 34 // Network specification. 35 Net string `json:"net"` 36} 37 38// UnmarshalJSON implements json.Unmarshaler. 39func (j *ConfigPeersElemRoutesElem) UnmarshalJSON(b []byte) error { 40 var raw map[string]interface{} 41 if err := json.Unmarshal(b, &raw); err != nil { 42 return err 43 } 44 if _, ok := raw["net"]; raw != nil && !ok { 45 return fmt.Errorf("field net in ConfigPeersElemRoutesElem: required") 46 } 47 type Plain ConfigPeersElemRoutesElem 48 var plain Plain 49 if err := json.Unmarshal(b, &plain); err != nil { 50 return err 51 } 52 *j = ConfigPeersElemRoutesElem(plain) 53 return nil 54} 55 56// UnmarshalJSON implements json.Unmarshaler. 57func (j *ConfigPeersElem) UnmarshalJSON(b []byte) error { 58 var raw map[string]interface{} 59 if err := json.Unmarshal(b, &raw); err != nil { 60 return err 61 } 62 if _, ok := raw["id"]; raw != nil && !ok { 63 return fmt.Errorf("field id in ConfigPeersElem: required") 64 } 65 type Plain ConfigPeersElem 66 var plain Plain 67 if err := json.Unmarshal(b, &plain); err != nil { 68 return err 69 } 70 if v, ok := raw["name"]; !ok || v == nil { 71 plain.Name = "" 72 } 73 if v, ok := raw["routes"]; !ok || v == nil { 74 plain.Routes = []ConfigPeersElemRoutesElem{} 75 } 76 *j = ConfigPeersElem(plain) 77 return nil 78} 79 80// The services this node provides via the Service Network. 81type ConfigServices map[string]string 82 83// UnmarshalJSON implements json.Unmarshaler. 84func (j *Config) UnmarshalJSON(b []byte) error { 85 var raw map[string]interface{} 86 if err := json.Unmarshal(b, &raw); err != nil { 87 return err 88 } 89 if _, ok := raw["privateKey"]; raw != nil && !ok { 90 return fmt.Errorf("field privateKey in Config: required") 91 } 92 type Plain Config 93 var plain Plain 94 if err := json.Unmarshal(b, &plain); err != nil { 95 return err 96 } 97 if v, ok := raw["listenAddresses"]; !ok || v == nil { 98 plain.ListenAddresses = []string{ 99 "/ip4/0.0.0.0/tcp/8001", 100 "/ip4/0.0.0.0/udp/8001/quic-v1", 101 "/ip6/::/tcp/8001", 102 "/ip6/::/udp/8001/quic-v1", 103 } 104 } 105 if v, ok := raw["peers"]; !ok || v == nil { 106 plain.Peers = []ConfigPeersElem{} 107 } 108 if v, ok := raw["services"]; !ok || v == nil { 109 plain.Services = map[string]string{} 110 } 111 *j = Config(plain) 112 return nil 113}