# pyfortiztp
Python API client library for Fortinet's [FortiZTP](https://fortiztp.forticloud.com).
The FortiZTP Cloud API provides:
- Retrieve provisioning status of FortiGates, FortiAPs, and FortiSwitch.
- Provision or un-provision devices to the cloud or on-premise targets.
## Installation
To install run `pip install pyfortiztp`.
Alternatively, you can clone the repo and run `python setup.py install`.
## Quick Start
To begin, import pyfortiztp and instantiate the API.
We need to provide our API credentials to our FortiCloud account.
Optionally, its possible to set the following settings:
- `client_id` which defaults to `fortiztp`.
- `forticloud_host` which defaults to `https://customerapiauth.fortinet.com`
- `fortiztp_host` which defaults to `https://fortiztp.forticloud.com`
**Code**
```
fortiztp = pyfortiztp.api(
userid = "<your forticloud userid>",
password = "<your forticloud password>"
)
```
## Examples
### Retrieve a single device.
**Code**
```
device = fortiztp.devices.all(deviceSN="FGT60FTK1234ABCD")
print(device)
```
**Output**
```
{
"deviceSN": "FGT60FTK1234ABCD",
"deviceType": "FortiGate",
"provisionStatus": "unprovisioned",
"provisionTarget": null,
"region": "global,europe,JP,US",
"externalControllerSn": null,
"externalControllerIp": null,
"platform": null
}
```
### Provision one or more devices to FortiManager.
`deviceSN` is a list of serial numbers. In this example, we only test with a single serial number.
**Code**
```
update = fortiztp.devices.update(
deviceSN = ["FGT60FTK1234ABCD"],
deviceType = "FortiGate",
provisionStatus = "provisioned",
provisionTarget = "FortiManager",
externalControllerIp = "<external IP of your fortimanager>",
externalControllerSn = "<serial number of your fortimanager>"
)
print(update)
```
**Output**
```
204
```
> **Note:** The FortiZTP API returns the HTTP response "204 No Content" on success.
### Unprovision one or more devices from FortiManager.
`deviceSN` is a list of serial numbers. In this example, we only test with a single serial number.
**Code**
```
update = fortiztp.devices.update(
deviceSN = ["FGT60FTK1234ABCD"],
deviceType = "FortiGate",
provisionStatus = "unprovisioned",
provisionTarget = "FortiManager",
externalControllerIp = "<external IP of your fortimanager>",
externalControllerSn = "<serial number of your fortimanager>"
)
print(update)
```
**Output**
```
204
```
### Error messages.
Error messages are provided as is, from the FortiZTP API.
**Code**
```
update = fortiztp.devices.update(
deviceSN = ["FGT60FTK1234ABCD", "testSN"],
deviceType = "FortiGate",
provisionStatus = "provisioned",
provisionTarget = "FortiManager"
)
print(update)
```
**Output**
```
{
"error": "invalid_request",
"error_description": "Device testSN doesn't exist in this account"
}
```
Raw data
{
"_id": null,
"home_page": "https://github.com/BESTSELLER/pyfortiztp",
"name": "pyfortiztp",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8, <4",
"maintainer_email": "",
"keywords": "fortinet,forticloud,fortiztp",
"author": "Rasmus Thing",
"author_email": "rasmus.thing@bestseller.com",
"download_url": "https://files.pythonhosted.org/packages/17/40/ca3d88a5fd29f598abb3381d366c4aa471502d4b13ed6b179df6a755ecb8/pyfortiztp-1.0.1.tar.gz",
"platform": null,
"description": "# pyfortiztp\nPython API client library for Fortinet's [FortiZTP](https://fortiztp.forticloud.com).\n\nThe FortiZTP Cloud API provides:\n - Retrieve provisioning status of FortiGates, FortiAPs, and FortiSwitch.\n - Provision or un-provision devices to the cloud or on-premise targets.\n\n## Installation\nTo install run `pip install pyfortiztp`.\n\nAlternatively, you can clone the repo and run `python setup.py install`.\n\n## Quick Start\nTo begin, import pyfortiztp and instantiate the API.\n\nWe need to provide our API credentials to our FortiCloud account.\n\nOptionally, its possible to set the following settings:\n- `client_id` which defaults to `fortiztp`.\n- `forticloud_host` which defaults to `https://customerapiauth.fortinet.com`\n- `fortiztp_host` which defaults to `https://fortiztp.forticloud.com`\n\n**Code**\n```\nfortiztp = pyfortiztp.api(\n userid = \"<your forticloud userid>\",\n password = \"<your forticloud password>\"\n)\n```\n\n## Examples\n### Retrieve a single device.\n**Code**\n```\ndevice = fortiztp.devices.all(deviceSN=\"FGT60FTK1234ABCD\")\nprint(device)\n```\n\n**Output**\n```\n{\n \"deviceSN\": \"FGT60FTK1234ABCD\",\n \"deviceType\": \"FortiGate\",\n \"provisionStatus\": \"unprovisioned\",\n \"provisionTarget\": null,\n \"region\": \"global,europe,JP,US\",\n \"externalControllerSn\": null,\n \"externalControllerIp\": null,\n \"platform\": null\n}\n```\n\n### Provision one or more devices to FortiManager.\n`deviceSN` is a list of serial numbers. In this example, we only test with a single serial number.\n\n**Code**\n```\nupdate = fortiztp.devices.update(\n deviceSN = [\"FGT60FTK1234ABCD\"],\n deviceType = \"FortiGate\",\n provisionStatus = \"provisioned\",\n provisionTarget = \"FortiManager\",\n externalControllerIp = \"<external IP of your fortimanager>\",\n externalControllerSn = \"<serial number of your fortimanager>\"\n)\nprint(update)\n```\n\n**Output**\n```\n204\n```\n\n> **Note:** The FortiZTP API returns the HTTP response \"204 No Content\" on success.\n\n### Unprovision one or more devices from FortiManager.\n`deviceSN` is a list of serial numbers. In this example, we only test with a single serial number.\n\n**Code**\n```\nupdate = fortiztp.devices.update(\n deviceSN = [\"FGT60FTK1234ABCD\"],\n deviceType = \"FortiGate\",\n provisionStatus = \"unprovisioned\",\n provisionTarget = \"FortiManager\",\n externalControllerIp = \"<external IP of your fortimanager>\",\n externalControllerSn = \"<serial number of your fortimanager>\"\n)\nprint(update)\n```\n\n**Output**\n```\n204\n```\n\n### Error messages.\nError messages are provided as is, from the FortiZTP API.\n\n**Code**\n```\nupdate = fortiztp.devices.update(\n deviceSN = [\"FGT60FTK1234ABCD\", \"testSN\"],\n deviceType = \"FortiGate\",\n provisionStatus = \"provisioned\",\n provisionTarget = \"FortiManager\"\n)\nprint(update)\n```\n\n**Output**\n```\n{\n \"error\": \"invalid_request\",\n \"error_description\": \"Device testSN doesn't exist in this account\"\n}\n```\n",
"bugtrack_url": null,
"license": "Apache2",
"summary": "Python API client library for Fortinet's FortiZTP.",
"version": "1.0.1",
"project_urls": {
"Homepage": "https://github.com/BESTSELLER/pyfortiztp"
},
"split_keywords": [
"fortinet",
"forticloud",
"fortiztp"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b757f707002d37c8de17edba01614981f07fc05084064702ab577ca7f256f9e3",
"md5": "4dbcdcd38247e2c579bcf020f80d9825",
"sha256": "239866c988faa4594f509fea016d72c3e8d7e349d5a1f4a4c3d3de6f50275bac"
},
"downloads": -1,
"filename": "pyfortiztp-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4dbcdcd38247e2c579bcf020f80d9825",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8, <4",
"size": 9120,
"upload_time": "2023-12-01T13:49:28",
"upload_time_iso_8601": "2023-12-01T13:49:28.925822Z",
"url": "https://files.pythonhosted.org/packages/b7/57/f707002d37c8de17edba01614981f07fc05084064702ab577ca7f256f9e3/pyfortiztp-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "1740ca3d88a5fd29f598abb3381d366c4aa471502d4b13ed6b179df6a755ecb8",
"md5": "03251885dbe9e4a60c0abb26beb27ebd",
"sha256": "4b8f502c92c4e5bad427a0c1cc12cd71bad71b7807af7fd82acf093bbb3e859a"
},
"downloads": -1,
"filename": "pyfortiztp-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "03251885dbe9e4a60c0abb26beb27ebd",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8, <4",
"size": 8374,
"upload_time": "2023-12-01T13:49:30",
"upload_time_iso_8601": "2023-12-01T13:49:30.571201Z",
"url": "https://files.pythonhosted.org/packages/17/40/ca3d88a5fd29f598abb3381d366c4aa471502d4b13ed6b179df6a755ecb8/pyfortiztp-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-01 13:49:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "BESTSELLER",
"github_project": "pyfortiztp",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "pyfortiztp"
}