# Check Point - Harmony Endpoint Management Python SDK
[![License](https://img.shields.io/github/license/CheckPointSW/harmony-endpoint-management-py-sdk.svg?style=plastic)](https://github.com/CheckPointSW/harmony-endpoint-management-py-sdk/blob/release/LICENSE) [![Latest Release](https://img.shields.io/github/v/release/CheckPointSW/harmony-endpoint-management-py-sdk?style=plastic)](https://github.com/CheckPointSW/harmony-endpoint-management-py-sdk/releases) [![PyPI version](https://img.shields.io/pypi/v/chkp-harmony-endpoint-management-sdk.svg?style=plastic)](https://pypi.org/project/chkp-harmony-endpoint-management-sdk/)
<!--
Coming soon :)
[![npm downloads](https://img.shields.io/npm/dt/@chkp/harmony-endpoint-management-sdk.svg.svg?style=plastic)](https://npmjs.com/package/@chkp/harmony-endpoint-management-sdk.svg)
[![GitHub stars](https://img.shields.io/github/stars/CheckPointSW/harmony-endpoint-management-py-sdk.svg?style=social&label=Star)](https://github.com/CheckPointSW/harmony-endpoint-management-py-sdk/stargazers) -->
[![Build SDK Package](https://github.com/CheckPointSW/harmony-endpoint-management-py-sdk/actions/workflows/build.yml/badge.svg)](https://github.com/CheckPointSW/harmony-endpoint-management-py-sdk/actions/workflows/build.yml) [![Publish package to PyPI](https://github.com/CheckPointSW/harmony-endpoint-management-py-sdk/actions/workflows/release.yml/badge.svg)](https://github.com/CheckPointSW/harmony-endpoint-management-py-sdk/actions/workflows/release.yml)
This is the Harmony Endpoint management SDK for Python ecosystem.
The SDK is based on the public [Harmony Endpoint management OpenAPI](https://app.swaggerhub.com/apis/Check-Point/web-mgmt-external-api-production) specifications.
With the SDK, you do not have to manage log in, send keep alive requests, worry about session expiration or pull long processing jobs.
> 💡 The Harmony Endpoint SDK supports simultaneous instances with different tenants.
## ⬇️ SDK installation
To start using this SDK, add the SDK package to your project
Via PIP (PyPi registry)
```bash
pip install chkp-harmony-endpoint-management-sdk
```
## 🚀 Getting started
First, import the `HarmonyEndpoint` object from the package.
```python
from chkp_harmony_endpoint_management_sdk import HarmonyEndpoint
```
Then, create a new instance of `HarmonyEndpoint`, which provides CloudInfra API credentials and a gateway to connect to.
To obtain CloudInfra credentials, open the Infinity Portal and create a suitable API Key. Make sure to select `Endpoint` in the `Service` field. For more information, see [Infinity Portal Administration Guide](https://sc1.checkpoint.com/documents/Infinity_Portal/WebAdminGuides/EN/Infinity-Portal-Admin-Guide/Content/Topics-Infinity-Portal/API-Keys.htm?tocpath=Global%20Settings%7C_____7#API_Keys).
Once the Client ID, Secret Key, and Authentication URL are obtained, Harmony Endpoint SDK can be used.
All API operations can be explored with the `HarmonyEndpoint` instance, notice to the documentation on each API operation, what and where are the arguments it requires.
All API's can be also explored in [SwaggerHub](https://app.swaggerhub.com/apis/Check-Point/web-mgmt-external-api-production)
A complete example:
```python
from chkp_harmony_endpoint_management_sdk import HarmonyEndpoint, InfinityPortalAuth
# Create a new instance of HarmonyEndpoint (we do support multiple instances in parallel)
he = HarmonyEndpoint()
# Connect to management using CloudInfra API credentials
he.connect(infinity_portal_auth=InfinityPortalAuth(
client_id="place here your CI client-id", # The "Client ID"
access_key= "place here your CI access-key", # The "Secret Key"
gateway="https://cloudinfra-gw-us.portal.checkpoint.com/auth/external" # The "Authentication URL"
))
# Query the API operation
rules_metadata_res = he.policy_general_api.get_all_rules_metadata(header_params={ "x-mgmt-run-as-job": 'off'})
print(rules_metadata_res.payload) # Your rulebase metadata
# Also you can query this operation using job, no extra logic required, in the background, it will trigger a job and will pull the status till it finish and return the final results.
rules_metadata_res = he.policy_general_api.get_all_rules_metadata(header_params={ "x-mgmt-run-as-job": 'on'})
print(rules_metadata_res.is_job) # True
print(rules_metadata_res.payload) # Your rulebase metadata
# Once finish, disconnect to stop all background session management.
he.disconnect()
```
### 🏠 On-premise
🛠️🛠️🛠️ **Under Development** 🛠️🛠️🛠️
Harmony Endpoint On-premise instances are also supported.
> Pay attention! Not all cloud operations are available for on-premise, also need to specify the SDK version to comply with your Gaia / JHF version
```python
from chkp_harmony_endpoint_management_sdk import HarmonyEndpointPremise, OnPremisePortalAuth
# Create a new instance of HarmonyEndpoint (we do support multiple instances in parallel)
hep = HarmonyEndpointPremise()
# Connect to management using CloudInfra API credentials
hep.connect(on_premise_portal_auth=OnPremisePortalAuth(
username="xxxx",
password= "xxxx",
url="https://x.x.x.x",
disable_tls_chain_validation=False # Set it true only if you fully trust this URL (e.g. case of internal but not verified https certificate)
))
# Query the API operation
rules_metadata_res = hep.policy_general_api.get_all_rules_metadata(header_params={ "x-mgmt-run-as-job": 'off'})
print(rules_metadata_res.payload) # Your rulebase metadata
# Once all finish, disconnect to stop all background session management.
hep.disconnect()
```
On-Premises API can be explored in [SwaggerHub](https://app.swaggerhub.com/apis/Check-Point/web-mgmt-external-api-premise)
### ☁️ Cloud & MSSP services APIs
Harmony Endpoint also provides APIs for MSSP and Cloud service management (relevant to SaaS customers only)
The usage is similar to the management API
```python
from chkp_harmony_endpoint_management_sdk import HarmonyEndpointSaaS, InfinityPortalAuth, HarmonyEndpointSaaSOptions
he_saas = HarmonyEndpointSaaS()
# Connect to management using CloudInfra API credentials
he_saas.connect(infinity_portal_auth=InfinityPortalAuth(
client_id="place here your CI client-id", # The "Client ID"
access_key= "place here your CI access-key", # The "Secret Key"
gateway="https://cloudinfra-gw-us.portal.checkpoint.com/auth/external", # The "Authentication URL"
harmony_endpoint_saas_options=HarmonyEndpointSaaSOptions(
activate_mssp_session=True # Activate MSSP's session management, turn on if you're using MSSP APIs
)
))
# Query the cloud API operation
instance_status_res = he_saas.self_service_api.public_machines_single_status()
print(instance_status_res.payload) # Your instance status
he_saas.disconnect()
```
API available at [SwaggerHub](https://app.swaggerhub.com/apis/Check-Point/harmony-endpoint-cloud-api-prod)
## 🔍 Troubleshooting and logging
The full version and build info of the SDK is available by `HarmonyEndpoint.info()` see example:
```python
from chkp_harmony_endpoint_management_sdk import HarmonyEndpoint, HarmonyEndpointSDKInfo
sdk_info: HarmonyEndpointSDKInfo = HarmonyEndpoint.info()
print(sdk_info) # sdk_build:"9728283", sdk_version:"1.0.2", spec:"web-mgmt-external-api-production", spec_version:"1.9.159", released_on:"2023-09-10T18:14:38.264Z"
```
Harmony Endpoint Management SDK uses the official python logger package for logging.
There are 3 loggers, for general info, errors and to inspect network.
As default they will be disabled, in order to enable logging, set to the `HARMONY_ENDPOINT_SDK_LOGGER` environment variable the following string before loading the SDK:
```bash
HARMONY_ENDPOINT_SDK_LOGGER="*"
```
And for a specific/s logger set the logger name followed by a command as following:
```bash
HARMONY_ENDPOINT_SDK_LOGGER="info,error,network"
```
or activate logger programmatically using SDK methods:
```python
from chkp_harmony_endpoint_management_sdk import activate_all_loggers, activate_info_logger, activate_error_logger, activate_network_logger
...
activate_all_loggers() # Will activate all logger
activate_info_logger() # Will activate the info logger only
activate_error_logger() # Will activate the error logger only
activate_network_logger() # Will activate the network logger only
```
## 🐞 Report Bug
In case of an issue or a bug found in the SDK, please open an [issue](https://github.com/CheckPointSW/harmony-endpoint-management-py-sdk/issues) or report to us [Check Point Software Technologies Ltd](mailto:harmony-endpoint-external-api@checkpoint.com).
## 🤝 Contributors
- Haim Kastner - [chkp-haimk](https://github.com/chkp-haimk)
- Yuval Pomerchik - [chkp-yuvalpo](https://github.com/chkp-yuvalpo)
Raw data
{
"_id": null,
"home_page": "https://github.com/CheckPointSW/harmony-endpoint-management-py-sdk",
"name": "chkp-harmony-endpoint-management-sdk",
"maintainer": "Haim Kastner",
"docs_url": null,
"requires_python": "<4.0,>=3.8",
"maintainer_email": "haimk@checkpoint.com",
"keywords": "python, harmony, endpoint, sdk, checkpoint",
"author": "Haim Kastner",
"author_email": "haimk@checkpoint.com",
"download_url": "https://files.pythonhosted.org/packages/2f/ff/50fc7721f2f3b9bd8795b8d8c21a31b044b6adaa6d528ca3165dd196070e/chkp_harmony_endpoint_management_sdk-1.1.38.tar.gz",
"platform": null,
"description": "# Check Point - Harmony Endpoint Management Python SDK\n\n[![License](https://img.shields.io/github/license/CheckPointSW/harmony-endpoint-management-py-sdk.svg?style=plastic)](https://github.com/CheckPointSW/harmony-endpoint-management-py-sdk/blob/release/LICENSE) [![Latest Release](https://img.shields.io/github/v/release/CheckPointSW/harmony-endpoint-management-py-sdk?style=plastic)](https://github.com/CheckPointSW/harmony-endpoint-management-py-sdk/releases) [![PyPI version](https://img.shields.io/pypi/v/chkp-harmony-endpoint-management-sdk.svg?style=plastic)](https://pypi.org/project/chkp-harmony-endpoint-management-sdk/)\n\n\n<!-- \nComing soon :)\n\n[![npm downloads](https://img.shields.io/npm/dt/@chkp/harmony-endpoint-management-sdk.svg.svg?style=plastic)](https://npmjs.com/package/@chkp/harmony-endpoint-management-sdk.svg)\n\n[![GitHub stars](https://img.shields.io/github/stars/CheckPointSW/harmony-endpoint-management-py-sdk.svg?style=social&label=Star)](https://github.com/CheckPointSW/harmony-endpoint-management-py-sdk/stargazers) -->\n\n[![Build SDK Package](https://github.com/CheckPointSW/harmony-endpoint-management-py-sdk/actions/workflows/build.yml/badge.svg)](https://github.com/CheckPointSW/harmony-endpoint-management-py-sdk/actions/workflows/build.yml) [![Publish package to PyPI](https://github.com/CheckPointSW/harmony-endpoint-management-py-sdk/actions/workflows/release.yml/badge.svg)](https://github.com/CheckPointSW/harmony-endpoint-management-py-sdk/actions/workflows/release.yml)\n\nThis is the Harmony Endpoint management SDK for Python ecosystem.\n\nThe SDK is based on the public [Harmony Endpoint management OpenAPI](https://app.swaggerhub.com/apis/Check-Point/web-mgmt-external-api-production) specifications.\n\nWith the SDK, you do not have to manage log in, send keep alive requests, worry about session expiration or pull long processing jobs.\n\n> \ud83d\udca1 The Harmony Endpoint SDK supports simultaneous instances with different tenants.\n\n## \u2b07\ufe0f SDK installation\n\nTo start using this SDK, add the SDK package to your project\n\nVia PIP (PyPi registry)\n```bash \npip install chkp-harmony-endpoint-management-sdk\n```\n\n## \ud83d\ude80 Getting started\n\nFirst, import the `HarmonyEndpoint` object from the package.\n\n```python\nfrom chkp_harmony_endpoint_management_sdk import HarmonyEndpoint\n```\n\nThen, create a new instance of `HarmonyEndpoint`, which provides CloudInfra API credentials and a gateway to connect to.\n\nTo obtain CloudInfra credentials, open the Infinity Portal and create a suitable API Key. Make sure to select `Endpoint` in the `Service` field. For more information, see [Infinity Portal Administration Guide](https://sc1.checkpoint.com/documents/Infinity_Portal/WebAdminGuides/EN/Infinity-Portal-Admin-Guide/Content/Topics-Infinity-Portal/API-Keys.htm?tocpath=Global%20Settings%7C_____7#API_Keys).\n\nOnce the Client ID, Secret Key, and Authentication URL are obtained, Harmony Endpoint SDK can be used.\n\nAll API operations can be explored with the `HarmonyEndpoint` instance, notice to the documentation on each API operation, what and where are the arguments it requires.\n\nAll API's can be also explored in [SwaggerHub](https://app.swaggerhub.com/apis/Check-Point/web-mgmt-external-api-production)\n\nA complete example:\n\n```python\nfrom chkp_harmony_endpoint_management_sdk import HarmonyEndpoint, InfinityPortalAuth\n\n# Create a new instance of HarmonyEndpoint (we do support multiple instances in parallel)\nhe = HarmonyEndpoint()\n\n# Connect to management using CloudInfra API credentials\nhe.connect(infinity_portal_auth=InfinityPortalAuth(\n client_id=\"place here your CI client-id\", # The \"Client ID\"\n access_key= \"place here your CI access-key\", # The \"Secret Key\"\n gateway=\"https://cloudinfra-gw-us.portal.checkpoint.com/auth/external\" # The \"Authentication URL\"\n )) \n\n# Query the API operation\nrules_metadata_res = he.policy_general_api.get_all_rules_metadata(header_params={ \"x-mgmt-run-as-job\": 'off'})\nprint(rules_metadata_res.payload) # Your rulebase metadata\n\n# Also you can query this operation using job, no extra logic required, in the background, it will trigger a job and will pull the status till it finish and return the final results. \nrules_metadata_res = he.policy_general_api.get_all_rules_metadata(header_params={ \"x-mgmt-run-as-job\": 'on'})\nprint(rules_metadata_res.is_job) # True\nprint(rules_metadata_res.payload) # Your rulebase metadata\n\n# Once finish, disconnect to stop all background session management. \nhe.disconnect()\n```\n\n### \ud83c\udfe0 On-premise\n\n\ud83d\udee0\ufe0f\ud83d\udee0\ufe0f\ud83d\udee0\ufe0f **Under Development** \ud83d\udee0\ufe0f\ud83d\udee0\ufe0f\ud83d\udee0\ufe0f\n\nHarmony Endpoint On-premise instances are also supported.\n\n> Pay attention! Not all cloud operations are available for on-premise, also need to specify the SDK version to comply with your Gaia / JHF version\n\n\n```python\nfrom chkp_harmony_endpoint_management_sdk import HarmonyEndpointPremise, OnPremisePortalAuth\n\n# Create a new instance of HarmonyEndpoint (we do support multiple instances in parallel)\nhep = HarmonyEndpointPremise()\n\n# Connect to management using CloudInfra API credentials\nhep.connect(on_premise_portal_auth=OnPremisePortalAuth(\n username=\"xxxx\", \n password= \"xxxx\", \n url=\"https://x.x.x.x\",\n disable_tls_chain_validation=False # Set it true only if you fully trust this URL (e.g. case of internal but not verified https certificate)\n )) \n\n# Query the API operation\nrules_metadata_res = hep.policy_general_api.get_all_rules_metadata(header_params={ \"x-mgmt-run-as-job\": 'off'})\nprint(rules_metadata_res.payload) # Your rulebase metadata\n\n# Once all finish, disconnect to stop all background session management. \nhep.disconnect()\n```\n\nOn-Premises API can be explored in [SwaggerHub](https://app.swaggerhub.com/apis/Check-Point/web-mgmt-external-api-premise)\n\n### \u2601\ufe0f Cloud & MSSP services APIs\n\nHarmony Endpoint also provides APIs for MSSP and Cloud service management (relevant to SaaS customers only) \n\n\nThe usage is similar to the management API\n```python\nfrom chkp_harmony_endpoint_management_sdk import HarmonyEndpointSaaS, InfinityPortalAuth, HarmonyEndpointSaaSOptions\n\nhe_saas = HarmonyEndpointSaaS()\n\n# Connect to management using CloudInfra API credentials\nhe_saas.connect(infinity_portal_auth=InfinityPortalAuth(\n client_id=\"place here your CI client-id\", # The \"Client ID\"\n access_key= \"place here your CI access-key\", # The \"Secret Key\"\n gateway=\"https://cloudinfra-gw-us.portal.checkpoint.com/auth/external\", # The \"Authentication URL\"\n harmony_endpoint_saas_options=HarmonyEndpointSaaSOptions(\n activate_mssp_session=True # Activate MSSP's session management, turn on if you're using MSSP APIs\n )\n )) \n\n# Query the cloud API operation\ninstance_status_res = he_saas.self_service_api.public_machines_single_status()\nprint(instance_status_res.payload) # Your instance status\n\nhe_saas.disconnect()\n```\nAPI available at [SwaggerHub](https://app.swaggerhub.com/apis/Check-Point/harmony-endpoint-cloud-api-prod)\n\n## \ud83d\udd0d Troubleshooting and logging\n\nThe full version and build info of the SDK is available by `HarmonyEndpoint.info()` see example:\n```python\nfrom chkp_harmony_endpoint_management_sdk import HarmonyEndpoint, HarmonyEndpointSDKInfo\n\nsdk_info: HarmonyEndpointSDKInfo = HarmonyEndpoint.info()\nprint(sdk_info) # sdk_build:\"9728283\", sdk_version:\"1.0.2\", spec:\"web-mgmt-external-api-production\", spec_version:\"1.9.159\", released_on:\"2023-09-10T18:14:38.264Z\"\n```\n\nHarmony Endpoint Management SDK uses the official python logger package for logging.\n\nThere are 3 loggers, for general info, errors and to inspect network.\n\nAs default they will be disabled, in order to enable logging, set to the `HARMONY_ENDPOINT_SDK_LOGGER` environment variable the following string before loading the SDK:\n```bash\nHARMONY_ENDPOINT_SDK_LOGGER=\"*\"\n```\n\nAnd for a specific/s logger set the logger name followed by a command as following:\n```bash\nHARMONY_ENDPOINT_SDK_LOGGER=\"info,error,network\"\n```\n\nor activate logger programmatically using SDK methods:\n```python\nfrom chkp_harmony_endpoint_management_sdk import activate_all_loggers, activate_info_logger, activate_error_logger, activate_network_logger\n...\nactivate_all_loggers() # Will activate all logger\nactivate_info_logger() # Will activate the info logger only\nactivate_error_logger() # Will activate the error logger only\nactivate_network_logger() # Will activate the network logger only\n```\n\n## \ud83d\udc1e Report Bug\n\nIn case of an issue or a bug found in the SDK, please open an [issue](https://github.com/CheckPointSW/harmony-endpoint-management-py-sdk/issues) or report to us [Check Point Software Technologies Ltd](mailto:harmony-endpoint-external-api@checkpoint.com).\n\n## \ud83e\udd1d Contributors \n- Haim Kastner - [chkp-haimk](https://github.com/chkp-haimk)\n- Yuval Pomerchik - [chkp-yuvalpo](https://github.com/chkp-yuvalpo)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Harmony Endpoint Official Python SDK",
"version": "1.1.38",
"project_urls": {
"Homepage": "https://github.com/CheckPointSW/harmony-endpoint-management-py-sdk"
},
"split_keywords": [
"python",
" harmony",
" endpoint",
" sdk",
" checkpoint"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7ed7b41fdf7156bf117f1739b590f88a4627ae722d1ceb2941502afd75874fc9",
"md5": "cf3ba9430695a6d1697b1886923196b3",
"sha256": "ae5473b09e23d783891726449cddfc6cb4235f4e4210686721dcb9072a824f38"
},
"downloads": -1,
"filename": "chkp_harmony_endpoint_management_sdk-1.1.38-py3-none-any.whl",
"has_sig": false,
"md5_digest": "cf3ba9430695a6d1697b1886923196b3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.8",
"size": 1858376,
"upload_time": "2024-06-09T10:07:19",
"upload_time_iso_8601": "2024-06-09T10:07:19.800185Z",
"url": "https://files.pythonhosted.org/packages/7e/d7/b41fdf7156bf117f1739b590f88a4627ae722d1ceb2941502afd75874fc9/chkp_harmony_endpoint_management_sdk-1.1.38-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "2fff50fc7721f2f3b9bd8795b8d8c21a31b044b6adaa6d528ca3165dd196070e",
"md5": "9f4cab4ceae82557f48e521b7dd6878e",
"sha256": "de12d8f095509191b4ca86c9619004262ff53c2f8a261d4011d2c6874bf4bd7b"
},
"downloads": -1,
"filename": "chkp_harmony_endpoint_management_sdk-1.1.38.tar.gz",
"has_sig": false,
"md5_digest": "9f4cab4ceae82557f48e521b7dd6878e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.8",
"size": 452365,
"upload_time": "2024-06-09T10:07:22",
"upload_time_iso_8601": "2024-06-09T10:07:22.192200Z",
"url": "https://files.pythonhosted.org/packages/2f/ff/50fc7721f2f3b9bd8795b8d8c21a31b044b6adaa6d528ca3165dd196070e/chkp_harmony_endpoint_management_sdk-1.1.38.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-06-09 10:07:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "CheckPointSW",
"github_project": "harmony-endpoint-management-py-sdk",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "aenum",
"specs": [
[
"==",
"3.1.15"
]
]
},
{
"name": "certifi",
"specs": [
[
"==",
"2023.7.22"
]
]
},
{
"name": "charset-normalizer",
"specs": [
[
"==",
"3.3.0"
]
]
},
{
"name": "frozendict",
"specs": [
[
"==",
"2.3.10"
]
]
},
{
"name": "idna",
"specs": [
[
"==",
"3.7"
]
]
},
{
"name": "MarkupSafe",
"specs": [
[
"==",
"2.1.3"
]
]
},
{
"name": "python-dateutil",
"specs": [
[
"==",
"2.8.2"
]
]
},
{
"name": "python-dotenv",
"specs": [
[
"==",
"1.0.0"
]
]
},
{
"name": "requests",
"specs": [
[
"==",
"2.32.0"
]
]
},
{
"name": "typing-extensions",
"specs": [
[
"==",
"4.8.0"
]
]
},
{
"name": "pyjwt",
"specs": [
[
"==",
"2.8.0"
]
]
},
{
"name": "unitsnet-py",
"specs": [
[
">=",
"0.1.82"
]
]
},
{
"name": "urllib3",
"specs": [
[
"==",
"2.0.7"
]
]
}
],
"lcname": "chkp-harmony-endpoint-management-sdk"
}