Skip to main content

A trivial set of API bindings for things I use. So far, TODA and FleetDM

Project description

TrivialAPI

(A set of requests-based, trivial API bindings for things I use)

FleetDM

Basic usage

(env-whatever) $ pip install trivialapi
Collecting trivialapi
...snip...
(env-whatever) $ python
Python 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from src.trivialapi.fleetdm import core
>>> core.FleetDM("https://your-server.url")
<src.trivialapi.fleetdm.core.FleetDM object at 0x7afe7e9ffaa0>
>>> fleet = _
>>> fleet.login("you@your.email", "your-password")
True
>>> fleet.hosts()
[...your hosts show up here...]
>>> fleet.host_livequery(host, "SELECT 1 FROM disk_encryption WHERE encrypted=1 AND name LIKE '/dev/dm-1';")
{'host_id': 1, 'rows': None, 'query': "SELECT 1 FROM disk_encryption WHERE encrypted=1 AND name LIKE '/dev/dm-1';", 'status': 'offline'}
>>> qs = fleet.standard_query_library()
>>> len(qs)
91
>>> qs[0]
{'name': 'Get OpenSSL versions', 'platform': ['linux'], 'description': 'Retrieves the OpenSSL version.', 'query': "SELECT name AS name, version AS version, 'deb_packages' AS source FROM deb_packages WHERE name LIKE 'openssl%' UNION SELECT name AS name, version AS version, 'apt_sources' AS source FROM apt_sources WHERE name LIKE 'openssl%' UNION SELECT name AS name, version AS version, 'rpm_packages' AS source FROM rpm_packages WHERE name LIKE 'openssl%';", 'purpose': 'Informational', 'tags': 'inventory', 'contributors': 'zwass'}
>>> enc_qs = [q for q in qs if "Full disk encryption" in q["name"]]
>>> q = enc_qs[0]
>>> fleet.add_query(q["query"], q["name"], q["description"], ",".join(q["platform"]))
<Response [200]>

TODA

  • A basic port of this that doesn't suck too much.

Basic usage

(env-whatever) $ pip install trivialapi
Collecting trivialapi
...snip...
(env-whatever) $ python
Python 3.10.12 (main, Mar 22 2024, 16:50:05) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from src.trivialapi.toda import core
<module 'src.trivialapi.toda.core'>
>>> tw = core.Twin.from_file("~/path/to/your/twin.json")
<src.trivialapi.toda.core.Twin object at 0x74622b7ed150>
>>> tw.hostname
'41a9cbc977c39bd3eb5a52a5924f8ef5.micro-staging.biz.todaq.net'
>>> tw.key
'redacted'
>>> tw.mint(1000, minting_info="Precision 0 minting test")
{'result': 'success', 'files': ['419bfe67b7fafe0842813f13044d637775349d2b4df347639eccc6ec82093a8ecb'], 'root': '41a2099e84dd4690ea55774506d58ee6cf6ac9fe0c9806239ef6e251a6bc597641'}
>>> tw.balance()
[{'balance': 1000, 'quantity': 1000, 'files': ['419bfe67b7fafe0842813f13044d637775349d2b4df347639eccc6ec82093a8ecb'], 'fileValue': {'419bfe67b7fafe0842813f13044d637775349d2b4df347639eccc6ec82093a8ecb': 1000}, 'poptop': '419ccac82bcf1216a70929664cdeaa97bcc01deb87d190a0c7ce90e62d7b89a6bf', 'displayPrecision': 0, 'type': '41a2099e84dd4690ea55774506d58ee6cf6ac9fe0c9806239ef6e251a6bc597641'}]

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

trivialapi-0.0.24.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

trivialapi-0.0.24-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file trivialapi-0.0.24.tar.gz.

File metadata

  • Download URL: trivialapi-0.0.24.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for trivialapi-0.0.24.tar.gz
Algorithm Hash digest
SHA256 9aa6c3da208e0df82dd5f2ad43fc18794008043d8fcc8f32dae64f22eedc0d2c
MD5 54259effa26fc86abdb3c037c6ba6ac6
BLAKE2b-256 b68863f6a6ffe050c6558ff03f8df6b94d4bd548c1ad824af936bf0c0271c781

See more details on using hashes here.

File details

Details for the file trivialapi-0.0.24-py3-none-any.whl.

File metadata

  • Download URL: trivialapi-0.0.24-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.20

File hashes

Hashes for trivialapi-0.0.24-py3-none-any.whl
Algorithm Hash digest
SHA256 ea323a16923b5880a0fc75fedcbb5cea88baf15169db11e2156c3c6fa4614e48
MD5 14c1f9e21878e9021e4f3f5b8d2c1a28
BLAKE2b-256 af57b5b641aa98acedbc06ed8f68e5de4325736a975e66d948bcfbfe6cc92e9e

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