Skip to content

Commit c956f81

Browse files
committed
(CombinedRateLimit) add get_limits, get_limits_by_period funcs
1 parent a6eb663 commit c956f81

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

xbox/webapi/common/ratelimits/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,15 @@ def get_reset_after(self) -> Union[datetime, None]:
170170
# dates_valid has no elements, return None
171171
return None
172172

173+
def get_limits(self) -> list[SingleRateLimit]:
174+
return self.__limits
175+
176+
def get_limits_by_period(self, period: TimePeriod) -> list[SingleRateLimit]:
177+
# Filter the list for the given LimitType
178+
matches = filter(lambda limit: limit.get_time_period() == period, self.__limits)
179+
# Convert the filter object to a list and return it
180+
return list(matches)
181+
173182
def is_exceeded(self) -> bool:
174183
# Map self.__limits to (limit).is_exceeded()
175184
is_exceeded_map = map(lambda limit: limit.is_exceeded(), self.__limits)

0 commit comments

Comments
 (0)