From 0a5fad1fde8b372eb8df25dae0214255ad30055a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20M=C3=BCller?= Date: Wed, 12 Jun 2019 14:45:02 +0200 Subject: [PATCH] Ad Checkpoint.MarshallJSON --- Checkpoint.go | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/Checkpoint.go b/Checkpoint.go index 2b27125..9bdc4f6 100644 --- a/Checkpoint.go +++ b/Checkpoint.go @@ -1,6 +1,9 @@ package gonetworkmanager -import "github.com/godbus/dbus" +import ( + "encoding/json" + "github.com/godbus/dbus" +) const ( CheckpointInterface = NetworkManagerInterface + ".Checkpoint" @@ -22,6 +25,8 @@ type Checkpoint interface { // Timeout in seconds for automatic rollback, or zero. GetPropertyRollbackTimeout() uint32 + + MarshalJSON() ([]byte, error) } func NewCheckpoint(objectPath dbus.ObjectPath) (Checkpoint, error) { @@ -59,3 +64,15 @@ func (c *checkpoint) GetPropertyRollbackTimeout() uint32 { func (c *checkpoint) GetPath() dbus.ObjectPath { return c.obj.Path() } + +func (c *checkpoint) marshalMap() map[string]interface{} { + return map[string]interface{}{ + "Devices": c.GetPropertyDevices(), + "Created": c.GetPropertyCreated(), + "RollbackTimeout": c.GetPropertyRollbackTimeout(), + } +} + +func (c *checkpoint) MarshalJSON() ([]byte, error) { + return json.Marshal(c.marshalMap()) +}