Check Point Management API Wrapper - Elixir v1.0.4 CpMgmt View Source

This module manages simple functions with the Web API

Link to this section Summary

Functions

Installs the specified policy package on the specified gateway or gatewayas

Checks to see if the sid is currently stored. If not, issues login

Runs the login function to the management API, sets env for :sid and :uid as well and returns sid to be used in the CpMgmt.logged_in?/0 function. Uses the user and password provided via the config params

Runs the logout function to the management API. Unregisters the :sid and :uid from the env

Checks to see if the request was successful. If it was publishes changes to the management server. If not does nothing

Shows an object by it’s uid

Shows the session specified by it’s uid

Shows all session from management server

Takes CpMgmt.transform_response/1 and the given struct, then converts it to the struct for the calling module

Transforms the Tesla response to a filtered version for use with CpMgmt.to_struct/1

Runs verification on the specified policy package

Link to this section Functions

Link to this function install_policy(package, gateways) View Source

Installs the specified policy package on the specified gateway or gatewayas.

Examples

Specifing a single gateway to install on.
iex> CpMgmt.install_policy("policy-package-name", "someGW")

You can also specify a list of gateways to install on
iex> CpMgmt.install_policy("policy-package-name", ["someGW", "someOtherGW", "yetAnotherGW"])

iex> CpMgmt.install_policy("policy-package-name", "someGW")
{:error, %{error}}

Checks to see if the sid is currently stored. If not, issues login

Runs the login function to the management API, sets env for :sid and :uid as well and returns sid to be used in the CpMgmt.logged_in?/0 function. Uses the user and password provided via the config params.

Examples

iex> CpMgmt.login
{:ok, "some_sid"}

iex> CpMgmt.login
{:error,
  %{
    body: %{
      "code" => "err_login_failed",
      "message" => "Authentication to server failed."
    },
    status: 403
  }}

iex> CpMgmt.login
{:error, some_network_error}

Runs the logout function to the management API. Unregisters the :sid and :uid from the env.

Examples

iex> CpMgmt.logout
{:ok, %{body: %{"message" => "OK"}, status: 200}}

iex> CpMgmt.logout
{:error, %{error}}

Checks to see if the request was successful. If it was publishes changes to the management server. If not does nothing

Shows an object by it’s uid

Examples

iex> CpMgmt.show_object(uid)
{:ok,
  %{
    data: %{
      "object" => %{
        "domain" => %{
          "domain-type" => "data domain",
          "name" => "Check Point Data",
          "uid" => "a0bbbc99-adef-4ef8-bb6d-defdefdefdef"
        },
        "name" => "Any",
        "type" => "CpmiAnyObject",
        "uid" => "97aeb369-9aea-11d5-bd16-0090272ccb30"
      }
    },
    status: 200
  }}
iex> CpMgmt.show_object(uid)
{:error, %{error}}
Link to this function show_objects(limit \\ 50, offset \\ 0) View Source

Shows all objects

Examples

iex> CpMgmt.show_object(uid)
{:ok,
  %{
    "from" => 1,
    "objects" => [
      %{
        "domain" => %{
          "domain-type" => "data domain",
          "name" => "APPI Data",
          "uid" => "8bf4ac51-2df7-40e1-9bce-bedbedbedbed"
        },
        "name" => "#hashtags",
        "type" => "application-site",
        "uid" => "00fa9e3c-36ef-0f65-e053-08241dc22da2"
      },
      %{
        "domain" => %{
          "domain-type" => "data domain",
          "name" => "APPI Data",
          "uid" => "8bf4ac51-2df7-40e1-9bce-bedbedbedbed"
        },
        "name" => "050 Plus",
        "type" => "application-site",
        "uid" => "00fa9e44-4035-0f65-e053-08241dc22da2"
      }
    status: 200
  }}
iex> CpMgmt.show_objects()
{:error, %{error}}

Shows the session specified by it’s uid

Link to this function show_sessions(limit \\ 50, offset \\ 0) View Source

Shows all session from management server

Link to this function to_struct(data, module_struct) View Source

Takes CpMgmt.transform_response/1 and the given struct, then converts it to the struct for the calling module

Link to this function transform_response(response) View Source

Transforms the Tesla response to a filtered version for use with CpMgmt.to_struct/1

Runs verification on the specified policy package.

Examples

iex> CpMgmt.verify_policy("policy-package-name")

iex> CpMgmt.verify_policy("policy-package-name")
{:error, %{error}}