Skip to content
Permalink
Browse files
JCLOUDS-1255 Server API migration.
  • Loading branch information
trevorflanagan authored and nacx committed Nov 24, 2017
1 parent 30a500f commit 730ced56e31fdbd3f9b4f5b3b7f70105dc6a3935
Showing 27 changed files with 1,313 additions and 102 deletions.
@@ -145,7 +145,7 @@
<test.dimensiondata-cloudcontrol.credential>
${test.dimensiondata-cloudcontrol.credential}
</test.dimensiondata-cloudcontrol.credential>
<jclouds.zones>LAB04_N2_VMWARE_1</jclouds.zones>
<jclouds.zones>EU6</jclouds.zones>
</systemPropertyVariables>
</configuration>
</execution>
@@ -19,6 +19,7 @@
import org.jclouds.dimensiondata.cloudcontrol.features.AccountApi;
import org.jclouds.dimensiondata.cloudcontrol.features.InfrastructureApi;
import org.jclouds.dimensiondata.cloudcontrol.features.NetworkApi;
import org.jclouds.dimensiondata.cloudcontrol.features.ServerApi;
import org.jclouds.dimensiondata.cloudcontrol.features.ServerImageApi;
import org.jclouds.rest.annotations.Delegate;

@@ -37,4 +38,7 @@ public interface DimensionDataCloudControlApi extends Closeable {

@Delegate
NetworkApi getNetworkApi();

@Delegate
ServerApi getServerApi();
}
@@ -29,17 +29,19 @@ public abstract class Disk {
@Nullable
public abstract String id();

public abstract int scsiId();
@Nullable
public abstract Integer scsiId();

public abstract int sizeGb();
@Nullable
public abstract Integer sizeGb();

public abstract String speed();

@Nullable
public abstract String state();

@SerializedNames({ "id", "scsiId", "sizeGb", "speed", "state" })
public static Disk create(String id, int scsiId, int sizeGb, String speed, String state) {
public static Disk create(String id, Integer scsiId, Integer sizeGb, String speed, String state) {
return builder().id(id).scsiId(scsiId).sizeGb(sizeGb).speed(speed).state(state).build();
}

@@ -49,9 +51,9 @@ public static Disk create(String id, int scsiId, int sizeGb, String speed, Strin
public abstract static class Builder {
public abstract Builder id(String id);

public abstract Builder scsiId(int scsiId);
public abstract Builder scsiId(Integer scsiId);

public abstract Builder sizeGb(int sizeGb);
public abstract Builder sizeGb(Integer sizeGb);

public abstract Builder speed(String speed);

@@ -53,7 +53,7 @@ public static Builder builder() {

public abstract Boolean deployed();

public abstract OperatingSystem operatingSystem();
public abstract Guest guest();

public abstract CPU cpu();

@@ -68,27 +68,23 @@ public static Builder builder() {
@Nullable
public abstract List<Object> softwareLabels();

@Nullable
public abstract VMwareTools vmwareTools();

@Nullable
public abstract Progress progress();

@Nullable
public abstract VirtualHardware virtualHardware();

@SerializedNames({ "id", "name", "description", "datacenterId", "state", "sourceImageId", "createTime", "started",
"deployed", "operatingSystem", "cpu", "memoryGb", "disk", "networkInfo", "softwareLabel", "vmwareTools",
"progress", "virtualHardware" })
"deployed", "guest", "cpu", "memoryGb", "disk", "networkInfo", "softwareLabel", "progress",
"virtualHardware" })
public static Server create(String id, String name, String description, String datacenterId, State state,
String sourceImageId, Date createTime, Boolean started, Boolean deployed, OperatingSystem operatingSystem,
CPU cpu, int memoryGb, List<Disk> disks, NetworkInfo networkInfo, List<Object> softwareLabels,
VMwareTools vmwareTools, Progress progress, VirtualHardware virtualHardware) {
String sourceImageId, Date createTime, Boolean started, Boolean deployed, Guest guest, CPU cpu, int memoryGb,
List<Disk> disks, NetworkInfo networkInfo, List<Object> softwareLabels, Progress progress,
VirtualHardware virtualHardware) {
return builder().id(id).name(name).datacenterId(datacenterId).description(description).state(state)
.sourceImageId(sourceImageId).createTime(createTime).started(started).deployed(deployed)
.operatingSystem(operatingSystem).cpu(cpu).memoryGb(memoryGb).disks(disks).networkInfo(networkInfo)
.softwareLabels(softwareLabels).vmwareTools(vmwareTools).progress(progress).virtualHardware(virtualHardware)
.build();
.sourceImageId(sourceImageId).createTime(createTime).started(started).deployed(deployed).guest(guest)
.cpu(cpu).memoryGb(memoryGb).disks(disks).networkInfo(networkInfo).softwareLabels(softwareLabels)
.progress(progress).virtualHardware(virtualHardware).build();
}

public abstract Builder toBuilder();
@@ -113,7 +109,7 @@ public abstract static class Builder {

public abstract Builder deployed(Boolean deployed);

public abstract Builder operatingSystem(OperatingSystem operatingSystem);
public abstract Builder guest(Guest guest);

public abstract Builder cpu(CPU cpu);

@@ -125,8 +121,6 @@ public abstract static class Builder {

public abstract Builder softwareLabels(List<Object> softwareLabels);

public abstract Builder vmwareTools(VMwareTools vmwareTools);

public abstract Builder progress(Progress progress);

public abstract Builder virtualHardware(VirtualHardware virtualHardware);
@@ -22,7 +22,7 @@

public enum State {

NORMAL, FAILED_ADD, FAILED_CHANGE, FAILED_DELETE, PENDING_DELETE, DELETED, UNRECOGNIZED;
NORMAL, FAILED_ADD, FAILED_CHANGE, FAILED_DELETE, PENDING_DELETE, DELETED, UNRECOGNIZED, PENDING_CHANGE;

@Override
public String toString() {

This file was deleted.

@@ -0,0 +1,128 @@
/*
* 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.jclouds.dimensiondata.cloudcontrol.domain.options;

import com.google.auto.value.AutoValue;
import org.jclouds.http.HttpRequest;
import org.jclouds.javax.annotation.Nullable;
import org.jclouds.json.SerializedNames;
import org.jclouds.rest.MapBinder;
import org.jclouds.rest.binders.BindToJsonPayload;

import javax.inject.Inject;
import java.util.Map;

import static com.google.common.base.Preconditions.checkNotNull;

public class CloneServerOptions implements MapBinder {

@Inject
private BindToJsonPayload jsonBinder;

private final String description;
private final String clusterId;
private final boolean guestOsCustomization;

public CloneServerOptions(String description, String clusterId, boolean guestOsCustomization) {
this.description = description;
this.clusterId = clusterId;
this.guestOsCustomization = guestOsCustomization;
}

@AutoValue
abstract static class CloneServerRequest {

abstract String id();

abstract String imageName();

@Nullable
abstract String description();

@Nullable
abstract String clusterId();

abstract boolean guestOsCustomization();

@SerializedNames({ "id", "imageName", "description", "clusterId", "guestOsCustomization" })
static CloneServerRequest create(String id, String imageName, String description, String clusterId,
Boolean guestOsCustomization) {
return new AutoValue_CloneServerOptions_CloneServerRequest(id, imageName, description, clusterId,
guestOsCustomization);
}

CloneServerRequest() {
}
}

@Override
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
CloneServerRequest cloneServer = CloneServerRequest
.create(checkNotNull(postParams.get("id"), "id parameter not present").toString(),
checkNotNull(postParams.get("imageName"), "imageName parameter not present").toString().toString(),
description, clusterId, guestOsCustomization);

return bindToRequest(request, cloneServer);
}

@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
return jsonBinder.bindToRequest(request, input);
}

public String getDescription() {
return description;
}

public String getClusterId() {
return clusterId;
}

public boolean isGuestOsCustomization() {
return guestOsCustomization;
}

public static class Builder {
private String description;
private String clusterId;
private boolean guestOsCustomization = false;

public Builder description(String description) {
this.description = description;
return this;
}

public Builder clusterId(String clusterId) {
this.clusterId = clusterId;
return this;
}

public Builder guestOsCustomization(boolean guestOsCustomization) {
this.guestOsCustomization = guestOsCustomization;
return this;
}

public CloneServerOptions build() {
return new CloneServerOptions(description, clusterId, guestOsCustomization);
}
}

public static CloneServerOptions.Builder builder() {
return new CloneServerOptions.Builder();
}

}

0 comments on commit 730ced5

Please sign in to comment.