Skip to content

Commit

Permalink
Merge pull request #214 from civo/vnc
Browse files Browse the repository at this point in the history
Added support for instance VNC
  • Loading branch information
uzaxirr authored Sep 26, 2024
2 parents f5f607f + 549f159 commit 46c541d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ 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"`
Name string `json:"name"`
Label string `json:"label"`
}

// PaginatedInstanceList returns a paginated list of Instance object
type PaginatedInstanceList struct {
Page int `json:"page"`
Expand Down Expand Up @@ -261,6 +269,21 @@ 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,
})
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)
Expand Down

0 comments on commit 46c541d

Please sign in to comment.