# pyfortiassetmgmt
Python API client library for Fortinet's [Asset Management](https://support.fortinet.com).
The Asset Management API provides:
- Contract management (Retrieve)
- Folder management (Retrieve, create, delete)
- License management (Retrieve, register, download)
- Product management (Register, retrieve, decommission)
- Service management (Register)
> **Note:** This library has been built and tested for API v3.
## Installation
To install run `pip install pyfortiassetmgmt`.
Alternatively, you can clone the repo and run `python setup.py install`.
## Quick Start
To begin, import pyfortiassetmgmt 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 `assetmanagement`.
- `forticloud_host` which defaults to `https://customerapiauth.fortinet.com`
- `fortiasset_host` which defaults to `https://support.fortinet.com`
**Code**
```
fortiassetmgmt = pyfortiassetmgmt.api(
userid = "<your forticloud userid>",
password = "<your forticloud password>"
)
```
## Examples
### Retrieve a product.
**Code**
```
products = fortiassetmgmt.products.all(serialNumber="FGT60FTK1234ABCD")
print(products)
```
**Output**
```
{
"build": "1.0.0",
"error": null,
"message": "Request processed successfully",
"status": 0,
"token": "<token>",
"version": "3.0",
"assets": [
{
"description": "Test FortiGate",
"entitlements": [
{
"endDate": "2024-07-31T00:00:00",
"level": 5,
"levelDesc": "Advanced HW",
"startDate": "2021-08-01T00:00:00",
"type": 1,
"typeDesc": "Hardware"
},
{
"endDate": "2024-07-31T00:00:00",
"level": 6,
"levelDesc": "Web/Online",
"startDate": "2021-08-01T00:00:00",
"type": 2,
"typeDesc": "Firmware & General Updates"
},
{
"endDate": "2024-07-31T00:00:00",
"level": 20,
"levelDesc": "Premium",
"startDate": "2021-08-01T00:00:00",
"type": 11,
"typeDesc": "Enhanced Support"
},
{
"endDate": "2024-07-31T00:00:00",
"level": 20,
"levelDesc": "Premium",
"startDate": "2021-08-01T00:00:00",
"type": 12,
"typeDesc": "Telephone Support"
},
{
"endDate": "2024-07-31T00:00:00",
"level": 6,
"levelDesc": "Web/Online",
"startDate": "2021-08-01T00:00:00",
"type": 21,
"typeDesc": "Advanced Malware Protection"
},
{
"endDate": "2024-07-31T00:00:00",
"level": 6,
"levelDesc": "Web/Online",
"startDate": "2021-08-01T00:00:00",
"type": 22,
"typeDesc": "NGFW"
},
{
"endDate": "2024-07-31T00:00:00",
"level": 6,
"levelDesc": "Web/Online",
"startDate": "2021-08-01T00:00:00",
"type": 41,
"typeDesc": "Web & Video Filtering"
},
{
"endDate": "2024-07-31T00:00:00",
"level": 6,
"levelDesc": "Web/Online",
"startDate": "2021-08-01T00:00:00",
"type": 51,
"typeDesc": "AntiSpam"
}
],
"isDecommissioned": false,
"productModel": "FortiGate 60F",
"registrationDate": "2023-01-09T00:37:25",
"serialNumber": "FGT60FTK1234ABCD",
"warrantySupports": null,
"assetGroups": [],
"contracts": [
{
"contractNumber": "<contractNumber>",
"sku": "FC-10-0060F-123-45-67",
"terms": [
{
"endDate": "2024-07-31T00:00:00",
"startDate": "2021-08-01T00:00:00",
"supportType": "Hardware"
},
{
"endDate": "2024-07-31T00:00:00",
"startDate": "2021-08-01T00:00:00",
"supportType": "Firmware & General Updates"
},
{
"endDate": "2024-07-31T00:00:00",
"startDate": "2021-08-01T00:00:00",
"supportType": "Enhanced Support"
},
{
"endDate": "2024-07-31T00:00:00",
"startDate": "2021-08-01T00:00:00",
"supportType": "Telephone Support"
}
]
},
{
"contractNumber": "<contractNumber>",
"sku": "FC-10-0060F-123-45-67",
"terms": [
{
"endDate": "2024-07-31T00:00:00",
"startDate": "2021-08-01T00:00:00",
"supportType": "Advanced Malware Protection"
}
]
},
{
"contractNumber": "<contractNumber>",
"sku": "FC-10-0060F-108-02-36",
"terms": [
{
"endDate": "2024-07-31T00:00:00",
"startDate": "2021-08-01T00:00:00",
"supportType": "NGFW"
}
]
},
{
"contractNumber": "<contractNumber>",
"sku": "FC-10-0060F-112-02-36",
"terms": [
{
"endDate": "2024-07-31T00:00:00",
"startDate": "2021-08-01T00:00:00",
"supportType": "Web & Video Filtering"
}
]
},
{
"contractNumber": "<contractNumber>",
"sku": "FC-10-0060F-114-02-36",
"terms": [
{
"endDate": "2024-07-31T00:00:00",
"startDate": "2021-08-01T00:00:00",
"supportType": "AntiSpam"
}
]
}
],
"productModelEoR": null,
"productModelEoS": null,
"status": "Registered"
}
],
"pageNumber": 1,
"totalPages": 1
}
```
### Retrieve a contract.
**Code**
```
contracts = fortiassetmgmt.contracts.all(contractNumber="1234AB123456")
print(contracts)
```
**Output**
```
{
"build": "1.0.0",
"error": null,
"message": "Success",
"status": 0,
"token": "<token>",
"version": "3.0",
"contracts": [
{
"contractNumber": "1234AB123456",
"contractSKU": "FC-10-0060E-123-45-67",
"status": "Registered"
}
]
}
```
### Register a product.
**Code**
```
register = fortiassetmgmt.products.register(
serialNumber = "FGT60FTK1234ABCD",
cloudKey = "80X4LSN3"
)
print(register)
```
**Output**
```
{
"build": "1.0.0",
"error": {
"errorCode": 301,
"message": "Failed"
},
"message": "Failed",
"status": 2,
"token": "<token>",
"version": "3.0",
"assets": [
{
"description": null,
"entitlements": null,
"isDecommissioned": false,
"productModel": null,
"registrationDate": null,
"serialNumber": "FGT60FTK1234ABCD",
"warrantySupports": null,
"assetGroups": null,
"contracts": null,
"productModelEoR": null,
"productModelEoS": null,
"additionalInfo": null,
"contractNumber": null,
"contractTerms": null,
"location": null,
"message": "Product-> Product already registered, but no contract associated with request. Please check again.",
"sku": null,
"status": 2,
"folderId": 0,
"folderPath": null
}
]
}
```
Raw data
{
"_id": null,
"home_page": "https://github.com/BESTSELLER/pyfortiassetmgmt",
"name": "pyfortiassetmgmt",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8, <4",
"maintainer_email": "",
"keywords": "fortinet,forticare,forticloud,asset-management",
"author": "Rasmus Thing",
"author_email": "rasmus.thing@bestseller.com",
"download_url": "https://files.pythonhosted.org/packages/26/0d/5a136ab39de46c700722122c1e1fd91cbf24a02619410165d55cb3fea74b/pyfortiassetmgmt-1.0.1.tar.gz",
"platform": null,
"description": "# pyfortiassetmgmt\nPython API client library for Fortinet's [Asset Management](https://support.fortinet.com).\n\nThe Asset Management API provides:\n- Contract management (Retrieve)\n- Folder management (Retrieve, create, delete)\n- License management (Retrieve, register, download)\n- Product management (Register, retrieve, decommission)\n- Service management (Register)\n\n> **Note:** This library has been built and tested for API v3.\n\n## Installation\nTo install run `pip install pyfortiassetmgmt`.\n\nAlternatively, you can clone the repo and run `python setup.py install`.\n\n## Quick Start\nTo begin, import pyfortiassetmgmt 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 `assetmanagement`.\n- `forticloud_host` which defaults to `https://customerapiauth.fortinet.com`\n- `fortiasset_host` which defaults to `https://support.fortinet.com`\n\n**Code**\n```\nfortiassetmgmt = pyfortiassetmgmt.api(\n userid = \"<your forticloud userid>\",\n password = \"<your forticloud password>\"\n)\n```\n\n## Examples\n### Retrieve a product.\n**Code**\n```\nproducts = fortiassetmgmt.products.all(serialNumber=\"FGT60FTK1234ABCD\")\nprint(products)\n```\n\n**Output**\n```\n{\n \"build\": \"1.0.0\",\n \"error\": null,\n \"message\": \"Request processed successfully\",\n \"status\": 0,\n \"token\": \"<token>\",\n \"version\": \"3.0\",\n \"assets\": [\n {\n \"description\": \"Test FortiGate\",\n \"entitlements\": [\n {\n \"endDate\": \"2024-07-31T00:00:00\",\n \"level\": 5,\n \"levelDesc\": \"Advanced HW\",\n \"startDate\": \"2021-08-01T00:00:00\",\n \"type\": 1,\n \"typeDesc\": \"Hardware\"\n },\n {\n \"endDate\": \"2024-07-31T00:00:00\",\n \"level\": 6,\n \"levelDesc\": \"Web/Online\",\n \"startDate\": \"2021-08-01T00:00:00\",\n \"type\": 2,\n \"typeDesc\": \"Firmware & General Updates\"\n },\n {\n \"endDate\": \"2024-07-31T00:00:00\",\n \"level\": 20,\n \"levelDesc\": \"Premium\",\n \"startDate\": \"2021-08-01T00:00:00\",\n \"type\": 11,\n \"typeDesc\": \"Enhanced Support\"\n },\n {\n \"endDate\": \"2024-07-31T00:00:00\",\n \"level\": 20,\n \"levelDesc\": \"Premium\",\n \"startDate\": \"2021-08-01T00:00:00\",\n \"type\": 12,\n \"typeDesc\": \"Telephone Support\"\n },\n {\n \"endDate\": \"2024-07-31T00:00:00\",\n \"level\": 6,\n \"levelDesc\": \"Web/Online\",\n \"startDate\": \"2021-08-01T00:00:00\",\n \"type\": 21,\n \"typeDesc\": \"Advanced Malware Protection\"\n },\n {\n \"endDate\": \"2024-07-31T00:00:00\",\n \"level\": 6,\n \"levelDesc\": \"Web/Online\",\n \"startDate\": \"2021-08-01T00:00:00\",\n \"type\": 22,\n \"typeDesc\": \"NGFW\"\n },\n {\n \"endDate\": \"2024-07-31T00:00:00\",\n \"level\": 6,\n \"levelDesc\": \"Web/Online\",\n \"startDate\": \"2021-08-01T00:00:00\",\n \"type\": 41,\n \"typeDesc\": \"Web & Video Filtering\"\n },\n {\n \"endDate\": \"2024-07-31T00:00:00\",\n \"level\": 6,\n \"levelDesc\": \"Web/Online\",\n \"startDate\": \"2021-08-01T00:00:00\",\n \"type\": 51,\n \"typeDesc\": \"AntiSpam\"\n }\n ],\n \"isDecommissioned\": false,\n \"productModel\": \"FortiGate 60F\",\n \"registrationDate\": \"2023-01-09T00:37:25\",\n \"serialNumber\": \"FGT60FTK1234ABCD\",\n \"warrantySupports\": null,\n \"assetGroups\": [],\n \"contracts\": [\n {\n \"contractNumber\": \"<contractNumber>\",\n \"sku\": \"FC-10-0060F-123-45-67\",\n \"terms\": [\n {\n \"endDate\": \"2024-07-31T00:00:00\",\n \"startDate\": \"2021-08-01T00:00:00\",\n \"supportType\": \"Hardware\"\n },\n {\n \"endDate\": \"2024-07-31T00:00:00\",\n \"startDate\": \"2021-08-01T00:00:00\",\n \"supportType\": \"Firmware & General Updates\"\n },\n {\n \"endDate\": \"2024-07-31T00:00:00\",\n \"startDate\": \"2021-08-01T00:00:00\",\n \"supportType\": \"Enhanced Support\"\n },\n {\n \"endDate\": \"2024-07-31T00:00:00\",\n \"startDate\": \"2021-08-01T00:00:00\",\n \"supportType\": \"Telephone Support\"\n }\n ]\n },\n {\n \"contractNumber\": \"<contractNumber>\",\n \"sku\": \"FC-10-0060F-123-45-67\",\n \"terms\": [\n {\n \"endDate\": \"2024-07-31T00:00:00\",\n \"startDate\": \"2021-08-01T00:00:00\",\n \"supportType\": \"Advanced Malware Protection\"\n }\n ]\n },\n {\n \"contractNumber\": \"<contractNumber>\",\n \"sku\": \"FC-10-0060F-108-02-36\",\n \"terms\": [\n {\n \"endDate\": \"2024-07-31T00:00:00\",\n \"startDate\": \"2021-08-01T00:00:00\",\n \"supportType\": \"NGFW\"\n }\n ]\n },\n {\n \"contractNumber\": \"<contractNumber>\",\n \"sku\": \"FC-10-0060F-112-02-36\",\n \"terms\": [\n {\n \"endDate\": \"2024-07-31T00:00:00\",\n \"startDate\": \"2021-08-01T00:00:00\",\n \"supportType\": \"Web & Video Filtering\"\n }\n ]\n },\n {\n \"contractNumber\": \"<contractNumber>\",\n \"sku\": \"FC-10-0060F-114-02-36\",\n \"terms\": [\n {\n \"endDate\": \"2024-07-31T00:00:00\",\n \"startDate\": \"2021-08-01T00:00:00\",\n \"supportType\": \"AntiSpam\"\n }\n ]\n }\n ],\n \"productModelEoR\": null,\n \"productModelEoS\": null,\n \"status\": \"Registered\"\n }\n ],\n \"pageNumber\": 1,\n \"totalPages\": 1\n}\n```\n\n### Retrieve a contract.\n**Code**\n```\ncontracts = fortiassetmgmt.contracts.all(contractNumber=\"1234AB123456\")\nprint(contracts)\n```\n\n**Output**\n```\n{\n \"build\": \"1.0.0\",\n \"error\": null,\n \"message\": \"Success\",\n \"status\": 0,\n \"token\": \"<token>\",\n \"version\": \"3.0\",\n \"contracts\": [\n {\n \"contractNumber\": \"1234AB123456\",\n \"contractSKU\": \"FC-10-0060E-123-45-67\",\n \"status\": \"Registered\"\n }\n ]\n}\n```\n\n### Register a product.\n**Code**\n```\nregister = fortiassetmgmt.products.register(\n serialNumber = \"FGT60FTK1234ABCD\",\n cloudKey = \"80X4LSN3\"\n)\nprint(register)\n```\n\n**Output**\n```\n{\n \"build\": \"1.0.0\",\n \"error\": {\n \"errorCode\": 301,\n \"message\": \"Failed\"\n },\n \"message\": \"Failed\",\n \"status\": 2,\n \"token\": \"<token>\",\n \"version\": \"3.0\",\n \"assets\": [\n {\n \"description\": null,\n \"entitlements\": null,\n \"isDecommissioned\": false,\n \"productModel\": null,\n \"registrationDate\": null,\n \"serialNumber\": \"FGT60FTK1234ABCD\",\n \"warrantySupports\": null,\n \"assetGroups\": null,\n \"contracts\": null,\n \"productModelEoR\": null,\n \"productModelEoS\": null,\n \"additionalInfo\": null,\n \"contractNumber\": null,\n \"contractTerms\": null,\n \"location\": null,\n \"message\": \"Product-> Product already registered, but no contract associated with request. Please check again.\",\n \"sku\": null,\n \"status\": 2,\n \"folderId\": 0,\n \"folderPath\": null\n }\n ]\n}\n```\n",
"bugtrack_url": null,
"license": "Apache2",
"summary": "Python API client library for Fortinet's Asset Management.",
"version": "1.0.1",
"project_urls": {
"Homepage": "https://github.com/BESTSELLER/pyfortiassetmgmt"
},
"split_keywords": [
"fortinet",
"forticare",
"forticloud",
"asset-management"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "aacee19042bddb4a438e4540d8afa2592a195d1e5930cc65beec061fe8241c60",
"md5": "02a24ff133a4b6f44508357c4b19aba6",
"sha256": "d24387641a97f52a118d7cd788c34defc53167ab9d9a6b5e0f7f9d47e1337627"
},
"downloads": -1,
"filename": "pyfortiassetmgmt-1.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "02a24ff133a4b6f44508357c4b19aba6",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8, <4",
"size": 13455,
"upload_time": "2023-10-30T14:40:45",
"upload_time_iso_8601": "2023-10-30T14:40:45.322559Z",
"url": "https://files.pythonhosted.org/packages/aa/ce/e19042bddb4a438e4540d8afa2592a195d1e5930cc65beec061fe8241c60/pyfortiassetmgmt-1.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "260d5a136ab39de46c700722122c1e1fd91cbf24a02619410165d55cb3fea74b",
"md5": "580cee41bd41df49fe47c198c437b347",
"sha256": "0ed5c4413e018f55cd55054b1594ab8ba005ec7690a6481691f53342e2fad311"
},
"downloads": -1,
"filename": "pyfortiassetmgmt-1.0.1.tar.gz",
"has_sig": false,
"md5_digest": "580cee41bd41df49fe47c198c437b347",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8, <4",
"size": 12124,
"upload_time": "2023-10-30T14:40:46",
"upload_time_iso_8601": "2023-10-30T14:40:46.897873Z",
"url": "https://files.pythonhosted.org/packages/26/0d/5a136ab39de46c700722122c1e1fd91cbf24a02619410165d55cb3fea74b/pyfortiassetmgmt-1.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-30 14:40:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "BESTSELLER",
"github_project": "pyfortiassetmgmt",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [],
"lcname": "pyfortiassetmgmt"
}