Skip to content

Commit 6570f7e

Browse files
committed
Moved TokenQuotaLimit class to different package
1 parent 2bc16ee commit 6570f7e

10 files changed

Lines changed: 37 additions & 36 deletions

File tree

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,8 @@ public RateLimitException build() {
149149
? new RateLimitException(this.limit, this.remaining, this.reset, this.values)
150150
: new RateLimitException(this.limit, this.remaining, this.reset);
151151

152-
if(this.clientQuotaLimit != null) {
153-
exception.clientQuotaLimit = this.clientQuotaLimit;
154-
}
155-
if(this.organizationQuotaLimit != null) {
156-
exception.organizationQuotaLimit = this.organizationQuotaLimit;
157-
}
152+
exception.clientQuotaLimit = this.clientQuotaLimit;
153+
exception.organizationQuotaLimit = this.organizationQuotaLimit;
158154

159155
return exception;
160156
}

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@JsonInclude(JsonInclude.Include.NON_NULL)
99
public class DefaultTokenQuota {
1010
@JsonProperty("clients")
11-
private Clients client;
11+
private Clients clients;
1212

1313
@JsonProperty("organizations")
1414
private Organizations organizations;
@@ -21,26 +21,26 @@ public DefaultTokenQuota() {}
2121
/**
2222
* Constructor for DefaultTokenQuota.
2323
*
24-
* @param client the clients
24+
* @param clients the clients
2525
* @param organizations the organizations
2626
*/
27-
public DefaultTokenQuota(Clients client, Organizations organizations) {
28-
this.client = client;
27+
public DefaultTokenQuota(Clients clients, Organizations organizations) {
28+
this.clients = clients;
2929
this.organizations = organizations;
3030
}
3131

3232
/**
3333
* @return the clients
3434
*/
35-
public Clients getClient() {
36-
return client;
35+
public Clients getClients() {
36+
return clients;
3737
}
3838

3939
/**
40-
* @param client the clients to set
40+
* @param clients the clients to set
4141
*/
42-
public void setClient(Clients client) {
43-
this.client = client;
42+
public void setClients(Clients clients) {
43+
this.clients = clients;
4444
}
4545

4646
/**

src/main/java/com/auth0/json/mgmt/tokenquota/ClientCredentials.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@ public class ClientCredentials {
99
private int perHour;
1010
@JsonProperty("enforce")
1111
private boolean enforce;
12+
/**
13+
* Default constructor for ClientCredentials.
14+
*/
15+
public ClientCredentials() {}
16+
17+
/**
18+
* Constructor for ClientCredentials.
19+
*
20+
* @param perDay the number of client credentials allowed per day
21+
* @param perHour the number of client credentials allowed per hour
22+
* @param enforce true if the quota is enforced, false otherwise
23+
*/
24+
public ClientCredentials(int perDay, int perHour, boolean enforce) {
25+
this.perDay = perDay;
26+
this.perHour = perHour;
27+
this.enforce = enforce;
28+
}
1229

1330
/**
1431
* @return the number of client credentials allowed per day

src/main/java/com/auth0/net/ResponseImpl.java

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

3-
import com.auth0.json.auth.TokenQuotaLimit;
4-
53
import java.util.Collections;
64
import java.util.Map;
75

src/main/java/com/auth0/net/TokenQuotaBucket.java

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

3-
import com.auth0.json.auth.TokenQuotaLimit;
4-
53
public class TokenQuotaBucket {
64
private TokenQuotaLimit perHour;
75
private TokenQuotaLimit perDay;

src/main/java/com/auth0/json/auth/TokenQuotaLimit.java renamed to src/main/java/com/auth0/net/TokenQuotaLimit.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.auth0.json.auth;
1+
package com.auth0.net;
22

33
public class TokenQuotaLimit {
44
private int quota;

src/main/java/com/auth0/utils/HttpResponseHeadersUtils.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.auth0.utils;
22

3-
import com.auth0.json.auth.TokenQuotaLimit;
3+
import com.auth0.net.TokenQuotaLimit;
44
import com.auth0.net.TokenQuotaBucket;
55

66
import java.util.Map;
@@ -14,10 +14,7 @@ public class HttpResponseHeadersUtils {
1414
* @return a TokenQuotaBucket containing client rate limits, or null if not present.
1515
*/
1616
public static TokenQuotaBucket getClientQuotaLimit(Map<String, String> headers) {
17-
String quotaHeader = headers.get("auth0-Quota-Client-Limit");
18-
if( quotaHeader == null) {
19-
quotaHeader = headers.get("auth0-quota-client-limit");
20-
}
17+
String quotaHeader = headers.get("auth0-quota-client-limit");
2118
if (quotaHeader != null) {
2219
return parseQuota(quotaHeader);
2320
}
@@ -31,10 +28,7 @@ public static TokenQuotaBucket getClientQuotaLimit(Map<String, String> headers)
3128
* @return a TokenQuotaBucket containing organization rate limits, or null if not present.
3229
*/
3330
public static TokenQuotaBucket getOrganizationQuotaLimit(Map<String, String> headers) {
34-
String quotaHeader = headers.get("auth0-Quota-Organization-Limit");
35-
if( quotaHeader == null) {
36-
quotaHeader = headers.get("auth0-quota-organization-limit");
37-
}
31+
String quotaHeader = headers.get("auth0-quota-organization-limit");
3832
if (quotaHeader != null) {
3933
return parseQuota(quotaHeader);
4034
}

src/test/java/com/auth0/json/mgmt/tenants/TenantTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ public void shouldDeserialize() throws Exception {
144144
assertThat(tenant.getMtls(), is(notNullValue()));
145145
assertThat(tenant.getMtls().getEnableEndpointAliases(), is(true));
146146
assertThat(tenant.getDefaultTokenQuota(), is(notNullValue()));
147-
assertThat(tenant.getDefaultTokenQuota().getClient(), is(notNullValue()));
148-
assertThat(tenant.getDefaultTokenQuota().getClient().getClientCredentials(), is(notNullValue()));
149-
assertThat(tenant.getDefaultTokenQuota().getClient().getClientCredentials().getPerDay(), is(100));
150-
assertThat(tenant.getDefaultTokenQuota().getClient().getClientCredentials().getPerHour(), is(20));
151-
assertThat(tenant.getDefaultTokenQuota().getClient().getClientCredentials().isEnforce(), is(true));
147+
assertThat(tenant.getDefaultTokenQuota().getClients(), is(notNullValue()));
148+
assertThat(tenant.getDefaultTokenQuota().getClients().getClientCredentials(), is(notNullValue()));
149+
assertThat(tenant.getDefaultTokenQuota().getClients().getClientCredentials().getPerDay(), is(100));
150+
assertThat(tenant.getDefaultTokenQuota().getClients().getClientCredentials().getPerHour(), is(20));
151+
assertThat(tenant.getDefaultTokenQuota().getClients().getClientCredentials().isEnforce(), is(true));
152152
assertThat(tenant.getDefaultTokenQuota().getOrganizations(), is(notNullValue()));
153153
assertThat(tenant.getDefaultTokenQuota().getOrganizations().getClientCredentials(), is(notNullValue()));
154154
assertThat(tenant.getDefaultTokenQuota().getOrganizations().getClientCredentials().getPerDay(), is(100));

src/test/java/com/auth0/net/BaseRequestTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import com.auth0.exception.Auth0Exception;
88
import com.auth0.exception.RateLimitException;
99
import com.auth0.json.auth.TokenHolder;
10-
import com.auth0.json.auth.TokenQuotaLimit;
1110
import com.auth0.net.client.*;
1211
import com.fasterxml.jackson.core.JsonParseException;
1312
import com.fasterxml.jackson.core.JsonProcessingException;

src/test/java/com/auth0/net/MultipartRequestTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.auth0.exception.Auth0Exception;
77
import com.auth0.exception.RateLimitException;
88
import com.auth0.json.auth.TokenHolder;
9-
import com.auth0.json.auth.TokenQuotaLimit;
109
import com.auth0.net.client.Auth0HttpClient;
1110
import com.auth0.net.client.Auth0MultipartRequestBody;
1211
import com.auth0.net.client.DefaultHttpClient;

0 commit comments

Comments
 (0)