viam.app.billing_client

Attributes

LOGGER

Classes

BillingClient

gRPC client for retrieving billing data from app.

Module Contents

viam.app.billing_client.LOGGER
class viam.app.billing_client.BillingClient(channel: grpclib.client.Channel, metadata: Mapping[str, str])[source]

gRPC client for retrieving billing data from app.

Constructor is used by ViamClient to instantiate relevant service stubs. Calls to BillingClient methods should be made through ViamClient.

Establish a Connection:

import asyncio

from viam.rpc.dial import DialOptions, Credentials
from viam.app.viam_client import ViamClient


async def connect() -> ViamClient:
    # Replace "<API-KEY>" (including brackets) with your API key and "<API-KEY-ID>" with your API key ID
    dial_options = DialOptions.with_api_key("<API-KEY>", "<API-KEY-ID>")
    return await ViamClient.create_from_dial_options(dial_options)


async def main():
    # Make a ViamClient
    viam_client = await connect()
    # Instantiate a BillingClient to run billing client API methods on
    billing_client = viam_client.billing_client

    viam_client.close()

if __name__ == '__main__':
    asyncio.run(main())

For more information, see Billing Client API.

async get_current_month_usage(org_id: str, timeout: float | None = None) viam.proto.app.billing.GetCurrentMonthUsageResponse[source]

Access data usage information for the current month for a given organization.

usage = await billing_client.get_current_month_usage("<ORG-ID>")
Parameters:

org_id (str) – the ID of the organization to request usage data for

Returns:

the current month usage information

Return type:

viam.proto.app.billing.GetCurrentMonthUsageResponse

For more information, see Billing Client API.

async get_invoice_pdf(invoice_id: str, org_id: str, dest: str, timeout: float | None = None) None[source]

Access invoice PDF data and optionally save it to a provided file path.

await billing_client.get_invoice_pdf("<INVOICE-ID>", "<ORG-ID>", "invoice.pdf")
Parameters:
  • invoice_id (str) – the ID of the invoice being requested

  • org_id (str) – the ID of the org to request data from

  • dest (str) – the filepath to save the invoice to

For more information, see Billing Client API.

async get_invoices_summary(org_id: str, timeout: float | None = None) viam.proto.app.billing.GetInvoicesSummaryResponse[source]

Access total outstanding balance plus invoice summaries for a given org.

summary = await billing_client.get_invoices_summary("<ORG-ID>")
Parameters:

org_id (str) – the ID of the org to request data for

Returns:

the summaries of all org invoices

Return type:

viam.proto.app.billing.GetInvoicesSummaryResponse

For more information, see Billing Client API.

async get_org_billing_information(org_id: str, timeout: float | None = None) viam.proto.app.billing.GetOrgBillingInformationResponse[source]

Access billing information (payment method, billing tier, etc.) for a given org.

information = await billing_client.get_org_billing_information("<ORG-ID>")
Parameters:

org_id (str) – the ID of the org to request data for

Returns:

the org billing information

Return type:

viam.proto.app.billing.GetOrgBillingInformationResponse

For more information, see Billing Client API.