Some renaming in Cloudstack Snapshot API impl to remove unnecessary words

This commit is contained in:
Richard Downer 2011-11-09 18:06:32 +02:00
parent 61d9d1e5e6
commit 1ba06c8973
6 changed files with 50 additions and 52 deletions

View File

@ -18,8 +18,6 @@
*/
package org.jclouds.cloudstack.binders;
import com.google.common.base.Joiner;
import com.google.common.collect.Iterables;
import org.jclouds.cloudstack.domain.SnapshotPolicySchedule;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.utils.ModifyRequest;
@ -51,7 +49,7 @@ public class BindSnapshotPolicyScheduleToQueryParam implements Binder {
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
checkArgument(input instanceof SnapshotPolicySchedule, "this binder is only valid for SnapshotPolicySchedule");
SnapshotPolicySchedule schedule = (SnapshotPolicySchedule) input;
R modifiedResult = ModifyRequest.addQueryParam(request, "intervaltype", schedule.getIntervalType(), uriBuilderProvider.get());
R modifiedResult = ModifyRequest.addQueryParam(request, "intervaltype", schedule.getInterval(), uriBuilderProvider.get());
modifiedResult = ModifyRequest.addQueryParam(modifiedResult, "schedule", schedule.getTime(), uriBuilderProvider.get());
return modifiedResult;
}

View File

