mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 11:52:28 +01:00
CLOUDSTACK-9131: Create a new API to check if the plugin is enabled.
fixing type
This commit is contained in:
parent
738b78886e
commit
3e22fbe457
@ -798,3 +798,4 @@ quotaTariffUpdate=1
|
||||
quotaCredits=1
|
||||
quotaEmailTemplateList=1
|
||||
quotaEmailTemplateUpdate=1
|
||||
quotaIsEnabled=15
|
||||
|
||||
@ -33,7 +33,7 @@ import org.apache.cloudstack.api.response.QuotaResponseBuilder;
|
||||
import org.apache.cloudstack.quota.vo.QuotaBalanceVO;
|
||||
import org.apache.cloudstack.api.response.QuotaStatementItemResponse;
|
||||
|
||||
@APICommand(name = "quotaBalance", responseObject = QuotaStatementItemResponse.class, description = "Create a quota balance statement", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
@APICommand(name = "quotaBalance", responseObject = QuotaStatementItemResponse.class, description = "Create a quota balance statement", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class QuotaBalanceCmd extends BaseCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(QuotaBalanceCmd.class);
|
||||
|
||||
@ -33,7 +33,7 @@ import org.apache.log4j.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@APICommand(name = "quotaCredits", responseObject = QuotaCreditsResponse.class, description = "Add +-credits to an account", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
@APICommand(name = "quotaCredits", responseObject = QuotaCreditsResponse.class, description = "Add +-credits to an account", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class QuotaCreditsCmd extends BaseCmd {
|
||||
|
||||
@Inject
|
||||
|
||||
@ -26,7 +26,7 @@ import org.apache.log4j.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@APICommand(name = "quotaEmailTemplateList", responseObject = QuotaEmailTemplateResponse.class, description = "Lists all quota email templates", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
@APICommand(name = "quotaEmailTemplateList", responseObject = QuotaEmailTemplateResponse.class, description = "Lists all quota email templates", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class QuotaEmailTemplateListCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(QuotaEmailTemplateListCmd.class);
|
||||
private static final String s_name = "quotaemailtemplatelistresponse";
|
||||
|
||||
@ -30,7 +30,7 @@ import org.apache.log4j.Logger;
|
||||
import javax.inject.Inject;
|
||||
import java.util.Arrays;
|
||||
|
||||
@APICommand(name = "quotaEmailTemplateUpdate", responseObject = SuccessResponse.class, description = "Updates existing email templates for quota alerts", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
@APICommand(name = "quotaEmailTemplateUpdate", responseObject = SuccessResponse.class, description = "Updates existing email templates for quota alerts", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class QuotaEmailTemplateUpdateCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(QuotaEmailTemplateUpdateCmd.class);
|
||||
private static final String s_name = "quotaemailtemplateupdateresponse";
|
||||
|
||||
@ -0,0 +1,62 @@
|
||||
//Licensed to the Apache Software Foundation (ASF) under one
|
||||
//or more contributor license agreements. See the NOTICE file
|
||||
//distributed with this work for additional information
|
||||
//regarding copyright ownership. The ASF licenses this file
|
||||
//to you under the Apache License, Version 2.0 (the
|
||||
//"License"); you may not use this file except in compliance
|
||||
//with the License. You may obtain a copy of the License at
|
||||
//
|
||||
//http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
//Unless required by applicable law or agreed to in writing,
|
||||
//software distributed under the License is distributed on an
|
||||
//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
//KIND, either express or implied. See the License for the
|
||||
//specific language governing permissions and limitations
|
||||
//under the License.
|
||||
package org.apache.cloudstack.api.command;
|
||||
|
||||
import com.cloud.user.Account;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.response.QuotaEnabledResponse;
|
||||
import org.apache.cloudstack.quota.QuotaService;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@APICommand(name = "quotaIsEnabled", responseObject = QuotaEnabledResponse.class, description = "Return true if the plugin is enabled", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class QuotaEnabledCmd extends BaseCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(QuotaEnabledCmd.class);
|
||||
|
||||
private static final String s_name = "quotaisenabledresponse";
|
||||
|
||||
@Inject
|
||||
QuotaService _quotaService;
|
||||
|
||||
public QuotaEnabledCmd() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCommandName() {
|
||||
return s_name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
Boolean isEnabled = _quotaService.isQuotaServiceEnabled();
|
||||
QuotaEnabledResponse response = new QuotaEnabledResponse(isEnabled);
|
||||
response.setResponseName(getCommandName());
|
||||
setResponseObject(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getEntityOwnerId() {
|
||||
return Account.ACCOUNT_ID_SYSTEM;
|
||||
}
|
||||
|
||||
}
|
||||
@ -36,7 +36,7 @@ import org.apache.cloudstack.api.response.QuotaStatementItemResponse;
|
||||
|
||||
import com.cloud.user.Account;
|
||||
|
||||
@APICommand(name = "quotaStatement", responseObject = QuotaStatementItemResponse.class, description = "Create a quota statement", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
@APICommand(name = "quotaStatement", responseObject = QuotaStatementItemResponse.class, description = "Create a quota statement", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class QuotaStatementCmd extends BaseCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(QuotaStatementCmd.class);
|
||||
|
||||
@ -34,7 +34,7 @@ import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@APICommand(name = "quotaSummary", responseObject = QuotaSummaryResponse.class, description = "Lists balance and quota usage for all accounts", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
@APICommand(name = "quotaSummary", responseObject = QuotaSummaryResponse.class, description = "Lists balance and quota usage for all accounts", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class QuotaSummaryCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(QuotaSummaryCmd.class);
|
||||
private static final String s_name = "quotasummaryresponse";
|
||||
|
||||
@ -34,7 +34,7 @@ import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@APICommand(name = "quotaTariffList", responseObject = QuotaTariffResponse.class, description = "Lists all quota tariff plans", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
@APICommand(name = "quotaTariffList", responseObject = QuotaTariffResponse.class, description = "Lists all quota tariff plans", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class QuotaTariffListCmd extends BaseListCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(QuotaTariffListCmd.class);
|
||||
private static final String s_name = "quotatarifflistresponse";
|
||||
|
||||
@ -33,7 +33,7 @@ import javax.inject.Inject;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@APICommand(name = "quotaTariffUpdate", responseObject = QuotaTariffResponse.class, description = "Update the tariff plan for a resource", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
@APICommand(name = "quotaTariffUpdate", responseObject = QuotaTariffResponse.class, description = "Update the tariff plan for a resource", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class QuotaTariffUpdateCmd extends BaseCmd {
|
||||
public static final Logger s_logger = Logger.getLogger(QuotaTariffUpdateCmd.class);
|
||||
private static final String s_name = "quotatariffupdateresponse";
|
||||
|
||||
@ -30,7 +30,7 @@ import java.util.Calendar;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@APICommand(name = "quotaUpdate", responseObject = QuotaUpdateResponse.class, description = "Update quota calculations, alerts and statements", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
@APICommand(name = "quotaUpdate", responseObject = QuotaUpdateResponse.class, description = "Update quota calculations, alerts and statements", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
|
||||
public class QuotaUpdateCmd extends BaseCmd {
|
||||
|
||||
public static final Logger s_logger = Logger.getLogger(QuotaUpdateCmd.class);
|
||||
|
||||
@ -0,0 +1,37 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import org.apache.cloudstack.api.BaseResponse;
|
||||
|
||||
import com.cloud.serializer.Param;
|
||||
|
||||
public class QuotaEnabledResponse extends BaseResponse {
|
||||
|
||||
@SerializedName("isenabled")
|
||||
@Param(description = "is quota service enabled")
|
||||
private Boolean isEnabled;
|
||||
|
||||
|
||||
public QuotaEnabledResponse(Boolean isEnabled) {
|
||||
this.isEnabled = isEnabled;
|
||||
setObjectName("isenabled");
|
||||
}
|
||||
|
||||
}
|
||||
@ -36,4 +36,6 @@ public interface QuotaService extends PluggableService {
|
||||
|
||||
void setMinBalance(Long accountId, Double balance);
|
||||
|
||||
Boolean isQuotaServiceEnabled();
|
||||
|
||||
}
|
||||
|
||||
@ -29,6 +29,7 @@ import com.cloud.utils.db.Filter;
|
||||
import org.apache.cloudstack.api.command.QuotaBalanceCmd;
|
||||
import org.apache.cloudstack.api.command.QuotaCreditsCmd;
|
||||
import org.apache.cloudstack.api.command.QuotaEmailTemplateUpdateCmd;
|
||||
import org.apache.cloudstack.api.command.QuotaEnabledCmd;
|
||||
import org.apache.cloudstack.api.command.QuotaEmailTemplateListCmd;
|
||||
import org.apache.cloudstack.api.command.QuotaStatementCmd;
|
||||
import org.apache.cloudstack.api.command.QuotaSummaryCmd;
|
||||
@ -114,6 +115,7 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi
|
||||
@Override
|
||||
public List<Class<?>> getCommands() {
|
||||
final List<Class<?>> cmdList = new ArrayList<Class<?>>();
|
||||
cmdList.add(QuotaEnabledCmd.class);
|
||||
if (!isQuotaServiceEnabled()) {
|
||||
return cmdList;
|
||||
}
|
||||
@ -140,6 +142,7 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi
|
||||
QuotaSmtpAuthType, QuotaSmtpSender };
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isQuotaServiceEnabled() {
|
||||
return QuotaPluginEnabled.value();
|
||||
}
|
||||
|
||||
@ -26,11 +26,11 @@
|
||||
title: 'Quota',
|
||||
preFilter: function(args) {
|
||||
var retval = $.ajax({
|
||||
url: createURL("listConfigurations&name=quota.enable.service"),
|
||||
url: createURL("quotaIsEnabled"),
|
||||
async: false
|
||||
});
|
||||
var json = JSON.parse(retval.responseText);
|
||||
return json.listconfigurationsresponse.configuration[0].value == 'true';
|
||||
return json.quotaisenabledresponse.isenabled.isenabled;
|
||||
},
|
||||
showOnNavigation: true,
|
||||
sectionSelect: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user