GutoVeronezi commented on code in PR #7599:
URL: https://github.com/apache/cloudstack/pull/7599#discussion_r1350170695


##########
plugins/api/discovery/src/main/java/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java:
##########
@@ -293,6 +310,22 @@ public ListResponse<? extends BaseResponse> listApis(User 
user, String name) {
         return response;
     }
 
+    private void removeQuotaApisIfQuotaEnabledButQuotaDisabledForAccount(User 
user, List<String> apisAllowed) {
+        if (PluginAccessConfigs.QuotaPluginEnabled.value() && 
!PluginAccessConfigs.QuotaAccountEnabled.valueIn(user.getAccountId())) {
+            apisAllowed.removeAll(quotaCmdList);
+            apisAllowed.add("quotaIsEnabled");
+        }
+    }
+
+    private boolean 
accountNotAdminAndQuotaEnabledAndQuotaAccountNotEnabledAndApiNameInQuotaCmdList(User
 user, String name, Account account) {
+        if (account.getType() != Account.Type.ADMIN && 
PluginAccessConfigs.QuotaPluginEnabled.value() &&
+            
!PluginAccessConfigs.QuotaAccountEnabled.valueIn(user.getAccountId()) && 
quotaCmdList.parallelStream().anyMatch(name::equalsIgnoreCase)) {
+
+            return true;
+        }
+        return false;

Review Comment:
   ```suggestion
           return account.getType() != Account.Type.ADMIN && 
PluginAccessConfigs.QuotaPluginEnabled.value() &&
               
!PluginAccessConfigs.QuotaAccountEnabled.valueIn(user.getAccountId()) && 
quotaCmdList.parallelStream().anyMatch(name::equalsIgnoreCase);
   ```



##########
plugins/api/discovery/src/main/java/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java:
##########
@@ -293,6 +310,22 @@ public ListResponse<? extends BaseResponse> listApis(User 
user, String name) {
         return response;
     }
 
+    private void removeQuotaApisIfQuotaEnabledButQuotaDisabledForAccount(User 
user, List<String> apisAllowed) {
+        if (PluginAccessConfigs.QuotaPluginEnabled.value() && 
!PluginAccessConfigs.QuotaAccountEnabled.valueIn(user.getAccountId())) {
+            apisAllowed.removeAll(quotaCmdList);
+            apisAllowed.add("quotaIsEnabled");
+        }
+    }
+
+    private boolean 
accountNotAdminAndQuotaEnabledAndQuotaAccountNotEnabledAndApiNameInQuotaCmdList(User
 user, String name, Account account) {

Review Comment:
   ```suggestion
       private boolean 
isAccountNotAdminAndQuotaEnabledAndQuotaAccountNotEnabledAndApiNameInQuotaCmdList(User
 user, String name, Account account) {
   ```



##########
plugins/api/discovery/src/main/java/org/apache/cloudstack/discovery/ApiDiscoveryServiceImpl.java:
##########
@@ -66,6 +68,8 @@ public class ApiDiscoveryServiceImpl extends 
ComponentLifecycleBase implements A
     List<PluggableService> _services = null;
     protected static Map<String, ApiDiscoveryResponse> 
s_apiNameDiscoveryResponseMap = null;
 
+    List<String> quotaCmdList;

Review Comment:
   ```suggestion
       private List<String> quotaCmdList;
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to