onekey-client


Nameonekey-client JSON
Version 2.1.1 PyPI version JSON
download
home_pagehttps://www.onekey.com/
SummaryONEKEY API client
upload_time2023-04-03 21:33:35
maintainer
docs_urlNone
authorONEKEY
requires_python>=3.7.0,<4.0.0
licenseMIT
keywords iot security firmware analysis
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ONEKEY API Client

This is the official Python client for the
[ONEKEY](https://www.onekey.com/) public API.

# Usage

First, you have to log in and select a tenant:

```python
from onekey_client import Client

YOUR_API_URL = "https://demo.onekey.com/api"

client = Client(api_url=YOUR_API_URL)

client.login(EMAIL, PASSWORD)
tenant = client.get_tenant("Environment name")
client.use_tenant(tenant)
```

After you logged in and selected the tenant, you can query the GraphQL API

```python
GET_ALL_FIRMWARES = """
query {
  allFirmwares {
    id
    name
  }
}
"""
res = client.query(GET_ALL_FIRMWARES)
print(res)

GET_PRODUCT_GROUPS = """
query {
  allProductGroups {
    id
    name
  }
}
"""
res = client.query(GET_PRODUCT_GROUPS)
default_product_group = next(pg for pg in res["allProductGroups"] if pg["name"] == "Default")
```

You can upload firmwares:

```python
metadata = FirmwareMetadata(
    name="myFirmware",
    vendor_name="myVendor",
    product_name="myProduct",
    product_group_id=default_product_group["id"],
)

firmware_path = Path("/path/to/firmware.bin")
res = client.upload_firmware(metadata, firmware_path, enable_monitoring=True)
print(res)
```

# Support

You can create a [new issue in this repo](https://github.com/onekey-sec/python-client/issues/new)
or contact us at support@onekey.com.

            

Raw data

            {
    "_id": null,
    "home_page": "https://www.onekey.com/",
    "name": "onekey-client",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7.0,<4.0.0",
    "maintainer_email": "",
    "keywords": "iot,security,firmware,analysis",
    "author": "ONEKEY",
    "author_email": "support@onekey.com",
    "download_url": "https://files.pythonhosted.org/packages/82/1f/25fae22563999dceb794a82fc593665c573e07f394b246b0b8c8dbec4529/onekey_client-2.1.1.tar.gz",
    "platform": null,
    "description": "# ONEKEY API Client\n\nThis is the official Python client for the\n[ONEKEY](https://www.onekey.com/) public API.\n\n# Usage\n\nFirst, you have to log in and select a tenant:\n\n```python\nfrom onekey_client import Client\n\nYOUR_API_URL = \"https://demo.onekey.com/api\"\n\nclient = Client(api_url=YOUR_API_URL)\n\nclient.login(EMAIL, PASSWORD)\ntenant = client.get_tenant(\"Environment name\")\nclient.use_tenant(tenant)\n```\n\nAfter you logged in and selected the tenant, you can query the GraphQL API\n\n```python\nGET_ALL_FIRMWARES = \"\"\"\nquery {\n  allFirmwares {\n    id\n    name\n  }\n}\n\"\"\"\nres = client.query(GET_ALL_FIRMWARES)\nprint(res)\n\nGET_PRODUCT_GROUPS = \"\"\"\nquery {\n  allProductGroups {\n    id\n    name\n  }\n}\n\"\"\"\nres = client.query(GET_PRODUCT_GROUPS)\ndefault_product_group = next(pg for pg in res[\"allProductGroups\"] if pg[\"name\"] == \"Default\")\n```\n\nYou can upload firmwares:\n\n```python\nmetadata = FirmwareMetadata(\n    name=\"myFirmware\",\n    vendor_name=\"myVendor\",\n    product_name=\"myProduct\",\n    product_group_id=default_product_group[\"id\"],\n)\n\nfirmware_path = Path(\"/path/to/firmware.bin\")\nres = client.upload_firmware(metadata, firmware_path, enable_monitoring=True)\nprint(res)\n```\n\n# Support\n\nYou can create a [new issue in this repo](https://github.com/onekey-sec/python-client/issues/new)\nor contact us at support@onekey.com.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "ONEKEY API client",
    "version": "2.1.1",
    "split_keywords": [
        "iot",
        "security",
        "firmware",
        "analysis"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "19a1fed9326f1bc02ffc0fb2064451ad410387dc31a977a95772b7ef0ab6d0b4",
                "md5": "30ec556494ba93eacf6d4e9a6e94d4a1",
                "sha256": "39fa8604e06aa4663a541748744f7649997169c66853caa41a16bee3b5aa02a6"
            },
            "downloads": -1,
            "filename": "onekey_client-2.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "30ec556494ba93eacf6d4e9a6e94d4a1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7.0,<4.0.0",
            "size": 26999,
            "upload_time": "2023-04-03T21:33:34",
            "upload_time_iso_8601": "2023-04-03T21:33:34.201472Z",
            "url": "https://files.pythonhosted.org/packages/19/a1/fed9326f1bc02ffc0fb2064451ad410387dc31a977a95772b7ef0ab6d0b4/onekey_client-2.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "821f25fae22563999dceb794a82fc593665c573e07f394b246b0b8c8dbec4529",
                "md5": "666c8de1ba4941816af0c84c3b653c90",
                "sha256": "a7479598a0f665082f732e0539cf37d80f53e705cb4039b14d047ef4604647af"
            },
            "downloads": -1,
            "filename": "onekey_client-2.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "666c8de1ba4941816af0c84c3b653c90",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7.0,<4.0.0",
            "size": 22994,
            "upload_time": "2023-04-03T21:33:35",
            "upload_time_iso_8601": "2023-04-03T21:33:35.772141Z",
            "url": "https://files.pythonhosted.org/packages/82/1f/25fae22563999dceb794a82fc593665c573e07f394b246b0b8c8dbec4529/onekey_client-2.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-03 21:33:35",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "lcname": "onekey-client"
}
        
Elapsed time: 0.08296s