-
Notifications
You must be signed in to change notification settings - Fork 4
/
client.go
241 lines (222 loc) · 9.23 KB
/
client.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
//Package ecx implements Equinix Fabric client
package ecx
const (
//ConnectionStatusNotAvailable indicates that request to create connection was not sent
//to the provider. Applicable for provider status only
ConnectionStatusNotAvailable = "NOT_AVAILABLE"
//ConnectionStatusPendingApproval indicates that connection awaits provider's approval.
ConnectionStatusPendingApproval = "PENDING_APPROVAL"
//ConnectionStatusPendingAutoApproval indicates that connection is in process of
//automatic approval
ConnectionStatusPendingAutoApproval = "PENDING_AUTO_APPROVAL"
//ConnectionStatusProvisioning indicates that connection is in creation process
ConnectionStatusProvisioning = "PROVISIONING"
//ConnectionStatusRejected indicates that provider has rejected the connection
ConnectionStatusRejected = "REJECTED"
//ConnectionStatusPendingBGPPeering indicates that connection was approved by provider and
//awaits for BGP peering configuration on provider side
ConnectionStatusPendingBGPPeering = "PENDING_BGP_PEERING"
//ConnectionStatusPendingProviderVlan indicates that connection awaits for provider approval
//and vlan assignment
ConnectionStatusPendingProviderVlan = "PENDING_PROVIDER_VLAN"
//ConnectionStatusProvisioned indicates that connection is created successfully
ConnectionStatusProvisioned = "PROVISIONED"
//ConnectionStatusAvailable indicates that connection is established.
//Applicable for provider status only
ConnectionStatusAvailable = "AVAILABLE"
//ConnectionStatusPendingDelete indicates that connection is in deletion process and awaits
//for providers approval to be removed
ConnectionStatusPendingDelete = "PENDING_DELETE"
//ConnectionStatusDeprovisioning indicates that connection is being removed
ConnectionStatusDeprovisioning = "DEPROVISIONING"
//ConnectionStatusDeprovisioned indicates that connection is removed
ConnectionStatusDeprovisioned = "DEPROVISIONED"
//ConnectionStatusDeleted indicates that connection was administratively deleted
ConnectionStatusDeleted = "DELETED"
)
//Client describes operations provided by Equinix Fabric client module
type Client interface {
GetUserPorts() ([]Port, error)
GetL2OutgoingConnections(statuses []string) ([]L2Connection, error)
GetL2Connection(uuid string) (*L2Connection, error)
CreateL2Connection(conn L2Connection) (*string, error)
CreateL2RedundantConnection(priConn L2Connection, secConn L2Connection) (*string, *string, error)
NewL2ConnectionUpdateRequest(uuid string) L2ConnectionUpdateRequest
DeleteL2Connection(uuid string) error
ConfirmL2Connection(uuid string, confirmConn L2ConnectionToConfirm) (*L2ConnectionConfirmation, error)
GetL2SellerProfiles() ([]L2ServiceProfile, error)
GetL2ServiceProfile(uuid string) (*L2ServiceProfile, error)
CreateL2ServiceProfile(sp L2ServiceProfile) (*string, error)
UpdateL2ServiceProfile(sp L2ServiceProfile) error
DeleteL2ServiceProfile(uuid string) error
}
//L2ConnectionUpdateRequest describes composite request to update given Layer2 connection
type L2ConnectionUpdateRequest interface {
WithName(name string) L2ConnectionUpdateRequest
WithBandwidth(speed int, speedUnit string) L2ConnectionUpdateRequest
WithSpeed(speed int) L2ConnectionUpdateRequest
WithSpeedUnit(speedUnit string) L2ConnectionUpdateRequest
Execute() error
}
//Error describes Equinix Fabric error that occurs during API call processing
type Error struct {
//ErrorCode is short error identifier
ErrorCode string
//ErrorMessage is textual description of an error
ErrorMessage string
}
//L2Connection describes layer 2 connection managed by Equinix Fabric
type L2Connection struct {
UUID *string
Name *string
ProfileUUID *string
Speed *int
SpeedUnit *string
Status *string
ProviderStatus *string
Notifications []string
PurchaseOrderNumber *string
PortUUID *string
DeviceUUID *string
DeviceInterfaceID *int
VlanSTag *int
VlanCTag *int
NamedTag *string
AdditionalInfo []L2ConnectionAdditionalInfo
ZSidePortUUID *string
ZSideVlanSTag *int
ZSideVlanCTag *int
SellerRegion *string
SellerMetroCode *string
AuthorizationKey *string
RedundantUUID *string
RedundancyType *string
RedundancyGroup *string
Actions []L2ConnectionAction
// ServiceToken is used to create connections with an a-side Equinix Fabric Token
// Applicable for CREATE operations: CreateL2Connection, CreateL2RedundantConnection...
//
// Deprecated: ServiceToken (GET operations) - Starting with v2.3.0 this field should not be
// used to populate the a-side token with which the connection was created. It is maintained
// for historical compability but can contain both a-side/z-side tokens. To access the token
// returned by a GET operation (GetL2Connection, GetL2OutgoingConnections...), use the
// L2Connection.VendorToken string.
ServiceToken *string
// ZSideServiceToken is used to create connections using a z-side Equinix Fabric Token
// Applicable for CREATE operations: CreateL2Connection, CreateL2RedundantConnection...
ZSideServiceToken *string
// VendorToken is used in GET Operations (GetL2Connection, GetL2OutgoingConnections...) to
// populate the Equinix Fabric Token the connection was created with (if applicable). The token
// can be any of ServiceToken (a-side) or ZSideServiceToken (z-side). Any mechanism to
// determine the token type (a-side/z-side), must be implemented by the user/consumer of the
// SDK.
VendorToken *string
}
//L2ConnectionAdditionalInfo additional info object used in L2 connections
type L2ConnectionAdditionalInfo struct {
Name *string
Value *string
}
//L2ConnectionAction describes pending actions to complete connection provisioning
type L2ConnectionAction struct {
Type *string
Message *string
OperationID *string
RequiredData []L2ConnectionActionData
}
//L2ConnectionActionData describes data required for a given to complete
type L2ConnectionActionData struct {
Key *string
Label *string
Value *string
IsEditable *bool
ValidationPattern *string
}
//L2ConnectionToConfirm accepts the hosted connection in the seller side
type L2ConnectionToConfirm struct {
AccessKey *string
SecretKey *string
}
//L2ConnectionConfirmation describes a connection confirmed
type L2ConnectionConfirmation struct {
PrimaryConnectionID *string
Message *string
}
//L2ServiceProfile describes layer 2 service profile managed by Equinix Fabric
type L2ServiceProfile struct {
UUID *string
State *string
AlertPercentage *float64
AllowCustomSpeed *bool
AllowOverSubscription *bool
APIAvailable *bool
AuthKeyLabel *string
ConnectionNameLabel *string
CTagLabel *string
EnableAutoGenerateServiceKey *bool
EquinixManagedPortAndVlan *bool
Features L2ServiceProfileFeatures
IntegrationID *string
Name *string
OnBandwidthThresholdNotification []string
OnProfileApprovalRejectNotification []string
OnVcApprovalRejectionNotification []string
OverSubscription *string
Ports []L2ServiceProfilePort
Private *bool
PrivateUserEmails []string
RequiredRedundancy *bool
SpeedBands []L2ServiceProfileSpeedBand
SpeedFromAPI *bool
TagType *string
VlanSameAsPrimary *bool
Description *string
Metros []L2SellerProfileMetro
AdditionalInfos []L2SellerProfileAdditionalInfo
Encapsulation *string
GlobalOrganization *string
OrganizationName *string
}
//L2ServiceProfilePort describes port used in L2 service profile
type L2ServiceProfilePort struct {
ID *string
MetroCode *string
}
//L2ServiceProfileSpeedBand describes speed / bandwidth used in L2 service profile
type L2ServiceProfileSpeedBand struct {
Speed *int
SpeedUnit *string
}
//L2ServiceProfileFeatures describes features used in L2 service profile
type L2ServiceProfileFeatures struct {
CloudReach *bool
TestProfile *bool
}
//Port describes Equinix Fabric's user port
type Port struct {
UUID *string
Name *string
Region *string
IBX *string
MetroCode *string
Priority *string
Encapsulation *string
Buyout *bool
Bandwidth *string
Status *string
}
//L2SellerProfileMetro describes details of a metro in which service provices is present
type L2SellerProfileMetro struct {
Code *string
Name *string
IBXes []string
Regions map[string]string
}
//L2SellerProfileAdditionalInfo describes additional information that might be provided by service buyer when using given seller profile
type L2SellerProfileAdditionalInfo struct {
Name *string
Description *string
DataType *string
IsMandatory *bool
IsCaptureInEmail *bool
}