cpauto.core package¶
Submodules¶
cpauto.core.exceptions module¶
This module contains the set of cpauto core exceptions.
-
exception
cpauto.core.exceptions.
ConnectionError
(message, http_status_code=None)[source]¶ Bases:
cpauto.core.exceptions.CoreClientError
A connection error occurred.
-
exception
cpauto.core.exceptions.
CoreClientError
(message, http_status_code=None)[source]¶ Bases:
cpauto.core.exceptions.WebClientError
Exception raised when an core web client runs into trouble.
-
exception
cpauto.core.exceptions.
Error
[source]¶ Bases:
exceptions.IOError
Base class for exceptions in this module.
-
exception
cpauto.core.exceptions.
HTTPError
(message, http_status_code=None)[source]¶ Bases:
cpauto.core.exceptions.CoreClientError
An HTTP error occurred.
-
exception
cpauto.core.exceptions.
InvalidURL
(message, http_status_code=None)[source]¶ Bases:
cpauto.core.exceptions.CoreClientError
,exceptions.ValueError
The URL provided was invalid.
-
exception
cpauto.core.exceptions.
SSLError
(message, http_status_code=None)[source]¶ Bases:
cpauto.core.exceptions.CoreClientError
An SSL error occurred.
-
exception
cpauto.core.exceptions.
Timeout
(message, http_status_code=None)[source]¶ Bases:
cpauto.core.exceptions.CoreClientError
The request timed out.
-
exception
cpauto.core.exceptions.
TooManyRedirects
(message, http_status_code=None)[source]¶ Bases:
cpauto.core.exceptions.CoreClientError
Too many redirects.
-
exception
cpauto.core.exceptions.
WaitOnTaskError
(message, http_status_code=None)[source]¶ Bases:
cpauto.core.exceptions.CoreClientError
An error occurred whilst waiting on a task or tasks.
-
exception
cpauto.core.exceptions.
WebClientError
(message, http_status_code=None)[source]¶ Bases:
cpauto.core.exceptions.Error
Exception raised when a web client runs into trouble.
cpauto.core.misc module¶
This module contains the primary objects needed to leverage other, powerful R80 Web API features.
-
class
cpauto.core.misc.
Misc
(core_client)[source]¶ Leverages other powerful misc. R80 Web API features.
-
put_file
(content='', name='', path='', targets='', comments='')[source]¶ Puts file content on a gateway or set of gateways.
https://sc1.checkpoint.com/documents/R80/APIs/index.html#web/put-file
Parameters: - content – The file content.
- name – The file name.
- path – The file path.
- targets (A string or list of strings.) – The gateway or set of gateways to receive the file.
- comments – Any comments regarding the file.
Return type:
-
run_script
(script='', name='', targets='', params={})[source]¶ Runs a script on a gateway or set of gateways.
https://sc1.checkpoint.com/documents/R80/APIs/index.html#web/run-script
Parameters: - script – The script to execute on the gateway or set of gateways.
- name – A name for the script.
- targets (A string or list of strings.) – The gateway or set of gateways to receive the script to execute.
- params – A dictionary of additional, supported parameter names and values.
Return type:
-
show_task
(task_id='', details_level='')[source]¶ Shows details of specified task or set of tasks.
https://sc1.checkpoint.com/documents/R80/APIs/index.html#web/show-task
Parameters: - task_id (A string or list of strings.) – A unique identifier for one or more tasks.
- details_level – (optional) The level of detail to show. Default value is ‘standard’ and the other options are: ‘uid’ or ‘full’
Return type:
-
cpauto.core.sessions module¶
This module contains the primary objects needed to manage R80 Web API sessions.
-
class
cpauto.core.sessions.
CoreClient
(user='', password='', mgmt_server='', port=443, verify=True, wait_for_tasks=True)[source]¶ The cpauto core client.
Provides basic configuration and persistence.
- Basic Usage::
>>> import cpauto >>> cc = cpauto.CoreClient('admin', 'vpn123', '10.11.12.13') >>> r = cc.login() >>> r.status_code 200
-
discard
(uid='')[source]¶ Discards all changes made and removes them from the database.
https://sc1.checkpoint.com/documents/R80/APIs/#web/discard
Parameters: uid – (optional) Specify a different sessions unique identifier to discard. Return type: CoreClientResult
-
http_post
(endpoint, send_sid=True, payload={})[source]¶ Makes an HTTP post to the specified API endpoint using user supplied data.
Parameters: - endpoint – The API endpoint (e.g. /login).
- send_sid – Send the session ID as a header when true.
- payload – The payload (dictionary) that will be included as JSON in the body of the request.
Return type:
-
keepalive
()[source]¶ Keeps the session alive and valid.
https://sc1.checkpoint.com/documents/R80/APIs/#web/keepalive
Return type: CoreClientResult
-
login
(params={})[source]¶ Login to the R80 Web API server and store the results of the request as a class attribute.
https://sc1.checkpoint.com/documents/R80/APIs/#web/login
Parameters: params – (optional) A dictionary of additional, supported parameter names and values. Return type: CoreClientResult
-
logout
()[source]¶ Logout of the R80 Web API server and invalidate the session.
https://sc1.checkpoint.com/documents/R80/APIs/#web/logout
Return type: CoreClientResult
-
merge_payloads
(payload_a, payload_b)[source]¶ Merges the contents of two payloads (dictionaries).
Parameters: - payload_a – A payload to merge
- payload_b – Another payload to merge
Returns: A single payload (dictionary) with the contents of the two original payloads
-
publish
(uid='')[source]¶ Makes all changes made visible to other users.
https://sc1.checkpoint.com/documents/R80/APIs/#web/publish
Parameters: uid – (optional) Specify a different session unique identifier to publish. Return type: CoreClientResult
-
class
cpauto.core.sessions.
CoreClientResult
(status_code, json)[source]¶ Stores the status code and JSON body received in an HTTP response to an API request.
-
class
cpauto.core.sessions.
LoginMessage
(core_client)[source]¶ Manage login message.
-
set
(params={})[source]¶ Sets new values for current login message.
https://sc1.checkpoint.com/documents/R80/APIs/#web/set-login-message
Parameters: params – (optional) A dictionary of additional, supported parameter names and values. Return type: CoreClientResult
-
show
()[source]¶ Shows details of current login message.
https://sc1.checkpoint.com/documents/R80/APIs/#web/show-login-message
Return type: CoreClientResult
-
-
class
cpauto.core.sessions.
Session
(core_client)[source]¶ Manage sessions.
-
continue_in_sc
(uid='')[source]¶ Logout from existing session. The session will be continued next time your open SmartConsole. In case ‘uid’ is not provided, use current session. In order for the session to pass successfully to SmartConsole, make sure you don’t have any other active GUI sessions.
https://sc1.checkpoint.com/documents/R80/APIs/#web/continue-session-in-smartconsole
Parameters: uid – (optional) The unique identifier of an existing session. Return type: CoreClientResult
-
set
(params={})[source]¶ Sets new values for certain parameters of the current session.
https://sc1.checkpoint.com/documents/R80/APIs/#web/set-session
Parameters: params – (optional) A dictionary of additional, supported parameter names and values. Return type: CoreClientResult
-
show
(uid='')[source]¶ Shows details of current session or a session with the specified uid.
https://sc1.checkpoint.com/documents/R80/APIs/#web/show-session
Parameters: uid – (optional) The unique identifier of an existing session. Return type: CoreClientResult
-
show_all
(limit=50, offset=0, order=[], details_level='')[source]¶ Shows all sessions with some reasonable limitations.
https://sc1.checkpoint.com/documents/R80/APIs/#web/show-sessions
Parameters: - limit – (optional) Limit the total number of sessions shown. The default value is 50 and allowed values are in the range 1 to 500.
- offset – (optional) Skip a number of sessions in the results before they are shown. Default value is 0.
- order – (optional) Sort the results by the specified field. The default is a random order.
- details_level – (optional) The level of detail to show. Default value is ‘standard’ and the other options are: ‘uid’ or ‘full’
Return type:
-
switch
(uid='')[source]¶ Switch sessions.
https://sc1.checkpoint.com/documents/R80/APIs/#web/switch-session
Parameters: uid – A session unique identifier. Return type: CoreClientResult
-