Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

buildgrid-metering-client-0.0.1.tar.gz (17.8 kB view hashes)

Uploaded Source

Built Distribution

buildgrid_metering_client-0.0.1-py3-none-any.whl (18.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page