Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions src/main/java/com/auth0/exception/RateLimitException.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.auth0.exception;

import com.auth0.net.TokenQuotaBucket;

import java.util.Map;

/**
Expand All @@ -16,6 +18,10 @@ public class RateLimitException extends APIException {
private final long remaining;
private final long reset;

private TokenQuotaBucket clientQuotaLimit;
private TokenQuotaBucket organizationQuotaLimit;
private long retryAfter;

private static final int STATUS_CODE_TOO_MANY_REQUEST = 429;

public RateLimitException(long limit, long remaining, long reset, Map<String, Object> values) {
Expand Down Expand Up @@ -56,4 +62,119 @@ public long getReset() {
return reset;
}

/**
* Getter for the client quota limit.
* @return The client quota limit or null if missing.
*/
public TokenQuotaBucket getClientQuotaLimit() {
return clientQuotaLimit;
}

/**
* Getter for the organization quota limit.
* @return The organization quota limit or null if missing.
*/
public TokenQuotaBucket getOrganizationQuotaLimit() {
return organizationQuotaLimit;
}

/**
* Getter for the retry after time in seconds.
* @return The retry after time in seconds or -1 if missing.
*/
public long getRetryAfter() {
return retryAfter;
}

/**
* Builder class for creating instances of RateLimitException.
*/
public static class Builder {
private long limit;
private long remaining;
private long reset;
private TokenQuotaBucket clientQuotaLimit;
private TokenQuotaBucket organizationQuotaLimit;
private long retryAfter;
private Map<String, Object> values;

/**
* Constructor for the Builder.
* @param limit The maximum number of requests available in the current time frame.
* @param remaining The number of remaining requests in the current time frame.
* @param reset The UNIX timestamp of the expected time when the rate limit will reset.
*/
public Builder(long limit, long remaining, long reset) {
this.limit = limit;
this.remaining = remaining;
this.reset = reset;
}

/**
* Constructor for the Builder.
* @param limit The maximum number of requests available in the current time frame.
* @param remaining The number of remaining requests in the current time frame.
* @param reset The UNIX timestamp of the expected time when the rate limit will reset.
* @param values The values map.
*/
public Builder(long limit, long remaining, long reset, Map<String, Object> values) {
this.limit = limit;
this.remaining = remaining;
this.reset = reset;
this.values = values;
}

/**
* Sets the client quota limit.
* @param clientQuotaLimit The client quota limit.
* @return The Builder instance.
*/
public Builder clientQuotaLimit(TokenQuotaBucket clientQuotaLimit) {
this.clientQuotaLimit = clientQuotaLimit;
return this;
}

/**
* Sets the organization quota limit.
* @param organizationQuotaLimit The organization quota limit.
* @return The Builder instance.
*/
public Builder organizationQuotaLimit(TokenQuotaBucket organizationQuotaLimit) {
this.organizationQuotaLimit = organizationQuotaLimit;
return this;
}

/**
* Sets the retry after time in seconds.
* @param retryAfter The retry after time in seconds.
* @return The Builder instance.
*/
public Builder retryAfter(long retryAfter) {
this.retryAfter = retryAfter;
return this;
}

/**
* Sets the values map.
* @param values The values map.
* @return The Builder instance.
*/
public Builder values(Map<String, Object> values) {
this.values = values;
return this;
}

public RateLimitException build() {
RateLimitException exception = (this.values != null)
? new RateLimitException(this.limit, this.remaining, this.reset, this.values)
: new RateLimitException(this.limit, this.remaining, this.reset);

exception.clientQuotaLimit = this.clientQuotaLimit;
exception.organizationQuotaLimit = this.organizationQuotaLimit;
exception.retryAfter = this.retryAfter;

return exception;
}
}

}
19 changes: 19 additions & 0 deletions src/main/java/com/auth0/json/mgmt/client/Client.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.auth0.json.mgmt.client;

