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.1a1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87f909c3a3f9906b9d74004672b560920a220a2223348f2fb9672d4412f40229 |
|
MD5 | 41d03405b93523b3cdbf4f0720c6760c |
|
BLAKE2b-256 | edfd6ba7e90af776a14fecd0ebd8b07ae19c7502d8a607cd99e095fd27de02c9 |
Close
Hashes for buildgrid_metering_client-0.0.1a1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8597609b7dc5394d6b69d88c894d73e332fb7d4fc4b3723952b1c9cf0c57e874 |
|
MD5 | 3812efa45dd0e5ac92a49e63e0031087 |
|
BLAKE2b-256 | ad79c368ab3af7e8ff4cc67af19efe6893b282533cc2896363eb32d638615b71 |