Skip to main content

Python API client library for Fortinet's Asset Management.

Project description

pyfortiassetmgmt

Python API client library for Fortinet's Asset Management.

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
        }
    ]
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfortiassetmgmt-1.0.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

pyfortiassetmgmt-1.0.1-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

Details for the file pyfortiassetmgmt-1.0.1.tar.gz.

File metadata

  • Download URL: pyfortiassetmgmt-1.0.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for pyfortiassetmgmt-1.0.1.tar.gz
Algorithm Hash digest
SHA256 0ed5c4413e018f55cd55054b1594ab8ba005ec7690a6481691f53342e2fad311
MD5 580cee41bd41df49fe47c198c437b347
BLAKE2b-256 260d5a136ab39de46c700722122c1e1fd91cbf24a02619410165d55cb3fea74b

See more details on using hashes here.

File details

Details for the file pyfortiassetmgmt-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pyfortiassetmgmt-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d24387641a97f52a118d7cd788c34defc53167ab9d9a6b5e0f7f9d47e1337627
MD5 02a24ff133a4b6f44508357c4b19aba6
BLAKE2b-256 aacee19042bddb4a438e4540d8afa2592a195d1e5930cc65beec061fe8241c60

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page