@@ -120,13 +120,27 @@ public ApiClient(ApiClientArgs args) {
120120 * @throws ApiClientException if error occurs while preforming an API call
121121 */
122122 public ApiLoginResponse login (String serverIpAddress , String payload ) throws ApiClientException {
123+ return login (serverIpAddress , payload , null );
124+ }
123125
126+ /**
127+ * This function uses the login command to login into the management server.
128+ *
129+ * @param serverIpAddress The IP address or name of the Check Point Management Server.
130+ * @param payload String representing a JSON object containing the login command's arguments.
131+ * @param cloudMgmtId The Smart-1 Cloud management UID.
132+ *
133+ * @return {@link ApiResponse} object
134+ *
135+ * @throws ApiClientException if error occurs while preforming an API call
136+ */
137+ public ApiLoginResponse login (String serverIpAddress , String payload , String cloudMgmtId ) throws ApiClientException {
124138 if (serverIpAddress == null || serverIpAddress .isEmpty ()){
125139 throw new ApiClientException ("Error: server IP address is invalid" );
126140 }
127141
128142 int port = portResolver .getPort (false );
129- ApiLoginResponse loginResponse = new ApiLoginResponse (serverIpAddress , OK_RESPONSE_CODE , port , new JSONObject ());
143+ ApiLoginResponse loginResponse = new ApiLoginResponse (serverIpAddress , OK_RESPONSE_CODE , port , new JSONObject (), cloudMgmtId );
130144 return (ApiLoginResponse ) apiCall (loginResponse ,"login" , payload );
131145 }
132146
@@ -135,18 +149,32 @@ public ApiLoginResponse login(String serverIpAddress, String payload) throws Api
135149 *
136150 * @param serverIpAddress The IP address or name of the Check Point Management Server.
137151 * @param payload JSON object containing the login command's arguments.
152+ * @param cloudMgmtId The Smart-1 Cloud management UID.
138153 *
139154 * @return {@link ApiResponse} object
140155 *
141156 * @throws ApiClientException if error occurs while preforming an API call
142157 */
143- public ApiLoginResponse login (String serverIpAddress , JSONObject payload ) throws ApiClientException {
144-
158+ public ApiLoginResponse login (String serverIpAddress , JSONObject payload , String cloudMgmtId ) throws ApiClientException {
145159 if (payload == null ){
146160 throw new ApiClientException ("Error: payload is invalid" );
147161 }
148162 String pay = payload .toString ();
149- return login (serverIpAddress ,pay );
163+ return login (serverIpAddress , pay , cloudMgmtId );
164+ }
165+
166+ /**
167+ * This function uses login command to login into the management server.
168+ *
169+ * @param serverIpAddress The IP address or name of the Check Point Management Server.
170+ * @param payload JSON object containing the login command's arguments.
171+ *
172+ * @return {@link ApiResponse} object
173+ *
174+ * @throws ApiClientException if error occurs while preforming an API call
175+ */
176+ public ApiLoginResponse login (String serverIpAddress , JSONObject payload ) throws ApiClientException {
177+ return login (serverIpAddress ,payload ,null );
150178 }
151179
152180 /**
@@ -242,7 +270,12 @@ public ApiResponse apiCall(ApiLoginResponse loginResponse, String command, Strin
242270 try {
243271 try {
244272 // 1) Establish Connection
245- url = new URL (URL_PROTOCOL , loginResponse .getServerIP (), loginResponse .getPort (), CONTEXT + command );
273+ String urlSuffix = "" ;
274+ if (loginResponse .getCloudMgmtId () != null && !loginResponse .getCloudMgmtId ().isEmpty ()) {
275+ urlSuffix = "/" + loginResponse .getCloudMgmtId () + "/" ;
276+ }
277+ urlSuffix += CONTEXT + command ;
278+ url = new URL (URL_PROTOCOL , loginResponse .getServerIP (), loginResponse .getPort (), urlSuffix );
246279 connection = establishConnection (loginResponse , command , url );
247280 }
248281 catch (Exception e ) {
@@ -269,7 +302,7 @@ public ApiResponse apiCall(ApiLoginResponse loginResponse, String command, Strin
269302 StringBuilder response = readResponse (input );
270303 if (LOGIN_CMD .equals (command )) {
271304 res = new ApiLoginResponse (loginResponse .getServerIP (), connection .getResponseCode (),
272- loginResponse .getPort (), (JSONObject )UtilClass .convertToJson (response .toString ()));
305+ loginResponse .getPort (), (JSONObject )UtilClass .convertToJson (response .toString ()), loginResponse . getCloudMgmtId () );
273306
274307 // 4) When the command is 'login', hiding the password so that it would not appear in the debug file.
275308 data = changePasswordInData (data );
0 commit comments