Skip to content

Commit 9801daa

Browse files
authored
SDK Limit M2M Java Support (#708)
1 parent df04f2e commit 9801daa

28 files changed

+1181
-29
lines changed

src/main/java/com/auth0/exception/RateLimitException.java

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.auth0.exception;
22

3+
import com.auth0.net.TokenQuotaBucket;
4+
35
import java.util.Map;
46

57
/**
@@ -16,6 +18,10 @@ public class RateLimitException extends APIException {
1618
private final long remaining;
1719
private final long reset;
1820

21+
private TokenQuotaBucket clientQuotaLimit;
22+
private TokenQuotaBucket organizationQuotaLimit;
23+
private long retryAfter;
24+
1925
private static final int STATUS_CODE_TOO_MANY_REQUEST = 429;
2026

2127
public RateLimitException(long limit, long remaining, long reset, Map<String, Object> values) {
@@ -56,4 +62,119 @@ public long getReset() {
5662
return reset;
5763
}
5864

65+
/**
66+
* Getter for the client quota limit.
67+
* @return The client quota limit or null if missing.
68+
*/
69+
public TokenQuotaBucket getClientQuotaLimit() {
70+
return clientQuotaLimit;
71+
}
72+
73+
/**
74+
* Getter for the organization quota limit.
75+
* @return The organization quota limit or null if missing.
76+
*/
77+
public TokenQuotaBucket getOrganizationQuotaLimit() {
78+
return organizationQuotaLimit;
79+
}
80+
81+
/**
82+
* Getter for the retry after time in seconds.
83+
* @return The retry after time in seconds or -1 if missing.
84+
*/
85+
public long getRetryAfter() {
86+
return retryAfter;
87+
}
88+
89+
/**
90+
* Builder class for creating instances of RateLimitException.
91+
*/
92+
public static class Builder {
93+
private long limit;
94+
private long remaining;
95+
private long reset;
96+
private TokenQuotaBucket clientQuotaLimit;
97+
private TokenQuotaBucket organizationQuotaLimit;
98+
private long retryAfter;
99+
private Map<String, Object> values;
100+
101+
/**
102+
* Constructor for the Builder.
103+
* @param limit The maximum number of requests available in the current time frame.
104+
* @param remaining The number of remaining requests in the current time frame.
105+
* @param reset The UNIX timestamp of the expected time when the rate limit will reset.
106+
*/
107+
public Builder(long limit, long remaining, long reset) {
108+
this.limit = limit;
109+
this.remaining = remaining;
110+
this.reset = reset;
111+
}
112+
113+
/**
114+
* Constructor for the Builder.
115+
* @param limit The maximum number of requests available in the current time frame.
116+
* @param remaining The number of remaining requests in the current time frame.
117+
* @param reset The UNIX timestamp of the expected time when the rate limit will reset.
118+
* @param values The values map.
119+
*/
120+
public Builder(long limit, long remaining, long reset, Map<String, Object> values) {
121+
this.limit = limit;
122+
this.remaining = remaining;
123+
this.reset = reset;
124+
this.values = values;
125+
}
126+
127+
/**
128+
* Sets the client quota limit.
129+
* @param clientQuotaLimit The client quota limit.
130+
* @return The Builder instance.
131+
*/
132+
public Builder clientQuotaLimit(TokenQuotaBucket clientQuotaLimit) {
133+
this.clientQuotaLimit = clientQuotaLimit;
134+
return this;
135+
}
136+
137+
/**
138+
* Sets the organization quota limit.
139+
* @param organizationQuotaLimit The organization quota limit.
140+
* @return The Builder instance.
141+
*/
142+
public Builder organizationQuotaLimit(TokenQuotaBucket organizationQuotaLimit) {
143+
this.organizationQuotaLimit = organizationQuotaLimit;
144+
return this;
145+
}
146+
147+
/**
148+
* Sets the retry after time in seconds.
149+
* @param retryAfter The retry after time in seconds.
150+
* @return The Builder instance.
151+
*/
152+
public Builder retryAfter(long retryAfter) {
153+
this.retryAfter = retryAfter;
154+
return this;
155+
}
156+
157+
/**
158+
* Sets the values map.
159+
* @param values The values map.
160+
* @return The Builder instance.
161+
*/
162+
public Builder values(Map<String, Object> values) {
163+
this.values = values;
164+
return this;
165+
}
166+
167+
public RateLimitException build() {
168+
RateLimitException exception = (this.values != null)
169+
? new RateLimitException(this.limit, this.remaining, this.reset, this.values)
170+
: new RateLimitException(this.limit, this.remaining, this.reset);
171+
172+
exception.clientQuotaLimit = this.clientQuotaLimit;
173+
exception.organizationQuotaLimit = this.organizationQuotaLimit;
174+
exception.retryAfter = this.retryAfter;
175+
176+
return exception;
177+
}
178+
}
179+
59180
}

