You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: osis-app/src/main/java/com/scality/osis/resource/ScalityOsisController.java
+4-4Lines changed: 4 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -332,17 +332,17 @@ public OsisTenant getTenant(
332
332
* @return The usage of the tenant or user is returned (status code 200)
333
333
* or The optional API is not implemented (status code 501)
334
334
*/
335
-
@Operation(summary = "Get the usage of the platform tenant or user", description = "Operation ID: getUsage<br> Get the platform usage of global (without query parameter), tenant (with tenant_id) or user (only with user_id)",
335
+
@Operation(summary = "Get the usage of the platform tenant or user", description = "Operation ID: getUsage<br> Get the platform usage of global (without query parameter), tenant (only with tenant_id) or user (with tenant_id and user_id).",
336
336
responses = {
337
337
@ApiResponse(responseCode = "200", description = "The usage of the tenant or user is returned"),
338
338
@ApiResponse(responseCode = "501", description = "The optional API is not implemented")
@Parameter(description = "The ID of the tenant to get its usage. 'tenant_id' takes precedence over 'user_id' to take effect if both are specified.") @Valid@RequestParam(value = "tenant_id", required = false) Optional<String> tenantId,
344
-
@Parameter(description = "The ID of the user to get its usage. 'tenant_id' takes precedence over 'user_id' to take effect if both are specified.") @Valid@RequestParam(value = "user_id", required = false) Optional<String> userId) {
345
-
if (!tenantId.isPresent() && userId.isPresent()) {
343
+
@Parameter(description = "The ID of the tenant to get its usage.") @Valid@RequestParam(value = "tenant_id", required = false) Optional<String> tenantId,
344
+
@Parameter(description = "The ID of the user to get its usage.") @Valid@RequestParam(value = "user_id", required = false) Optional<String> userId) {
345
+
if (tenantId.isEmpty() && userId.isPresent()) {
346
346
thrownewBadRequestException("userId must be specified with associated tenantId!");
osisUsage.setTotalBytes((long) account.getQuota()); // set total bytes by the vault quota
1303
+
osisUsage.setAvailableBytes(osisUsage.getTotalBytes() - osisUsage.getUsedBytes()); // set available bytes by the difference between total bytes and used bytes
1304
+
}
1305
+
logger.info("Usage for tenant:{} is:{}", tenantId.get(), newGson().toJson(osisUsage));
1306
+
1307
+
} else {
1308
+
1309
+
logger.info("tenant ID and user ID are specified, getting usage at user level, tenant ID:{}, user ID:{}", tenantId.get(), userId.get());
1310
+
1311
+
logger.debug("[UTAPI] Listing metrics for user:{}", userId.get());
0 commit comments