@@ -31,17 +31,17 @@ import (
3131)
3232
3333const (
34- InProgress string = "in progress"
35- DefaultPort int = 443
36- Limit int = 50
37- Filename string = "fingerprints.json"
38- TimeOut time.Duration = time .Second * 10
39- SleepTime time.Duration = time .Second * 2
40- GaiaContext string = "gaia_api"
41- WebContext string = "web_api"
42- DefaultProxyPort = - 1
43- DefaultProxyHost = ""
44- AutoPublishBatchSize int = 100
34+ InProgress string = "in progress"
35+ DefaultPort int = 443
36+ Limit int = 50
37+ Filename string = "fingerprints.json"
38+ TimeOut time.Duration = time .Second * 10
39+ SleepTime time.Duration = time .Second * 2
40+ GaiaContext string = "gaia_api"
41+ WebContext string = "web_api"
42+ DefaultProxyPort = - 1
43+ DefaultProxyHost = ""
44+ AutoPublishBatchSize int = 100
4545)
4646
4747// Check Point API Client (Management/GAIA)
@@ -66,15 +66,15 @@ type ApiClient struct {
6666 userAgent string
6767 cloudMgmtId string
6868 autoPublishBatchSize int
69- activeCallsLock sync.Mutex
70- autoPublishLock sync.Mutex
71- totalCallsLock sync.Mutex
69+ activeCallsLock sync.Mutex
70+ autoPublishLock sync.Mutex
71+ totalCallsLock sync.Mutex
7272 duringPublish bool
73- activeCallsCtr int
74- totalCallsCtr int
73+ activeCallsCtr int
74+ totalCallsCtr int
7575}
7676
77- // Api Client constructor
77+ // ApiClient constructor
7878// Input ApiClientArgs
7979// Returns new client instance
8080func APIClient (apiCA ApiClientArgs ) * ApiClient {
@@ -212,7 +212,7 @@ func (c *ApiClient) DisableAutoPublish() {
212212 c .totalCallsCtr = 0
213213}
214214
215- // Deprecated: Do not use.
215+ // Deprecated: Do not use. Use ApiLogin instead
216216func (c * ApiClient ) Login (username string , password string , continueLastSession bool , domain string , readOnly bool , payload string ) (APIResponse , error ) {
217217 credentials := map [string ]interface {}{
218218 "user" : username ,
@@ -221,7 +221,7 @@ func (c *ApiClient) Login(username string, password string, continueLastSession
221221 return c .commonLoginLogic (credentials , continueLastSession , domain , readOnly , make (map [string ]interface {}))
222222}
223223
224- // Deprecated: Do not use.
224+ // Deprecated: Do not use. Use ApiLoginWithApiKey instead
225225func (c * ApiClient ) LoginWithApiKey (apiKey string , continueLastSession bool , domain string , readOnly bool , payload string ) (APIResponse , error ) {
226226 credentials := map [string ]interface {}{
227227 "api-key" : apiKey ,
@@ -230,7 +230,7 @@ func (c *ApiClient) LoginWithApiKey(apiKey string, continueLastSession bool, dom
230230}
231231
232232/*
233- Performs a ' login' API call to management server
233+ Performs login API call to the management server using username and password
234234
235235username: Check Point admin name
236236password: Check Point admin password
@@ -251,7 +251,7 @@ func (c *ApiClient) ApiLogin(username string, password string, continueLastSessi
251251}
252252
253253/*
254- performs a ' login' API call to the management server
254+ Performs login API call to the management server using api key
255255
256256api_key: Check Point api-key
257257continue_last_session: [optional] It is possible to continue the last Check Point session
@@ -411,9 +411,9 @@ func (c *ApiClient) apiCall(command string, payload map[string]interface{}, sid
411411 if ! internal && c .autoPublishBatchSize > 0 {
412412 waitToRun := true
413413 for waitToRun {
414- if c .totalCallsCtr + 1 <= c .autoPublishBatchSize && ! c .duringPublish {
414+ if c .totalCallsCtr + 1 <= c .autoPublishBatchSize && ! c .duringPublish {
415415 c .totalCallsLock .Lock ()
416- if c .totalCallsCtr + 1 <= c .autoPublishBatchSize && ! c .duringPublish {
416+ if c .totalCallsCtr + 1 <= c .autoPublishBatchSize && ! c .duringPublish {
417417 c .totalCallsCtr ++
418418 waitToRun = false
419419 }
@@ -519,9 +519,9 @@ func (c *ApiClient) apiCall(command string, payload map[string]interface{}, sid
519519
520520 if ! internal && c .autoPublishBatchSize > 0 {
521521 c .decreaseActiveCalls ()
522- if c .totalCallsCtr > 0 && c .totalCallsCtr % c .autoPublishBatchSize == 0 && ! c .duringPublish {
522+ if c .totalCallsCtr > 0 && c .totalCallsCtr % c .autoPublishBatchSize == 0 && ! c .duringPublish {
523523 c .autoPublishLock .Lock ()
524- if c .totalCallsCtr > 0 && c .totalCallsCtr % c .autoPublishBatchSize == 0 && ! c .duringPublish {
524+ if c .totalCallsCtr > 0 && c .totalCallsCtr % c .autoPublishBatchSize == 0 && ! c .duringPublish {
525525 c .duringPublish = true
526526 c .autoPublishLock .Unlock ()
527527 for c .activeCallsCtr > 0 {
@@ -531,16 +531,16 @@ func (c *ApiClient) apiCall(command string, payload map[string]interface{}, sid
531531 }
532532 // Going to publish
533533 fmt .Println ("Start auto publish..." )
534- publishRes , _ := c .apiCall ("publish" , map [string ]interface {}{},c .GetSessionID (),true ,c .IsProxyUsed (), true )
534+ publishRes , _ := c .apiCall ("publish" , map [string ]interface {}{}, c .GetSessionID (), true , c .IsProxyUsed (), true )
535535
536536 if ! publishRes .Success {
537537 fmt .Println ("Auto publish failed. Message: " + publishRes .ErrorMsg )
538- }else {
538+ } else {
539539 fmt .Println ("Auto publish finished successfully" )
540540 }
541541 c .totalCallsCtr = 0
542542 c .duringPublish = false
543- }else {
543+ } else {
544544 c .autoPublishLock .Unlock ()
545545 }
546546 }
0 commit comments