Create a Post
cancel
Showing results for 
Search instead for 
Did you mean: 
Eric_Beasley
Employee
Employee

Check Point API Template base for CLI operations on Gaia

Overview

This is a template you can use to create API scripts for use on Gaia in expert mode with the mgmt_cli command.

Description

The template includes some helpful elements to provide a date-time-group for logging operations, saving credentials operation for easy re-use with many-line scripts, and a framework to build the API script from.

The simple version of the template does not abstract the credential configuration to variables, instead using raw naming.

Instructions

This is a template and should be downloaded to your Work In Progress folder for copy-pasting as a framework for building API scripts for use on the Gaia expert shell.

To use, update the necessary export command lines to reflect your tastes or standards for documentation and operation.

Key values defined:

- $DATE - current date time group at time script is launched (1)

- $APICLIadmin - user name of the administrator account (management server) that is executing the API commands

- $APICLIsessionfile - full path and name of the session security file used to authenticate the API operations, allows easy execution of multiple commands without re-authentication (2.)

(1) The $DATE value uses this format as currently defined "2016-06-23-1250CDT" which sorts nicely, but is my standard, so adjust as necessary.

(2) Current default path and file name for the session security file is the local folder where the shell executes with a file name of "id.txt"

During execution the "mgmt_cli login user $APICLIadmin > $APICLIsessionfile" line will prompt for the password of the administrator account identified by $APICLIadmin and then output the session security file for reference that was stored at path $APICLIsessionfile.

The "shell meat" section is used to write your shell script API and CLI commands like the example creating a dump folder and sub-folders that would be used by the example mgmt_cli commands that are in the commented out examples section.

After the "shell meat" the template shows how to execute an API publish operation to publish the actions executed by the sections before it.

Last API operation is to logout the session, effectively invalidating the session security file.

The template then executes a listing of the dump directories from the example.

This should make it easy to quickly build API CLI scripts for execution on the management server Gaia CLI.

Improvement feedback welcome.

Code Version

Code version 1.0.7

Tested on version

R80, API version 1.0, and R80 with JHF 29 applied

NOTICE: By using this sample code you agree to terms and conditions in this Not authorized to view the specified document 1042

...

0 Kudos
0 Replies

Leaderboard

Epsum factorial non deposit quid pro quo hic escorol.

Upcoming Events

    CheckMates Events