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 below 1.0.0
. 🚧
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
File details
Details for the file buildgrid-metering-client-0.0.4.tar.gz
.
File metadata
- Download URL: buildgrid-metering-client-0.0.4.tar.gz
- Upload date:
- Size: 18.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 980d67048619f22ff3689cc47b765545c771832f381ef9887330344e9b25d3a7 |
|
MD5 | 2fc854f6336050e57542b020a264388c |
|
BLAKE2b-256 | 7a0a0783c0870ce8a571bf9346827fb533d33025376e2b164ae33281a00a0515 |
File details
Details for the file buildgrid_metering_client-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: buildgrid_metering_client-0.0.4-py3-none-any.whl
- Upload date:
- Size: 19.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5216cd37c865c03e4bf42619006f248e8807ec1521389534e678da6f90e24353 |
|
MD5 | 0029a532fef547a340cadbbefa46a216 |
|
BLAKE2b-256 | c0b57f81fa30981e302b39f7d38e6ad565915e46e9394080e61c4add2e927924 |