
com.jelastic.api.billing.response.AccountConsumptionResponse Maven / Gradle / Ivy
The newest version!
package com.jelastic.api.billing.response;
import com.jelastic.api.Response;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.Map;
/**
* Created by doba on 6/14/16.
*/
public class AccountConsumptionResponse extends Response {
private static final String SSL = "ssl";
private static final String CPU = "cpu";
private static final String STORAGE = "storage";
private static final String MEM = "mem";
private static final String BANDWIDTH = "bandwidth";
private static final String EXTERNAL_IPS = "externalIps";
private static final String EXTERNAL_V6_IPS = "externalV6Ips";
private static final String LICENSE = "license";
private static final String CLOUDLETS = "cloudlets";
private static final String FIXED_CLOUDLETS = "fixedCloudlets";
private static final String FLEXIBLE_CLOUDLETS = "flexibleCloudlets";
private long mem;
private long cpu;
private long storage;
private long bandwidth;
private int externalIps;
private int externalV6Ips;
private int ssl;
private Map license;
private int cloudlets;
private int fixedCloudlets;
private int flexibleCloudlets;
public AccountConsumptionResponse() {
super(OK);
}
public AccountConsumptionResponse(int ssl, long mem, long cpu, long storage, long bandwidth, int externalIps, Map license) {
this();
this.ssl = ssl;
this.mem = mem;
this.cpu = cpu;
this.storage = storage;
this.bandwidth = bandwidth;
this.externalIps = externalIps;
this.license = license;
}
public AccountConsumptionResponse(int result, String error) {
super(result, error);
}
public int getSsl() {
return ssl;
}
public void setSsl(int ssl) {
this.ssl = ssl;
}
public long getMem() {
return mem;
}
public void setMem(long mem) {
this.mem = mem;
}
public long getCpu() {
return cpu;
}
public void setCpu(long cpu) {
this.cpu = cpu;
}
public long getStorage() {
return storage;
}
public void setStorage(long storage) {
this.storage = storage;
}
public long getBandwidth() {
return bandwidth;
}
public void setBandwidth(long bandwidth) {
this.bandwidth = bandwidth;
}
public int getExternalIps() {
return externalIps;
}
public void setExternalIps(int externalIps) {
this.externalIps = externalIps;
}
public int getExternalV6Ips() {
return externalV6Ips;
}
public void setExternalV6Ips(int externalV6Ips) {
this.externalV6Ips = externalV6Ips;
}
public int getCloudlets() {
return cloudlets;
}
public void setCloudlets(int cloudlets) {
this.cloudlets = cloudlets;
}
public int getFixedCloudlets() {
return fixedCloudlets;
}
public void setFixedCloudlets(int fixedCloudlets) {
this.fixedCloudlets = fixedCloudlets;
}
public int getFlexibleCloudlets() {
return flexibleCloudlets;
}
public void setFlexibleCloudlets(int flexibleCloudlets) {
this.flexibleCloudlets = flexibleCloudlets;
}
public Map getLicense() {
return license;
}
public void setLicense(Map license) {
this.license = license;
}
@Override
public JSONObject _toJSON() throws JSONException {
JSONObject json = super._toJSON();
json.put(SSL, this.ssl);
json.put(CPU, this.cpu);
json.put(STORAGE, this.storage);
json.put(MEM, this.mem);
json.put(BANDWIDTH, this.bandwidth);
json.put(EXTERNAL_IPS, this.externalIps);
json.put(EXTERNAL_V6_IPS, this.externalV6Ips);
json.put(LICENSE, this.license);
json.put(CLOUDLETS, this.cloudlets);
json.put(FIXED_CLOUDLETS, this.fixedCloudlets);
json.put(FLEXIBLE_CLOUDLETS, this.flexibleCloudlets);
return json;
}
@Override
public AccountConsumptionResponse _fromJSON(JSONObject json) throws JSONException {
super._fromJSON(json);
if (json.has(SSL)) {
this.ssl = json.getInt(SSL);
}
if (json.has(MEM)) {
this.mem = json.getLong(MEM);
}
if (json.has(CPU)) {
this.cpu = json.getLong(CPU);
}
if (json.has(STORAGE)) {
this.storage = json.getLong(STORAGE);
}
if (json.has(BANDWIDTH)) {
this.bandwidth = json.getLong(BANDWIDTH);
}
if (json.has(EXTERNAL_IPS)) {
this.externalIps = json.getInt(EXTERNAL_IPS);
}
if (json.has(EXTERNAL_V6_IPS)) {
this.externalV6Ips = json.getInt(EXTERNAL_V6_IPS);
}
if (json.has(CLOUDLETS)) {
this.cloudlets = json.getInt(CLOUDLETS);
}
if (json.has(FIXED_CLOUDLETS)) {
this.fixedCloudlets = json.getInt(FIXED_CLOUDLETS);
}
if (json.has(FLEXIBLE_CLOUDLETS)) {
this.flexibleCloudlets = json.getInt(FLEXIBLE_CLOUDLETS);
}
return this;
}
}