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_cli.types import OnOffToggleEnum
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
Release history Release notifications | RSS feed
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.16.tar.gz
(5.5 kB
view details)
Built Distribution
File details
Details for the file nssurge_api-0.2.16.tar.gz
.
File metadata
- Download URL: nssurge_api-0.2.16.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d578e19edfaba78d6fab94107cacb27f5f223801f43ebfc41fc62815a58a369 |
|
MD5 | c9cc215b81b0975cf1bd88c7ee0545de |
|
BLAKE2b-256 | 100d60ae545d82a1aea321995df126085221fefd7b21276cf4e563c41330e826 |
File details
Details for the file nssurge_api-0.2.16-py3-none-any.whl
.
File metadata
- Download URL: nssurge_api-0.2.16-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | c653d5207c9e762da224e307f6c12544b2e40d52d6ce5227db646e31ede9d1ca |
|
MD5 | 9f818782d759a70d3969026ed24385ef |
|
BLAKE2b-256 | aad37fac2a48f9fb4687e3ff719dafef7f7373d6d090687865a1d5501af6fee7 |