From 69e85e1b4f5dde4671cdc6bf84965d02e1044d79 Mon Sep 17 00:00:00 2001 From: Uzair Ali <72073401+uzaxirr@users.noreply.github.com> Date: Thu, 26 Sep 2024 10:29:38 +0530 Subject: [PATCH 1/2] Added support for instance VNC --- instance.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/instance.go b/instance.go index efced0b..5ff9d09 100644 --- a/instance.go +++ b/instance.go @@ -63,6 +63,13 @@ type InstanceConsole struct { URL string `json:"url"` } +type InstanceVnc struct { + URI string `json:"uri"` + Result string `json:"result"` + Name string `json:"name"` + Label string `json:"label"` +} + // PaginatedInstanceList returns a paginated list of Instance object type PaginatedInstanceList struct { Page int `json:"page"` @@ -261,6 +268,20 @@ func (c *Client) UpdateInstance(i *Instance) (*SimpleResponse, error) { return response, err } +func (c *Client) GetInstanceVnc(id string) (InstanceVnc, error) { + resp, err := c.SendPutRequest(fmt.Sprintf("/v2/instances/%s/vnc", id), map[string]string{ + "region": c.Region, + }) + vnc := InstanceVnc{} + + if err != nil { + return vnc, decodeError(err) + } + + err = json.NewDecoder(bytes.NewReader(resp)).Decode(&vnc) + return vnc, err +} + // DeleteInstance deletes an instance and frees its resources func (c *Client) DeleteInstance(id string) (*SimpleResponse, error) { resp, err := c.SendDeleteRequest("/v2/instances/" + id) From 549f159a7b9d856433ceb5153c2a950e74cce5c2 Mon Sep 17 00:00:00 2001 From: Uzair Ali <72073401+uzaxirr@users.noreply.github.com> Date: Thu, 26 Sep 2024 10:55:01 +0530 Subject: [PATCH 2/2] lint --- instance.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/instance.go b/instance.go index 5ff9d09..2d7e9e8 100644 --- a/instance.go +++ b/instance.go @@ -63,6 +63,7 @@ type InstanceConsole struct { URL string `json:"url"` } +// InstanceVnc represents VNC information for an instances type InstanceVnc struct { URI string `json:"uri"` Result string `json:"result"` @@ -268,6 +269,7 @@ func (c *Client) UpdateInstance(i *Instance) (*SimpleResponse, error) { return response, err } +// GetInstanceVnc enables and gets the VNC information for an instance func (c *Client) GetInstanceVnc(id string) (InstanceVnc, error) { resp, err := c.SendPutRequest(fmt.Sprintf("/v2/instances/%s/vnc", id), map[string]string{ "region": c.Region,