Skip to content

Commit c2ba588

Browse files
feat(centralnic reseller go-sdk): introducing CNR Go-SDK API Connector
BREAKING CHANGE: We have deprecated hexonet go sdk and introduced centralnic reseller go sdk due to merger of Hexonet to CNR
1 parent f6b96a0 commit c2ba588

File tree

7 files changed

+188
-260
lines changed

7 files changed

+188
-260
lines changed

apiclient/apiclient.go

Lines changed: 19 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ import (
2727
SC "github.com/centralnicgroup-opensource/rtldev-middleware-go-sdk/v4/socketconfig"
2828
)
2929

30-
// ISPAPI_CONNECTION_URL_PROXY represents the url used for the high performance connection setup
31-
const ISPAPI_CONNECTION_URL_PROXY = "http://127.0.0.1/api/call.cgi" //nolint
30+
// CNR_CONNECTION_URL_PROXY represents the url used for the high performance connection setup
31+
const CNR_CONNECTION_URL_PROXY = "http://127.0.0.1/api/call.cgi" //nolint
3232

33-
// ISPAPI_CONNECTION_URL_LIVE represents the url used for the default connection setup
34-
const ISPAPI_CONNECTION_URL_LIVE = "https://api.ispapi.net/api/call.cgi" //nolint
33+
// CNR_CONNECTION_URL_LIVE represents the url used for the default connection setup
34+
const CNR_CONNECTION_URL_LIVE = "https://api.rrpproxy.net/api/call.cgi" //nolint
3535

36-
// ISPAPI_CONNECTION_URL_OTE represents the url used for the OT&E (demo system) connection setup
37-
const ISPAPI_CONNECTION_URL_OTE = "https://api-ote.ispapi.net/api/call.cgi" //nolint
36+
// CNR_CONNECTION_URL_OTE represents the url used for the OT&E (demo system) connection setup
37+
const CNR_CONNECTION_URL_OTE = "https://api-ote.rrpproxy.net/api/call.cgi" //nolint
3838

3939
var rtm = RTM.GetInstance()
4040

