Skip to content

Commit e99c9e1

Browse files
remove unused VNC params (#265)
* remove unused VNC params * removed old console SDK methods and fields * fix vnc
1 parent 639be60 commit e99c9e1

File tree

3 files changed

+8
-47
lines changed

3 files changed

+8
-47
lines changed

fake_client.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ type Clienter interface {
8383
SoftRebootInstance(id string) (*SimpleResponse, error)
8484
StopInstance(id string) (*SimpleResponse, error)
8585
StartInstance(id string) (*SimpleResponse, error)
86-
GetInstanceConsoleURL(id string) (string, error)
8786
UpgradeInstance(id, newSize string) (*SimpleResponse, error)
8887
MovePublicIPToInstance(id, ipAddress string) (*SimpleResponse, error)
8988
SetInstanceFirewall(id, firewallID string) (*SimpleResponse, error)

instance.go

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -60,22 +60,18 @@ type Instance struct {
6060
AllowedIPs []string `json:"allowed_ips,omitempty"`
6161
}
6262

63-
//"cpu_cores":1,"ram_mb":2048,"disk_gb":25
64-
65-
// InstanceConsole represents a link to a webconsole for an instances
66-
type InstanceConsole struct {
67-
URL string `json:"url"`
68-
}
69-
7063
// InstanceVnc represents VNC information for an instances
7164
type InstanceVnc struct {
7265
URI string `json:"uri,omitempty"`
73-
Result string `json:"result,omitempty"`
74-
Name string `json:"name,omitempty"`
75-
Label string `json:"label,omitempty"`
7666
Expiration string `json:"expiration,omitempty"`
7767
}
7868

69+
// CreateInstanceVncResp represents VNC information for a new instance console
70+
type CreateInstanceVncResp struct {
71+
URI string `json:"uri,omitempty"`
72+
Duration string `json:"duration,omitempty"`
73+
}
74+
7975
// PaginatedInstanceList returns a paginated list of Instance object
8076
type PaginatedInstanceList struct {
8177
Page int `json:"page"`
@@ -291,7 +287,7 @@ func (c *Client) UpdateInstance(i *Instance) (*SimpleResponse, error) {
291287

292288
// GetInstanceVnc enables and gets the VNC information for an instance
293289
// duration is optional and follows Go's duration string format (e.g. "30m", "1h", "24h")
294-
func (c *Client) GetInstanceVnc(id string, duration ...string) (InstanceVnc, error) {
290+
func (c *Client) GetInstanceVnc(id string, duration ...string) (CreateInstanceVncResp, error) {
295291
url := fmt.Sprintf("/v2/instances/%s/vnc", id)
296292
if len(duration) > 0 && duration[0] != "" {
297293
url = fmt.Sprintf("%s?duration=%s", url, duration[0])
@@ -300,7 +296,7 @@ func (c *Client) GetInstanceVnc(id string, duration ...string) (InstanceVnc, err
300296
resp, err := c.SendPutRequest(url, map[string]string{
301297
"region": c.Region,
302298
})
303-
vnc := InstanceVnc{}
299+
vnc := CreateInstanceVncResp{}
304300

305301
if err != nil {
306302
return vnc, decodeError(err)
@@ -402,18 +398,6 @@ func (c *Client) StartInstance(id string) (*SimpleResponse, error) {
402398
return response, err
403399
}
404400

405-
// GetInstanceConsoleURL gets the web URL for an instance's console
406-
func (c *Client) GetInstanceConsoleURL(id string) (string, error) {
407-
resp, err := c.SendGetRequest(fmt.Sprintf("/v2/instances/%s/console", id))
408-
if err != nil {
409-
return "", decodeError(err)
410-
}
411-
412-
console := InstanceConsole{}
413-
err = json.NewDecoder(bytes.NewReader(resp)).Decode(&console)
414-
return console.URL, err
415-
}
416-
417401
// UpgradeInstance resizes the instance up to the new specification
418402
// it's not possible to resize the instance to a smaller size
419403
func (c *Client) UpgradeInstance(id, newSize string) (*SimpleResponse, error) {

instance_test.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -442,28 +442,6 @@ func TestGetInstanceVncStatus(t *testing.T) {
442442
}
443443
}
444444

445-
func TestGetInstanceConsoleURL(t *testing.T) {
446-
client, server, _ := NewAdvancedClientForTesting([]ConfigAdvanceClientForTesting{
447-
{
448-
Method: "GET",
449-
Value: []ValueAdvanceClientForTesting{
450-
{
451-
RequestBody: `""`,
452-
URL: "/v2/instances/12345/console",
453-
ResponseBody: `{"url": "https://console.example.com/12345"}`,
454-
},
455-
},
456-
},
457-
})
458-
defer server.Close()
459-
460-
got, _ := client.GetInstanceConsoleURL("12345")
461-
462-
if got != "https://console.example.com/12345" {
463-
t.Errorf("Expected %s, got %s", "https://console.example.com/12345", got)
464-
}
465-
}
466-
467445
func TestSetInstanceFirewall(t *testing.T) {
468446
client, server, _ := NewAdvancedClientForTesting([]ConfigAdvanceClientForTesting{
469447
{

0 commit comments

Comments
 (0)