src/main/java/com/auth0/json/mgmt/client/Client.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.auth0.json.mgmt.client;
22

3+
import com.auth0.json.mgmt.tokenquota.TokenQuota;
34
import com.fasterxml.jackson.annotation.JsonCreator;
45
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
56
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -104,6 +105,8 @@ public class Client {
104105
private Boolean requireProofOfPossession;
105106
@JsonProperty("default_organization")
106107
private ClientDefaultOrganization defaultOrganization;
108+
@JsonProperty("token_quota")
109+
private TokenQuota tokenQuota;
107110

108111
/**
109112
* Getter for the name of the tenant this client belongs to.
@@ -907,5 +910,21 @@ public ClientDefaultOrganization getDefaultOrganization() {
907910
public void setDefaultOrganization(ClientDefaultOrganization defaultOrganization) {
908911
this.defaultOrganization = defaultOrganization;
909912
}
913+
914+
/**
915+
* Getter for the token quota configuration.
916+
* @return the token quota configuration.
917+
*/
918+
public TokenQuota getTokenQuota() {
919+
return tokenQuota;
920+
}
921+
922+
/**
923+
* Setter for the token quota configuration.
924+
* @param tokenQuota the token quota configuration to set.
925+
*/
926+
public void setTokenQuota(TokenQuota tokenQuota) {
927+
this.tokenQuota = tokenQuota;
928+
}
910929
}
911930

src/main/java/com/auth0/json/mgmt/organizations/Organization.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.auth0.json.mgmt.organizations;
22

