Client library of buildgrid-metering service
Project description
Buildgrid Metering Service Client
🚧 This library is currently WIP and the interfaces might not be stable while the version is 0.0.1-alpha.*
. 🚧
Asyncio Python client of buildgrid-metering
service.
Example
Suppose buildgrid-metering
is running on http://localhost:8000
requiring no authentication.
The service can be queried using this library via its asyncio
interfaces.
import asyncio
from buildgrid_metering.client import MeteringServiceClient
from buildgrid_metering.client.auth import (
AuthTokenConfig,
AuthTokenLoader,
AuthTokenMode,
)
from buildgrid_metering.models.dataclasses import ComputingUsage, Identity, Usage
token_loader = AuthTokenLoader(AuthTokenConfig(AuthTokenMode.NONE, ""))
client = MeteringServiceClient("http://localhost:8000", token_loader)
identity = Identity(instance="dev", workflow="build", actor="tool", subject="username")
async def main():
# Put usage of identity
usage = Usage(computing=ComputingUsage(utime=1, stime=2, maxrss=3))
await client.put_usage(identity, "op", usage)
# Check throttling of identity
resp = await client.get_throttling(identity)
print(resp)
if __name__ == "__main__":\
# Run the script with asyncio
asyncio.run(main())
Contact us
See more details at BuildGrid Resources.
Contributing
See more details at CONTRIBUTING.md and BuildGrid.
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
Built Distribution
Close
Hashes for buildgrid-metering-client-0.0.1a3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea64b9b2adfd6b8259f6967f8d90e01378da06866653f031f361c9ff40c31df3 |
|
MD5 | 0b67a1a56ec9c865f7246625b6b1f1b4 |
|
BLAKE2b-256 | 0eb0b342b505a4cc398fad4a52cf8ac500ef6e9d503f2a628896d7b1c2084839 |
Close
Hashes for buildgrid_metering_client-0.0.1a3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c542b913d0c248e51e4bebe40427e16d9c45350ed8f0ffdaf4dd103ef280d80 |
|
MD5 | 8925464db7220e22f1dc0824a96171b5 |
|
BLAKE2b-256 | 82844da64eacdcb510b7177edc7094ee0275f5298ebe24bfb6ec17732eff3a4e |