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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9cff3c5152d6c00d98788e0bf31978193fd83675a732ccb45204aaa3ad0dae7 |
|
MD5 | c8d193a0b0a974ce6e88d7be953dbe47 |
|
BLAKE2b-256 | a2d05c707854010436832805facbdea1ad245cd9f21e9848996fcb27ca6cedcc |
Close
Hashes for buildgrid_metering_client-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 760fe107e9adb3df87b2deb877b73f019e3a50e1b96aba12ded82de9d0c62bd2 |
|
MD5 | f4359aff626c0af7f43c83e5a1a6bd22 |
|
BLAKE2b-256 | c18f51bf293a7ffdfd7a0582efade5e10e543bc86640834bdfb159bed4387cee |