@ -40,12 +40,12 @@ public class Snapshot implements Comparable<Snapshot> {
private Date created;
private String domain;
private long domainId;
private SnapshotIntervalType intervalType;
private Interval interval;
private long jobId;
private String jobStatus;
private String name;
private SnapshotType snapshotType;
private SnapshotState state;
private Type snapshotType;
private State state;
private long volumeId;
private String volumeName;
private String volumeType;
@ -91,10 +91,10 @@ public class Snapshot implements Comparable<Snapshot> {
}
/**
* @param intervalType valid types are hourly, daily, weekly, monthy, template, and none.
* @param interval valid types are hourly, daily, weekly, monthy, template, and none.
*/
public Builder intervalType(SnapshotIntervalType intervalType) {
this.intervalType = intervalType;
public Builder interval(Interval interval) {
this.interval = interval;
return this;
}
@ -125,7 +125,7 @@ public class Snapshot implements Comparable<Snapshot> {
/**
* @param snapshotType the type of the snapshot
*/
public Builder snapshotType(SnapshotType snapshotType) {
public Builder snapshotType(Type snapshotType) {
this.snapshotType = snapshotType;
return this;
}
@ -133,7 +133,7 @@ public class Snapshot implements Comparable<Snapshot> {
/**
* @param state the state of the snapshot. BackedUp means that snapshot is ready to be used; Creating - the snapshot is being allocated on the primary storage; BackingUp - the snapshot is being backed up on secondary storage
*/
public Builder state(SnapshotState state) {
public Builder state(State state) {
this.state = state;
return this;
}
@ -164,11 +164,11 @@ public class Snapshot implements Comparable<Snapshot> {
}
public enum SnapshotState {
public static enum State {
BackedUp, Creating, BackingUp, UNRECOGNIZED;
public static SnapshotState fromValue(String type) {
public static State fromValue(String type) {
try {
return valueOf(checkNotNull(type, "type"));
} catch (IllegalArgumentException e) {
@ -177,11 +177,11 @@ public class Snapshot implements Comparable<Snapshot> {
}
}
public enum SnapshotType {
public static enum Type {
MANUAL, RECURRING, UNRECOGNIZED;
public static SnapshotType fromValue(String type) {
public static Type fromValue(String type) {
try {
return valueOf(checkNotNull(type, "type"));
} catch (IllegalArgumentException e) {
@ -190,11 +190,11 @@ public class Snapshot implements Comparable<Snapshot> {
}
}
public enum SnapshotIntervalType {
public static enum Interval {
HOURLY, DAILY, WEEKLY, MONTHLY, template, none, UNRECOGNIZED;
public static SnapshotIntervalType fromValue(String type) {
public static Interval fromValue(String type) {
try {
return valueOf(checkNotNull(type, "type"));
} catch (IllegalArgumentException e) {
@ -210,15 +210,15 @@ public class Snapshot implements Comparable<Snapshot> {
@SerializedName("domainid")
private long domainId;
@SerializedName("intervaltype")
private SnapshotIntervalType intervalType;
private Interval interval;
@SerializedName("jobid")
private long jobId;
@SerializedName("jobstatus")
private String jobStatus;
private String name;
@SerializedName("snapshottype")
private SnapshotType snapshotType;
private SnapshotState state;
private Type snapshotType;
private State state;
@SerializedName("volumeid")
private long volumeId;
@SerializedName("volumename")
@ -270,8 +270,8 @@ public class Snapshot implements Comparable<Snapshot> {
/**
* @return valid types are hourly, daily, weekly, monthy, template, and none.
*/
public SnapshotIntervalType getIntervalType() {
return intervalType;
public Interval getInterval() {
return interval;
}
/**
@ -298,14 +298,14 @@ public class Snapshot implements Comparable<Snapshot> {
/**
* @return the type of the snapshot
*/
public SnapshotType getSnapshotType() {
public Type getSnapshotType() {
return snapshotType;
}
/**
* @return the state of the snapshot. BackedUp means that snapshot is ready to be used; Creating - the snapshot is being allocated on the primary storage; BackingUp - the snapshot is being backed up on secondary storage
*/
public SnapshotState getState() {
public State getState() {
return state;
}
@ -344,7 +344,7 @@ public class Snapshot implements Comparable<Snapshot> {
if (account != null ? !account.equals(snapshot.account) : snapshot.account != null) return false;
if (created != null ? !created.equals(snapshot.created) : snapshot.created != null) return false;
if (domain != null ? !domain.equals(snapshot.domain) : snapshot.domain != null) return false;
if (intervalType != snapshot.intervalType) return false;
if (interval != snapshot.interval) return false;
if (jobStatus != null ? !jobStatus.equals(snapshot.jobStatus) : snapshot.jobStatus != null) return false;
if (name != null ? !name.equals(snapshot.name) : snapshot.name != null) return false;
if (snapshotType != snapshot.snapshotType) return false;
@ -362,7 +362,7 @@ public class Snapshot implements Comparable<Snapshot> {
result = 31 * result + (created != null ? created.hashCode() : 0);
result = 31 * result + (domain != null ? domain.hashCode() : 0);
result = 31 * result + (int) (domainId ^ (domainId >>> 32));
result = 31 * result + (intervalType != null ? intervalType.hashCode() : 0);
result = 31 * result + (interval != null ? interval.hashCode() : 0);
result = 31 * result + (int) (jobId ^ (jobId >>> 32));
result = 31 * result + (jobStatus != null ? jobStatus.hashCode() : 0);
result = 31 * result + (name != null ? name.hashCode() : 0);
@ -382,7 +382,7 @@ public class Snapshot implements Comparable<Snapshot> {
", created=" + created +
", domain='" + domain + '\'' +
", domainId=" + domainId +
", intervalType=" + intervalType +
", interval=" + interval +
", jobId=" + jobId +
", jobStatus='" + jobStatus + '\'' +
", name='" + name + '\'' +

View File

@ -32,7 +32,7 @@ public class SnapshotPolicy implements Comparable<SnapshotPolicy> {
public static class Builder {
private long id;
private Snapshot.SnapshotIntervalType intervalType;
private Snapshot.Interval interval;
private long numberToRetain;
private String schedule;
private String timezone;
@ -47,10 +47,10 @@ public class SnapshotPolicy implements Comparable<SnapshotPolicy> {
}
/**
* @param intervalType valid types are hourly, daily, weekly, monthy, template, and none.
* @param interval valid types are hourly, daily, weekly, monthy, template, and none.
*/
public Builder intervalType(Snapshot.SnapshotIntervalType intervalType) {
this.intervalType = intervalType;
public Builder interval(Snapshot.Interval interval) {
this.interval = interval;
return this;
}
@ -90,7 +90,7 @@ public class SnapshotPolicy implements Comparable<SnapshotPolicy> {
private long id;
@SerializedName("intervaltype")
private Snapshot.SnapshotIntervalType intervalType;
private Snapshot.Interval interval;
@SerializedName("maxsnaps")
private long numberToRetain;
private String schedule;
@ -114,8 +114,8 @@ public class SnapshotPolicy implements Comparable<SnapshotPolicy> {
/**
* @return valid types are hourly, daily, weekly, monthy, template, and none.
*/
public Snapshot.SnapshotIntervalType getIntervalType() {
return intervalType;
public Snapshot.Interval getInterval() {
return interval;
}
/**

View File

@ -8,31 +8,31 @@ package org.jclouds.cloudstack.domain;
public class SnapshotPolicySchedule {
public static SnapshotPolicySchedule hourly(int minute) {
return new SnapshotPolicySchedule(Snapshot.SnapshotIntervalType.HOURLY, "FIXME");
return new SnapshotPolicySchedule(Snapshot.Interval.HOURLY, "FIXME");
}
public static SnapshotPolicySchedule daily(int hour, int minute) {
return new SnapshotPolicySchedule(Snapshot.SnapshotIntervalType.DAILY, "FIXME");
return new SnapshotPolicySchedule(Snapshot.Interval.DAILY, "FIXME");
}
public static SnapshotPolicySchedule weekly(int day, int hour, int minute) {
return new SnapshotPolicySchedule(Snapshot.SnapshotIntervalType.WEEKLY, "FIXME");
return new SnapshotPolicySchedule(Snapshot.Interval.WEEKLY, "FIXME");
}
public static SnapshotPolicySchedule monthly(int day, int hour, int minute) {
return new SnapshotPolicySchedule(Snapshot.SnapshotIntervalType.MONTHLY, String.format("%02d:%02d:%02d", minute, hour, day));
return new SnapshotPolicySchedule(Snapshot.Interval.MONTHLY, String.format("%02d:%02d:%02d", minute, hour, day));
}
private Snapshot.SnapshotIntervalType intervalType;
private Snapshot.Interval interval;
private String time;
private SnapshotPolicySchedule(Snapshot.SnapshotIntervalType intervalType, String time) {
this.intervalType = intervalType;
private SnapshotPolicySchedule(Snapshot.Interval interval, String time) {
this.interval = interval;
this.time = time;
}
public Snapshot.SnapshotIntervalType getIntervalType() {
return intervalType;
public Snapshot.Interval getInterval() {
return interval;
}
public String getTime() {

View File

@ -41,10 +41,10 @@ public class ListSnapshotsOptions extends AccountInDomainOptions {
}
/**
* @param intervalType valid values are HOURLY, DAILY, WEEKLY, and MONTHLY.
* @param interval valid values are HOURLY, DAILY, WEEKLY, and MONTHLY.
*/
public ListSnapshotsOptions intervalType(Snapshot.SnapshotIntervalType intervalType) {
this.queryParameters.replaceValues("intervaltype", ImmutableSet.of(intervalType + ""));
public ListSnapshotsOptions interval(Snapshot.Interval interval) {
this.queryParameters.replaceValues("intervaltype", ImmutableSet.of(interval + ""));
return this;
}
@ -75,7 +75,7 @@ public class ListSnapshotsOptions extends AccountInDomainOptions {
/**
* @param snapshotType valid values are MANUAL or RECURRING.
*/
public ListSnapshotsOptions snapshotType(Snapshot.SnapshotType snapshotType) {
public ListSnapshotsOptions snapshotType(Snapshot.Type snapshotType) {
this.queryParameters.replaceValues("snapshottype", ImmutableSet.of(snapshotType + ""));
return this;
}
@ -113,10 +113,10 @@ public class ListSnapshotsOptions extends AccountInDomainOptions {
}
/**
* @param intervalType valid values are HOURLY, DAILY, WEEKLY, and MONTHLY.
* @param interval valid values are HOURLY, DAILY, WEEKLY, and MONTHLY.
*/
public static ListSnapshotsOptions intervalType(Snapshot.SnapshotIntervalType intervalType) {
return new ListSnapshotsOptions().intervalType(intervalType);
public static ListSnapshotsOptions interval(Snapshot.Interval interval) {
return new ListSnapshotsOptions().interval(interval);
}
/**
@ -143,7 +143,7 @@ public class ListSnapshotsOptions extends AccountInDomainOptions {
/**
* @param snapshotType valid values are MANUAL or RECURRING.
*/
public static ListSnapshotsOptions snapshotType(Snapshot.SnapshotType snapshotType) {
public static ListSnapshotsOptions snapshotType(Snapshot.Type snapshotType) {
return new ListSnapshotsOptions().snapshotType(snapshotType);
}

View File

@ -117,7 +117,7 @@ public class SnapshotAsyncClientTest extends BaseCloudStackAsyncClientTest<Snaps
public void testListSnapshotsOptions() throws NoSuchMethodException {
Method method = SnapshotAsyncClient.class.getMethod("listSnapshots", ListSnapshotsOptions[].class);
HttpRequest httpRequest = processor.createRequest(method, ListSnapshotsOptions.Builder.accountInDomain("acc", 7).id(5).intervalType(Snapshot.SnapshotIntervalType.MONTHLY).isRecursive(true).keyword("fred").name("fred's snapshot").snapshotType(Snapshot.SnapshotType.RECURRING).volumeId(11));
HttpRequest httpRequest = processor.createRequest(method, ListSnapshotsOptions.Builder.accountInDomain("acc", 7).id(5).interval(Snapshot.Interval.MONTHLY).isRecursive(true).keyword("fred").name("fred's snapshot").snapshotType(Snapshot.Type.RECURRING).volumeId(11));
assertRequestLineEquals(httpRequest,
"GET http://localhost:8080/client/api?response=json&command=listSnapshots&account=acc&domainid=7&id=5&intervaltype=MONTHLY&isrecursive=true&keyword=fred&name=fred%27s%20snapshot&snapshottype=RECURRING&volumeid=11 HTTP/1.1");