import com.auth0.json.mgmt.tokenquota.TokenQuota;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
Expand Down Expand Up @@ -104,6 +105,8 @@ public class Client {
private Boolean requireProofOfPossession;
@JsonProperty("default_organization")
private ClientDefaultOrganization defaultOrganization;
@JsonProperty("token_quota")
private TokenQuota tokenQuota;

/**
* Getter for the name of the tenant this client belongs to.
Expand Down Expand Up @@ -907,5 +910,21 @@ public ClientDefaultOrganization getDefaultOrganization() {
public void setDefaultOrganization(ClientDefaultOrganization defaultOrganization) {
this.defaultOrganization = defaultOrganization;
}

/**
* Getter for the token quota configuration.
* @return the token quota configuration.
*/
public TokenQuota getTokenQuota() {
return tokenQuota;
}

/**
* Setter for the token quota configuration.
* @param tokenQuota the token quota configuration to set.
*/
public void setTokenQuota(TokenQuota tokenQuota) {
this.tokenQuota = tokenQuota;
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.auth0.json.mgmt.organizations;

import com.auth0.client.mgmt.filter.PageFilter;
import com.auth0.json.mgmt.tokenquota.TokenQuota;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
Expand Down Expand Up @@ -29,6 +30,8 @@ public class Organization {
private Branding branding;
@JsonProperty("enabled_connections")
private List<EnabledConnection> enabledConnections;
@JsonProperty("token_quota")
private TokenQuota tokenQuota;

public Organization() {}

Expand Down Expand Up @@ -132,4 +135,20 @@ public List<EnabledConnection> getEnabledConnections() {
public void setEnabledConnections(List<EnabledConnection> enabledConnections) {
this.enabledConnections = enabledConnections;
}

/**
* @return the token quota of this Organization.
*/
public TokenQuota getTokenQuota() {
return tokenQuota;
}

/**
* Sets the token quota of this Organization.
*
* @param tokenQuota the token quota of this Organization.
*/
public void setTokenQuota(TokenQuota tokenQuota) {
this.tokenQuota = tokenQuota;
}
}
35 changes: 35 additions & 0 deletions src/main/java/com/auth0/json/mgmt/tenants/Clients.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.auth0.json.mgmt.tenants;

import com.auth0.json.mgmt.tokenquota.ClientCredentials;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Clients {
@JsonProperty("client_credentials")
private ClientCredentials clientCredentials;

/**
* Default constructor for Clients.
*/
public Clients() {
}

/**
* Constructor for Clients.
*
* @param clientCredentials the client credentials
*/
public Clients(ClientCredentials clientCredentials) {
this.clientCredentials = clientCredentials;
}

/**
* @return the client credentials
*/
public ClientCredentials getClientCredentials() {
return clientCredentials;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.auth0.json.mgmt.tenants;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class DefaultTokenQuota {
@JsonProperty("clients")
private Clients clients;

@JsonProperty("organizations")
private Organizations organizations;

/**
* Default constructor for DefaultTokenQuota.
*/
public DefaultTokenQuota() {}

/**
* Constructor for DefaultTokenQuota.
*
* @param clients the clients
* @param organizations the organizations
*/
public DefaultTokenQuota(Clients clients, Organizations organizations) {
this.clients = clients;
this.organizations = organizations;
}

/**
* @return the clients
*/
public Clients getClients() {
return clients;
}

/**
* @param clients the clients to set
*/
public void setClients(Clients clients) {
this.clients = clients;
}

/**
* @return the organizations
*/
public Organizations getOrganizations() {
return organizations;
}

/**
* @param organizations the organizations to set
*/
public void setOrganizations(Organizations organizations) {
this.organizations = organizations;
}
}
34 changes: 34 additions & 0 deletions src/main/java/com/auth0/json/mgmt/tenants/Organizations.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.auth0.json.mgmt.tenants;

import com.auth0.json.mgmt.tokenquota.ClientCredentials;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

@JsonIgnoreProperties(ignoreUnknown = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Organizations {
@JsonProperty("client_credentials")
private ClientCredentials clientCredentials;

/**
* Default constructor for Organizations.
*/
public Organizations() {}

/**
* Constructor for Organizations.
*
* @param clientCredentials the client credentials
*/
public Organizations(ClientCredentials clientCredentials) {
this.clientCredentials = clientCredentials;
}

/**
* @return the client credentials
*/
public ClientCredentials getClientCredentials() {
return clientCredentials;
}
}
37 changes: 37 additions & 0 deletions src/main/java/com/auth0/json/mgmt/tenants/Tenant.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public class Tenant {
@JsonProperty("mtls")
private Mtls mtls;

@JsonProperty("authorization_response_iss_parameter_supported")
private boolean authorizationResponseIssParameterSupported;

@JsonProperty("default_token_quota")
private DefaultTokenQuota defaultTokenQuota;

/**
* Getter for the change password page customization.
Expand Down Expand Up @@ -397,4 +402,36 @@ public Mtls getMtls() {
public void setMtls(Mtls mtls) {
this.mtls = mtls;
}

/**
* @return the value of the {@code authorization_response_iss_parameter_supported} field
*/
public boolean isAuthorizationResponseIssParameterSupported() {
return authorizationResponseIssParameterSupported;
}

/**
* Sets the value of the {@code authorization_response_iss_parameter_supported} field
*
* @param authorizationResponseIssParameterSupported the value of the {@code authorization_response_iss_parameter_supported} field
*/
public void setAuthorizationResponseIssParameterSupported(boolean authorizationResponseIssParameterSupported) {
this.authorizationResponseIssParameterSupported = authorizationResponseIssParameterSupported;
}

/**
* @return the value of the {@code default_token_quota} field
*/
public DefaultTokenQuota getDefaultTokenQuota() {
return defaultTokenQuota;
}

/**
* Sets the value of the {@code default_token_quota} field
*
* @param defaultTokenQuota the value of the {@code default_token_quota} field
*/
public void setDefaultTokenQuota(DefaultTokenQuota defaultTokenQuota) {
this.defaultTokenQuota = defaultTokenQuota;
}
}
Loading
Loading