Package net.ygbstudio.jbrave.api.rate
Record Class XRateLimitReset
java.lang.Object
java.lang.Record
net.ygbstudio.jbrave.api.rate.XRateLimitReset
- Record Components:
secondsUntilNextRequest- Seconds until you can make another request (per-second limit resets)secondsUntilMonthlyReset- Seconds until your monthly quota fully resetstimestamp- the instant the rate-limit metadata was read
public record XRateLimitReset(int secondsUntilNextRequest, int secondsUntilMonthlyReset, Instant timestamp)
extends Record
Shows when each quota window will reset, expressed in seconds from now.
When you receive a 429 status code, check the X-RateLimit-Reset header to
determine how long to wait before retrying.
-
Constructor Summary
ConstructorsConstructorDescriptionXRateLimitReset(int secondsUntilNextRequest, int secondsUntilMonthlyReset, Instant timestamp) Creates an instance of aXRateLimitResetrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static <T> Optional<XRateLimitReset> from(@NotNull HttpResponse<T> httpResponse) Extracts the rate limit reset from the HTTP Response.final inthashCode()Returns a hash code value for this object.intReturns the value of thesecondsUntilMonthlyResetrecord component.intReturns the value of thesecondsUntilNextRequestrecord component.Returns the value of thetimestamprecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
XRateLimitReset
public XRateLimitReset(int secondsUntilNextRequest, int secondsUntilMonthlyReset, Instant timestamp) Creates an instance of aXRateLimitResetrecord class.- Parameters:
secondsUntilNextRequest- the value for thesecondsUntilNextRequestrecord componentsecondsUntilMonthlyReset- the value for thesecondsUntilMonthlyResetrecord componenttimestamp- the value for thetimestamprecord component
-
-
Method Details
-
from
Extracts the rate limit reset from the HTTP Response.- Type Parameters:
T- the type of the response body- Parameters:
httpResponse- the HTTP Response object containing the rate limit reset information- Returns:
- an optional of the rate limit reset extracted from the httpResponse
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
secondsUntilNextRequest
public int secondsUntilNextRequest()Returns the value of thesecondsUntilNextRequestrecord component.- Returns:
- the value of the
secondsUntilNextRequestrecord component
-
secondsUntilMonthlyReset
public int secondsUntilMonthlyReset()Returns the value of thesecondsUntilMonthlyResetrecord component.- Returns:
- the value of the
secondsUntilMonthlyResetrecord component
-
timestamp
Returns the value of thetimestamprecord component.- Returns:
- the value of the
timestamprecord component
-