Session Management#
This class is used to manage the session with the API.
- class Session#
- continue_session_in_smartconsole(uid=None)#
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.
- Parameters
uid (str, optional) – Session unique identifier. Defaults to None
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.continue_session_in_smartconsole(uid="7a13a360-9b24-40d7-acd3-5b50247be33e")
- discard(uid=None)#
All changes done by user are discarded and removed from database.
- Parameters
uid (str, optional) – Session unique identifier. Specify it to publish a different session than the one you currently use. Defaults to None.
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.discard(uid="7a13a360-9b24-40d7-acd3-5b50247be33e")
- disconnect(uid, discard=False)#
Disconnect a private session.
- Parameters
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.disconnect()
- keepalive()#
Keep the session valid/alive.
- Returns
The response from the server
- Return type
Response
Examples
>>> FirewallManagement.session.keepalive()
- login(user=None, password=None, api_key=None, **kw)#
Creates a Firewall Management authentication session. You should authenticate using either a username/password or by using an API key.
- Parameters
user (str, optional) – Username of admin user for the authentication session. If set, you must specify
passwordtoo. Defaults to Nonepassword (str, optional) – Password of the admin user for the authentication session. If set, you must specify
usertoo. Defaults to Noneapi_key (str, optional) – An API key used to authenticate instead of a user/password.You must enter either a
user/passwordor anapi_key. Defaults to None**kw (dict, optional) – Arbitrary keyword arguments for secondary parameters.
- Keyword Arguments
**continue-last-session (bool, optional) – When ‘continue-last-session’ is set to ‘True’, the new session would continue where the last session was stopped. This option is available when the administrator has only one session that can be continued. If there is more than one session, see ‘switch-session’ API. Defaults to ‘False’
**domain (str, optional) – Use domain to login to specific domain. Domain can be identified by name or UID.
**enter-last-published-session (bool, optional) – Login to the last published session. Such login is done with the Read Only permissions.
**read-only (bool, optional) – Login with Read Only permissions. This parameter is not considered in case continue-last-session is true.
**session-comments (str, optional) – Session comments. Can be viewed only using the show-session API.
**session-description (str, optional) – A description of the session’s purpose.
**session-name (str, optional) – Session unique name.
**session-timeout (int, optional) – Session expiration timeout in seconds. Default 600 seconds.
- Raises
MandatoryFieldMissing – The value is not given as a keyword parameter and it’s mandatory
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.login(username='admin@example.com', password='MyInsecurePassword')
- login_to_domain(domain)#
Login from MDS to other domain. This command is available only after logging in to the System Data domain.
- Parameters
domain (str) – Domain identified by the name or UID.
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.login_to_domain(domain="OneDomain")
- logout()#
Ends an authentication session.
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.logout()
- publish(uid=None)#
All the changes done by this user will be seen by all users only after publish is called.
- Parameters
uid (str, optional) – Session unique identifier. Specify it to publish a different session than the one you currently use.. Defaults to None
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.publish(uid="7a13a360-9b24-40d7-acd3-5b50247be33e")
- purge_published_sessions(number_of_sessions_to_preserve=None, preserve_to_date=None)#
Permanently deletes all data which belongs to the published sessions not selected for preservation. This operation is irreversible.
- Parameters
number_of_sessions_to_preserve (int, optional) – The number of newest sessions to preserve, by the sessions’s publish date. Required if
preserve_to_dateis not set. Defaults to Nonepreserve_to_date (str, optional) – The date until which sessions are preserved, by the sessions’s publish date. ISO 8601. If timezone isn’t specified in the input, the Management server’s timezone is used. Required if
number_of_sessions_to_preserveis not set. Defaults to None
- Raises
MandatoryFieldMissing – The value is not given as a keyword parameter and it’s mandatory
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.purge_published_sessions(number_of_sessions_to_preserve=1)
- revert_to_revision(to_session=None)#
Revert the Management Database to the selected revision.
- Parameters
to_session (str, optional) – Session unique identifier. Specify the session id you would like to revert your database to.. Defaults to None
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.revert_to_revision(to_session="7a13a360-9b24-40d7-acd3-5b50247be33e")
- set_automatic_purge(enabled, keep_sessions_by_count=True, number_of_sessions_to_keep=999, keep_sessions_by_days=True, number_of_days_to_keep=365, scheduling=None)#
Set Automatic Purge. ⚠️ Note: This command will permanently delete all of the data which belongs to the published sessions not selected for preservation.⚠️
- Parameters
enabled (bool) – Turn on/off the automatic-purge feature
keep_sessions_by_count (bool, optional) – Whether or not to keep the latest N sessions. Note: when the automatic purge feature is enabled, this field and/or the “keep-sessions-by-date” field must be set to ‘true’. Defaults to True
number_of_sessions_to_keep (int, optional) – When “keep-sessions-by-count = true” this sets the number of newest sessions to preserve, by the sessions’s publish date. Defaults to 999
keep_sessions_by_days (bool, optional) – Whether or not to keep the sessions for D days. Note: when the automatic purge feature is enabled, this field and/or the “keep-sessions-by-count” field must be set to ‘true’. Defaults to True
number_of_days_to_keep (int, optional) – When “keep-sessions-by-days = true” this sets the number of days to keep the sessions. Defaults to 365
scheduling (dict, optional) – When to purge sessions that do not meet the “keep” criteria. Note: when the automatic purge feature is enabled, this field must be set. Defaults to None
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.set_automatic_purge(enabled=True)
- set_login_message(header=None, message=None, show_message=None, warning=None, **kw)#
Edit existing object using object name or uid.
- Parameters
header (str, optional) – Login message header. Defaults to None
message (str, optional) – Login message body. Defaults to None
show_message (bool, optional) – Whether to show login message. Defaults to None
warning (bool, optional) – Add warning sign. Defaults to None
**kw (dict, optional) – Arbitrary keyword arguments for secondary parameters.
- Keyword Arguments
**details-level (str, optional) – The level of detail for some of the fields in the response can vary from showing only the UID value of the object to a fully detailed representation of the object.
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.set_login_message(message="Hello World!")
- set_session(description=None, new_name=None, tags=None, **kw)#
Edit user’s current session.
- Parameters
- Keyword Arguments
**color (string, optional) – Color of the object. Should be one of existing colors.
**comments (string, optional) – Comments string.
**details-level (string, optional) – The level of detail for some of the fields in the response can vary from showing only the UID value of the object to a fully detailed representation of the object.
**ignore-warnings (bool, optional) – Apply changes ignoring warnings. Defaults to “False”
**ignore-errors (bool, optional) – Apply changes ignoring errors. You won’t be able to publish such a changes. If ignore-warnings flag was omitted - warnings will also be ignored. Defaults to “False”
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.set_session(description="My custom description")
- show_automatic_purge()#
Show Automatic Purge.
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.show_automatic_purge()
- show_last_published_session()#
Shows the last published session.
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.show_last_published_session()
- show_login_message(**kw)#
Retrieve existing object using object name or uid.
- Parameters
**kw (dict, optional) – Arbitrary keyword arguments for secondary parameters.
- Keyword Arguments
**details-level (string, optional) – The level of detail for some of the fields in the response can vary from showing only the UID value of the object to a fully detailed representation of the object.
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.show_login_message()
- show_session(uid=None)#
Show session.
- Parameters
uid (str, optional) – Session unique identifier. Defaults to None.
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.show_session(uid="7a13a360-9b24-40d7-acd3-5b50247be33e")
- show_sessions(filter_results=None, limit=50, offset=0, order=None, view_published_sessions=False, **kw)#
Retrieve all objects.
- Parameters
filter_results (str, optional) – Search expression to filter objects by. The provided text should be exactly the same as it would be given in SmartConsole Object Explorer. The logical operators in the expression (‘AND’, ‘OR’) should be provided in capital letters.The search involves both a IP search and a textual search in name, comment, tags etc. Defaults to None
limit (int, optional) – The maximal number of returned results. Defaults to 50 (between 1 and 500).
offset (int, optional) – Number of the results to initially skip. Defaults to 0
order (List[dict], optional) – Sorts results by the given field. By default the results are sorted in the descending order by the session publish time. Defaults to None
view_published_sessions (bool, optional) – Show a list of published sessions. Defaults to False
**kw (dict, optional) – Arbitrary keyword arguments for secondary parameters.
- Keyword Arguments
**details-level (str, optional) – The level of detail for some of the fields in the response can vary from showing only the UID value of the object to a fully detailed representation of the object.
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.switch_session(uid="7a13a360-9b24-40d7-acd3-5b50247be33e")
- switch_session(uid)#
Switch to a disconnected Management API session of the same administrator. To switch to an open session or to a session of a different administrator use the take-over session API.
- Parameters
uid (str) – Session unique identifier. It should belong to the current administrator. Switching to the sessions opened in SmartConsole is not supported.
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.switch_session(uid="7a13a360-9b24-40d7-acd3-5b50247be33e")
- take_over_session(uid, disconnect_active_session=False)#
Take ownership of another session and start working on it.
- Parameters
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.take_over_session(uid="7a13a360-9b24-40d7-acd3-5b50247be33e")
- verify_revert(to_session)#
Verify the Management Database can revert to the selected revision.
- Parameters
to_session (str) – Session unique identifier. Specify the session id you would like to revert your database to.
- Returns
The response from the server
- Return type
Box
Examples
>>> FirewallManagement.session.verify_revert(to_session="7a13a360-9b24-40d7-acd3-5b50247be33e")