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
Close
Hashes for buildgrid-metering-client-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | b375f8a6a7cd6346e66c0419edc2d9b6dc4cc773924d0b7e99bedadf81cec42c |
|
MD5 | e4a5cca61bc08a656c52753cf41bcac2 |
|
BLAKE2b-256 | 7cc325539e5852352740f10862f5ad4cbc2599b4c9d38104b4da973077a25f92 |
Close
Hashes for buildgrid_metering_client-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21c5ea760dd0a64f5c53ab5d1743b1538e83cd541c25cae85f8a8c097acec13e |
|
MD5 | fe06b5da3cc1d82e4995ec2254e4fdfc |
|
BLAKE2b-256 | 3168030d122bf0e95b83dc22b1f9b1dcd67069787c34a678d1fa33cf39571d99 |