mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +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
|
quotaCredits=1
|
||||||
quotaEmailTemplateList=1
|
quotaEmailTemplateList=1
|
||||||
quotaEmailTemplateUpdate=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.quota.vo.QuotaBalanceVO;
|
||||||
import org.apache.cloudstack.api.response.QuotaStatementItemResponse;
|
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 class QuotaBalanceCmd extends BaseCmd {
|
||||||
|
|
||||||
public static final Logger s_logger = Logger.getLogger(QuotaBalanceCmd.class);
|
public static final Logger s_logger = Logger.getLogger(QuotaBalanceCmd.class);
|
||||||
|
|||||||
@ -33,7 +33,7 @@ import org.apache.log4j.Logger;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
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 {
|
public class QuotaCreditsCmd extends BaseCmd {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
|
|||||||
@ -26,7 +26,7 @@ import org.apache.log4j.Logger;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
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 class QuotaEmailTemplateListCmd extends BaseListCmd {
|
||||||
public static final Logger s_logger = Logger.getLogger(QuotaEmailTemplateListCmd.class);
|
public static final Logger s_logger = Logger.getLogger(QuotaEmailTemplateListCmd.class);
|
||||||
private static final String s_name = "quotaemailtemplatelistresponse";
|
private static final String s_name = "quotaemailtemplatelistresponse";
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import org.apache.log4j.Logger;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.Arrays;
|
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 class QuotaEmailTemplateUpdateCmd extends BaseCmd {
|
||||||
public static final Logger s_logger = Logger.getLogger(QuotaEmailTemplateUpdateCmd.class);
|
public static final Logger s_logger = Logger.getLogger(QuotaEmailTemplateUpdateCmd.class);
|
||||||
private static final String s_name = "quotaemailtemplateupdateresponse";
|
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;
|
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 class QuotaStatementCmd extends BaseCmd {
|
||||||
|
|
||||||
public static final Logger s_logger = Logger.getLogger(QuotaStatementCmd.class);
|
public static final Logger s_logger = Logger.getLogger(QuotaStatementCmd.class);
|
||||||
|
|||||||
@ -34,7 +34,7 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
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 class QuotaSummaryCmd extends BaseListCmd {
|
||||||
public static final Logger s_logger = Logger.getLogger(QuotaSummaryCmd.class);
|
public static final Logger s_logger = Logger.getLogger(QuotaSummaryCmd.class);
|
||||||
private static final String s_name = "quotasummaryresponse";
|
private static final String s_name = "quotasummaryresponse";
|
||||||
|
|||||||
@ -34,7 +34,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
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 class QuotaTariffListCmd extends BaseListCmd {
|
||||||
public static final Logger s_logger = Logger.getLogger(QuotaTariffListCmd.class);
|
public static final Logger s_logger = Logger.getLogger(QuotaTariffListCmd.class);
|
||||||
private static final String s_name = "quotatarifflistresponse";
|
private static final String s_name = "quotatarifflistresponse";
|
||||||
|
|||||||
@ -33,7 +33,7 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import java.util.Date;
|
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 class QuotaTariffUpdateCmd extends BaseCmd {
|
||||||
public static final Logger s_logger = Logger.getLogger(QuotaTariffUpdateCmd.class);
|
public static final Logger s_logger = Logger.getLogger(QuotaTariffUpdateCmd.class);
|
||||||
private static final String s_name = "quotatariffupdateresponse";
|
private static final String s_name = "quotatariffupdateresponse";
|
||||||
|
|||||||
@ -30,7 +30,7 @@ import java.util.Calendar;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
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 class QuotaUpdateCmd extends BaseCmd {
|
||||||
|
|
||||||
public static final Logger s_logger = Logger.getLogger(QuotaUpdateCmd.class);
|
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);
|
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.QuotaBalanceCmd;
|
||||||
import org.apache.cloudstack.api.command.QuotaCreditsCmd;
|
import org.apache.cloudstack.api.command.QuotaCreditsCmd;
|
||||||
import org.apache.cloudstack.api.command.QuotaEmailTemplateUpdateCmd;
|
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.QuotaEmailTemplateListCmd;
|
||||||
import org.apache.cloudstack.api.command.QuotaStatementCmd;
|
import org.apache.cloudstack.api.command.QuotaStatementCmd;
|
||||||
import org.apache.cloudstack.api.command.QuotaSummaryCmd;
|
import org.apache.cloudstack.api.command.QuotaSummaryCmd;
|
||||||
@ -114,6 +115,7 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi
|
|||||||
@Override
|
@Override
|
||||||
public List<Class<?>> getCommands() {
|
public List<Class<?>> getCommands() {
|
||||||
final List<Class<?>> cmdList = new ArrayList<Class<?>>();
|
final List<Class<?>> cmdList = new ArrayList<Class<?>>();
|
||||||
|
cmdList.add(QuotaEnabledCmd.class);
|
||||||
if (!isQuotaServiceEnabled()) {
|
if (!isQuotaServiceEnabled()) {
|
||||||
return cmdList;
|
return cmdList;
|
||||||
}
|
}
|
||||||
@ -140,6 +142,7 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi
|
|||||||
QuotaSmtpAuthType, QuotaSmtpSender };
|
QuotaSmtpAuthType, QuotaSmtpSender };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public Boolean isQuotaServiceEnabled() {
|
public Boolean isQuotaServiceEnabled() {
|
||||||
return QuotaPluginEnabled.value();
|
return QuotaPluginEnabled.value();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,12 +25,12 @@
|
|||||||
id: 'quota',
|
id: 'quota',
|
||||||
title: 'Quota',
|
title: 'Quota',
|
||||||
preFilter: function(args) {
|
preFilter: function(args) {
|
||||||
var retval = $.ajax({
|
var retval = $.ajax({
|
||||||
url: createURL("listConfigurations&name=quota.enable.service"),
|
url: createURL("quotaIsEnabled"),
|
||||||
async: false
|
async: false
|
||||||
});
|
});
|
||||||
var json = JSON.parse(retval.responseText);
|
var json = JSON.parse(retval.responseText);
|
||||||
return json.listconfigurationsresponse.configuration[0].value == 'true';
|
return json.quotaisenabledresponse.isenabled.isenabled;
|
||||||
},
|
},
|
||||||
showOnNavigation: true,
|
showOnNavigation: true,
|
||||||
sectionSelect: {
|
sectionSelect: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user