diff --git a/src/apify/_charging.py b/src/apify/_charging.py index 65cce951..4d95d9b5 100644 --- a/src/apify/_charging.py +++ b/src/apify/_charging.py @@ -64,6 +64,16 @@ def get_pricing_info(self) -> ActorPricingInfo: This can be used for instance when your code needs to support multiple pricing models in transition periods. """ + def get_charged_event_count(self, event_name: str) -> int: + """Get the number of events with the given name that were charged so far. + + Args: + event_name: Name of the inspected event. + """ + + def get_max_total_charge_usd(self) -> Decimal: + """Get the configured maximum total charge for this Actor run.""" + @docs_group('Charging') @dataclass(frozen=True) @@ -309,6 +319,15 @@ def get_pricing_info(self) -> ActorPricingInfo: }, ) + @ensure_context + def get_charged_event_count(self, event_name: str) -> int: + item = self._charging_state.get(event_name) + return item.charge_count if item is not None else 0 + + @ensure_context + def get_max_total_charge_usd(self) -> Decimal: + return self._max_total_charge_usd + @dataclass class ChargingStateItem: