Consumption#

class council.contexts.Consumption(value: float, unit: str, kind: str)[source]#

Bases: object

A class representing a consumption measurement with value, unit, and kind information.

__init__(value: float, unit: str, kind: str) None[source]#

Initializes a Consumption instance.

Parameters:
  • value (float) – The numeric value of the consumption measurement.

  • unit (str) – The unit of measurement for the consumption (e.g., liters, watts, etc.).

  • kind (str) – The kind or category of the consumption (e.g., water, electricity, etc.).

property value: float#

The numeric value of the consumption measurement.

property unit: str#

The unit of measurement for the consumption (e.g., tokens, api_calls, etc.).

property kind: str#

The kind or category of the consumption.

add(value: float) Consumption[source]#

Returns a new Consumption instance with the value incremented by the specified value.

subtract(value: float) Consumption[source]#

Returns a new Consumption instance with the value decremented by the specified value.

add_value(value: float) None[source]#

Increments the value of the consumption by the specified value.

subtract_value(value: float) None[source]#

Decrements the value of the consumption by the specified value.

static call(value: int, kind: str) Consumption[source]#

Returns a Consumption instance with “call” unit.

static duration(value: float, kind: str) Consumption[source]#

Returns a Consumption instance with “second” unit.

static token(value: int, kind: str) Consumption[source]#

Returns a Consumption instance with “token” unit.

static cost(value: float, kind: str) Consumption[source]#

Returns a Consumption instance with “USD” unit.