mirror of https://github.com/apache/jclouds.git
naming conventions
This commit is contained in:
parent
52fc2c2be1
commit
42e8cd4977
|
@ -20,15 +20,15 @@ package org.jclouds.glesys.domain;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Set;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.base.Objects;
|
import com.google.common.base.Objects;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lists the allowed arguments for some of the functions in this module such as disksize, cpucores etc.
|
* Sets the allowed arguments for some of the functions in this module such as disksize, cpucores etc.
|
||||||
*
|
*
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
* @see <a href="https://customer.glesys.com/api.php?a=doc#server_allowedarguments" />
|
* @see <a href="https://customer.glesys.com/api.php?a=doc#server_allowedarguments" />
|
||||||
|
@ -39,64 +39,64 @@ public class AllowedArgumentsForCreateServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Builder {
|
public static class Builder {
|
||||||
private List<Integer> diskSizes;
|
private Set<Integer> diskSizes;
|
||||||
private List<Integer> memorySizes;
|
private Set<Integer> memorySizes;
|
||||||
private List<Integer> cpuCores;
|
private Set<Integer> cpuCores;
|
||||||
private List<String> templates;
|
private Set<String> templates;
|
||||||
private List<Integer> transfers;
|
private Set<Integer> transfers;
|
||||||
private List<String> dataCenters;
|
private Set<String> dataCenters;
|
||||||
|
|
||||||
public Builder diskSizes(Integer... sizes) {
|
public Builder diskSizes(Integer... sizes) {
|
||||||
return diskSizes(Arrays.<Integer>asList(sizes));
|
return diskSizes(ImmutableSet.<Integer>copyOf(sizes));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder diskSizes(List<Integer> sizes) {
|
public Builder diskSizes(Set<Integer> sizes) {
|
||||||
this.diskSizes = sizes;
|
this.diskSizes = sizes;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder memorySizes(Integer... sizes) {
|
public Builder memorySizes(Integer... sizes) {
|
||||||
return memorySizes(Arrays.<Integer>asList(sizes));
|
return memorySizes(ImmutableSet.<Integer>copyOf(sizes));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder memorySizes(List<Integer> sizes) {
|
public Builder memorySizes(Set<Integer> sizes) {
|
||||||
this.memorySizes = sizes;
|
this.memorySizes = sizes;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder cpuCores(Integer... cpuCores) {
|
public Builder cpuCores(Integer... cpuCores) {
|
||||||
this.cpuCores = Arrays.<Integer>asList(cpuCores);
|
this.cpuCores = ImmutableSet.<Integer>copyOf(cpuCores);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder cpuCores(List<Integer> cpuCores) {
|
public Builder cpuCores(Set<Integer> cpuCores) {
|
||||||
this.cpuCores = cpuCores;
|
this.cpuCores = cpuCores;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder templates(String... templates) {
|
public Builder templates(String... templates) {
|
||||||
return templates(Arrays.<String>asList(templates));
|
return templates(ImmutableSet.<String>copyOf(templates));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder templates(List<String> templates) {
|
public Builder templates(Set<String> templates) {
|
||||||
this.templates = templates;
|
this.templates = templates;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder transfers(Integer... transfers) {
|
public Builder transfers(Integer... transfers) {
|
||||||
return transfers(Arrays.<Integer>asList(transfers));
|
return transfers(ImmutableSet.<Integer>copyOf(transfers));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder transfers(List<Integer> transfers) {
|
public Builder transfers(Set<Integer> transfers) {
|
||||||
this.transfers = transfers;
|
this.transfers = transfers;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder dataCenters(String... dataCenters) {
|
public Builder dataCenters(String... dataCenters) {
|
||||||
return dataCenters(Arrays.<String>asList(dataCenters));
|
return dataCenters(ImmutableSet.<String>copyOf(dataCenters));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder dataCenters(List<String> dataCenters) {
|
public Builder dataCenters(Set<String> dataCenters) {
|
||||||
this.dataCenters = dataCenters;
|
this.dataCenters = dataCenters;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -106,30 +106,30 @@ public class AllowedArgumentsForCreateServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromAllowedArguments(AllowedArgumentsForCreateServer in) {
|
public Builder fromAllowedArguments(AllowedArgumentsForCreateServer in) {
|
||||||
return diskSizes(in.getDiskSizes())
|
return diskSizes(in.getDiskSizesInGB())
|
||||||
.memorySizes(in.getMemorySizes())
|
.memorySizes(in.getMemorySizesInMB())
|
||||||
.cpuCores(in.getCpuCores())
|
.cpuCores(in.getCpuCoreOptions())
|
||||||
.templates(in.getTemplates())
|
.templates(in.getTemplateNames())
|
||||||
.transfers(in.getTransfers())
|
.transfers(in.getTransfersInGB())
|
||||||
.dataCenters(in.getDataCenters());
|
.dataCenters(in.getDataCenters());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@SerializedName("disksize")
|
@SerializedName("disksize")
|
||||||
private final List<Integer> diskSizes;
|
private final Set<Integer> diskSizes;
|
||||||
@SerializedName("memorysize")
|
@SerializedName("memorysize")
|
||||||
private final List<Integer> memorySizes;
|
private final Set<Integer> memorySizes;
|
||||||
@SerializedName("cpucores")
|
@SerializedName("cpucores")
|
||||||
private final List<Integer> cpuCores;
|
private final Set<Integer> cpuCores;
|
||||||
@SerializedName("template")
|
@SerializedName("template")
|
||||||
private final List<String> templates;
|
private final Set<String> templates;
|
||||||
@SerializedName("transfer")
|
@SerializedName("transfer")
|
||||||
private final List<Integer> transfers;
|
private final Set<Integer> transfers;
|
||||||
@SerializedName("datacenter")
|
@SerializedName("datacenter")
|
||||||
private final List<String> dataCenters;
|
private final Set<String> dataCenters;
|
||||||
|
|
||||||
public AllowedArgumentsForCreateServer(List<Integer> diskSizes, List<Integer> memorySizes, List<Integer> cpuCores,
|
public AllowedArgumentsForCreateServer(Set<Integer> diskSizes, Set<Integer> memorySizes, Set<Integer> cpuCores,
|
||||||
List<String> templates, List<Integer> transfers, List<String> dataCenters) {
|
Set<String> templates, Set<Integer> transfers, Set<String> dataCenters) {
|
||||||
checkNotNull(diskSizes, "diskSizes");
|
checkNotNull(diskSizes, "diskSizes");
|
||||||
checkNotNull(memorySizes, "memorySizes");
|
checkNotNull(memorySizes, "memorySizes");
|
||||||
checkNotNull(cpuCores, "cpuCores");
|
checkNotNull(cpuCores, "cpuCores");
|
||||||
|
@ -147,46 +147,46 @@ public class AllowedArgumentsForCreateServer {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a list of disk sizes, in GB, that can be used for creating servers on this platform
|
* @return a list of disk sizes, in GB, that can be used for creating servers on this platform
|
||||||
* @see org.jclouds.glesys.domain.Template#getMinDiskSize()
|
* @see org.jclouds.glesys.domain.OSTemplate#getMinDiskSize()
|
||||||
*/
|
*/
|
||||||
public List<Integer> getDiskSizes() {
|
public Set<Integer> getDiskSizesInGB() {
|
||||||
return diskSizes;
|
return diskSizes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a list of memory sizes, in MB, that can be used for creating servers on this platform
|
* @return a list of memory sizes, in MB, that can be used for creating servers on this platform
|
||||||
* @see org.jclouds.glesys.domain.Template#getMinMemSize()
|
* @see org.jclouds.glesys.domain.OSTemplate#getMinMemSize()
|
||||||
*/
|
*/
|
||||||
public List<Integer> getMemorySizes() {
|
public Set<Integer> getMemorySizesInMB() {
|
||||||
return memorySizes;
|
return memorySizes;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a list of which core counts can be used for creating servers on this platform
|
* @return a list of which core counts can be used for creating servers on this platform
|
||||||
*/
|
*/
|
||||||
public List<Integer> getCpuCores() {
|
public Set<Integer> getCpuCoreOptions() {
|
||||||
return cpuCores;
|
return cpuCores;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a list of template names available for creating servers on this platform
|
* @return a list of template names available for creating servers on this platform
|
||||||
* @see org.jclouds.glesys.domain.Template#getName()
|
* @see org.jclouds.glesys.domain.OSTemplate#getName()
|
||||||
*/
|
*/
|
||||||
public List<String> getTemplates() {
|
public Set<String> getTemplateNames() {
|
||||||
return templates;
|
return templates;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the list of transfer settings available for creating servers on this platform
|
* @return the list of transfer settings available for creating servers on this platform
|
||||||
*/
|
*/
|
||||||
public List<Integer> getTransfers() {
|
public Set<Integer> getTransfersInGB() {
|
||||||
return transfers;
|
return transfers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the list of datacenters available that support creating servers on this platform
|
* @return the list of datacenters available that support creating servers on this platform
|
||||||
*/
|
*/
|
||||||
public List<String> getDataCenters() {
|
public Set<String> getDataCenters() {
|
||||||
return dataCenters;
|
return dataCenters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ import com.google.gson.annotations.SerializedName;
|
||||||
* @author Adam Lowe
|
* @author Adam Lowe
|
||||||
* @see <a href= "https://customer.glesys.com/api.php?a=doc#server_templates" />
|
* @see <a href= "https://customer.glesys.com/api.php?a=doc#server_templates" />
|
||||||
*/
|
*/
|
||||||
public class Template implements Comparable<Template>{
|
public class OSTemplate implements Comparable<OSTemplate>{
|
||||||
|
|
||||||
public static Builder builder() {
|
public static Builder builder() {
|
||||||
return new Builder();
|
return new Builder();
|
||||||
|
@ -66,11 +66,11 @@ public class Template implements Comparable<Template>{
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Template build() {
|
public OSTemplate build() {
|
||||||
return new Template(name, minDiskSize, minMemSize, os, platform);
|
return new OSTemplate(name, minDiskSize, minMemSize, os, platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromTemplate(Template in) {
|
public Builder fromTemplate(OSTemplate in) {
|
||||||
return name(in.getName()).minDiskSize(in.getMinDiskSize()).minMemSize(in.getMinMemSize()).os(in.getOs()).platform(in.getPlatform());
|
return name(in.getName()).minDiskSize(in.getMinDiskSize()).minMemSize(in.getMinMemSize()).os(in.getOs()).platform(in.getPlatform());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class Template implements Comparable<Template>{
|
||||||
private final String os;
|
private final String os;
|
||||||
private final String platform;
|
private final String platform;
|
||||||
|
|
||||||
public Template(String name, int minDiskSize, int minMemSize, String os, String platform) {
|
public OSTemplate(String name, int minDiskSize, int minMemSize, String os, String platform) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.minDiskSize = minDiskSize;
|
this.minDiskSize = minDiskSize;
|
||||||
this.minMemSize = minMemSize;
|
this.minMemSize = minMemSize;
|
||||||
|
@ -99,7 +99,7 @@ public class Template implements Comparable<Template>{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the minimum allowed disk size in GB
|
* @return the minimum allowed disk size in GB
|
||||||
* @see org.jclouds.glesys.domain.AllowedArgumentsForCreateServer#getDiskSizes()
|
* @see org.jclouds.glesys.domain.AllowedArgumentsForCreateServer#getDiskSizesInGB()
|
||||||
*/
|
*/
|
||||||
public int getMinDiskSize() {
|
public int getMinDiskSize() {
|
||||||
return minDiskSize;
|
return minDiskSize;
|
||||||
|
@ -107,7 +107,7 @@ public class Template implements Comparable<Template>{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the minimum allowed memory size in MB
|
* @return the minimum allowed memory size in MB
|
||||||
* @see org.jclouds.glesys.domain.AllowedArgumentsForCreateServer#getMemorySizes()
|
* @see org.jclouds.glesys.domain.AllowedArgumentsForCreateServer#getMemorySizesInMB()
|
||||||
*/
|
*/
|
||||||
public int getMinMemSize() {
|
public int getMinMemSize() {
|
||||||
return minMemSize;
|
return minMemSize;
|
||||||
|
@ -132,8 +132,8 @@ public class Template implements Comparable<Template>{
|
||||||
if (this == object) {
|
if (this == object) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (object instanceof Template) {
|
if (object instanceof OSTemplate) {
|
||||||
final Template other = (Template) object;
|
final OSTemplate other = (OSTemplate) object;
|
||||||
return Objects.equal(name, other.name)
|
return Objects.equal(name, other.name)
|
||||||
&& Objects.equal(platform, other.platform);
|
&& Objects.equal(platform, other.platform);
|
||||||
} else {
|
} else {
|
||||||
|
@ -153,7 +153,7 @@ public class Template implements Comparable<Template>{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareTo(Template arg0) {
|
public int compareTo(OSTemplate arg0) {
|
||||||
return Ordering.usingToString().compare(this, arg0);
|
return Ordering.usingToString().compare(this, arg0);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -97,7 +97,7 @@ public class ServerDetails extends Server {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder fromServerDetails(ServerDetails in) {
|
public Builder fromServerDetails(ServerDetails in) {
|
||||||
return fromServer(in).templateName(in.getTemplateName()).memorySize(in.getMemorySize()).diskSize(in.getDiskSize()).cpuCores(in.getCpuCores()).cost(in.getCost())
|
return fromServer(in).templateName(in.getTemplateName()).memorySize(in.getMemorySizeMB()).diskSize(in.getDiskSizeGB()).cpuCores(in.getCpuCores()).cost(in.getCost())
|
||||||
.description(in.getDescription()).ips(in.getIps());
|
.description(in.getDescription()).ips(in.getIps());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -171,21 +171,21 @@ public class ServerDetails extends Server {
|
||||||
/**
|
/**
|
||||||
* @return the disk of the server in GB
|
* @return the disk of the server in GB
|
||||||
*/
|
*/
|
||||||
public int getDiskSize() {
|
public int getDiskSizeGB() {
|
||||||
return diskSize;
|
return diskSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the memory of the server in MB
|
* @return the memory of the server in MB
|
||||||
*/
|
*/
|
||||||
public int getMemorySize() {
|
public int getMemorySizeMB() {
|
||||||
return memorySize;
|
return memorySize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the transfer of the server
|
* @return the transfer of the server
|
||||||
*/
|
*/
|
||||||
public int getTransfer() {
|
public int getTransferGB() {
|
||||||
return transfer;
|
return transfer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class ServerSpec {
|
||||||
protected int diskSizeGB;
|
protected int diskSizeGB;
|
||||||
protected int memorySizeMB;
|
protected int memorySizeMB;
|
||||||
protected int cpuCores;
|
protected int cpuCores;
|
||||||
protected int transfer;
|
protected int transferGB;
|
||||||
|
|
||||||
public Builder datacenter(String datacenter) {
|
public Builder datacenter(String datacenter) {
|
||||||
this.datacenter = datacenter;
|
this.datacenter = datacenter;
|
||||||
|
@ -78,19 +78,19 @@ public class ServerSpec {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder transfer(int transfer) {
|
public Builder transferGB(int transferGB) {
|
||||||
this.transfer = transfer;
|
this.transferGB = transferGB;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ServerSpec build() {
|
public ServerSpec build() {
|
||||||
return new ServerSpec(platform, datacenter, memorySizeMB, diskSizeGB, templateName, cpuCores, transfer);
|
return new ServerSpec(platform, datacenter, memorySizeMB, diskSizeGB, templateName, cpuCores, transferGB);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Builder fromServerSpecification(ServerSpec in) {
|
public static Builder fromServerSpecification(ServerSpec in) {
|
||||||
return new Builder().platform(in.getPlatform()).datacenter(in.getDatacenter())
|
return new Builder().platform(in.getPlatform()).datacenter(in.getDatacenter())
|
||||||
.memorySizeMB(in.getMemorySizeMB()).diskSizeGB(in.getDiskSizeGB()).templateName(in.getTemplateName())
|
.memorySizeMB(in.getMemorySizeMB()).diskSizeGB(in.getDiskSizeGB()).templateName(in.getTemplateName())
|
||||||
.cpuCores(in.getCpuCores()).transfer(in.getTransfer());
|
.cpuCores(in.getCpuCores()).transferGB(in.getTransferGB());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,17 +100,17 @@ public class ServerSpec {
|
||||||
protected final int diskSizeGB;
|
protected final int diskSizeGB;
|
||||||
protected final String templateName;
|
protected final String templateName;
|
||||||
protected final int cpuCores;
|
protected final int cpuCores;
|
||||||
protected final int transfer;
|
protected final int transferGB;
|
||||||
|
|
||||||
protected ServerSpec(String platform, String datacenter, int memorySizeMB, int diskSizeGB, String templateName,
|
protected ServerSpec(String platform, String datacenter, int memorySizeMB, int diskSizeGB, String templateName,
|
||||||
int cpuCores, int transfer) {
|
int cpuCores, int transferGB) {
|
||||||
this.platform = checkNotNull(platform, "platform");
|
this.platform = checkNotNull(platform, "platform");
|
||||||
this.datacenter = checkNotNull(datacenter, "datacenter");
|
this.datacenter = checkNotNull(datacenter, "datacenter");
|
||||||
this.memorySizeMB = memorySizeMB;
|
this.memorySizeMB = memorySizeMB;
|
||||||
this.diskSizeGB = diskSizeGB;
|
this.diskSizeGB = diskSizeGB;
|
||||||
this.templateName = checkNotNull(templateName, "templateName");
|
this.templateName = checkNotNull(templateName, "templateName");
|
||||||
this.cpuCores = cpuCores;
|
this.cpuCores = cpuCores;
|
||||||
this.transfer = transfer;
|
this.transferGB = transferGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,10 +156,10 @@ public class ServerSpec {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return number of transfer
|
* @return bandwidth of in GB
|
||||||
*/
|
*/
|
||||||
public int getTransfer() {
|
public int getTransferGB() {
|
||||||
return transfer;
|
return transferGB;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -172,7 +172,7 @@ public class ServerSpec {
|
||||||
return equal(platform, that.platform) && equal(datacenter, that.datacenter)
|
return equal(platform, that.platform) && equal(datacenter, that.datacenter)
|
||||||
&& equal(memorySizeMB, that.memorySizeMB) && equal(diskSizeGB, that.diskSizeGB)
|
&& equal(memorySizeMB, that.memorySizeMB) && equal(diskSizeGB, that.diskSizeGB)
|
||||||
&& equal(templateName, that.templateName) && equal(cpuCores, that.cpuCores)
|
&& equal(templateName, that.templateName) && equal(cpuCores, that.cpuCores)
|
||||||
&& equal(transfer, that.transfer);
|
&& equal(transferGB, that.transferGB);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -180,13 +180,13 @@ public class ServerSpec {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return Objects.hashCode(platform, datacenter, memorySizeMB, diskSizeGB, templateName, cpuCores, transfer);
|
return Objects.hashCode(platform, datacenter, memorySizeMB, diskSizeGB, templateName, cpuCores, transferGB);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return toStringHelper("").add("platform", platform).add("datacenter", datacenter)
|
return toStringHelper("").add("platform", platform).add("datacenter", datacenter)
|
||||||
.add("templateName", templateName).add("cpuCores", cpuCores).add("cpuCores", cpuCores)
|
.add("templateName", templateName).add("cpuCores", cpuCores).add("cpuCores", cpuCores)
|
||||||
.add("diskSizeGB", diskSizeGB).add("transfer", transfer).toString();
|
.add("diskSizeGB", diskSizeGB).add("transferGB", transferGB).toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.jclouds.glesys.domain.ServerDetails;
|
||||||
import org.jclouds.glesys.domain.ServerLimit;
|
import org.jclouds.glesys.domain.ServerLimit;
|
||||||
import org.jclouds.glesys.domain.ServerSpec;
|
import org.jclouds.glesys.domain.ServerSpec;
|
||||||
import org.jclouds.glesys.domain.ServerStatus;
|
import org.jclouds.glesys.domain.ServerStatus;
|
||||||
import org.jclouds.glesys.domain.Template;
|
import org.jclouds.glesys.domain.OSTemplate;
|
||||||
import org.jclouds.glesys.functions.ParseTemplatesFromHttpResponse;
|
import org.jclouds.glesys.functions.ParseTemplatesFromHttpResponse;
|
||||||
import org.jclouds.glesys.options.CloneServerOptions;
|
import org.jclouds.glesys.options.CloneServerOptions;
|
||||||
import org.jclouds.glesys.options.CreateServerOptions;
|
import org.jclouds.glesys.options.CreateServerOptions;
|
||||||
|
@ -134,7 +134,7 @@ public interface ServerAsyncClient {
|
||||||
@Path("/server/templates/format/json")
|
@Path("/server/templates/format/json")
|
||||||
@ResponseParser(ParseTemplatesFromHttpResponse.class)
|
@ResponseParser(ParseTemplatesFromHttpResponse.class)
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
@Consumes(MediaType.APPLICATION_JSON)
|
||||||
ListenableFuture<Set<Template>> getTemplates();
|
ListenableFuture<Set<OSTemplate>> listTemplates();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see ServerClient#stopServer
|
* @see ServerClient#stopServer
|
||||||
|
|
|
@ -30,7 +30,7 @@ import org.jclouds.glesys.domain.ServerDetails;
|
||||||
import org.jclouds.glesys.domain.ServerLimit;
|
import org.jclouds.glesys.domain.ServerLimit;
|
||||||
import org.jclouds.glesys.domain.ServerSpec;
|
import org.jclouds.glesys.domain.ServerSpec;
|
||||||
import org.jclouds.glesys.domain.ServerStatus;
|
import org.jclouds.glesys.domain.ServerStatus;
|
||||||
import org.jclouds.glesys.domain.Template;
|
import org.jclouds.glesys.domain.OSTemplate;
|
||||||
import org.jclouds.glesys.options.CloneServerOptions;
|
import org.jclouds.glesys.options.CloneServerOptions;
|
||||||
import org.jclouds.glesys.options.CreateServerOptions;
|
import org.jclouds.glesys.options.CreateServerOptions;
|
||||||
import org.jclouds.glesys.options.DestroyServerOptions;
|
import org.jclouds.glesys.options.DestroyServerOptions;
|
||||||
|
@ -105,7 +105,7 @@ public interface ServerClient {
|
||||||
*
|
*
|
||||||
* @return the set of information about each template
|
* @return the set of information about each template
|
||||||
*/
|
*/
|
||||||
Set<Template> getTemplates();
|
Set<OSTemplate> listTemplates();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get information about valid arguments to #createServer for each platform
|
* Get information about valid arguments to #createServer for each platform
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Set;
|
||||||
|
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import org.jclouds.glesys.domain.Template;
|
import org.jclouds.glesys.domain.OSTemplate;
|
||||||
import org.jclouds.http.HttpResponse;
|
import org.jclouds.http.HttpResponse;
|
||||||
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
import org.jclouds.http.functions.ParseFirstJsonValueNamed;
|
||||||
import org.jclouds.json.internal.GsonWrapper;
|
import org.jclouds.json.internal.GsonWrapper;
|
||||||
|
@ -40,19 +40,19 @@ import com.google.inject.TypeLiteral;
|
||||||
* @author Adrian Cole
|
* @author Adrian Cole
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ParseTemplatesFromHttpResponse implements Function<HttpResponse, Set<Template>> {
|
public class ParseTemplatesFromHttpResponse implements Function<HttpResponse, Set<OSTemplate>> {
|
||||||
private final ParseFirstJsonValueNamed<Map<String, Set<Template>>> parser;
|
private final ParseFirstJsonValueNamed<Map<String, Set<OSTemplate>>> parser;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public ParseTemplatesFromHttpResponse(GsonWrapper gsonWrapper) {
|
public ParseTemplatesFromHttpResponse(GsonWrapper gsonWrapper) {
|
||||||
this.parser = new ParseFirstJsonValueNamed<Map<String, Set<Template>>>(checkNotNull(gsonWrapper,
|
this.parser = new ParseFirstJsonValueNamed<Map<String, Set<OSTemplate>>>(checkNotNull(gsonWrapper,
|
||||||
"gsonWrapper"), new TypeLiteral<Map<String, Set<Template>>>() {
|
"gsonWrapper"), new TypeLiteral<Map<String, Set<OSTemplate>>>() {
|
||||||
}, "templates");
|
}, "templates");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Template> apply(HttpResponse response) {
|
public Set<OSTemplate> apply(HttpResponse response) {
|
||||||
checkNotNull(response, "response");
|
checkNotNull(response, "response");
|
||||||
Map<String, Set<Template>> toParse = parser.apply(response);
|
Map<String, Set<OSTemplate>> toParse = parser.apply(response);
|
||||||
checkNotNull(toParse, "parsed result from %s", response);
|
checkNotNull(toParse, "parsed result from %s", response);
|
||||||
return ImmutableSet.copyOf(Iterables.concat(toParse.values()));
|
return ImmutableSet.copyOf(Iterables.concat(toParse.values()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ public class CreateServerOptions implements MapBinder {
|
||||||
formParams.put("disksize", serverSpec.getDiskSizeGB() + "");
|
formParams.put("disksize", serverSpec.getDiskSizeGB() + "");
|
||||||
formParams.put("memorysize", serverSpec.getMemorySizeMB() + "");
|
formParams.put("memorysize", serverSpec.getMemorySizeMB() + "");
|
||||||
formParams.put("cpucores", serverSpec.getCpuCores() + "");
|
formParams.put("cpucores", serverSpec.getCpuCores() + "");
|
||||||
formParams.put("transfer", serverSpec.getTransfer() + "");
|
formParams.put("transfer", serverSpec.getTransferGB() + "");
|
||||||
if (ip != null)
|
if (ip != null)
|
||||||
formParams.put("ip", ip);
|
formParams.put("ip", ip);
|
||||||
if (description != null)
|
if (description != null)
|
||||||
|
|
Loading…
Reference in New Issue