github.com/david-imola/snapd@v0.0.0-20210611180407-2de8ddeece6d/daemon/api_json.go (about) 1 // -*- Mode: Go; indent-tabs-mode: t -*- 2 3 /* 4 * Copyright (C) 2016-2018 Canonical Ltd 5 * 6 * This program is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License version 3 as 8 * published by the Free Software Foundation. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program. If not, see <http://www.gnu.org/licenses/>. 17 * 18 */ 19 20 package daemon 21 22 import ( 23 "github.com/snapcore/snapd/interfaces" 24 ) 25 26 // plugJSON aids in marshaling snap.PlugInfo into JSON. 27 type plugJSON struct { 28 Snap string `json:"snap"` 29 Name string `json:"plug"` 30 Interface string `json:"interface,omitempty"` 31 Attrs map[string]interface{} `json:"attrs,omitempty"` 32 Apps []string `json:"apps,omitempty"` 33 Label string `json:"label,omitempty"` 34 // Connections are synthesized, they are not on the original type. 35 Connections []interfaces.SlotRef `json:"connections,omitempty"` 36 } 37 38 // slotJSON aids in marshaling snap.SlotInfo into JSON. 39 type slotJSON struct { 40 Snap string `json:"snap"` 41 Name string `json:"slot"` 42 Interface string `json:"interface,omitempty"` 43 Attrs map[string]interface{} `json:"attrs,omitempty"` 44 Apps []string `json:"apps,omitempty"` 45 Label string `json:"label,omitempty"` 46 // Connections are synthesized, they are not on the original type. 47 Connections []interfaces.PlugRef `json:"connections,omitempty"` 48 } 49 50 // interfaceJSON aids in marshaling interfaces.Info into JSON. 51 type interfaceJSON struct { 52 Name string `json:"name,omitempty"` 53 Summary string `json:"summary,omitempty"` 54 DocURL string `json:"doc-url,omitempty"` 55 Plugs []*plugJSON `json:"plugs,omitempty"` 56 Slots []*slotJSON `json:"slots,omitempty"` 57 } 58 59 // interfaceAction is an action performed on the interface system. 60 type interfaceAction struct { 61 Action string `json:"action"` 62 Forget bool `json:"forget,omitempty"` 63 Plugs []plugJSON `json:"plugs,omitempty"` 64 Slots []slotJSON `json:"slots,omitempty"` 65 } 66 67 // connectionsJSON aids in marshalling information about a single connection 68 // into JSON 69 type connectionJSON struct { 70 Slot interfaces.SlotRef `json:"slot"` 71 Plug interfaces.PlugRef `json:"plug"` 72 Interface string `json:"interface"` 73 Manual bool `json:"manual,omitempty"` 74 Gadget bool `json:"gadget,omitempty"` 75 SlotAttrs map[string]interface{} `json:"slot-attrs,omitempty"` 76 PlugAttrs map[string]interface{} `json:"plug-attrs,omitempty"` 77 } 78 79 // legacyConnectionsJSON aids in marshaling legacy connections into JSON. 80 type legacyConnectionsJSON struct { 81 Plugs []*plugJSON `json:"plugs,omitempty"` 82 Slots []*slotJSON `json:"slots,omitempty"` 83 } 84 85 // connectionsJSON aids in marshaling connections into JSON. 86 type connectionsJSON struct { 87 Established []connectionJSON `json:"established"` 88 Undesired []connectionJSON `json:"undesired,omitempty"` 89 Plugs []*plugJSON `json:"plugs"` 90 Slots []*slotJSON `json:"slots"` 91 }