33
import com.auth0.client.mgmt.filter.PageFilter;
4+
import com.auth0.json.mgmt.tokenquota.TokenQuota;
45
import com.fasterxml.jackson.annotation.JsonCreator;
56
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
67
import com.fasterxml.jackson.annotation.JsonInclude;
@@ -29,6 +30,8 @@ public class Organization {
2930
private Branding branding;
3031
@JsonProperty("enabled_connections")
3132
private List<EnabledConnection> enabledConnections;
33+
@JsonProperty("token_quota")
34+
private TokenQuota tokenQuota;
3235

3336
public Organization() {}
3437

@@ -132,4 +135,20 @@ public List<EnabledConnection> getEnabledConnections() {
132135
public void setEnabledConnections(List<EnabledConnection> enabledConnections) {
133136
this.enabledConnections = enabledConnections;
134137
}
138+
139+
/**
140+
* @return the token quota of this Organization.
141+
*/
142+
public TokenQuota getTokenQuota() {
143+
return tokenQuota;
144+
}
145+
146+
/**
147+
* Sets the token quota of this Organization.
148+
*
149+
* @param tokenQuota the token quota of this Organization.
150+
*/
151+
public void setTokenQuota(TokenQuota tokenQuota) {
152+
this.tokenQuota = tokenQuota;
153+
}
135154
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.auth0.json.mgmt.tenants;
2+
3+
import com.auth0.json.mgmt.tokenquota.ClientCredentials;
4+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5+
import com.fasterxml.jackson.annotation.JsonInclude;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
8+
@JsonIgnoreProperties(ignoreUnknown = true)
9+
@JsonInclude(JsonInclude.Include.NON_NULL)
10+
public class Clients {
11+
@JsonProperty("client_credentials")
12+
private ClientCredentials clientCredentials;
13+
14+
/**
15+
* Default constructor for Clients.
16+
*/
17+
public Clients() {
18+
}
19+
20+
/**
21+
* Constructor for Clients.
22+
*
23+
* @param clientCredentials the client credentials
24+
*/
25+
public Clients(ClientCredentials clientCredentials) {
26+
this.clientCredentials = clientCredentials;
27+
}
28+
29+
/**
30+
* @return the client credentials
31+
*/
32+
public ClientCredentials getClientCredentials() {
33+
return clientCredentials;
34+
}
35+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.auth0.json.mgmt.tenants;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonInclude;
5+
import com.fasterxml.jackson.annotation.JsonProperty;
6+
7+
@JsonIgnoreProperties(ignoreUnknown = true)
8+
@JsonInclude(JsonInclude.Include.NON_NULL)
9+
public class DefaultTokenQuota {
10+
@JsonProperty("clients")
11+
private Clients clients;
12+
13+
@JsonProperty("organizations")
14+
private Organizations organizations;
15+
16+
/**
17+
* Default constructor for DefaultTokenQuota.
18+
*/
19+
public DefaultTokenQuota() {}
20+
21+
/**
22+
* Constructor for DefaultTokenQuota.
23+
*
24+
* @param clients the clients
25+
* @param organizations the organizations
26+
*/
27+
public DefaultTokenQuota(Clients clients, Organizations organizations) {
28+
this.clients = clients;
29+
this.organizations = organizations;
30+
}
31+
32+
/**
33+
* @return the clients
34+
*/
35+
public Clients getClients() {
36+
return clients;
37+
}
38+
39+
/**
40+
* @param clients the clients to set
41+
*/
42+
public void setClients(Clients clients) {
43+
this.clients = clients;
44+
}
45+
46+
/**
47+
* @return the organizations
48+
*/
49+
public Organizations getOrganizations() {
50+
return organizations;
51+
}
52+
53+
/**
54+
* @param organizations the organizations to set
55+
*/
56+
public void setOrganizations(Organizations organizations) {
57+
this.organizations = organizations;
58+
}
59+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package com.auth0.json.mgmt.tenants;
2+
3+
import com.auth0.json.mgmt.tokenquota.ClientCredentials;
4+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
5+
import com.fasterxml.jackson.annotation.JsonInclude;
6+
import com.fasterxml.jackson.annotation.JsonProperty;
7+
8+
@JsonIgnoreProperties(ignoreUnknown = true)
9+
@JsonInclude(JsonInclude.Include.NON_NULL)
10+
public class Organizations {
11+
@JsonProperty("client_credentials")
12+
private ClientCredentials clientCredentials;
13+
14+
/**
15+
* Default constructor for Organizations.
16+
*/
17+
public Organizations() {}
18+
19+
/**
20+
* Constructor for Organizations.
21+
*
22+
* @param clientCredentials the client credentials
23+
*/
24+
public Organizations(ClientCredentials clientCredentials) {
25+
this.clientCredentials = clientCredentials;
26+
}
27+
28+
/**
29+
* @return the client credentials
30+
*/
31+
public ClientCredentials getClientCredentials() {
32+
return clientCredentials;
33+
}
34+
}

src/main/java/com/auth0/json/mgmt/tenants/Tenant.java

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ public class Tenant {
5858
@JsonProperty("mtls")
5959
private Mtls mtls;
6060

61+
@JsonProperty("authorization_response_iss_parameter_supported")
62+
private boolean authorizationResponseIssParameterSupported;
63+
64+
@JsonProperty("default_token_quota")
65+
private DefaultTokenQuota defaultTokenQuota;
6166

6267
/**
6368
* Getter for the change password page customization.
@@ -397,4 +402,36 @@ public Mtls getMtls() {
397402
public void setMtls(Mtls mtls) {
398403
this.mtls = mtls;
399404
}
405+
406+
/**
407+
* @return the value of the {@code authorization_response_iss_parameter_supported} field
408+
*/
409+
public boolean isAuthorizationResponseIssParameterSupported() {
410+
return authorizationResponseIssParameterSupported;
411+
}
412+
413+
/**
414+
* Sets the value of the {@code authorization_response_iss_parameter_supported} field
415+
*
416+
* @param authorizationResponseIssParameterSupported the value of the {@code authorization_response_iss_parameter_supported} field
417+
*/
418+
public void setAuthorizationResponseIssParameterSupported(boolean authorizationResponseIssParameterSupported) {
419+
this.authorizationResponseIssParameterSupported = authorizationResponseIssParameterSupported;
420+
}
421+
422+
/**
423+
* @return the value of the {@code default_token_quota} field
424+
*/
425+
public DefaultTokenQuota getDefaultTokenQuota() {
426+
return defaultTokenQuota;
427+
}
428+
429+
/**
430+
* Sets the value of the {@code default_token_quota} field
431+
*
432+
* @param defaultTokenQuota the value of the {@code default_token_quota} field
433+
*/
434+
public void setDefaultTokenQuota(DefaultTokenQuota defaultTokenQuota) {
435+
this.defaultTokenQuota = defaultTokenQuota;
436+
}
400437
}

0 commit comments

Comments
 (0)