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.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc6a5e9a1ae8806c0626bb371706a5cb9f9157f0e3abbedded2eadf211d8838e |
|
MD5 | ba24ea209ef1a97a485b775763a453c8 |
|
BLAKE2b-256 | 0d3dca66f90f802b00ca4f3fb35841aef94bf35c648f38b27b9ef541da8ae2cd |
Close
Hashes for buildgrid_metering_client-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0c52ec8d515f3ac18444f4e8556e3016b7b0f970c1c207e858c72af340d2aa0 |
|
MD5 | 0323c9228db7fd8759fd8715796bd0bf |
|
BLAKE2b-256 | eeac0c3fa20ff7eefc8a2baa36c821be6be2d787752352b6ef43672bfe6f3bd3 |