Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 24 additions & 3 deletions APIFiles/APIClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,23 @@ func (c *ApiClient) GetSessionID() string {
return c.sid
}

// Deprecated: Do not use.
func (c *ApiClient) Login(username string, password string, continueLastSession bool, domain string, readOnly bool, payload string) (APIResponse, error) {
credentials := map[string]interface{}{
"user": username,
"password": password,
}
return c.commonLoginLogic(credentials, continueLastSession, domain, readOnly, make(map[string]interface{}))
}

// Deprecated: Do not use.
func (c *ApiClient) LoginWithApiKey(apiKey string, continueLastSession bool, domain string, readOnly bool, payload string) (APIResponse, error) {
credentials := map[string]interface{}{
"api-key": apiKey,
}
return c.commonLoginLogic(credentials, continueLastSession, domain, readOnly, make(map[string]interface{}))
}

/*
Performs a 'login' API call to management server

Expand All @@ -185,7 +202,7 @@ returns: APIResponse, error
side-effects: updates the class's uid and server variables

*/
func (c *ApiClient) Login(username string, password string, continueLastSession bool, domain string, readOnly bool, payload string) (APIResponse, error) {
func (c *ApiClient) ApiLogin(username string, password string, continueLastSession bool, domain string, readOnly bool, payload map[string]interface{}) (APIResponse, error) {
credentials := map[string]interface{}{
"user": username,
"password": password,
Expand All @@ -206,14 +223,14 @@ payload: [optional] More settings for the login command
returns: APIResponse object
side-effects: updates the class's uid and server variables
*/
func (c *ApiClient) LoginWithApiKey(apiKey string, continueLastSession bool, domain string, readOnly bool, payload string) (APIResponse, error) {
func (c *ApiClient) ApiLoginWithApiKey(apiKey string, continueLastSession bool, domain string, readOnly bool, payload map[string]interface{}) (APIResponse, error) {
credentials := map[string]interface{}{
"api-key": apiKey,
}
return c.commonLoginLogic(credentials, continueLastSession, domain, readOnly, payload)
}

func (c *ApiClient) commonLoginLogic(credentials map[string]interface{}, continueLastSession bool, domain string, readOnly bool, payload string) (APIResponse, error) {
func (c *ApiClient) commonLoginLogic(credentials map[string]interface{}, continueLastSession bool, domain string, readOnly bool, payload map[string]interface{}) (APIResponse, error) {

if c.context == WebContext {
credentials["continue-last-session"] = continueLastSession
Expand All @@ -224,6 +241,10 @@ func (c *ApiClient) commonLoginLogic(credentials map[string]interface{}, continu
credentials["domain"] = domain
}

for k, v := range payload {
credentials[k] = v
}

loginRes, errCall := c.ApiCall("login", credentials, "", false, false)
if errCall != nil {
return loginRes, errCall
Expand Down