Skip to main content

NSSurge HTTP API for Python

Project description

NSSurge Python API Client

Python implementation of the Surge HTTP API spec client using aiohttp.

Installation

pip

$ pip install nssurge-api

Usage

# source: https://github.com/tddschn/nssurge-cli/blob/master/nssurge_cli/cap_commands.py
from nssurge_api import SurgeAPIClient
from nssurge_api.types import Capability
import asyncio

async def get_set_cap(
    capability: Capability, on_off: OnOffToggleEnum | None = None
) -> bool | tuple[bool, bool]:
    """
    Get or set a capability
    """
    async with SurgeAPIClient(*get_config()) as client:
        state_orig = await get_cap_state(client, capability)
        match on_off:
            case OnOffToggleEnum.on | OnOffToggleEnum.off:
                await client.set_cap(capability, s2b(on_off))
            case OnOffToggleEnum.toggle:
                await client.set_cap(capability, not state_orig)
            case _:
                return state_orig
        state_new = await get_cap_state(client, capability)
        return state_orig, state_new

Develop

$ git clone https://github.com/tddschn/nssurge-api.git
$ cd nssurge-api
$ poetry install

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

nssurge_api-0.2.15.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nssurge_api-0.2.15-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file nssurge_api-0.2.15.tar.gz.

File metadata

  • Download URL: nssurge_api-0.2.15.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Darwin/22.5.0

File hashes

Hashes for nssurge_api-0.2.15.tar.gz
Algorithm Hash digest
SHA256 93d11a44e45e8b3e80e1fc401deb9dbe8bb2a83b4c80dd0e92257823aa76ddbc
MD5 c9151b8561e258061b16c6c013563980
BLAKE2b-256 a287a622b7be020f3747f5a4d242d768ae7381c8649a7d69ca175f7bdf23e4df

See more details on using hashes here.

File details

Details for the file nssurge_api-0.2.15-py3-none-any.whl.

File metadata

  • Download URL: nssurge_api-0.2.15-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.4.2 CPython/3.11.3 Darwin/22.5.0

File hashes

Hashes for nssurge_api-0.2.15-py3-none-any.whl
Algorithm Hash digest
SHA256 42fb2f99479ccd45bd19f4f720e4da7c16678538d5477a4f7759c794b4ed18c0
MD5 7f9cf98659bc778538169b79fb1d19a3
BLAKE2b-256 b1503ec0c355afb9e543290a6885d0ad846b39577f1e3b9ff709db17f627c3e1

See more details on using hashes here.

Supported by

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