-
Notifications
You must be signed in to change notification settings - Fork 4
/
ip_methods.go
70 lines (56 loc) · 2.5 KB
/
ip_methods.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package pncp
import (
"fmt"
)
func (r *Client) ListPublicIPsForVirtualMachine(id uint64) (Future, error) {
path := fmt.Sprintf(`/virtualmachine/%s/publicip`, id)
return r.call(`GET`, path, "", nil)
}
func (r *Client) ListPublicIPsForVirtualMachineResource(resource string) (Future, error) {
path := fmt.Sprintf(`%s/publicip`, resource)
return r.call(`GET`, path, "", nil)
}
func (r *Client) ListPrivateIPsForVirtualMachine(id uint64) (Future, error) {
path := fmt.Sprintf(`/virtualmachine/%s/privateip`, id)
return r.call(`GET`, path, "", nil)
}
func (r *Client) GetPublicIPDetailsOnVirtualMachine(id uint64, ip string) (Future, error) {
path := fmt.Sprintf(`/virtualmachine/%s/publicip/%s`, id, ip)
return r.call(`GET`, path, "", nil)
}
func (r *Client) GetPublicIPResourceDetails(resource string) (Future, error) {
return r.call(`GET`, resource, "", nil)
}
func (r *Client) GetPrivateIPDetailsOnVirtualMachine(id uint64, ip string) (Future, error) {
path := fmt.Sprintf(`/virtualmachine/%s/privateip/%s`, id, ip)
return r.call(`GET`, path, "", nil)
}
func (r *Client) AssignPublicIPToVirtualMachine(id uint64, spec PublicIPSpec) (Future, error) {
path := fmt.Sprintf(`/virtualmachine/%s/publicip`, id)
return r.call(`POST`, path, "", spec)
}
func (r *Client) AssignPublicIPToVirtualMachineResource(resource string, spec PublicIPSpec) (Future, error) {
path := fmt.Sprintf(`%s/publicip`, resource)
return r.call(`POST`, path, "", spec)
}
func (r *Client) AssignPrivateIPToVirtualMachine(id uint64, spec PrivateIPSpec) (Future, error) {
path := fmt.Sprintf(`/virtualmachine/%s/privateip`, id)
return r.call(`POST`, path, "", spec)
}
func (r *Client) ModifyPublicIPOnVirtualMachine(id uint64, ip string, spec PublicIPUpdateSpec) (Future, error) {
path := fmt.Sprintf(`/virtualmachine/%s/publicip/%s`, id, ip)
return r.call(`PUT`, path, "", spec)
}
func (r *Client) ModifyPrivateIPOnVirtualMachine(id uint64, ip string, spec PrivateIPUpdateSpec) (Future, error) {
path := fmt.Sprintf(`/virtualmachine/%s/privateip/%s`, id, ip)
return r.call(`PUT`, path, "", spec)
}
func (r *Client) ReleasePublicIPOnVirtualMachine(id uint64, ip string, release bool) (Future, error) {
path := fmt.Sprintf(`/virtualmachine/%s/publicip/%s`, id, ip)
qs := fmt.Sprintf(`?moveToReservedList=%s`, release)
return r.call(`DELETE`, path, qs, nil)
}
func (r *Client) ReleasePrivateIPOnVirtualMachine(id uint64, ip string) (Future, error) {
path := fmt.Sprintf(`/virtualmachine/%s/privateip/%s`, id, ip)
return r.call(`DELETE`, path, "", nil)
}