Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for instance VNC #214

Merged
merged 2 commits into from
Sep 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading