viam.app.billing_client ======================= .. py:module:: viam.app.billing_client Attributes ---------- .. autoapisummary:: viam.app.billing_client.LOGGER Classes ------- .. autoapisummary:: viam.app.billing_client.BillingClient Module Contents --------------- .. py:data:: LOGGER .. py:class:: BillingClient(channel: grpclib.client.Channel, metadata: Mapping[str, str]) 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 "" (including brackets) with your API key and "" with your API key ID dial_options = DialOptions.with_api_key("", "") 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 `_. .. py:method:: get_current_month_usage(org_id: str, timeout: Optional[float] = None) -> viam.proto.app.billing.GetCurrentMonthUsageResponse :async: Access data usage information for the current month for a given organization. :: usage = await billing_client.get_current_month_usage("") :param org_id: the ID of the organization to request usage data for :type org_id: str :returns: the current month usage information :rtype: viam.proto.app.billing.GetCurrentMonthUsageResponse For more information, see `Billing Client API `_. .. py:method:: get_invoice_pdf(invoice_id: str, org_id: str, dest: str, timeout: Optional[float] = None) -> None :async: Access invoice PDF data and optionally save it to a provided file path. :: await billing_client.get_invoice_pdf("", "", "invoice.pdf") :param invoice_id: the ID of the invoice being requested :type invoice_id: str :param org_id: the ID of the org to request data from :type org_id: str :param dest: the filepath to save the invoice to :type dest: str For more information, see `Billing Client API `_. .. py:method:: get_invoices_summary(org_id: str, timeout: Optional[float] = None) -> viam.proto.app.billing.GetInvoicesSummaryResponse :async: Access total outstanding balance plus invoice summaries for a given org. :: summary = await billing_client.get_invoices_summary("") :param org_id: the ID of the org to request data for :type org_id: str :returns: the summaries of all org invoices :rtype: viam.proto.app.billing.GetInvoicesSummaryResponse For more information, see `Billing Client API `_. .. py:method:: get_org_billing_information(org_id: str, timeout: Optional[float] = None) -> viam.proto.app.billing.GetOrgBillingInformationResponse :async: Access billing information (payment method, billing tier, etc.) for a given org. :: information = await billing_client.get_org_billing_information("") :param org_id: the ID of the org to request data for :type org_id: str :returns: the org billing information :rtype: viam.proto.app.billing.GetOrgBillingInformationResponse For more information, see `Billing Client API `_. .. py:method:: create_invoice_and_charge_immediately(org_id_to_charge: str, amount: float, description: Optional[str] = None, org_id_for_branding: Optional[str] = None) -> None :async: Create a flat fee invoice and charge the organization on the spot. The caller must be an owner of the organization being charged. This function blocks until payment is confirmed, but will time out after 2 minutes if there is no confirmation. :: await billing_client.create_invoice_and_charge_immediately("", , , "") :param org_id_to_charge: the organization to charge :type org_id_to_charge: str :param amount: the amount to charge in dollars :type amount: float :param description: a short description of the charge to display on the invoice PDF (must be 100 characters or less) :type description: str :param org_id_for_branding: the organization whose branding to use in the invoice confirmation email :type org_id_for_branding: str