@@ -66,7 +66,7 @@ func NewAPIClient() *APIClient {
6666
cl := &APIClient{
6767
debugMode: false,
6868
socketTimeout: 300 * time.Second,
69-
socketURL: ISPAPI_CONNECTION_URL_LIVE,
69+
socketURL: CNR_CONNECTION_URL_LIVE,
7070
socketConfig: SC.NewSocketConfig(),
7171
curlopts: map[string]string{},
7272
ua: "",
@@ -139,6 +139,12 @@ func (cl *APIClient) DisableDebugMode() *APIClient {
139139
return cl
140140
}
141141

142+
// UseHighPerformanceConnectionSetup to activate high performance conneciton setup
143+
func (cl *APIClient) UseHighPerformanceConnectionSetup() *APIClient {
144+
cl.SetURL(CNR_CONNECTION_URL_PROXY)
145+
return cl
146+
}
147+
142148
// GetPOSTData method to Serialize given command for POST request
143149
// including connection configuration data
144150
func (cl *APIClient) GetPOSTData(cmd map[string]string, secured ...bool) string {
@@ -219,7 +225,6 @@ func (cl *APIClient) GetVersion() string {
219225
// Please save/update that map into user session
220226
func (cl *APIClient) SaveSession(sessionobj map[string]interface{}) *APIClient {
221227
sessionobj["socketcfg"] = map[string]string{
222-
"entity": cl.socketConfig.GetSystemEntity(),
223228
"session": cl.socketConfig.GetSession(),
224229
}
225230
return cl
@@ -229,7 +234,6 @@ func (cl *APIClient) SaveSession(sessionobj map[string]interface{}) *APIClient {
229234
// to rebuild and reuse connection settings
230235
func (cl *APIClient) ReuseSession(sessionobj map[string]interface{}) *APIClient {
231236
cfg := sessionobj["socketcfg"].(map[string]string)
232-
cl.socketConfig.SetSystemEntity(cfg["entity"])
233237
cl.SetSession(cfg["session"])
234238
return cl
235239
}
@@ -252,12 +256,6 @@ func (cl *APIClient) SetSession(value string) *APIClient {
252256
return cl
253257
}
254258

255-
// SetRemoteIPAddress method to set an Remote IP Address to be used for API communication
256-
func (cl *APIClient) SetRemoteIPAddress(value string) *APIClient {
257-
cl.socketConfig.SetRemoteAddress(value)
258-
return cl
259-
}
260-
261259
// SetCredentials method to set Credentials to be used for API communication
262260
func (cl *APIClient) SetCredentials(uid string, pw string) *APIClient {
263261
cl.socketConfig.SetLogin(uid)
@@ -268,7 +266,7 @@ func (cl *APIClient) SetCredentials(uid string, pw string) *APIClient {
268266
// SetRoleCredentials method to set Role User Credentials to be used for API communication
269267
func (cl *APIClient) SetRoleCredentials(uid string, role string, pw string) *APIClient {
270268
if len(role) > 0 {
271-
return cl.SetCredentials(uid+"!"+role, pw)
269+
return cl.SetCredentials(uid+":"+role, pw)
272270
}
273271
return cl.SetCredentials(uid, pw)
274272
}
@@ -283,7 +281,7 @@ func (cl *APIClient) Login(params ...string) *R.Response {
283281
cl.SetOTP(otp)
284282
rr := cl.Request(map[string]interface{}{"COMMAND": "StartSession"})
285283
if rr.IsSuccess() {
286-
col := rr.GetColumn("SESSION")
284+
col := rr.GetColumn("SESSIONID")
287285
if col != nil {
288286
cl.SetSession(col.GetData()[0])
289287
} else {
@@ -314,7 +312,7 @@ func (cl *APIClient) LoginExtended(params ...interface{}) *R.Response {
314312
}
315313
rr := cl.Request(cmd)
316314
if rr.IsSuccess() {
317-
col := rr.GetColumn("SESSION")
315+
col := rr.GetColumn("SESSIONID")
318316
if col != nil {
319317
cl.SetSession(col.GetData()[0])
320318
} else {
@@ -460,42 +458,22 @@ func (cl *APIClient) RequestAllResponsePages(cmd map[string]string) []R.Response
460458
return responses
461459
}
462460

463-
// SetUserView method to set a data view to a given subuser
464-
func (cl *APIClient) SetUserView(uid string) *APIClient {
465-
cl.socketConfig.SetUser(uid)
466-
return cl
467-
}
468-
469-
// ResetUserView method to reset data view back from subuser to user
470-
func (cl *APIClient) ResetUserView() *APIClient {
471-
cl.socketConfig.SetUser("")
472-
return cl
473-
}
474-
475-
// UseHighPerformanceConnectionSetup to activate high performance conneciton setup
476-
func (cl *APIClient) UseHighPerformanceConnectionSetup() *APIClient {
477-
cl.SetURL(ISPAPI_CONNECTION_URL_PROXY)
478-
return cl
479-
}
480-
481461
// UseDefaultConnectionSetup to activate default conneciton setup (the default anyways)
482462
func (cl *APIClient) UseDefaultConnectionSetup() *APIClient {
483-
cl.SetURL(ISPAPI_CONNECTION_URL_LIVE)
463+
cl.SetURL(CNR_CONNECTION_URL_LIVE)
484464
return cl
485465
}
486466

487467
// UseOTESystem method to set OT&E System for API communication
488468
func (cl *APIClient) UseOTESystem() *APIClient {
489-
cl.SetURL(ISPAPI_CONNECTION_URL_OTE)
490-
cl.socketConfig.SetSystemEntity("1234")
469+
cl.SetURL(CNR_CONNECTION_URL_OTE)
491470
return cl
492471
}
493472

494473
// UseLIVESystem method to set LIVE System for API communication
495474
// Usage of LIVE System is active by default.
496475
func (cl *APIClient) UseLIVESystem() *APIClient {
497-
cl.SetURL(ISPAPI_CONNECTION_URL_LIVE)
498-
cl.socketConfig.SetSystemEntity("54cd")
476+
cl.SetURL(CNR_CONNECTION_URL_LIVE)
499477
return cl
500478
}
501479

0 commit comments

Comments
 (0)