@@ -240,7 +240,6 @@ read_only: [optional] Login with Read Only permissions. This parameter is not co
240240payload: [optional] More settings for the login command
241241returns: APIResponse, error
242242side-effects: updates the class's uid and server variables
243-
244243*/
245244func (c * ApiClient ) ApiLogin (username string , password string , continueLastSession bool , domain string , readOnly bool , payload map [string ]interface {}) (APIResponse , error ) {
246245 credentials := map [string ]interface {}{
@@ -309,15 +308,16 @@ command: the command is placed in the URL field
309308payload: a JSON object (or a string representing a JSON object) with the command arguments
310309sid: The Check Point session-id. when omitted use self.sid.
311310waitForTask: determines the behavior when the API server responds with a "task-id".
311+
312312 by default, the function will periodically check the status of the task
313313 and will not return until the task is completed.
314314 when wait_for_task=False, it is up to the user to call the "show-task" API and check
315315 the status of the command.
316+
316317useProxy: Determines if the user wants to use the proxy server and port provider.
317318method: HTTP request method - POST by default
318319return: APIResponse object
319320side-effects: updates the class's uid and server variables
320-
321321*/
322322func (c * ApiClient ) ApiCall (command string , payload map [string ]interface {}, sid string , waitForTask bool , useProxy bool , method ... string ) (APIResponse , error ) {
323323 return c .apiCall (command , payload , sid , waitForTask , useProxy , false , method ... )
@@ -549,7 +549,8 @@ func (c *ApiClient) apiCall(command string, payload map[string]interface{}, sid
549549 return res , nil
550550}
551551
552- /**
552+ /*
553+ *
553554The APIs that return a list of objects are limited by the number of objects that they return.
554555To get the full list of objects, there's a need to make repeated API calls each time using a different offset
555556until all the objects are returned.
@@ -558,19 +559,25 @@ note: this function calls gen_api_query and iterates over the generator until it
558559then returns.
559560
560561command: name of API command. This command should be an API that returns an array of
562+
561563 objects (for example: show-hosts, show networks, ...)
564+
562565details_level: query APIs always take a details-level argument.
566+
563567 possible values are "standard", "full", "uid"
568+
564569container_key: name of the key that holds the objects in the JSON response (usually "objects").
565570include_container_key: If set to False the 'data' field of the APIResponse object
571+
566572 will be a list of the wanted objects. Otherwise, the date field of the APIResponse will be a dictionary in the following
573+
567574format: { container_key: [ List of the wanted objects], "total": size of the list}
568575payload: a JSON object (or a string representing a JSON object) with the command arguments
569576return: if include-container-key is False:
577+
570578 an APIResponse object whose .data member contains a list of the objects requested: [ , , , ...]
571579 if include-container-key is True:
572580 an APIResponse object whose .data member contains a dict: { container_key: [...], "total": n }
573-
574581*/
575582func (c * ApiClient ) ApiQuery (command string , detailsLevel string , containerKey string , includeContainerKey bool , payload map [string ]interface {}) (APIResponse , error ) {
576583
@@ -617,7 +624,9 @@ This is in contrast to normal API calls that return only a limited number of obj
617624This function can be used to show progress when requesting many objects (i.e. "Received x/y objects.")
618625
619626command: name of API command. This command should be an API that returns an array of objects
627+
620628 (for example: show-hosts, show networks, ...)
629+
621630details_level: query APIs always take a details-level argument. Possible values are "standard", "full", "uid"
622631container_keys: the field in the .data dict that contains the objects
623632payload: a JSON object (or a string representing a JSON object) with the command arguments
@@ -712,7 +721,8 @@ func (c *ApiClient) genApiQuery(command string, detailsLevel string, containerKe
712721 return serverResponse
713722}
714723
715- /**
724+ /*
725+ *
716726When the server needs to perform an API call that may take a long time (e.g. run-script, install-policy,
717727publish), the server responds with a 'task-id'.
718728Using the show-task API it is possible to check on the status of this task until its completion.
@@ -759,10 +769,10 @@ func (c *ApiClient) waitForTask(taskId string) (APIResponse, error) {
759769 totalTasks := 0
760770 for _ , task := range taskResult .GetData ()["tasks" ].([]interface {}) {
761771 totalTasks ++
762- if task .(map [string ]interface {})["status" ].(string ) != InProgress {
772+ taskMap := task .(map [string ]interface {})
773+ if taskMap ["status" ] != nil && taskMap ["status" ].(string ) != InProgress {
763774 completedTasks ++
764775 }
765-
766776 }
767777
768778 if completedTasks == totalTasks {
@@ -778,7 +788,8 @@ func (c *ApiClient) waitForTask(taskId string) (APIResponse, error) {
778788
779789}
780790
781- /**
791+ /*
792+ *
782793The version of waitForTask function for the collection of tasks
783794
784795task_objects: A list of task objects
@@ -823,7 +834,8 @@ func (c *ApiClient) waitForTasks(taskObjects []interface{}) APIResponse {
823834
824835}
825836
826- /**
837+ /*
838+ *
827839This method checks if one of the tasks failed and if so, changes the response status to be False
828840
829841task_result: api_response returned from "show-task" command
@@ -846,7 +858,8 @@ func checkTasksStatus(taskResult *APIResponse) {
846858 @===================@
847859*/
848860
849- /**
861+ /*
862+ *
850863This function checks if the server's certificate is stored in the local fingerprints file.
851864If the server's fingerprint is not found, an HTTPS connection is made to the server
852865and the user is asked if he or she accepts the server's fingerprint.
@@ -928,7 +941,8 @@ func (c *ApiClient) loadFingerprintFromFile() (string, error) {
928941
929942}
930943
931- /**
944+ /*
945+ *
932946This function takes the content of the file $FILENAME (which is a json file)
933947and parses it's content to a map (from string to string)
934948
@@ -960,13 +974,16 @@ func (c *ApiClient) fpFileToMap() (map[string]string, error) {
960974
961975}
962976
963- /**
977+ /*
978+ *
964979store a server's fingerprint into a local file.
965980
966981server: the IP address/name of the Check Point management server.
967982fingerprint: A SHA1 fingerprint of the server's certificate.
968983filename: The file in which to store the certificates. The file will hold a JSON structure in which
984+
969985 the key is the server and the value is its fingerprint.
986+
970987return: 'True' if everything went well. 'False' if there was some kind of error storing the fingerprint.
971988*/
972989func (c * ApiClient ) saveFingerprintToFile (server string , fingerprint string ) error {
0 commit comments