forked from ionos-enterprise/ionos-enterprise-sdk-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pcc.go
128 lines (110 loc) · 3.87 KB
/
pcc.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package profitbricks
import "net/http"
// PrivateCrossConnect type
type PrivateCrossConnect struct {
// URL to the object representation (absolute path)
// Read Only: true
// Format: uri
Href string `json:"href,omitempty"`
// The resource's unique identifier.
// Read Only: true
ID string `json:"id,omitempty"`
// metadata
Metadata *Metadata `json:"metadata,omitempty"`
// properties
// Required: true
Properties *PrivateCrossConnectProperties `json:"properties"`
// The type of object
// Read Only: true
// Enum: [pcc]
PBType string `json:"type,omitempty"`
}
// PrivateCrossConnects type
type PrivateCrossConnects struct {
// URL to the collection representation (absolute path)
// Read Only: true
// Format: uri
Href string `json:"href,omitempty"`
// Unique representation for private cros-connect as a collection on a resource.
// Read Only: true
ID string `json:"id,omitempty"`
// Slice of items in that collection
// Read Only: true
Items []PrivateCrossConnect `json:"items"`
// The type of resource within a collection
// Read Only: true
// Enum: [collection]
PBType string `json:"type,omitempty"`
}
// PrivateCrossConnectProperties type
type PrivateCrossConnectProperties struct {
// The desired name for the PrivateCrossConnect
// Required: true
Name string `json:"name,omitempty"`
// A description for this PrivateCrossConnect
// Required: true
Description string `json:"description,omitempty"`
// The peers of the PrivateCrossConnect
// Required: false
// Readonly: true
Peers *[]PCCPeer `json:"peers,omitempty"`
// The Connectable VDC's
// Required: false
// Readonly: true
ConnectableDatacenters *[]PCCConnectableDataCenter `json:"connectableDatacenters,omitempty"`
}
// PCCPeer type
type PCCPeer struct {
// The id of the cross-connected LAN
// Required: false
LANId string `json:"id,omitempty"`
// The name of the cross-connected LAN
// Required: false
LANName string `json:"name,omitempty"`
// The id of the cross-connected VDC
// Required: false
DataCenterID string `json:"datacenterId,omitempty"`
// The name of the cross-connected VDC
// Required: false
DataCenterName string `json:"datacenterName,omitempty"`
// The location of the cross-connected VDC
// Required: false
Location string `json:"location,omitempty"`
}
// PCCConnectableDataCenter type
type PCCConnectableDataCenter struct {
// The id of the cross-connectable VDC
// Required: false
ID string `json:"id,omitempty"`
// The name of the cross-connectable VDC
// Required: false
Name string `json:"name,omitempty"`
// The name of the cross-connectable VDC
// Required: false
Location string `json:"location,omitempty"`
}
// ListPrivateCrossConnects gets a list of all private cross-connects
func (c *Client) ListPrivateCrossConnects() (*PrivateCrossConnects, error) {
rsp := &PrivateCrossConnects{}
return rsp, c.GetOK(PrivateCrossConnectsPath(), rsp)
}
// GetPrivateCrossConnect gets a private cross-connect with given id
func (c *Client) GetPrivateCrossConnect(pccID string) (*PrivateCrossConnect, error) {
rsp := &PrivateCrossConnect{}
return rsp, c.GetOK(PrivateCrossConnectPath(pccID), rsp)
}
// CreatePrivateCrossConnect creates a private cross-connect
func (c *Client) CreatePrivateCrossConnect(pcc PrivateCrossConnect) (*PrivateCrossConnect, error) {
rsp := &PrivateCrossConnect{}
return rsp, c.PostAcc(PrivateCrossConnectsPath(), pcc, rsp)
}
// UpdatePrivateCrossConnect updates a private cross-connect
func (c *Client) UpdatePrivateCrossConnect(pccID string, pcc PrivateCrossConnect) (*PrivateCrossConnect, error) {
rsp := &PrivateCrossConnect{}
return rsp, c.PatchAcc(PrivateCrossConnectPath(pccID), pcc.Properties, rsp)
}
// DeletePrivateCrossConnect deletes a private cross-connect by its id
func (c *Client) DeletePrivateCrossConnect(pccID string) (*http.Header, error) {
h := &http.Header{}
return h, c.Delete(PrivateCrossConnectPath(pccID), h, http.StatusAccepted)
}