Merge branch 'master' of github.com:jclouds/jclouds into 1.5.x

* 'master' of github.com:jclouds/jclouds: (30 commits)
  Issue 1011: introducing PagedIterable
  Transform to work with SaxParser
  added @Transform
  disabled test that broke cloudbees build
  Issue 1022:Move naming convention to Api from Client or Services:: cdmi
  merged cdmi changes and fixed classpath issues
  Issue 1022:Move naming convention to Api from Client or Services:: glesys jenkins openstack-* opsource-servers savvis-symphonyvpdc cloudwatch cloudidentity rackspace-cloudidentity aws-cloudwatch rackspace-cloudservers-us hpcloud-compute rackspace-cloudservers-us trystack-nova
  Issue 1022: naming conventions
  cloudstack: removing unnecessary (and in some cases misleading Named annotations). Also removing CloudstackParserModule - handling deserialization in constructors marked with ConstructorProperties annotation
  Issue 1022:Move naming convention to Api from Client or Services:: carrenza-vcloud-director
  Issue 1022:Move naming convention to Api from Client or Services:: joyent-cloudapi joyentcloud
  Issue 1022:Move naming convention to Api from Client or Services:: vcloud-director
  cleaned up http builders and expect tests
  Fix infinite loops, found by FindBugs
  Log hostnames only if they differ
  vcloud tidies
  nodepool progress and AdminAccessBuilderSpec
  Issue 1022: updated aws-elb aws-iam aws-rds iam elb rds to new naming conventions
  Issue 1022: added BaseRestApiExpectTest
  swift keystone 2.0: applying defaultProperties()
  ...
This commit is contained in:
Adrian Cole 2012-07-15 23:46:35 -07:00
commit e4545fe5fa
1477 changed files with 28081 additions and 19070 deletions

View File

@ -27,27 +27,27 @@ import javax.inject.Singleton;
import org.jclouds.atmos.domain.UserMetadata;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.utils.ModifyRequest;
import org.jclouds.rest.Binder;
import com.google.common.base.Function;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Multimaps;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.Multimaps;
/**
* @author Adrian Cole
*/
@Singleton
public class BindUserMetadataToHeaders implements Binder, Function<UserMetadata, Map<String, String>> {
@SuppressWarnings("unchecked")
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
checkArgument(checkNotNull(input, "input") instanceof UserMetadata,
"this binder is only valid for UserMetadatas!");
checkNotNull(request, "request");
return ModifyRequest.putHeaders(request, Multimaps.forMap(apply(UserMetadata.class.cast(input))));
return (R) request.toBuilder().replaceHeaders(Multimaps.forMap(apply(UserMetadata.class.cast(input)))).build();
}
@Override

View File

@ -25,8 +25,6 @@ import org.jclouds.atmos.domain.MutableContentMetadata;
import org.jclouds.io.ContentMetadataBuilder;
import org.jclouds.io.payloads.BaseMutableContentMetadata;
import com.google.common.collect.Multimap;
/**
*
* @author Adrian Cole

View File

@ -41,7 +41,6 @@ import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpRequestFilter;
import org.jclouds.http.HttpUtils;
import org.jclouds.http.internal.SignatureWire;
import org.jclouds.http.utils.ModifyRequest;
import org.jclouds.io.InputSuppliers;
import org.jclouds.logging.Logger;
import org.jclouds.rest.annotations.Credential;
@ -51,8 +50,8 @@ import org.jclouds.util.Strings2;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Multimaps;
import com.google.common.collect.ImmutableMap.Builder;
import com.google.common.collect.Multimaps;
/**
* Signs the EMC Atmos Online Storage request.
@ -98,9 +97,9 @@ public class SignRequest implements HttpRequestFilter {
builder.put(HttpHeaders.DATE, date);
if (request.getHeaders().containsKey(AtmosHeaders.DATE))
builder.put(AtmosHeaders.DATE, date);
request = ModifyRequest.replaceHeaders(request, Multimaps.forMap(builder.build()));
request = request.toBuilder().replaceHeaders(Multimaps.forMap(builder.build())).build();
String signature = calculateSignature(createStringToSign(request));
request = ModifyRequest.replaceHeader(request, AtmosHeaders.SIGNATURE, signature);
request = request.toBuilder().replaceHeader(AtmosHeaders.SIGNATURE, signature).build();
utils.logRequest(signatureLog, request, "<<");
return request;
}

View File

@ -21,9 +21,6 @@ package org.jclouds.atmos.binders;
import static org.testng.Assert.assertEquals;
import java.io.File;
import java.net.URI;
import javax.ws.rs.HttpMethod;
import org.jclouds.atmos.domain.AtmosObject;
import org.jclouds.http.HttpRequest;
@ -50,27 +47,27 @@ public class BindMetadataToHeadersTest {
object.setPayload(payload);
object.getUserMetadata().getListableMetadata().put("apple", "bear");
object.getUserMetadata().getListableMetadata().put("sushi", "king");
HttpRequest request = new HttpRequest("GET", URI.create("http://localhost"));
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
request = binder.bindToRequest(request, object);
assertEquals(request.getFirstHeaderOrNull("x-emc-listable-meta"), "apple=bear,sushi=king");
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void testMustBeAtmosObject() {
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
binder.bindToRequest(request, new File("foo"));
}
@Test(expectedExceptions = NullPointerException.class)
public void testNullIsBad() {
HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build();
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
binder.bindToRequest(request, null);
}
@Test(expectedExceptions = NullPointerException.class)
public void testNullPayloadIsBad() {
AtmosObject object = injector.getInstance(AtmosObject.Factory.class).create(null);
HttpRequest request = new HttpRequest("GET", URI.create("http://localhost"));
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
binder.bindToRequest(request, object);
}
@ -80,7 +77,7 @@ public class BindMetadataToHeadersTest {
Payload payload = Payloads.newStringPayload("");
payload.getContentMetadata().setContentLength(null);
object.setPayload(payload);
HttpRequest request = new HttpRequest("GET", URI.create("http://localhost"));
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
binder.bindToRequest(request, object);
}

View File

@ -21,9 +21,6 @@ package org.jclouds.atmos.binders;
import static org.testng.Assert.assertEquals;
import java.io.File;
import java.net.URI;
import javax.ws.rs.HttpMethod;
import org.jclouds.atmos.domain.UserMetadata;
import org.jclouds.http.HttpRequest;
@ -46,7 +43,7 @@ public class BindUserMetadataToHeadersTest {
UserMetadata metadata = new UserMetadata();
metadata.getMetadata().put("apple", "bear");
metadata.getMetadata().put("sushi", "king");
HttpRequest request = new HttpRequest("GET", URI.create("http://localhost"));
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
request = binder.bindToRequest(request, metadata);
assertEquals(request.getFirstHeaderOrNull("x-emc-meta"), "apple=bear,sushi=king");
}
@ -55,7 +52,7 @@ public class BindUserMetadataToHeadersTest {
UserMetadata metadata = new UserMetadata();
metadata.getListableMetadata().put("apple", "bear");
metadata.getListableMetadata().put("sushi", "king");
HttpRequest request = new HttpRequest("GET", URI.create("http://localhost"));
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
request = binder.bindToRequest(request, metadata);
assertEquals(request.getFirstHeaderOrNull("x-emc-listable-meta"), "apple=bear,sushi=king");
}
@ -64,7 +61,7 @@ public class BindUserMetadataToHeadersTest {
UserMetadata tagsdata = new UserMetadata();
tagsdata.getTags().add("apple");
tagsdata.getTags().add("sushi");
HttpRequest request = new HttpRequest("GET", URI.create("http://localhost"));
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
request = binder.bindToRequest(request, tagsdata);
assertEquals(request.getFirstHeaderOrNull("x-emc-tags"), "apple,sushi");
}
@ -73,20 +70,20 @@ public class BindUserMetadataToHeadersTest {
UserMetadata tagsdata = new UserMetadata();
tagsdata.getListableTags().add("apple");
tagsdata.getListableTags().add("sushi");
HttpRequest request = new HttpRequest("GET", URI.create("http://localhost"));
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://localhost").build();
request = binder.bindToRequest(request, tagsdata);
assertEquals(request.getFirstHeaderOrNull("x-emc-listable-tags"), "apple,sushi");
}
@Test(expectedExceptions = IllegalArgumentException.class)
public void testMustBeUserMetadata() {
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();
binder.bindToRequest(request, new File("foo"));
}
@Test(expectedExceptions = { NullPointerException.class, IllegalStateException.class })
public void testNullIsBad() {
HttpRequest request = HttpRequest.builder().method("GET").endpoint(URI.create("http://momma")).build();
HttpRequest request = HttpRequest.builder().method("GET").endpoint("http://momma").build();
binder.bindToRequest(request, null);
}
}

View File

@ -21,8 +21,6 @@ package org.jclouds.atmos.blobstore;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.jclouds.apis.ApiMetadata;
@ -35,7 +33,6 @@ import org.jclouds.blobstore.domain.Blob;
import org.jclouds.blobstore.domain.Blob.Factory;
import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpRequest;
import org.jclouds.io.ContentMetadata;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.internal.BaseAsyncClientTest;
import org.jclouds.rest.internal.RestAnnotationProcessor;

View File

@ -27,7 +27,7 @@ import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.blobstore.internal.BlobStoreContextImpl;
import org.jclouds.blobstore.strategy.ContainsValueInListStrategy;
import org.jclouds.logging.config.NullLoggingModule;
import org.jclouds.rest.internal.BaseRestClientTest.MockModule;
import org.jclouds.rest.internal.BaseRestApiTest.MockModule;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;

View File

@ -21,7 +21,6 @@ package org.jclouds.atmos.filters;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.net.URI;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
@ -35,16 +34,16 @@ import org.jclouds.date.TimeStamp;
import org.jclouds.http.HttpRequest;
import org.jclouds.logging.config.NullLoggingModule;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.rest.internal.BaseRestClientTest.MockModule;
import org.jclouds.rest.internal.BaseRestApiTest.MockModule;
import org.jclouds.util.Strings2;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import com.google.common.base.Supplier;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableMultimap.Builder;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Multimap;
import com.google.common.collect.ImmutableMultimap.Builder;
import com.google.inject.Injector;
import com.google.inject.Module;
@ -122,7 +121,10 @@ public class SignRequestTest {
}
public HttpRequest newRequest(Multimap<String, String> headers) {
HttpRequest request = new HttpRequest("POST", URI.create("http://localhost/rest/objects"), headers);
HttpRequest request = HttpRequest.builder()
.method("POST")
.endpoint("http://localhost/rest/objects")
.headers(headers).build();
request.setPayload("");
request.getPayload().getContentMetadata().setContentLength(4286l);
request.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_OCTET_STREAM);

View File

@ -33,7 +33,6 @@ import org.jclouds.io.Payloads;
import org.testng.annotations.Test;
import com.google.common.base.Function;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSet.Builder;
@ -51,8 +50,11 @@ public class ParseDirectoryListFromContentAndHeadersTest extends BaseHandlerTest
}
public void testWithToken() {
HttpResponse response = new HttpResponse(200, "ok", Payloads.newPayload(getClass().getResourceAsStream(
"/list_basic.xml")), ImmutableMultimap.of(AtmosHeaders.TOKEN, "token"));
HttpResponse response = HttpResponse.builder()
.statusCode(200)
.message("ok")
.payload(Payloads.newPayload(getClass().getResourceAsStream("/list_basic.xml")))
.addHeader(AtmosHeaders.TOKEN, "token").build();
BoundedSet<DirectoryEntry> result = createFn().apply(response);
assertEquals(result, new BoundedLinkedHashSet<DirectoryEntry>(values(), "token"));
@ -60,8 +62,11 @@ public class ParseDirectoryListFromContentAndHeadersTest extends BaseHandlerTest
}
public void testWithoutToken() {
HttpResponse response = new HttpResponse(200, "ok", Payloads.newPayload(getClass().getResourceAsStream(
"/list_basic.xml")));
HttpResponse response = HttpResponse.builder()
.statusCode(200)
.message("ok")
.payload(Payloads.newPayload(getClass().getResourceAsStream("/list_basic.xml"))).build();
BoundedSet<DirectoryEntry> result = createFn().apply(response);
assertEquals(ImmutableSet.copyOf(result), values());

View File

@ -23,7 +23,6 @@ import static org.testng.Assert.assertEquals;
import org.jclouds.atmos.domain.AtmosObject;
import org.jclouds.atmos.reference.AtmosHeaders;
import org.jclouds.http.HttpResponse;
import org.jclouds.io.Payloads;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMultimap;
@ -34,17 +33,21 @@ import com.google.inject.Guice;
*
* @author Adrian Cole
*/
@Test(groups = "unit")
@Test(groups = "unit", testName = "ParseObjectFromHeadersAndHttpContentTest")
public class ParseObjectFromHeadersAndHttpContentTest {
static final HttpResponse RESPONSE = new HttpResponse(200, "ok", Payloads.newStringPayload(""),
static final HttpResponse RESPONSE = HttpResponse.builder()
.statusCode(200)
.message("ok")
.payload("")
.headers(
ImmutableMultimap.of(AtmosHeaders.TAGS, "tag1, tag2", AtmosHeaders.LISTABLE_TAGS,
"listabletag1, listabletag2", AtmosHeaders.META,
"meta1=foo1, content-md5=1f3870be274f6c49b3e31a0c6728957f, atime=2009-10-12T16:09:42Z, mtime=2009-10-19T04:37:00Z,"
+ " ctime=2009-10-19T04:37:00Z, itime=2009-10-12T16:09:42Z, type=directory, uid=root, "
+ "gid=rootr, objectid=4980cdb2b010109b04a44f7bb83f5f04ad354c638ae5, "
+ "objname=e913e09366364e9ba384b8fead643d43, size=4096, nlink=1, policyname=default",
AtmosHeaders.LISTABLE_META, "listablemeta1=listablefoo1, listablemeta2=listablefoo2"));
AtmosHeaders.LISTABLE_META, "listablemeta1=listablefoo1, listablemeta2=listablefoo2")).build();
public static final AtmosObject EXPECTED;

View File

@ -28,7 +28,6 @@ import java.util.SortedSet;
import org.jclouds.cloudfiles.domain.ContainerCDNMetadata;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.ParseJson;
import org.jclouds.io.Payloads;
import org.jclouds.json.config.GsonModule;
import org.testng.annotations.Test;
@ -61,6 +60,6 @@ public class ParseContainerCDNMetadataListFromJsonResponseTest {
ParseJson<SortedSet<ContainerCDNMetadata>> parser = i.getInstance(Key
.get(new TypeLiteral<ParseJson<SortedSet<ContainerCDNMetadata>>>() {
}));
assertEquals(parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is))), expects);
assertEquals(parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build()), expects);
}
}

View File

@ -77,7 +77,6 @@ public abstract class BaseCloudLoadBalancersAsyncClientTest<T> extends BaseAsync
protected void configure() {
}
@SuppressWarnings("unused")
@Provides
@Singleton
GetAuth provideGetAuth() {

View File

@ -82,7 +82,7 @@ public class CloudServersComputeServiceContextModule extends
// we aren't converting location from a provider-specific type
bind(new TypeLiteral<Function<Location, Location>>() {
}).to((Class) IdentityFunction.class);
}).to(Class.class.cast(IdentityFunction.class));
bind(new TypeLiteral<ImageExtension>() {
}).to(CloudServersImageExtension.class);

View File

@ -27,7 +27,6 @@ import java.util.List;
import org.jclouds.cloudservers.domain.Addresses;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.io.Payloads;
import org.jclouds.json.config.GsonModule;
import org.testng.annotations.Test;
@ -51,7 +50,7 @@ public class ParseAddressesFromJsonResponseTest {
UnwrapOnlyJsonValue<Addresses> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Addresses>>() {
}));
Addresses response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
Addresses response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
List<String> publicAddresses = ImmutableList.of("67.23.10.132", "67.23.10.131");
List<String> privateAddresses = ImmutableList.of("10.176.42.16");

View File

@ -28,7 +28,6 @@ import org.jclouds.cloudservers.domain.DailyBackup;
import org.jclouds.cloudservers.domain.WeeklyBackup;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.io.Payloads;
import org.jclouds.json.config.GsonModule;
import org.testng.annotations.Test;
@ -52,7 +51,7 @@ public class ParseBackupScheduleFromJsonResponseTest {
UnwrapOnlyJsonValue<BackupSchedule> parser = i.getInstance(Key
.get(new TypeLiteral<UnwrapOnlyJsonValue<BackupSchedule>>() {
}));
BackupSchedule response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
BackupSchedule response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
assertEquals(new BackupSchedule(WeeklyBackup.THURSDAY, DailyBackup.H_0400_0600, true), response);
}
@ -61,8 +60,9 @@ public class ParseBackupScheduleFromJsonResponseTest {
UnwrapOnlyJsonValue<BackupSchedule> parser = i.getInstance(Key
.get(new TypeLiteral<UnwrapOnlyJsonValue<BackupSchedule>>() {
}));
BackupSchedule response = parser.apply(new HttpResponse(200, "ok", Payloads
.newStringPayload("{\"backupSchedule\":{\"enabled\" : false}}")));
BackupSchedule response = parser.apply(HttpResponse.builder()
.statusCode(200).message("ok")
.payload("{\"backupSchedule\":{\"enabled\" : false}}").build());
assertEquals(new BackupSchedule(), response);
}
}

View File

@ -25,7 +25,6 @@ import java.io.InputStream;
import org.jclouds.cloudservers.domain.Flavor;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.io.Payloads;
import org.jclouds.json.config.GsonModule;
import org.testng.annotations.Test;
@ -57,7 +56,7 @@ public class ParseFlavorFromJsonResponseTest {
UnwrapOnlyJsonValue<Flavor> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Flavor>>() {
}));
Flavor response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
Flavor response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
return response;
}

View File

@ -27,7 +27,6 @@ import java.util.List;
import org.jclouds.cloudservers.domain.Flavor;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.io.Payloads;
import org.jclouds.json.config.GsonModule;
import org.testng.annotations.Test;
@ -55,7 +54,7 @@ public class ParseFlavorListFromJsonResponseTest {
UnwrapOnlyJsonValue<List<Flavor>> parser = i.getInstance(Key
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Flavor>>>() {
}));
List<Flavor> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
List<Flavor> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
assertEquals(response, expects);
}
@ -65,7 +64,7 @@ public class ParseFlavorListFromJsonResponseTest {
UnwrapOnlyJsonValue<List<Flavor>> parser = i.getInstance(Key
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Flavor>>>() {
}));
List<Flavor> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
List<Flavor> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
assertEquals(response.get(0).getId(), 1);
assertEquals(response.get(0).getName(), "256 MB Server");
assertEquals(response.get(0).getDisk(), new Integer(10));

View File

@ -28,7 +28,6 @@ import org.jclouds.cloudservers.domain.ImageStatus;
import org.jclouds.date.DateService;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.io.Payloads;
import org.jclouds.json.config.GsonModule;
import org.jclouds.json.config.GsonModule.DateAdapter;
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
@ -85,7 +84,7 @@ public class ParseImageFromJsonResponseTest {
UnwrapOnlyJsonValue<Image> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Image>>() {
}));
Image response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
Image response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
return response;
}

View File

@ -29,7 +29,6 @@ import org.jclouds.cloudservers.domain.ImageStatus;
import org.jclouds.date.DateService;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.io.Payloads;
import org.jclouds.json.config.GsonModule;
import org.jclouds.json.config.GsonModule.DateAdapter;
import org.jclouds.json.config.GsonModule.Iso8601DateAdapter;
@ -67,7 +66,7 @@ public class ParseImageListFromJsonResponseTest {
UnwrapOnlyJsonValue<List<Image>> parser = i.getInstance(Key
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Image>>>() {
}));
List<Image> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
List<Image> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
assertEquals(response, expects);
}
@ -78,7 +77,7 @@ public class ParseImageListFromJsonResponseTest {
UnwrapOnlyJsonValue<List<Image>> parser = i.getInstance(Key
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Image>>>() {
}));
List<Image> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
List<Image> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
assertEquals(response.get(0).getId(), 2);
assertEquals(response.get(0).getName(), "CentOS 5.2");

View File

@ -26,7 +26,6 @@ import java.util.List;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.io.Payloads;
import org.jclouds.json.config.GsonModule;
import org.testng.annotations.Test;
@ -52,7 +51,7 @@ public class ParseInetAddressListFromJsonResponseTest {
UnwrapOnlyJsonValue<List<String>> parser = i.getInstance(Key
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<String>>>() {
}));
List<String> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
List<String> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
assertEquals(response, ImmutableList.of("67.23.10.132", "67.23.10.131"));
}
@ -63,7 +62,7 @@ public class ParseInetAddressListFromJsonResponseTest {
UnwrapOnlyJsonValue<List<String>> parser = i.getInstance(Key
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<String>>>() {
}));
List<String> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
List<String> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
assertEquals(response, ImmutableList.of("10.176.42.16"));
}

View File

@ -29,7 +29,6 @@ import org.jclouds.cloudservers.domain.Server;
import org.jclouds.cloudservers.domain.ServerStatus;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.io.Payloads;
import org.jclouds.json.config.GsonModule;
import org.testng.annotations.Test;
@ -75,7 +74,7 @@ public class ParseServerFromJsonResponseTest {
UnwrapOnlyJsonValue<Server> parser = i.getInstance(Key.get(new TypeLiteral<UnwrapOnlyJsonValue<Server>>() {
}));
Server response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
Server response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
return response;
}

View File

@ -29,7 +29,6 @@ import org.jclouds.cloudservers.domain.Server;
import org.jclouds.cloudservers.domain.ServerStatus;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.io.Payloads;
import org.jclouds.json.config.GsonModule;
import org.testng.annotations.Test;
@ -59,7 +58,7 @@ public class ParseServerListFromJsonResponseTest {
UnwrapOnlyJsonValue<List<Server>> parser = i.getInstance(Key
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Server>>>() {
}));
List<Server> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
List<Server> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
assertEquals(response, expects);
}
@ -70,7 +69,7 @@ public class ParseServerListFromJsonResponseTest {
UnwrapOnlyJsonValue<List<Server>> parser = i.getInstance(Key
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<Server>>>() {
}));
List<Server> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
List<Server> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
assertEquals(response.get(0).getId(), 1234);
assertEquals(response.get(0).getName(), "sample-server");

View File

@ -26,7 +26,6 @@ import java.net.UnknownHostException;
import org.jclouds.cloudservers.domain.SharedIpGroup;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.io.Payloads;
import org.jclouds.json.config.GsonModule;
import org.testng.annotations.Test;
@ -52,7 +51,7 @@ public class ParseSharedIpGroupFromJsonResponseTest {
UnwrapOnlyJsonValue<SharedIpGroup> parser = i.getInstance(Key
.get(new TypeLiteral<UnwrapOnlyJsonValue<SharedIpGroup>>() {
}));
SharedIpGroup response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
SharedIpGroup response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
assertEquals(response.getId(), 1234);
assertEquals(response.getName(), "Shared IP Group 1");

View File

@ -27,7 +27,6 @@ import java.util.List;
import org.jclouds.cloudservers.domain.SharedIpGroup;
import org.jclouds.http.HttpResponse;
import org.jclouds.http.functions.UnwrapOnlyJsonValue;
import org.jclouds.io.Payloads;
import org.jclouds.json.config.GsonModule;
import org.testng.annotations.Test;
@ -56,7 +55,7 @@ public class ParseSharedIpGroupListFromJsonResponseTest {
UnwrapOnlyJsonValue<List<SharedIpGroup>> parser = i.getInstance(Key
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<SharedIpGroup>>>() {
}));
List<SharedIpGroup> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
List<SharedIpGroup> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
assertEquals(response, expects);
@ -68,7 +67,7 @@ public class ParseSharedIpGroupListFromJsonResponseTest {
UnwrapOnlyJsonValue<List<SharedIpGroup>> parser = i.getInstance(Key
.get(new TypeLiteral<UnwrapOnlyJsonValue<List<SharedIpGroup>>>() {
}));
List<SharedIpGroup> response = parser.apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
List<SharedIpGroup> response = parser.apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
assertEquals(response.get(0).getId(), 1234);
assertEquals(response.get(0).getName(), "Shared IP Group 1");

View File

@ -18,8 +18,6 @@
*/
package org.jclouds.cloudservers.handlers;
import java.net.URI;
import org.jclouds.cloudservers.CloudServersClient;
import org.jclouds.cloudservers.internal.BaseCloudServersRestClientExpectTest;
import org.jclouds.http.HttpRequest;
@ -28,8 +26,6 @@ import org.jclouds.io.Payloads;
import org.jclouds.rest.AuthorizationException;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableMultimap;
/**
* Tests behavior of {@code RetryOnRenew} handler
*
@ -42,16 +38,14 @@ public class RetryOnRenewExpectTest extends BaseCloudServersRestClientExpectTest
public void testShouldReauthenticateOn401() {
HttpRequest deleteImage = HttpRequest.builder().method("DELETE")
.endpoint(URI.create("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/11?now=1257695648897"))
.headers(ImmutableMultimap.<String, String> builder().put("X-Auth-Token", authToken).build()).build();
.endpoint("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/11?now=1257695648897")
.addHeader("X-Auth-Token", authToken).build();
HttpResponse pleaseRenew = HttpResponse
.builder()
.statusCode(401)
.message("HTTP/1.1 401 Unauthorized")
.payload(
Payloads
.newStringPayload("[{\"unauthorized\":{\"message\":\"Invalid authentication token. Please renew.\",\"code\":401}}]"))
.payload("[{\"unauthorized\":{\"message\":\"Invalid authentication token. Please renew.\",\"code\":401}}]")
.build();
// second auth uses same creds as initial one
@ -59,15 +53,13 @@ public class RetryOnRenewExpectTest extends BaseCloudServersRestClientExpectTest
String authToken2 = "12345678-9012-47c0-9770-2c5097da25fc";
HttpResponse responseWithUrls2 = HttpResponse
.Builder.from(responseWithAuth)
.payload(
Payloads.newPayload(responseWithAuth.getPayload().getRawContent().toString()
.replace(authToken, authToken2))).build();
HttpResponse responseWithUrls2 = responseWithAuth.toBuilder()
.payload(responseWithAuth.getPayload().getRawContent().toString().replace(authToken, authToken2))
.build();
HttpRequest deleteImage2 = HttpRequest.builder().method("DELETE")
.endpoint(URI.create("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/11?now=1257695648897"))
.headers(ImmutableMultimap.<String, String> builder().put("X-Auth-Token", authToken2).build()).build();
.endpoint("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/11?now=1257695648897")
.addHeader("X-Auth-Token", authToken2).build();
HttpResponse imageDeleted = HttpResponse.builder().statusCode(204).message("HTTP/1.1 204 No Content").build();
@ -80,15 +72,14 @@ public class RetryOnRenewExpectTest extends BaseCloudServersRestClientExpectTest
@Test(expectedExceptions = AuthorizationException.class)
public void testDoesNotReauthenticateOnFatal401() {
HttpRequest deleteImage = HttpRequest.builder().method("DELETE")
.endpoint(URI.create("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/11?now=1257695648897"))
.headers(ImmutableMultimap.<String, String> builder().put("X-Auth-Token", authToken).build()).build();
.endpoint("https://lon.servers.api.rackspacecloud.com/v1.0/10001786/images/11?now=1257695648897")
.addHeader("X-Auth-Token", authToken).build();
HttpResponse unauthResponse = HttpResponse
.builder()
.statusCode(401)
.message("HTTP/1.1 401 Unauthorized")
.payload(
Payloads.newStringPayload("[{\"unauthorized\":{\"message\":\"Fatal unauthorized.\",\"code\":401}}]"))
.payload("[{\"unauthorized\":{\"message\":\"Fatal unauthorized.\",\"code\":401}}]")
.build();
CloudServersClient client = orderedRequestsSendResponses(initialAuth, responseWithAuth, deleteImage,

View File

@ -23,10 +23,6 @@ import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withS
import static org.jclouds.cloudservers.options.CreateServerOptions.Builder.withSharedIpGroup;
import static org.testng.Assert.assertEquals;
import java.net.URI;
import javax.ws.rs.HttpMethod;
import org.jclouds.http.HttpRequest;
import org.jclouds.json.config.GsonModule;
import org.testng.annotations.Test;
@ -54,7 +50,7 @@ public class CreateServerOptionsTest {
private HttpRequest buildRequest(CreateServerOptions options) {
injector.injectMembers(options);
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();;
options.bindToRequest(request, ImmutableMap.<String, Object>of("name", "foo", "imageId", "1", "flavorId", "2"));
return request;
}

View File

@ -21,10 +21,6 @@ package org.jclouds.cloudservers.options;
import static org.jclouds.cloudservers.options.CreateSharedIpGroupOptions.Builder.withServer;
import static org.testng.Assert.assertEquals;
import java.net.URI;
import javax.ws.rs.HttpMethod;
import org.jclouds.http.HttpRequest;
import org.jclouds.json.config.GsonModule;
import org.testng.annotations.Test;
@ -52,7 +48,7 @@ public class CreateSharedIpGroupOptionsTest {
private HttpRequest buildRequest(CreateSharedIpGroupOptions options) {
injector.injectMembers(options);
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();;
options.bindToRequest(request, ImmutableMap.<String,Object>of("name", "foo"));
return request;
}

View File

@ -21,11 +21,8 @@ package org.jclouds.cloudservers.options;
import static org.jclouds.cloudservers.options.RebuildServerOptions.Builder.withImage;
import static org.testng.Assert.assertEquals;
import java.net.URI;
import java.util.HashMap;
import javax.ws.rs.HttpMethod;
import org.jclouds.http.HttpRequest;
import org.jclouds.json.config.GsonModule;
import org.testng.annotations.Test;
@ -52,7 +49,7 @@ public class RebuildServerOptionsTest {
private HttpRequest buildRequest(RebuildServerOptions options) {
injector.injectMembers(options);
HttpRequest request = new HttpRequest(HttpMethod.POST, URI.create("http://localhost"));
HttpRequest request = HttpRequest.builder().method("POST").endpoint("http://localhost").build();;
options.bindToRequest(request, new HashMap<String, Object>());
return request;
}

View File

@ -29,7 +29,6 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import javax.ws.rs.core.MediaType;
import org.jclouds.cloudsigma.CloudSigmaAsyncClient;
import org.jclouds.cloudsigma.functions.ListOfMapsToListOfKeyValuesDelimitedByBlankLines;
import org.jclouds.cloudsigma.options.CloneDriveOptions;
import org.jclouds.http.HttpRequest;
@ -59,8 +58,7 @@ public class BindCloneDriveOptionsToPlainTextString implements MapBinder {
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
checkArgument(checkNotNull(request, "request") instanceof GeneratedHttpRequest,
"this binder is only valid for GeneratedHttpRequests!");
@SuppressWarnings("unchecked")
GeneratedHttpRequest<CloudSigmaAsyncClient> gRequest = (GeneratedHttpRequest<CloudSigmaAsyncClient>) request;
GeneratedHttpRequest gRequest = GeneratedHttpRequest.class.cast(request);
checkState(gRequest.getArgs() != null, "args should be initialized at this point");
CloneDriveOptions options = findOptionsInArgsOrNull(gRequest);
@ -78,7 +76,7 @@ public class BindCloneDriveOptionsToPlainTextString implements MapBinder {
return request;
}
static CloneDriveOptions findOptionsInArgsOrNull(GeneratedHttpRequest<?> gRequest) {
static CloneDriveOptions findOptionsInArgsOrNull(GeneratedHttpRequest gRequest) {
for (Object arg : gRequest.getArgs()) {
if (arg instanceof CloneDriveOptions) {
return (CloneDriveOptions) arg;

View File

@ -77,11 +77,11 @@ public class CloudSigmaComputeServiceContextModule extends
bind(new TypeLiteral<Function<ServerInfo, NodeMetadata>>() {
}).to(ServerInfoToNodeMetadata.class);
bind(new TypeLiteral<Function<Hardware, Hardware>>() {
}).to((Class) IdentityFunction.class);
}).to(Class.class.cast(IdentityFunction.class));
bind(new TypeLiteral<Function<DriveInfo, Image>>() {
}).to(PreinstalledDiskToImage.class);
bind(new TypeLiteral<Function<Location, Location>>() {
}).to((Class) IdentityFunction.class);
}).to(Class.class.cast(IdentityFunction.class));
bind(new TypeLiteral<Function<Device, Volume>>() {
}).to(DeviceToVolume.class);
bind(new TypeLiteral<Function<Server, String>>() {

View File

@ -23,11 +23,11 @@ import javax.inject.Singleton;
import org.jclouds.cloudsigma.domain.DriveInfo;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.Image.Status;
import org.jclouds.compute.domain.ImageBuilder;
import org.jclouds.compute.domain.OperatingSystem;
import org.jclouds.compute.domain.OsFamilyVersion64Bit;
import org.jclouds.compute.domain.Image.Status;
import org.jclouds.compute.domain.OperatingSystem.Builder;
import org.jclouds.compute.domain.OsFamilyVersion64Bit;
import org.jclouds.domain.Location;
import com.google.common.base.Function;

View File

@ -37,11 +37,11 @@ import org.jclouds.collect.Memoized;
import org.jclouds.compute.domain.HardwareBuilder;
import org.jclouds.compute.domain.Image;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.NodeMetadata.Status;
import org.jclouds.compute.domain.NodeMetadataBuilder;
import org.jclouds.compute.domain.Processor;
import org.jclouds.compute.domain.Volume;
import org.jclouds.compute.domain.VolumeBuilder;
import org.jclouds.compute.domain.NodeMetadata.Status;
import org.jclouds.compute.functions.GroupNamingConvention;
import org.jclouds.domain.Location;
import org.jclouds.logging.Logger;

View File

@ -58,7 +58,7 @@ public class BindCloneDriveOptionsToPlainTextStringTest {
protected void assertInputAndArgsCreatesPayload(ImmutableMap<String, Object> inputMap, List<Object> args,
String expected) {
GeneratedHttpRequest<?> request = createMock(GeneratedHttpRequest.class);
GeneratedHttpRequest request = createMock(GeneratedHttpRequest.class);
expect(request.getArgs()).andReturn(args).atLeastOnce();
request.setPayload(expected);
Payload payload = createMock(Payload.class);

View File

@ -21,7 +21,6 @@ package org.jclouds.cloudsigma.binders;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import javax.ws.rs.core.MediaType;
@ -61,7 +60,7 @@ public class BindDriveDataToPlainTextStringTest {
}).getInstance(BindDriveDataToPlainTextString.class);
public void testSimple() {
HttpRequest request = new HttpRequest("POST", URI.create("https://host/drives/create"));
HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://host/drives/create").build();
FN.bindToRequest(request, new DriveData.Builder().name("foo").size(100l).build());
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN);
assertEquals(request.getPayload().getRawContent(), "name foo\nsize 100");
@ -77,7 +76,7 @@ public class BindDriveDataToPlainTextStringTest {
.use(ImmutableSet.of("tag1", "tag2"))//
.build();
HttpRequest request = new HttpRequest("POST", URI.create("https://host/drives/create"));
HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://host/drives/create").build();
FN.bindToRequest(request, input);
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN);
assertEquals(request.getPayload().getRawContent(),

View File

@ -21,7 +21,6 @@ package org.jclouds.cloudsigma.binders;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import javax.ws.rs.core.MediaType;
@ -62,7 +61,7 @@ public class BindDriveToPlainTextStringTest {
}).getInstance(BindDriveToPlainTextString.class);
public void testSimple() {
HttpRequest request = new HttpRequest("POST", URI.create("https://host/drives/create"));
HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://host/drives/create").build();
FN.bindToRequest(request, new CreateDriveRequest.Builder().name("foo").size(100l).build());
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN);
assertEquals(request.getPayload().getRawContent(), "name foo\nsize 100");
@ -78,7 +77,7 @@ public class BindDriveToPlainTextStringTest {
.use(ImmutableSet.of("tag1", "tag2"))//
.encryptionCipher("aes-xts-plain").avoid(ImmutableSet.of("avoid1")).build();
HttpRequest request = new HttpRequest("POST", URI.create("https://host/drives/create"));
HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://host/drives/create").build();
FN.bindToRequest(request, input);
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN);
assertEquals(request.getPayload().getRawContent(),

View File

@ -21,7 +21,6 @@ package org.jclouds.cloudsigma.binders;
import static org.testng.Assert.assertEquals;
import java.io.IOException;
import java.net.URI;
import java.util.Map;
import javax.ws.rs.core.MediaType;
@ -37,9 +36,9 @@ import org.jclouds.util.Strings2;
import org.testng.annotations.Test;
import com.google.common.base.Function;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.base.Throwables;
import com.google.inject.AbstractModule;
import com.google.inject.Guice;
import com.google.inject.TypeLiteral;
@ -83,7 +82,7 @@ public class BindServerToPlainTextStringTest {
}).getInstance(BindServerToPlainTextString.class);
public void testSimple() throws IOException {
HttpRequest request = new HttpRequest("POST", URI.create("https://host/drives/create"));
HttpRequest request = HttpRequest.builder().method("POST").endpoint("https://host/drives/create").build();
FN.bindToRequest(request, SERVER);
assertEquals(request.getPayload().getContentMetadata().getContentType(), MediaType.TEXT_PLAIN);
assertEquals(request.getPayload().getRawContent(), CREATED_SERVER);

View File

@ -21,7 +21,6 @@ package org.jclouds.cloudsigma.functions;
import static org.testng.Assert.assertEquals;
import org.jclouds.http.HttpResponse;
import org.jclouds.io.Payloads;
import org.testng.annotations.Test;
import com.google.inject.Guice;
@ -37,13 +36,13 @@ public class KeyValuesDelimitedByBlankLinesToDriveInfoTest {
KeyValuesDelimitedByBlankLinesToDriveInfo.class);
public void testNone() {
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload(""))), null);
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload("\n\n"))), null);
assertEquals(FN.apply(new HttpResponse(200, "", null)), null);
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), null);
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), null);
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), null);
}
public void testOne() {
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newInputStreamPayload(MapToDriveInfoTest.class
.getResourceAsStream("/drive.txt")))), MapToDriveInfoTest.ONE);
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToDriveInfoTest.class
.getResourceAsStream("/drive.txt")).build()), MapToDriveInfoTest.ONE);
}
}

View File

@ -21,7 +21,6 @@ package org.jclouds.cloudsigma.functions;
import static org.testng.Assert.assertEquals;
import org.jclouds.http.HttpResponse;
import org.jclouds.io.Payloads;
import org.testng.annotations.Test;
import com.google.inject.Guice;
@ -37,13 +36,13 @@ public class KeyValuesDelimitedByBlankLinesToProfileInfoTest {
KeyValuesDelimitedByBlankLinesToProfileInfo.class);
public void testNone() {
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload(""))), null);
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload("\n\n"))), null);
assertEquals(FN.apply(new HttpResponse(200, "", null)), null);
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), null);
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), null);
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), null);
}
public void testOne() {
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newInputStreamPayload(MapToProfileInfoTest.class
.getResourceAsStream("/profile.txt")))), MapToProfileInfoTest.ONE);
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToProfileInfoTest.class
.getResourceAsStream("/profile.txt")).build()), MapToProfileInfoTest.ONE);
}
}

View File

@ -29,7 +29,6 @@ import org.jclouds.cloudsigma.domain.NIC;
import org.jclouds.cloudsigma.domain.ServerMetrics;
import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId;
import org.jclouds.http.HttpResponse;
import org.jclouds.io.Payloads;
import org.testng.annotations.Test;
import com.google.common.base.Function;
@ -63,18 +62,18 @@ public class KeyValuesDelimitedByBlankLinesToServerInfoTest {
}).getInstance(KeyValuesDelimitedByBlankLinesToServerInfo.class);
public void testNone() {
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload(""))), null);
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload("\n\n"))), null);
assertEquals(FN.apply(new HttpResponse(200, "", null)), null);
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), null);
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), null);
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), null);
}
public void testOne() {
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newInputStreamPayload(MapToServerInfoTest.class
.getResourceAsStream("/servers.txt")))), MapToServerInfoTest.ONE);
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToServerInfoTest.class
.getResourceAsStream("/servers.txt")).build()), MapToServerInfoTest.ONE);
}
public void testNew() {
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newInputStreamPayload(MapToServerInfoTest.class
.getResourceAsStream("/new_server.txt")))), MapToServerInfoTest.NEW);
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToServerInfoTest.class
.getResourceAsStream("/new_server.txt")).build()), MapToServerInfoTest.NEW);
}
}

View File

@ -21,7 +21,6 @@ package org.jclouds.cloudsigma.functions;
import static org.testng.Assert.assertEquals;
import org.jclouds.http.HttpResponse;
import org.jclouds.io.Payloads;
import org.testng.annotations.Test;
import com.google.inject.Guice;
@ -37,13 +36,13 @@ public class KeyValuesDelimitedByBlankLinesToVLANInfoTest {
KeyValuesDelimitedByBlankLinesToVLANInfo.class);
public void testNone() {
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload(""))), null);
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload("\n\n"))), null);
assertEquals(FN.apply(new HttpResponse(200, "", null)), null);
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), null);
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), null);
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), null);
}
public void testOne() {
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newInputStreamPayload(MapToVLANInfoTest.class
.getResourceAsStream("/vlan.txt")))), MapToVLANInfoTest.ONE);
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToVLANInfoTest.class
.getResourceAsStream("/vlan.txt")).build()), MapToVLANInfoTest.ONE);
}
}

View File

@ -22,7 +22,6 @@ import static org.testng.Assert.assertEquals;
import org.jclouds.cloudsigma.domain.DriveInfo;
import org.jclouds.http.HttpResponse;
import org.jclouds.io.Payloads;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@ -39,13 +38,13 @@ public class ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSetTest {
ListOfKeyValuesDelimitedByBlankLinesToDriveInfoSet.class);
public void testNone() {
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload(""))), ImmutableSet.<DriveInfo> of());
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload("\n\n"))), ImmutableSet.<DriveInfo> of());
assertEquals(FN.apply(new HttpResponse(200, "", null)), ImmutableSet.<DriveInfo> of());
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), ImmutableSet.<DriveInfo> of());
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), ImmutableSet.<DriveInfo> of());
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), ImmutableSet.<DriveInfo> of());
}
public void testOne() {
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newInputStreamPayload(MapToDriveInfoTest.class
.getResourceAsStream("/drive.txt")))), ImmutableSet.<DriveInfo> of(MapToDriveInfoTest.ONE));
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToDriveInfoTest.class
.getResourceAsStream("/drive.txt")).build()), ImmutableSet.<DriveInfo> of(MapToDriveInfoTest.ONE));
}
}

View File

@ -30,7 +30,6 @@ import org.jclouds.cloudsigma.domain.ServerInfo;
import org.jclouds.cloudsigma.domain.ServerMetrics;
import org.jclouds.cloudsigma.functions.MapToDevices.DeviceToId;
import org.jclouds.http.HttpResponse;
import org.jclouds.io.Payloads;
import org.testng.annotations.Test;
import com.google.common.base.Function;
@ -66,15 +65,15 @@ public class ListOfKeyValuesDelimitedByBlankLinesToServerInfoSetTest {
}).getInstance(ListOfKeyValuesDelimitedByBlankLinesToServerInfoSet.class);
public void testNone() {
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload(""))), ImmutableSet.<ServerInfo> of());
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload("\n\n"))),
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), ImmutableSet.<ServerInfo> of());
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()),
ImmutableSet.<ServerInfo> of());
assertEquals(FN.apply(new HttpResponse(200, "", null)), ImmutableSet.<ServerInfo> of());
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), ImmutableSet.<ServerInfo> of());
}
public void testOne() {
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newInputStreamPayload(MapToServerInfoTest.class
.getResourceAsStream("/servers.txt")))), ImmutableSet.<ServerInfo> of(MapToServerInfoTest.ONE,
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToServerInfoTest.class
.getResourceAsStream("/servers.txt")).build()), ImmutableSet.<ServerInfo> of(MapToServerInfoTest.ONE,
MapToServerInfoTest.TWO));
}
}

View File

@ -22,7 +22,6 @@ import static org.testng.Assert.assertEquals;
import org.jclouds.cloudsigma.domain.VLANInfo;
import org.jclouds.http.HttpResponse;
import org.jclouds.io.Payloads;
import org.testng.annotations.Test;
import com.google.common.collect.ImmutableSet;
@ -39,13 +38,13 @@ public class ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSetTest {
ListOfKeyValuesDelimitedByBlankLinesToVLANInfoSet.class);
public void testNone() {
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload(""))), ImmutableSet.<VLANInfo> of());
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newStringPayload("\n\n"))), ImmutableSet.<VLANInfo> of());
assertEquals(FN.apply(new HttpResponse(200, "", null)), ImmutableSet.<VLANInfo> of());
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("").build()), ImmutableSet.<VLANInfo> of());
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload("\n\n").build()), ImmutableSet.<VLANInfo> of());
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").build()), ImmutableSet.<VLANInfo> of());
}
public void testOne() {
assertEquals(FN.apply(new HttpResponse(200, "", Payloads.newInputStreamPayload(MapToVLANInfoTest.class
.getResourceAsStream("/vlan.txt")))), ImmutableSet.<VLANInfo> of(MapToVLANInfoTest.ONE));
assertEquals(FN.apply(HttpResponse.builder().statusCode(200).message("").payload(MapToVLANInfoTest.class
.getResourceAsStream("/vlan.txt")).build()), ImmutableSet.<VLANInfo> of(MapToVLANInfoTest.ONE));
}
}

View File

@ -24,7 +24,6 @@ import java.io.InputStream;
import java.util.Set;
import org.jclouds.http.HttpResponse;
import org.jclouds.io.Payloads;
import org.testng.annotations.Test;
import com.google.common.base.Function;
@ -45,7 +44,7 @@ public class SplitNewlinesTest {
public void test() {
InputStream is = SplitNewlinesTest.class.getResourceAsStream("/uuids.txt");
Set<String> list = createParser().apply(new HttpResponse(200, "ok", Payloads.newInputStreamPayload(is)));
Set<String> list = createParser().apply(HttpResponse.builder().statusCode(200).message("ok").payload(is).build());
assertEquals(list, ImmutableSortedSet.of("7e8ab721-81c9-4cb9-a651-4cafbfe1501c",
"ea6a8fdb-dab3-4d06-86c2-41a5835e6ed9", "74744450-d338-4087-b3b8-59b505110a57"));
}

View File

@ -30,10 +30,8 @@ import org.easymock.IArgumentMatcher;
import org.jclouds.http.HttpCommand;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.HttpResponse;
import org.jclouds.io.Payloads;
import org.jclouds.rest.AuthorizationException;
import org.jclouds.rest.ResourceNotFoundException;
import org.jclouds.util.Strings2;
import org.testng.annotations.Test;
import com.google.inject.Guice;
@ -103,9 +101,8 @@ public class CloudSigmaErrorHandlerTest {
CloudSigmaErrorHandler function = Guice.createInjector().getInstance(CloudSigmaErrorHandler.class);
HttpCommand command = createMock(HttpCommand.class);
HttpRequest request = new HttpRequest(method, uri);
HttpResponse response = new HttpResponse(statusCode, message, Payloads.newInputStreamPayload(Strings2
.toInputStream(content)));
HttpRequest request = HttpRequest.builder().method(method).endpoint(uri).build();
HttpResponse response = HttpResponse.builder().statusCode(statusCode).message(message).payload(content).build();
response.getPayload().getContentMetadata().setContentType(contentType);
expect(command.getCurrentRequest()).andReturn(request).atLeastOnce();

View File

@ -29,7 +29,7 @@ import javax.inject.Singleton;
import javax.ws.rs.core.UriBuilder;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.utils.ModifyRequest;
import org.jclouds.http.utils.Queries;
import org.jclouds.rest.Binder;
import com.google.common.collect.ImmutableMultimap;
@ -58,12 +58,12 @@ public class BindAccountSecurityGroupPairsToIndexedQueryParams implements Binder
UriBuilder builder = uriBuilderProvider.get();
builder.uri(request.getEndpoint());
Builder<String, String> map = ImmutableMultimap.<String, String> builder().putAll(
ModifyRequest.parseQueryToMap(request.getEndpoint().getQuery()));
Queries.parseQueryToMap(request.getEndpoint().getQuery()));
int i = 0;
for (Entry<String, String> entry : pairs.entries())
map.put(String.format("usersecuritygrouplist[%d].account", i), entry.getKey()).put(
String.format("usersecuritygrouplist[%d].group", i++), entry.getValue());
builder.replaceQuery(ModifyRequest.makeQueryLine(map.build(), null));
builder.replaceQuery(Queries.makeQueryLine(map.build(), null));
return (R) request.toBuilder().endpoint(builder.build()).build();
}
}

View File

@ -21,13 +21,9 @@ package org.jclouds.cloudstack.binders;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import javax.ws.rs.core.UriBuilder;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.utils.ModifyRequest;
import org.jclouds.rest.Binder;
import com.google.common.base.Joiner;
@ -39,12 +35,6 @@ import com.google.common.collect.Iterables;
*/
@Singleton
public class BindCIDRsToCommaDelimitedQueryParam implements Binder {
private final Provider<UriBuilder> uriBuilderProvider;
@Inject
public BindCIDRsToCommaDelimitedQueryParam(Provider<UriBuilder> uriBuilderProvider) {
this.uriBuilderProvider = checkNotNull(uriBuilderProvider, "uriBuilderProvider");
}
@SuppressWarnings("unchecked")
@Override
@ -52,6 +42,6 @@ public class BindCIDRsToCommaDelimitedQueryParam implements Binder {
checkArgument(input instanceof Iterable<?>, "this binder is only valid for Iterables!");
Iterable<String> cidrs = (Iterable<String>) checkNotNull(input, "cidr list");
checkArgument(Iterables.size(cidrs) > 0, "you must specify at least one cidr range");
return ModifyRequest.addQueryParam(request, "cidrlist", Joiner.on(',').join(cidrs), uriBuilderProvider.get());
return (R) request.toBuilder().replaceQueryParam("cidrlist", Joiner.on(',').join(cidrs)).build();
}
}

View File

@ -21,13 +21,9 @@ package org.jclouds.cloudstack.binders;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import javax.ws.rs.core.UriBuilder;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.utils.ModifyRequest;
import org.jclouds.rest.Binder;
import com.google.common.base.Joiner;
@ -38,12 +34,6 @@ import com.google.common.collect.Iterables;
*/
@Singleton
public class BindIdListToCommaDelimitedQueryParam implements Binder {
private final Provider<UriBuilder> uriBuilderProvider;
@Inject
public BindIdListToCommaDelimitedQueryParam(Provider<UriBuilder> uriBuilderProvider) {
this.uriBuilderProvider = checkNotNull(uriBuilderProvider, "uriBuilderProvider");
}
@SuppressWarnings("unchecked")
@Override
@ -51,6 +41,6 @@ public class BindIdListToCommaDelimitedQueryParam implements Binder {
checkArgument(input instanceof Iterable<?>, "this binder is only valid for Iterables!");
Iterable<Long> numbers = (Iterable<Long>) checkNotNull(input, "list of Longs");
checkArgument(Iterables.size(numbers) > 0, "you must specify at least one element");
return ModifyRequest.addQueryParam(request, "ids", Joiner.on(',').join(numbers), uriBuilderProvider.get());
return (R) request.toBuilder().replaceQueryParam("ids", Joiner.on(',').join(numbers)).build();
}
}

View File

@ -19,37 +19,31 @@
package org.jclouds.cloudstack.binders;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.inject.Singleton;
import javax.ws.rs.core.UriBuilder;
import org.jclouds.cloudstack.domain.SnapshotPolicySchedule;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.utils.ModifyRequest;
import org.jclouds.rest.Binder;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableMultimap.Builder;
/**
*
* @author Adrian Cole
*/
@Singleton
public class BindSnapshotPolicyScheduleToQueryParam implements Binder {
private final Provider<UriBuilder> uriBuilderProvider;
@Inject
public BindSnapshotPolicyScheduleToQueryParam(Provider<UriBuilder> uriBuilderProvider) {
this.uriBuilderProvider = checkNotNull(uriBuilderProvider, "uriBuilderProvider");
}
@SuppressWarnings("unchecked")
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
checkArgument(input instanceof SnapshotPolicySchedule, "this binder is only valid for SnapshotPolicySchedule");
SnapshotPolicySchedule schedule = SnapshotPolicySchedule.class.cast(input);
R modifiedResult = ModifyRequest.addQueryParam(request, "intervaltype", schedule.getInterval(), uriBuilderProvider.get());
modifiedResult = ModifyRequest.addQueryParam(modifiedResult, "schedule", schedule.getTime(), uriBuilderProvider.get());
return modifiedResult;
Builder<String, String> builder = ImmutableMultimap.<String, String> builder();
builder.put("intervaltype", schedule.getInterval().toString());
builder.put("schedule", schedule.getTime().toString());
return (R) request.toBuilder().replaceQueryParams(builder.build()).build();
}
}

View File

@ -19,47 +19,40 @@
package org.jclouds.cloudstack.binders;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.ws.rs.core.UriBuilder;
import org.jclouds.cloudstack.domain.TemplateMetadata;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.utils.ModifyRequest;
import org.jclouds.rest.Binder;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableMultimap.Builder;
/**
* @author Richard Downer
*/
public class BindTemplateMetadataToQueryParams implements Binder {
private final Provider<UriBuilder> uriBuilderProvider;
@Inject
public BindTemplateMetadataToQueryParams(Provider<UriBuilder> uriBuilderProvider) {
this.uriBuilderProvider = checkNotNull(uriBuilderProvider, "uriBuilderProvider");
}
@SuppressWarnings("unchecked")
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
checkArgument(input instanceof TemplateMetadata, "this binder is only valid for TemplateMetadata");
TemplateMetadata metadata = (TemplateMetadata) input;
request = ModifyRequest.addQueryParam(request, "name", metadata.getName(), uriBuilderProvider.get());
request = ModifyRequest.addQueryParam(request, "ostypeid", metadata.getOsTypeId(), uriBuilderProvider.get());
request = ModifyRequest.addQueryParam(request, "displaytext", metadata.getDisplayText(), uriBuilderProvider.get());
Builder<String, String> builder = ImmutableMultimap.<String, String>builder();
builder.put("name", metadata.getName());
builder.put("ostypeid", metadata.getOsTypeId());
builder.put("displaytext", metadata.getDisplayText());
if (metadata.getSnapshotId() != null) {
request = ModifyRequest.addQueryParam(request, "snapshotid", metadata.getSnapshotId(), uriBuilderProvider.get());
builder.put("snapshotid", metadata.getSnapshotId());
}
if (metadata.getVolumeId() != null) {
request = ModifyRequest.addQueryParam(request, "volumeid", metadata.getVolumeId(), uriBuilderProvider.get());
builder.put("volumeid", metadata.getVolumeId());
}
if (metadata.getVirtualMachineId() != null) {
request = ModifyRequest.addQueryParam(request, "virtualmachineid", metadata.getVirtualMachineId(), uriBuilderProvider.get());
builder.put("virtualmachineid", metadata.getVirtualMachineId());
}
if (metadata.isPasswordEnabled() != null) {
request = ModifyRequest.addQueryParam(request, "passwordenabled", metadata.isPasswordEnabled(), uriBuilderProvider.get());
builder.put("passwordenabled", metadata.isPasswordEnabled().toString());
}
return request;
return (R) request.toBuilder().replaceQueryParams(builder.build()).build();
}
}

View File

@ -19,17 +19,14 @@
package org.jclouds.cloudstack.binders;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import javax.inject.Inject;
import javax.inject.Provider;
import javax.ws.rs.core.UriBuilder;
import org.jclouds.cloudstack.domain.ResourceLimit;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.utils.ModifyRequest;
import org.jclouds.rest.Binder;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.ImmutableMultimap.Builder;
/**
* @author Adrian Cole
*
@ -38,22 +35,17 @@ import org.jclouds.rest.Binder;
* />
*/
public class ResourceLimitToQueryParams implements Binder {
private final Provider<UriBuilder> uriBuilderProvider;
@Inject
public ResourceLimitToQueryParams(Provider<UriBuilder> uriBuilderProvider) {
this.uriBuilderProvider = checkNotNull(uriBuilderProvider, "uriBuilderProvider");
}
@SuppressWarnings("unchecked")
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
checkArgument(input instanceof ResourceLimit, "this binder is only valid for ResourceLimit");
ResourceLimit limit = (ResourceLimit) input;
request = ModifyRequest.addQueryParam(request, "resourcetype", limit.getResourceType().getCode(),
uriBuilderProvider.get());
request = ModifyRequest.addQueryParam(request, "account", limit.getAccount(), uriBuilderProvider.get());
request = ModifyRequest.addQueryParam(request, "domainid", limit.getDomainId(), uriBuilderProvider.get());
request = ModifyRequest.addQueryParam(request, "max", limit.getMax(), uriBuilderProvider.get());
return request;
Builder<String, String> builder = ImmutableMultimap.<String, String> builder();
builder.put("resourcetype", limit.getResourceType().getCode() + "");
builder.put("account", limit.getAccount());
builder.put("domainid", limit.getDomainId());
builder.put("max", limit.getMax() + "");
return (R) request.toBuilder().replaceQueryParams(builder.build()).build();
}
}

View File

@ -20,11 +20,10 @@ package org.jclouds.cloudstack.compute.strategy;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Predicates.and;
import static com.google.common.base.Predicates.not;
import static com.google.common.collect.Iterables.filter;
import static org.jclouds.cloudstack.predicates.NetworkPredicates.defaultNetworkInZone;
import static org.jclouds.cloudstack.predicates.NetworkPredicates.supportsStaticNAT;
import static org.jclouds.cloudstack.predicates.NetworkPredicates.isIsolatedNetwork;
import static org.jclouds.cloudstack.predicates.NetworkPredicates.supportsStaticNAT;
import java.util.Map;

View File

@ -1,296 +0,0 @@
/**
* Licensed to jclouds, Inc. (jclouds) under one or more
* contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. jclouds 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.cloudstack.config;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import javax.inject.Singleton;
import org.jclouds.cloudstack.domain.Account;
import org.jclouds.cloudstack.domain.FirewallRule;
import org.jclouds.cloudstack.domain.LoadBalancerRule;
import org.jclouds.cloudstack.domain.PortForwardingRule;
import org.jclouds.cloudstack.domain.User;
import org.jclouds.cloudstack.domain.Account.State;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Sets;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.annotations.SerializedName;
import com.google.inject.AbstractModule;
import com.google.inject.TypeLiteral;
/**
* Configures the cloudstack parsers.
*
* @author Adrian Cole, Andrei Savu
*/
public class CloudStackParserModule extends AbstractModule {
@Singleton
public static class PortForwardingRuleAdapter implements JsonSerializer<PortForwardingRule>, JsonDeserializer<PortForwardingRule> {
public JsonElement serialize(PortForwardingRule src, Type typeOfSrc, JsonSerializationContext context) {
return context.serialize(src);
}
public PortForwardingRule deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
return apply(context.<PortForwardingRuleInternal>deserialize(json, PortForwardingRuleInternal.class));
}
public PortForwardingRule apply(PortForwardingRuleInternal in) {
Set<String> cidrSet;
if (in.CIDRs != null) {
String[] elements = in.CIDRs.split(",");
cidrSet = Sets.newTreeSet(Arrays.asList(elements));
} else {
cidrSet = Collections.emptySet();
}
return PortForwardingRule.builder().id(in.id).IPAddress(in.IPAddress).IPAddressId(in.IPAddressId)
.privatePort(in.privatePort).protocol(in.protocol).publicPort(in.publicPort).state(in.state)
.virtualMachineDisplayName(in.virtualMachineDisplayName).virtualMachineId(in.virtualMachineId)
.virtualMachineName(in.virtualMachineName).CIDRs(cidrSet).privateEndPort(in.privateEndPort)
.publicEndPort(in.publicEndPort).build();
}
static final class PortForwardingRuleInternal {
private String id;
@SerializedName("ipaddress")
private String IPAddress;
@SerializedName("ipaddressid")
private String IPAddressId;
@SerializedName("privateport")
private int privatePort;
private PortForwardingRule.Protocol protocol;
@SerializedName("publicport")
public int publicPort;
private PortForwardingRule.State state;
@SerializedName("virtualmachinedisplayname")
private String virtualMachineDisplayName;
@SerializedName("virtualmachineid")
public String virtualMachineId;
@SerializedName("virtualmachinename")
private String virtualMachineName;
@SerializedName("cidrlist")
private String CIDRs;
@SerializedName("privateendport")
private int privateEndPort;
@SerializedName("publicendport")
private int publicEndPort;
}
}
@Singleton
public static class FirewallRuleAdapter implements JsonSerializer<FirewallRule>, JsonDeserializer<FirewallRule> {
public JsonElement serialize(FirewallRule src, Type typeOfSrc, JsonSerializationContext context) {
return context.serialize(src);
}
public FirewallRule deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
return apply(context.<FirewallRuleInternal>deserialize(json, FirewallRuleInternal.class));
}
public FirewallRule apply(FirewallRuleInternal in) {
Set<String> cidrSet;
if (in.CIDRs != null) {
String[] elements = in.CIDRs.split(",");
cidrSet = Sets.newTreeSet(Arrays.asList(elements));
} else {
cidrSet = Collections.emptySet();
}
return FirewallRule.builder().id(in.id).CIDRs(cidrSet).startPort(in.startPort).endPort(in.endPort)
.icmpCode(in.icmpCode).icmpType(in.icmpType).ipAddress(in.ipAddress).ipAddressId(in.ipAddressId)
.protocol(in.protocol).state(in.state).build();
}
static final class FirewallRuleInternal {
private String id;
@SerializedName("cidrlist")
private String CIDRs;
@SerializedName("startport")
private int startPort;
@SerializedName("endport")
private int endPort;
@SerializedName("icmpcode")
private String icmpCode;
@SerializedName("icmptype")
private String icmpType;
@SerializedName("ipaddress")
private String ipAddress;
@SerializedName("ipaddressid")
private String ipAddressId;
private FirewallRule.Protocol protocol;
private FirewallRule.State state;
}
}
@Singleton
public static class LoadBalancerRuleAdapter implements JsonSerializer<LoadBalancerRule>, JsonDeserializer<LoadBalancerRule> {
public JsonElement serialize(LoadBalancerRule src, Type typeOfSrc, JsonSerializationContext context) {
return context.serialize(src);
}
public LoadBalancerRule deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
return apply(context.<LoadBalancerRuleInternal>deserialize(json, LoadBalancerRuleInternal.class));
}
public LoadBalancerRule apply(LoadBalancerRuleInternal in) {
Set<String> cidrSet = Sets.newHashSet(in.CIDRs.split(","));
return LoadBalancerRule.builder().id(in.id).account(in.account).algorithm(in.algorithm)
.description(in.description).domain(in.domain).domainId(in.domainId).name(in.name)
.privatePort(in.privatePort).publicIP(in.publicIP).publicIPId(in.publicIPId)
.publicPort(in.publicPort).state(in.state).CIDRs(cidrSet).zoneId(in.zoneId).build();
}
static final class LoadBalancerRuleInternal {
private String id;
private String account;
private LoadBalancerRule.Algorithm algorithm;
private String description;
private String domain;
@SerializedName("domainid")
private String domainId;
private String name;
@SerializedName("privateport")
private int privatePort;
@SerializedName("publicip")
private String publicIP;
@SerializedName("publicipid")
private String publicIPId;
@SerializedName("publicport")
private int publicPort;
private LoadBalancerRule.State state;
@SerializedName("cidrlist")
private String CIDRs;
@SerializedName("zoneId")
private String zoneId;
}
}
@Singleton
public static class BreakGenericSetAdapter implements JsonSerializer<Account>, JsonDeserializer<Account> {
public JsonElement serialize(Account src, Type typeOfSrc, JsonSerializationContext context) {
return context.serialize(src);
}
public Account deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
throws JsonParseException {
return apply(context.<AccountInternal>deserialize(json, AccountInternal.class));
}
public Account apply(AccountInternal in) {
return Account.builder().id(in.id).type(in.type).domain(in.domain).domainId(in.domainId)
.IPsAvailable(nullIfUnlimited(in.IPsAvailable)).IPLimit(nullIfUnlimited(in.IPLimit)).IPs(in.IPs)
.cleanupRequired(in.cleanupRequired).name(in.name).receivedBytes(in.receivedBytes)
.sentBytes(in.sentBytes).snapshotsAvailable(nullIfUnlimited(in.snapshotsAvailable))
.snapshotLimit(nullIfUnlimited(in.snapshotLimit)).snapshots(in.snapshots).state(in.state)
.templatesAvailable(nullIfUnlimited(in.templatesAvailable))
.templateLimit(nullIfUnlimited(in.templateLimit)).templates(in.templates)
.VMsAvailable(nullIfUnlimited(in.VMsAvailable)).VMLimit(nullIfUnlimited(in.VMLimit))
.VMsRunning(in.VMsRunning).VMsStopped(in.VMsStopped).VMs(in.VMs)
.volumesAvailable(nullIfUnlimited(in.volumesAvailable)).volumeLimit(nullIfUnlimited(in.volumeLimit))
.volumes(in.volumes).users(in.users).build();
}
static final class AccountInternal {
private String id;
@SerializedName("accounttype")
private Account.Type type;
private String domain;
@SerializedName("domainid")
private String domainId;
@SerializedName("ipavailable")
private String IPsAvailable;
@SerializedName("iplimit")
private String IPLimit;
@SerializedName("iptotal")
private long IPs;
@SerializedName("iscleanuprequired")
private boolean cleanupRequired;
private String name;
@SerializedName("receivedbytes")
private long receivedBytes;
@SerializedName("sentbytes")
private long sentBytes;
@SerializedName("snapshotavailable")
private String snapshotsAvailable;
@SerializedName("snapshotlimit")
private String snapshotLimit;
@SerializedName("snapshottotal")
private long snapshots;
@SerializedName("state")
private State state;
@SerializedName("templateavailable")
private String templatesAvailable;
@SerializedName("templatelimit")
private String templateLimit;
@SerializedName("templatetotal")
private long templates;
@SerializedName("vmavailable")
private String VMsAvailable;
@SerializedName("vmlimit")
private String VMLimit;
@SerializedName("vmrunning")
private long VMsRunning;
@SerializedName("vmstopped")
private long VMsStopped;
@SerializedName("vmtotal")
private long VMs;
@SerializedName("volumeavailable")
private String volumesAvailable;
@SerializedName("volumelimit")
private String volumeLimit;
@SerializedName("volumetotal")
private long volumes;
@SerializedName("user")
private Set<User> users;
}
private static Long nullIfUnlimited(String in) {
return in == null || "Unlimited".equals(in) ? null : new Long(in);
}
}
@Override
protected void configure() {
bind(new TypeLiteral<Map<Type, Object>>() {
}).toInstance(ImmutableMap.<Type, Object>of(
Account.class, new BreakGenericSetAdapter(),
LoadBalancerRule.class, new LoadBalancerRuleAdapter(),
PortForwardingRule.class, new PortForwardingRuleAdapter(),
FirewallRule.class, new FirewallRuleAdapter()
));
}
}

View File

@ -33,86 +33,7 @@ import org.jclouds.cloudstack.CloudStackDomainClient;
import org.jclouds.cloudstack.CloudStackGlobalAsyncClient;
import org.jclouds.cloudstack.CloudStackGlobalClient;
import org.jclouds.cloudstack.domain.LoginResponse;
import org.jclouds.cloudstack.features.AccountAsyncClient;
import org.jclouds.cloudstack.features.AccountClient;
import org.jclouds.cloudstack.features.AddressAsyncClient;
import org.jclouds.cloudstack.features.AddressClient;
import org.jclouds.cloudstack.features.AsyncJobAsyncClient;
import org.jclouds.cloudstack.features.AsyncJobClient;
import org.jclouds.cloudstack.features.ConfigurationAsyncClient;
import org.jclouds.cloudstack.features.ConfigurationClient;
import org.jclouds.cloudstack.features.DomainAccountAsyncClient;
import org.jclouds.cloudstack.features.DomainAccountClient;
import org.jclouds.cloudstack.features.DomainDomainAsyncClient;
import org.jclouds.cloudstack.features.DomainDomainClient;
import org.jclouds.cloudstack.features.DomainLimitAsyncClient;
import org.jclouds.cloudstack.features.DomainLimitClient;
import org.jclouds.cloudstack.features.DomainUserAsyncClient;
import org.jclouds.cloudstack.features.DomainUserClient;
import org.jclouds.cloudstack.features.EventAsyncClient;
import org.jclouds.cloudstack.features.EventClient;
import org.jclouds.cloudstack.features.FirewallAsyncClient;
import org.jclouds.cloudstack.features.FirewallClient;
import org.jclouds.cloudstack.features.GlobalAccountAsyncClient;
import org.jclouds.cloudstack.features.GlobalAccountClient;
import org.jclouds.cloudstack.features.GlobalAlertAsyncClient;
import org.jclouds.cloudstack.features.GlobalAlertClient;
import org.jclouds.cloudstack.features.GlobalCapacityAsyncClient;
import org.jclouds.cloudstack.features.GlobalCapacityClient;
import org.jclouds.cloudstack.features.GlobalConfigurationAsyncClient;
import org.jclouds.cloudstack.features.GlobalConfigurationClient;
import org.jclouds.cloudstack.features.GlobalDomainAsyncClient;
import org.jclouds.cloudstack.features.GlobalDomainClient;
import org.jclouds.cloudstack.features.GlobalHostAsyncClient;
import org.jclouds.cloudstack.features.GlobalHostClient;
import org.jclouds.cloudstack.features.GlobalOfferingAsyncClient;
import org.jclouds.cloudstack.features.GlobalOfferingClient;
import org.jclouds.cloudstack.features.GlobalPodAsyncClient;
import org.jclouds.cloudstack.features.GlobalPodClient;
import org.jclouds.cloudstack.features.GlobalStoragePoolAsyncClient;
import org.jclouds.cloudstack.features.GlobalStoragePoolClient;
import org.jclouds.cloudstack.features.GlobalUsageAsyncClient;
import org.jclouds.cloudstack.features.GlobalUsageClient;
import org.jclouds.cloudstack.features.GlobalUserAsyncClient;
import org.jclouds.cloudstack.features.GlobalUserClient;
import org.jclouds.cloudstack.features.GlobalVlanAsyncClient;
import org.jclouds.cloudstack.features.GlobalVlanClient;
import org.jclouds.cloudstack.features.GlobalZoneAsyncClient;
import org.jclouds.cloudstack.features.GlobalZoneClient;
import org.jclouds.cloudstack.features.GuestOSAsyncClient;
import org.jclouds.cloudstack.features.GuestOSClient;
import org.jclouds.cloudstack.features.HypervisorAsyncClient;
import org.jclouds.cloudstack.features.HypervisorClient;
import org.jclouds.cloudstack.features.ISOAsyncClient;
import org.jclouds.cloudstack.features.ISOClient;
import org.jclouds.cloudstack.features.LimitAsyncClient;
import org.jclouds.cloudstack.features.LimitClient;
import org.jclouds.cloudstack.features.LoadBalancerAsyncClient;
import org.jclouds.cloudstack.features.LoadBalancerClient;
import org.jclouds.cloudstack.features.NATAsyncClient;
import org.jclouds.cloudstack.features.NATClient;
import org.jclouds.cloudstack.features.NetworkAsyncClient;
import org.jclouds.cloudstack.features.NetworkClient;
import org.jclouds.cloudstack.features.OfferingAsyncClient;
import org.jclouds.cloudstack.features.OfferingClient;
import org.jclouds.cloudstack.features.SSHKeyPairAsyncClient;
import org.jclouds.cloudstack.features.SSHKeyPairClient;
import org.jclouds.cloudstack.features.SecurityGroupAsyncClient;
import org.jclouds.cloudstack.features.SecurityGroupClient;
import org.jclouds.cloudstack.features.SessionAsyncClient;
import org.jclouds.cloudstack.features.SessionClient;
import org.jclouds.cloudstack.features.SnapshotAsyncClient;
import org.jclouds.cloudstack.features.SnapshotClient;
import org.jclouds.cloudstack.features.TemplateAsyncClient;
import org.jclouds.cloudstack.features.TemplateClient;
import org.jclouds.cloudstack.features.VMGroupAsyncClient;
import org.jclouds.cloudstack.features.VMGroupClient;
import org.jclouds.cloudstack.features.VirtualMachineAsyncClient;
import org.jclouds.cloudstack.features.VirtualMachineClient;
import org.jclouds.cloudstack.features.VolumeAsyncClient;
import org.jclouds.cloudstack.features.VolumeClient;
import org.jclouds.cloudstack.features.ZoneAsyncClient;
import org.jclouds.cloudstack.features.ZoneClient;
import org.jclouds.cloudstack.features.*;
import org.jclouds.cloudstack.filters.AddSessionKeyAndJSessionIdToRequest;
import org.jclouds.cloudstack.filters.AuthenticationFilter;
import org.jclouds.cloudstack.filters.QuerySigner;
@ -233,7 +154,6 @@ public class CloudStackRestClientModule extends RestClientModule<CloudStackClien
bind(new TypeLiteral<RestContext<CloudStackGlobalClient, CloudStackGlobalAsyncClient>>() {
}).to(new TypeLiteral<RestContextImpl<CloudStackGlobalClient, CloudStackGlobalAsyncClient>>() {
});
install(new CloudStackParserModule());
bind(CredentialType.class).toProvider(CredentialTypeFromPropertyOrDefault.class);
// session client is used directly for filters and retry handlers, so let's bind it explicitly

View File

@ -24,8 +24,6 @@ import java.beans.ConstructorProperties;
import java.util.Map;
import java.util.Set;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.CaseFormat;
@ -424,58 +422,60 @@ public class Account extends ForwardingSet<User> {
}
private final String id;
@Named("accounttype")
private final Account.Type type;
@Named("networkdomain")
private final String networkDomain;
private final String domain;
private final String domainId;
@Named("ipsavailable")
private final Long IPsAvailable;
@Named("iplimit")
private final Long IPLimit;
@Named("iptotal")
private final long IPs;
@Named("iscleanuprequired")
private final boolean cleanupRequired;
private final String name;
@Named("receivedbytes")
private final long receivedBytes;
@Named("sentbytes")
private final long sentBytes;
@Named("snapshotavailable")
private final Long snapshotsAvailable;
private final Long snapshotLimit;
@Named("snapshottotal")
private final long snapshots;
private final Account.State state;
@Named("templateavailable")
private final Long templatesAvailable;
@Named("templatelimit")
private final Long templateLimit;
@Named("templatetotal")
private final long templates;
@Named("vmavailable")
private final Long VMsAvailable;
@Named("vmlimit")
private final Long VMLimit;
@Named("vmrunning")
private final long VMsRunning;
@Named("vmstopped")
private final long VMsStopped;
@Named("vmtotal")
private final long VMs;
@Named("volumeavailable")
private final Long volumesAvailable;
@Named("volumelimit")
private final Long volumeLimit;
@Named("volumetotal")
private final long volumes;
private final Set<User> users;
@ConstructorProperties({
"id", "accounttype", "networkdomain", "domain", "domainId", "ipsavailable", "iplimit", "iptotal", "iscleanuprequired", "name", "receivedbytes", "sentbytes", "snapshotavailable", "snapshotLimit", "snapshottotal", "state", "templateavailable", "templatelimit", "templatetotal", "vmavailable", "vmlimit", "vmrunning", "vmstopped", "vmtotal", "volumeavailable", "volumelimit", "volumetotal", "users"
"id", "accounttype", "networkdomain", "domain", "domainid", "ipavailable", "iplimit", "iptotal", "iscleanuprequired",
"name", "receivedbytes", "sentbytes", "snapshotavailable", "snapshotlimit", "snapshottotal", "state", "templateavailable",
"templatelimit", "templatetotal", "vmavailable", "vmlimit", "vmrunning", "vmstopped", "vmtotal", "volumeavailable", "volumelimit",
"volumetotal", "user"
})
@SuppressWarnings("unused")
private Account(String id, @Nullable Type type, @Nullable String networkDomain, @Nullable String domain,
@Nullable String domainId, @Nullable String IPsAvailable, @Nullable String IPLimit, long IPs,
boolean cleanupRequired, @Nullable String name, long receivedBytes, long sentBytes,
@Nullable String snapshotsAvailable, @Nullable String snapshotLimit, long snapshots,
@Nullable State state, @Nullable String templatesAvailable, @Nullable String templateLimit,
long templates, @Nullable String VMsAvailable, @Nullable String VMLimit, long VMsRunning,
long VMsStopped, long VMs, @Nullable String volumesAvailable, @Nullable String volumeLimit,
long volumes, @Nullable Set<User> users) {
this(id, type, networkDomain, domain, domainId, toLongNullIfUnlimited(IPsAvailable), toLongNullIfUnlimited(IPLimit), IPs,
cleanupRequired, name, receivedBytes, sentBytes, toLongNullIfUnlimited(snapshotsAvailable), toLongNullIfUnlimited(snapshotLimit),
snapshots, state, toLongNullIfUnlimited(templatesAvailable), toLongNullIfUnlimited(templateLimit), templates,
toLongNullIfUnlimited(VMsAvailable), toLongNullIfUnlimited(VMLimit), VMsRunning, VMsStopped, VMs,
toLongNullIfUnlimited(volumesAvailable), toLongNullIfUnlimited(volumeLimit), volumes, users);
}
private static Long toLongNullIfUnlimited(String in) {
return in == null || "Unlimited".equals(in) ? null : new Long(in);
}
protected Account(String id, @Nullable Account.Type type, @Nullable String networkDomain, @Nullable String domain,
@Nullable String domainId, @Nullable Long IPsAvailable, @Nullable Long IPLimit, long IPs,
boolean cleanupRequired, @Nullable String name, long receivedBytes, long sentBytes, @Nullable Long snapshotsAvailable,
@ -554,7 +554,7 @@ public class Account extends ForwardingSet<User> {
/**
* @return the total number of public ip addresses available for this account
to acquire, or null if unlimited
* to acquire, or null if unlimited
*/
@Nullable
public Long getIPsAvailable() {
@ -563,7 +563,7 @@ public class Account extends ForwardingSet<User> {
/**
* @return the total number of public ip addresses this account can acquire,
or null if unlimited
* or null if unlimited
*/
@Nullable
public Long getIPLimit() {
@ -608,7 +608,7 @@ public class Account extends ForwardingSet<User> {
/**
* @return the total number of snapshots available for this account, or null
if unlimited
* if unlimited
*/
@Nullable
public Long getSnapshotsAvailable() {
@ -617,7 +617,7 @@ public class Account extends ForwardingSet<User> {
/**
* @return the total number of snapshots which can be stored by this account,
or null if unlimited
* or null if unlimited
*/
@Nullable
public Long getSnapshotLimit() {
@ -641,7 +641,7 @@ public class Account extends ForwardingSet<User> {
/**
* @return the total number of templates available to be created by this
account, or null if unlimited
* account, or null if unlimited
*/
@Nullable
public Long getTemplatesAvailable() {
@ -650,7 +650,7 @@ public class Account extends ForwardingSet<User> {
/**
* @return the total number of templates which can be created by this
account, or null if unlimited
* account, or null if unlimited
*/
@Nullable
public Long getTemplateLimit() {
@ -659,7 +659,7 @@ public class Account extends ForwardingSet<User> {
/**
* @return the total number of templates which have been created by this
account
* account
*/
public long getTemplates() {
return this.templates;
@ -667,7 +667,7 @@ public class Account extends ForwardingSet<User> {
/**
* @return the total number of virtual machines available for this account to
acquire, or null if unlimited
* acquire, or null if unlimited
*/
@Nullable
public Long getVMsAvailable() {
@ -676,7 +676,7 @@ public class Account extends ForwardingSet<User> {
/**
* @return the total number of virtual machines that can be deployed by this
account, or null if unlimited
* account, or null if unlimited
*/
@Nullable
public Long getVMLimit() {
@ -714,7 +714,7 @@ public class Account extends ForwardingSet<User> {
/**
* @return the total volume which can be used by this account, or null if
unlimited
* unlimited
*/
@Nullable
public Long getVolumeLimit() {

View File

@ -30,7 +30,7 @@ public enum AllocationState {
UNKNOWN;
public static AllocationState fromValue(String value) {
try{
try {
return valueOf(value.toUpperCase());
} catch (IllegalArgumentException e) {
return UNKNOWN;

View File

@ -20,8 +20,6 @@ package org.jclouds.cloudstack.domain;
import java.beans.ConstructorProperties;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -82,9 +80,7 @@ public class ApiKeyPair {
}
}
@Named("apikey")
private final String apiKey;
@Named("secretkey")
private final String secretKey;
@ConstructorProperties({

View File

@ -20,8 +20,6 @@ package org.jclouds.cloudstack.domain;
import java.beans.ConstructorProperties;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -84,7 +82,6 @@ public class AsyncCreateResponse {
}
private final String id;
@Named("jobid")
private final String jobId;
@ConstructorProperties({

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Date;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -41,9 +39,9 @@ public class AsyncJob<S> {
* Valid job result codes
*/
public static enum ResultCode {
SUCCESS (0),
FAIL (530),
UNKNOWN (-1);
SUCCESS(0),
FAIL(530),
UNKNOWN(-1);
private final int code;
@ -51,7 +49,9 @@ public class AsyncJob<S> {
this.code = code;
}
public int code() { return this.code; }
public int code() {
return this.code;
}
public static ResultCode fromValue(String value) {
try {
@ -64,7 +64,7 @@ public class AsyncJob<S> {
default:
return UNKNOWN;
}
} catch(NumberFormatException e) {
} catch (NumberFormatException e) {
return UNKNOWN;
}
}
@ -74,10 +74,10 @@ public class AsyncJob<S> {
* Valid async job statuses
*/
public static enum Status {
IN_PROGRESS (0),
SUCCEEDED (1),
FAILED (2),
UNKNOWN (-1);
IN_PROGRESS(0),
SUCCEEDED(1),
FAILED(2),
UNKNOWN(-1);
private final int code;
@ -85,7 +85,9 @@ public class AsyncJob<S> {
this.code = code;
}
public int code() { return this.code; }
public int code() {
return this.code;
}
public static Status fromValue(String value) {
try {
@ -106,7 +108,7 @@ public class AsyncJob<S> {
}
}
public static <T> Builder<?,T> builder() {
public static <T> Builder<?, T> builder() {
return new ConcreteBuilder<T>();
}
@ -114,7 +116,7 @@ public class AsyncJob<S> {
return new ConcreteBuilder<S>().fromAsyncJob(this);
}
public static abstract class Builder<T extends Builder<T,S>, S> {
public static abstract class Builder<T extends Builder<T, S>, S> {
protected abstract T self();
protected String accountId;
@ -262,34 +264,24 @@ public class AsyncJob<S> {
}
}
private static class ConcreteBuilder<T> extends Builder<ConcreteBuilder<T>,T> {
private static class ConcreteBuilder<T> extends Builder<ConcreteBuilder<T>, T> {
@Override
protected ConcreteBuilder<T> self() {
return this;
}
}
@Named("accountid")
private final String accountId;
private final String cmd;
private final Date created;
@Named("jobid")
private final String id;
@Named("jobinstanceid")
private final String instanceId;
@Named("jobinstancetype")
private final String instanceType;
@Named("jobprocstatus")
private final int progress;
@Named("jobresult")
private final S result;
@Named("jobresultcode")
private final AsyncJob.ResultCode resultCode;
@Named("jobresulttype")
private final String resultType;
@Named("jobstatus")
private final AsyncJob.Status status;
@Named("userid")
private final String userId;
private final AsyncJobError error;
@ -412,7 +404,7 @@ public class AsyncJob<S> {
/**
* @return the error related to this command, or null if no error or error
not yet encountered.
* not yet encountered.
*/
@Nullable
public AsyncJobError getError() {

View File

@ -20,15 +20,12 @@ package org.jclouds.cloudstack.domain;
import java.beans.ConstructorProperties;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
/**
*
* @author Adrian Cole
*/
public class AsyncJobError {
@ -37,15 +34,15 @@ public class AsyncJobError {
* Error codes for job errors
*/
public static enum ErrorCode {
INTERNAL_ERROR (530),
ACCOUNT_ERROR (531),
INTERNAL_ERROR(530),
ACCOUNT_ERROR(531),
ACCOUNT_RESOURCE_LIMIT_ERROR(532),
INSUFFICIENT_CAPACITY_ERROR (533),
RESOURCE_UNAVAILABLE_ERROR (534),
RESOURCE_ALLOCATION_ERROR (535),
RESOURCE_IN_USE_ERROR (536),
NETWORK_RULE_CONFLICT_ERROR (537),
UNKNOWN (-1);
INSUFFICIENT_CAPACITY_ERROR(533),
RESOURCE_UNAVAILABLE_ERROR(534),
RESOURCE_ALLOCATION_ERROR(535),
RESOURCE_IN_USE_ERROR(536),
NETWORK_RULE_CONFLICT_ERROR(537),
UNKNOWN(-1);
private final int code;
@ -53,19 +50,21 @@ public class AsyncJobError {
this.code = code;
}
public int code() { return this.code; }
public int code() {
return this.code;
}
public static ErrorCode fromValue(String value) {
try {
int errorCode = Integer.parseInt(value);
for(ErrorCode candidate : values()) {
for (ErrorCode candidate : values()) {
if (candidate.code() == errorCode) {
return candidate;
}
}
return UNKNOWN;
} catch(NumberFormatException e) {
} catch (NumberFormatException e) {
return UNKNOWN;
}
}
@ -119,9 +118,7 @@ public class AsyncJobError {
}
}
@Named("errorcode")
private final ErrorCode errorCode;
@Named("errortext")
private final String errorText;
@ConstructorProperties({

View File

@ -20,8 +20,6 @@ package org.jclouds.cloudstack.domain;
import java.beans.ConstructorProperties;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -112,11 +110,8 @@ public class Capabilities {
}
}
@Named("cloudstackversion")
private final String cloudStackVersion;
@Named("securitygroupsenabled")
private final boolean securityGroupsEnabled;
@Named("userpublictemplateenabled")
private final boolean canShareTemplates;
private final boolean firewallRuleUiEnabled;
private final boolean supportELB;

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Map;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Function;
@ -190,20 +188,13 @@ public class Capacity implements Comparable<Capacity> {
}
}
@Named("capacitytotal")
private final long capacityTotal;
@Named("capacityused")
private final long capacityUsed;
@Named("percentused")
private final double percentUsed;
@Named("podid")
private final String podId;
@Named("podname")
private final String podName;
private final Capacity.Type type;
@Named("zoneid")
private final String zoneId;
@Named("zonename")
private final String zoneName;
@ConstructorProperties({

View File

@ -24,8 +24,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -48,7 +46,7 @@ public class Cluster implements Comparable<Cluster> {
UNRECOGNIZED;
public static ManagedState fromValue(String value) {
try{
try {
return valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, value));
} catch (IllegalArgumentException e) {
return UNRECOGNIZED;
@ -190,22 +188,14 @@ public class Cluster implements Comparable<Cluster> {
}
private final String id;
@Named("allocationstate")
private final AllocationState allocationState;
@Named("clustertype")
private final Host.ClusterType clusterType;
@Named("hypervisortype")
private final String hypervisor;
@Named("managedstate")
private final Cluster.ManagedState managedState;
private final String name;
@Named("podid")
private final String podId;
@Named("podname")
private final String podName;
@Named("zoneid")
private final String zoneId;
@Named("zonename")
private final String zoneName;
@ConstructorProperties({

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Date;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -157,15 +155,11 @@ public class DiskOffering implements Comparable<DiskOffering> {
private final String id;
private final String name;
@Named("displaytext")
private final String displayText;
private final Date created;
private final String domain;
@Named("domainid")
private final String domainId;
@Named("disksize")
private final int diskSize;
@Named("iscustomized")
private final boolean customized;
private final String tags;

View File

@ -22,8 +22,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -135,15 +133,11 @@ public class Domain implements Comparable<Domain> {
}
private final String id;
@Named("haschild")
private final boolean hasChild;
private final long level;
private final String name;
@Named("networkdomain")
private final String networkDomain;
@Named("parentdomainid")
private final String parentDomainId;
@Named("parentdomainname")
private final String parentDomainName;
@ConstructorProperties({

View File

@ -213,7 +213,7 @@ public class Event implements Comparable<Event> {
/**
* @return the account name for the account that owns the object being acted on in the event
(e.g. the owner of the virtual machine, ip address, or security group)
* (e.g. the owner of the virtual machine, ip address, or security group)
*/
@Nullable
public String getAccount() {
@ -286,7 +286,7 @@ public class Event implements Comparable<Event> {
/**
* @return the name of the user who performed the action (can be different from the account if
an admin is performing an action for a user, e.g. starting/stopping a user's virtual machine)
* an admin is performing an action for a user, e.g. starting/stopping a user's virtual machine)
*/
@Nullable
public String getUsername() {

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Set;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.CaseFormat;
@ -50,7 +48,7 @@ public class FirewallRule implements Comparable<FirewallRule> {
public static Protocol fromValue(String value) {
try {
return valueOf(value.toUpperCase());
} catch(IllegalArgumentException e) {
} catch (IllegalArgumentException e) {
return UNKNOWN;
}
}
@ -73,7 +71,7 @@ public class FirewallRule implements Comparable<FirewallRule> {
public static State fromValue(String value) {
try {
return valueOf(value.toUpperCase());
} catch(IllegalArgumentException e) {
} catch (IllegalArgumentException e) {
return UNKNOWN;
}
}
@ -217,19 +215,12 @@ public class FirewallRule implements Comparable<FirewallRule> {
}
private final String id;
@Named("cidrlist")
private final Set<String> CIDRs;
@Named("startport")
private final int startPort;
@Named("endport")
private final int endPort;
@Named("icmpcode")
private final String icmpCode;
@Named("icmptype")
private final String icmpType;
@Named("ipaddress")
private final String ipAddress;
@Named("ipaddressid")
private final String ipAddressId;
private final FirewallRule.Protocol protocol;
private final FirewallRule.State state;
@ -237,7 +228,19 @@ public class FirewallRule implements Comparable<FirewallRule> {
@ConstructorProperties({
"id", "cidrlist", "startport", "endport", "icmpcode", "icmptype", "ipaddress", "ipaddressid", "protocol", "state"
})
protected FirewallRule(String id, @Nullable Set<String> CIDRs, int startPort, int endPort, @Nullable String icmpCode,
@SuppressWarnings("unused")
private FirewallRule(String id, @Nullable String CIDRs, int startPort, int endPort, @Nullable String icmpCode,
@Nullable String icmpType, @Nullable String ipAddress, @Nullable String ipAddressId,
@Nullable Protocol protocol, @Nullable State state) {
this(id, splitStringOnCommas(CIDRs), startPort, endPort, icmpCode, icmpType, ipAddress, ipAddressId, protocol, state);
}
private static Set<String> splitStringOnCommas(String in) {
return in == null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(in.split(","));
}
protected FirewallRule(String id, @Nullable Iterable<String> CIDRs, int startPort, int endPort, @Nullable String icmpCode,
@Nullable String icmpType, @Nullable String ipAddress, @Nullable String ipAddressId,
@Nullable FirewallRule.Protocol protocol, @Nullable FirewallRule.State state) {
this.id = checkNotNull(id, "id");

View File

@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.CaseFormat;
/**
*
* @author Adrian Cole
* @see org.jclouds.cloudstack.features.OfferingClient#listNetworkOfferings
*/

View File

@ -25,8 +25,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Date;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -75,7 +73,7 @@ public class Host implements Comparable<Host> {
public static State fromValue(String value) {
try {
return valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, value));
} catch(IllegalArgumentException e) {
} catch (IllegalArgumentException e) {
return UNKNOWN;
}
}
@ -108,7 +106,7 @@ public class Host implements Comparable<Host> {
}
return valueOf(UPPER_CAMEL.to(UPPER_UNDERSCORE, value));
} catch(IllegalArgumentException e) {
} catch (IllegalArgumentException e) {
return UNKNOWN;
}
}
@ -572,77 +570,46 @@ public class Host implements Comparable<Host> {
}
private final String id;
@Named("allocationstate")
private final AllocationState allocationState;
@Named("averageload")
private final int averageLoad;
private final String capabilities;
@Named("clusterid")
private final String clusterId;
@Named("clustername")
private final String clusterName;
@Named("clustertype")
private final Host.ClusterType clusterType;
@Named("cpuallocated")
private final String cpuAllocated;
@Named("cpunumber")
private final int cpuNumber;
@Named("cpuspeed")
private final int cpuSpeed;
@Named("cpuused")
private final String cpuUsed;
@Named("cpuwithoverprovisioning")
private final float cpuWithOverProvisioning;
private final Date created;
private final Date disconnected;
@Named("disksizeallocated")
private final long diskSizeAllocated;
@Named("disksizetotal")
private final long diskSizeTotal;
private final String events;
@Named("hasenoughcapacity")
private final boolean hasEnoughCapacity;
@Named("hosttags")
private final String hostTags;
private final String hypervisor;
@Named("ipaddress")
private final String ipAddress;
@Named("islocalstorageactive")
private final boolean localStorageActive;
@Named("jobid")
private final String jobId;
@Named("jobstatus")
private final AsyncJob.Status jobStatus;
@Named("lastpinged")
private final Date lastPinged;
@Named("managementserverid")
private final String managementServerId;
@Named("memoryallocated")
private final long memoryAllocated;
@Named("memorytotal")
private final long memoryTotal;
@Named("memoryused")
private final long memoryUsed;
private final String name;
@Named("networkkbsread")
private final long networkKbsRead;
@Named("networkkbswrite")
private final long networkKbsWrite;
@Named("oscategoryid")
private final String osCategoryId;
@Named("oscategoryname")
private final String osCategoryName;
@Named("podid")
private final String podId;
@Named("podname")
private final String podName;
private final Date removed;
private final Host.State state;
private final Host.Type type;
private final String version;
@Named("zoneid")
private final String zoneId;
@Named("zonename")
private final String zoneName;
@ConstructorProperties({

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Set;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -35,7 +33,7 @@ import com.google.common.collect.ImmutableSet;
* Class IPForwardingRule
*
* @author Adrian Cole
*/
*/
public class IPForwardingRule implements Comparable<IPForwardingRule> {
public static Builder<?> builder() {
@ -212,29 +210,18 @@ public class IPForwardingRule implements Comparable<IPForwardingRule> {
}
private final String id;
@Named("ipaddress")
private final String IPAddress;
@Named("ipaddressid")
private final String IPAddressId;
@Named("startport")
private final int startPort;
private final String protocol;
@Named("endport")
private final int endPort;
private final String state;
@Named("virtualmachinedisplayname")
private final String virtualMachineDisplayName;
@Named("virtualmachineid")
private final String virtualMachineId;
@Named("virtualmachinename")
private final String virtualMachineName;
@Named("publicport")
private final int publicPort;
@Named("cidrlist")
private final Set<String> CIDRs;
@Named("privateendport")
private final int privateEndPort;
@Named("publicendport")
private final int publicEndPort;
@ConstructorProperties({

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Date;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -34,7 +32,7 @@ import com.google.common.base.Objects.ToStringHelper;
* Class ISO
*
* @author Richard Downer
*/
*/
public class ISO {
/**
@ -405,54 +403,35 @@ public class ISO {
private final String id;
private final String account;
@Named("accountid")
private final String accountId;
private final boolean bootable;
private final String checksum;
private final Date created;
private final boolean crossZones;
@Named("displaytext")
private final String displayText;
private final String domain;
@Named("domainId")
private final String domainid;
private final String format;
@Named("hostid")
private final String hostId;
@Named("hostname")
private final String hostName;
private final String hypervisor;
@Named("isextractable")
private final boolean isExtractable;
@Named("isfeatured")
private final boolean isFeatured;
@Named("ispublic")
private final boolean isPublic;
@Named("isready")
private final boolean isReady;
@Named("jobid")
private final String jobId;
@Named("jobstatus")
private final String jobStatus;
private final String name;
@Named("ostypeid")
private final String osTypeId;
@Named("ostypename")
private final String osTypeName;
@Named("passwordenabled")
private final boolean passwordEnabled;
private final Date removed;
private final long size;
@Named("sourcetemplateid")
private final String sourceTemplateId;
private final String status;
@Named("templatetag")
private final String templateTag;
@Named("templatetype")
private final String templateType;
@Named("zoneid")
private final String zoneId;
@Named("zonename")
private final String zoneName;
@ConstructorProperties({

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Date;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -34,7 +32,7 @@ import com.google.common.base.Objects.ToStringHelper;
* Class ISOExtraction
*
* @author Richard Downer
*/
*/
public class ISOExtraction {
public static Builder<?> builder() {
@ -196,7 +194,6 @@ public class ISOExtraction {
}
private final String id;
@Named("accountid")
private final String accountId;
private final Date created;
private final String extractId;
@ -204,14 +201,10 @@ public class ISOExtraction {
private final String name;
private final String state;
private final String status;
@Named("storagetype")
private final String storageType;
@Named("uploadpercentage")
private final int uploadPercentage;
private final String url;
@Named("zoneid")
private final String zoneId;
@Named("zonename")
private final String zoneName;
@ConstructorProperties({

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Set;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -35,7 +33,7 @@ import com.google.common.collect.ImmutableSet;
* Class ISOPermissions
*
* @author Richard Downer
*/
*/
public class ISOPermissions {
public static Builder<?> builder() {
@ -111,11 +109,8 @@ public class ISOPermissions {
}
private final String id;
@Named("account")
private final Set<String> accounts;
@Named("domainid")
private final String domainId;
@Named("ispublic")
private final boolean isPublic;
@ConstructorProperties({

View File

@ -22,17 +22,14 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
import com.google.common.base.Objects.ToStringHelper;
/**
*
* @author Adrian Cole
*/
*/
public class IngressRule implements Comparable<IngressRule> {
public static Builder<?> builder() {
@ -154,20 +151,13 @@ public class IngressRule implements Comparable<IngressRule> {
}
private final String account;
@Named("cidr")
private final String CIDR;
@Named("endport")
private final int endPort;
@Named("icmpcode")
private final int ICMPCode;
@Named("icmptype")
private final int ICMPType;
private final String protocol;
@Named("ruleid")
private final String id;
@Named("securitygroupname")
private final String securityGroupName;
@Named("startport")
private final int startPort;
@ConstructorProperties({

View File

@ -20,8 +20,6 @@ package org.jclouds.cloudstack.domain;
import java.beans.ConstructorProperties;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -29,12 +27,12 @@ import com.google.common.base.Objects.ToStringHelper;
/**
* The result of an operation.
*
* <p/>
* A handful of Cloudstack API calls return this structure when there is no domain model data to return - for example,
* when deleting an object.
*
* @author Richard Downer
*/
*/
public class JobResult {
public static Builder<?> builder() {
@ -86,7 +84,6 @@ public class JobResult {
}
private final boolean success;
@Named("displaytext")
private final String displayText;
@ConstructorProperties({

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Set;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.CaseFormat;
@ -36,7 +34,7 @@ import com.google.common.collect.ImmutableSet;
* Class LoadBalancerRule
*
* @author Adrian Cole
*/
*/
public class LoadBalancerRule {
/**
@ -254,29 +252,39 @@ public class LoadBalancerRule {
private final LoadBalancerRule.Algorithm algorithm;
private final String description;
private final String domain;
@Named("domainid")
private final String domainId;
private final String name;
@Named("privateport")
private final int privatePort;
@Named("publicip")
private final String publicIP;
@Named("publicipid")
private final String publicIPId;
@Named("publicport")
private final int publicPort;
private final LoadBalancerRule.State state;
@Named("cidrlist")
private final Set<String> CIDRs;
private final String zoneId;
@ConstructorProperties({
"id", "account", "algorithm", "description", "domain", "domainid", "name", "privateport", "publicip", "publicipid", "publicport", "state", "cidrlist", "zoneId"
"id", "account", "algorithm", "description", "domain", "domainid", "name", "privateport", "publicip",
"publicipid", "publicport", "state", "cidrlist", "zoneId"
})
@SuppressWarnings("unused")
private LoadBalancerRule(String id, @Nullable String account, @Nullable Algorithm algorithm,
@Nullable String description, @Nullable String domain, @Nullable String domainId,
@Nullable String name, int privatePort, @Nullable String publicIP,
@Nullable String publicIPId, int publicPort, @Nullable State state,
@Nullable String CIDRs, @Nullable String zoneId) {
this(id, account, algorithm, description, domain, domainId, name, privatePort, publicIP, publicIPId, publicPort, state,
splitStringOnCommas(CIDRs), zoneId);
}
private static Set<String> splitStringOnCommas(String in) {
return in == null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(in.split(","));
}
protected LoadBalancerRule(String id, @Nullable String account, @Nullable LoadBalancerRule.Algorithm algorithm,
@Nullable String description, @Nullable String domain, @Nullable String domainId, @Nullable String name,
int privatePort, @Nullable String publicIP, @Nullable String publicIPId, int publicPort,
@Nullable LoadBalancerRule.State state, @Nullable Set<String> CIDRs, @Nullable String zoneId) {
@Nullable LoadBalancerRule.State state, @Nullable Iterable<String> CIDRs, @Nullable String zoneId) {
this.id = checkNotNull(id, "id");
this.account = account;
this.algorithm = algorithm;

View File

@ -20,8 +20,6 @@ package org.jclouds.cloudstack.domain;
import java.beans.ConstructorProperties;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -31,7 +29,7 @@ import com.google.common.base.Objects.ToStringHelper;
* Representation of the login API call response
*
* @author Andrei Savu
*/
*/
public class LoginResponse {
public static Builder<?> builder() {
@ -203,25 +201,17 @@ public class LoginResponse {
}
private final String username;
@Named("userid")
private final String userId;
private final String password;
@Named("domainid")
private final String domainId;
private final long timeout;
private final boolean registered;
@Named("account")
private final String accountName;
@Named("firstname")
private final String firstName;
@Named("lastname")
private final String lastName;
@Named("type")
private final Account.Type accountType;
private final String timezone;
@Named("timezoneoffset")
private final String timezoneOffset;
@Named("sessionkey")
private final String sessionKey;
private final String jSessionId;

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.net.URI;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -34,7 +32,7 @@ import com.google.common.base.Objects.ToStringHelper;
* Class NIC
*
* @author Adrian Cole
*/
*/
public class NIC {
public static Builder<?> builder() {
@ -176,23 +174,15 @@ public class NIC {
}
private final String id;
@Named("broadcasturi")
private final URI broadcastURI;
private final String gateway;
@Named("ipaddress")
private final String IPAddress;
@Named("isdefault")
private final boolean isDefault;
@Named("isolationuri")
private final URI isolationURI;
private final String netmask;
@Named("macaddress")
private final String macAddress;
@Named("networkid")
private final String networkId;
@Named("traffictype")
private final TrafficType trafficType;
@Named("type")
private final GuestIPType guestIPType;
@ConstructorProperties({

View File

@ -25,8 +25,6 @@ import java.net.URI;
import java.util.List;
import java.util.Set;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -38,7 +36,7 @@ import com.google.common.collect.ImmutableSortedSet;
* Class Network
*
* @author Adrian Cole
*/
*/
public class Network {
public static Builder<?> builder() {
@ -132,6 +130,7 @@ public class Network {
if (DNS.size() > 1) this.DNS2 = DNS.get(1);
return self();
}
/**
* @see Network#getDomain()
*/
@ -372,56 +371,34 @@ public class Network {
private final String id;
private final String account;
@Named("broadcastdomaintype")
private final String broadcastDomainType;
@Named("broadcasturi")
private final URI broadcastURI;
@Named("displaytext")
private final String displayText;
@Named("dns1")
private final String DNS1;
@Named("dns2")
private final String DNS2;
private final String domain;
@Named("domainid")
private final String domainId;
@Named("endip")
private final String endIP;
private final String gateway;
@Named("isdefault")
private final boolean isDefault;
@Named("isshared")
private final boolean isShared;
@Named("issystem")
private final boolean isSystem;
private final String netmask;
@Named("networkdomain")
private final String networkDomain;
@Named("networkofferingavailability")
private final String networkOfferingAvailability;
@Named("networkofferingdisplaytext")
private final String networkOfferingDisplayText;
@Named("networkofferingid")
private final String networkOfferingId;
@Named("networkofferingname")
private final String networkOfferingName;
private final String related;
@Named("startip")
private final String startIP;
private final String name;
private final String state;
@Named("type")
private final GuestIPType guestIPType;
@Named("vlan")
private final String VLAN;
@Named("traffictype")
private final TrafficType trafficType;
@Named("zoneid")
private final String zoneId;
private final String tags;
@Named("securitygroupenabled")
private final boolean securityGroupEnabled;
@Named("service")
private final Set<? extends NetworkService> services;
@ConstructorProperties({

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Date;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -34,7 +32,7 @@ import com.google.common.base.Objects.ToStringHelper;
* Class NetworkOffering
*
* @author Adrian Cole
*/
*/
public class NetworkOffering implements Comparable<NetworkOffering> {
public static Builder<?> builder() {
@ -187,21 +185,14 @@ public class NetworkOffering implements Comparable<NetworkOffering> {
private final String id;
private final String name;
@Named("displaytext")
private final String displayText;
private final Date created;
private final NetworkOfferingAvailabilityType availability;
@Named("maxconnections")
private final Integer maxConnections;
@Named("isdefault")
private final boolean isDefault;
@Named("specifyvlan")
private final boolean supportsVLAN;
@Named("traffictype")
private final TrafficType trafficType;
@Named("guestiptype")
private final GuestIPType guestIPType;
@Named("networkrate")
private final int networkRate;
private final String tags;
@ -264,7 +255,7 @@ public class NetworkOffering implements Comparable<NetworkOffering> {
/**
* @return the max number of concurrent connection the network offering
supports
* supports
*/
@Nullable
public Integer getMaxConnections() {

View File

@ -23,7 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.CaseFormat;
/**
*
* @author Andrei Savu
*/
public enum NetworkOfferingAvailabilityType {

View File

@ -24,8 +24,6 @@ import java.beans.ConstructorProperties;
import java.util.Map;
import java.util.Set;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -194,7 +192,6 @@ public class NetworkService implements Comparable<NetworkService> {
}
private final String name;
@Named("capability")
private final Set<Capability> capabilities;
@ConstructorProperties({

View File

@ -25,7 +25,6 @@ import org.jclouds.cloudstack.features.TemplateClient;
import com.google.common.base.CaseFormat;
/**
*
* @author Adrian Cole
* @see TemplateClient#listZones
*/

View File

@ -22,8 +22,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -95,7 +93,6 @@ public class OSType implements Comparable<OSType> {
}
private final String id;
@Named("oscategoryid")
private final String OSCategoryId;
private final String description;

View File

@ -22,8 +22,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -33,7 +31,7 @@ import com.google.common.base.Objects.ToStringHelper;
* Represents a Pod in CloudStack.
*
* @author Richard Downer
*/
*/
public class Pod implements Comparable<Pod> {
public static Builder<?> builder() {
@ -156,17 +154,12 @@ public class Pod implements Comparable<Pod> {
private final String id;
private final String name;
@Named("zoneid")
private final String zoneId;
@Named("zonename")
private final String zoneName;
private final String gateway;
private final String netmask;
@Named("startip")
private final String startIp;
@Named("endip")
private final String endIp;
@Named("allocationstate")
private final AllocationState allocationState;
@ConstructorProperties({

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Set;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.CaseFormat;
@ -36,7 +34,7 @@ import com.google.common.collect.ImmutableSet;
* Class PortForwardingRule
*
* @author Adrian Cole, Andrei Savu
*/
*/
public class PortForwardingRule implements Comparable<PortForwardingRule> {
public static enum Protocol {
@ -246,33 +244,36 @@ public class PortForwardingRule implements Comparable<PortForwardingRule> {
}
private final String id;
@Named("ipaddress")
private final String IPAddress;
@Named("ipaddressid")
private final String IPAddressId;
@Named("privateport")
private final int privatePort;
private final PortForwardingRule.Protocol protocol;
@Named("publicport")
private final int publicPort;
private final PortForwardingRule.State state;
@Named("virtualmachinedisplayname")
private final String virtualMachineDisplayName;
@Named("virtualmachineid")
private final String virtualMachineId;
@Named("virtualmachinename")
private final String virtualMachineName;
@Named("cidrlist")
private final Set<String> CIDRs;
@Named("privateendport")
private final int privateEndPort;
@Named("publicendport")
private final int publicEndPort;
@ConstructorProperties({
"id", "ipaddress", "ipaddressid", "privateport", "protocol", "publicport", "state", "virtualmachinedisplayname",
"virtualmachineid", "virtualmachinename", "cidrlist", "privateendport", "publicendport"
})
@SuppressWarnings("unused")
private PortForwardingRule(String id, @Nullable String IPAddress, @Nullable String IPAddressId, int privatePort,
@Nullable Protocol protocol, int publicPort, @Nullable State state, @Nullable String virtualMachineDisplayName,
@Nullable String virtualMachineId, @Nullable String virtualMachineName, @Nullable String CIDRs,
int privateEndPort, int publicEndPort) {
this(id, IPAddress, IPAddressId, privatePort, protocol, publicPort, state, virtualMachineDisplayName, virtualMachineId,
virtualMachineName, splitStringOnCommas(CIDRs), privateEndPort, publicEndPort);
}
private static Set<String> splitStringOnCommas(String in) {
return in == null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(in.split(","));
}
protected PortForwardingRule(String id, @Nullable String IPAddress, @Nullable String IPAddressId, int privatePort,
@Nullable Protocol protocol, int publicPort, @Nullable State state,
@Nullable String virtualMachineDisplayName, @Nullable String virtualMachineId,

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Date;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.CaseFormat;
@ -35,7 +33,7 @@ import com.google.common.base.Objects.ToStringHelper;
* Class PublicIPAddress
*
* @author Adrian Cole
*/
*/
public class PublicIPAddress {
/**
@ -299,39 +297,23 @@ public class PublicIPAddress {
private final String id;
private final String account;
private final Date allocated;
@Named("associatednetworkid")
private final String associatedNetworkId;
private final String domain;
@Named("domainid")
private final String domainId;
@Named("forvirtualnetwork")
private final boolean usesVirtualNetwork;
@Named("ipaddress")
private final String IPAddress;
@Named("issourcenat")
private final boolean isSourceNAT;
@Named("isstaticnat")
private final boolean isStaticNAT;
@Named("networkid")
private final String networkId;
private final PublicIPAddress.State state;
@Named("virtualmachinedisplayname")
private final String virtualMachineDisplayName;
@Named("virtualmachineid")
private final String virtualMachineId;
@Named("virtualmachinename")
private final String virtualMachineName;
@Named("VLANid")
private final String VLANId;
@Named("VLANname")
private final String VLANName;
@Named("zoneid")
private final String zoneId;
@Named("zonename")
private final String zoneName;
@Named("jobid")
private final String jobId;
@Named("jobstatus")
private final Integer jobStatus;
@ConstructorProperties({
@ -454,7 +436,7 @@ public class PublicIPAddress {
/**
* @return State of the ip address. Can be: Allocating, Allocated and
Releasing
* Releasing
*/
@Nullable
public PublicIPAddress.State getState() {
@ -463,7 +445,7 @@ public class PublicIPAddress {
/**
* @return virtual machine display name the ip address is assigned to (not
null only for static nat Ip)
* null only for static nat Ip)
*/
@Nullable
public String getVirtualMachineDisplayName() {
@ -472,7 +454,7 @@ public class PublicIPAddress {
/**
* @return virtual machine id the ip address is assigned to (not null only
for static nat Ip)
* for static nat Ip)
*/
@Nullable
public String getVirtualMachineId() {
@ -481,7 +463,7 @@ public class PublicIPAddress {
/**
* @return virtual machine name the ip address is assigned to (not null only
for static nat Ip)
* for static nat Ip)
*/
@Nullable
public String getVirtualMachineName() {
@ -522,8 +504,8 @@ public class PublicIPAddress {
/**
* @return shows the current pending asynchronous job ID. This tag is not
returned if no current pending jobs are acting on the virtual
machine
* returned if no current pending jobs are acting on the virtual
* machine
*/
@Nullable
public String getJobId() {

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Map;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Function;
@ -37,7 +35,7 @@ import com.google.common.collect.Maps;
* Class ResourceLimit
*
* @author Vijay Kiran
*/
*/
public class ResourceLimit {
/**
@ -83,7 +81,7 @@ public class ResourceLimit {
this.code = code;
}
public int getCode(){
public int getCode() {
return code;
}
@ -178,10 +176,8 @@ public class ResourceLimit {
private final String account;
private final String domain;
@Named("domainid")
private final String domainId;
private final int max;
@Named("resourcetype")
private final ResourceLimit.ResourceType resourceType;
@ConstructorProperties({

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Set;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -36,7 +34,7 @@ import com.google.common.collect.ImmutableSortedSet;
* Class SecurityGroup
*
* @author Adrian Cole
*/
*/
public class SecurityGroup implements Comparable<SecurityGroup> {
public static Builder<?> builder() {
@ -162,13 +160,9 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
private final String name;
private final String description;
private final String domain;
@Named("domainid")
private final String domainId;
@Named("jobid")
private final String jobId;
@Named("jobstatus")
private final Integer jobStatus;
@Named("ingressrule")
private final Set<IngressRule> ingressRules;
@ConstructorProperties({
@ -237,8 +231,8 @@ public class SecurityGroup implements Comparable<SecurityGroup> {
/**
* @return shows the current pending asynchronous job ID. This tag is not
returned if no current pending jobs are acting on the virtual
machine
* returned if no current pending jobs are acting on the virtual
* machine
*/
@Nullable
public String getJobId() {

View File

@ -24,8 +24,6 @@ import java.beans.ConstructorProperties;
import java.util.Date;
import java.util.Set;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Joiner;
@ -252,33 +250,21 @@ public class ServiceOffering implements Comparable<ServiceOffering> {
private final String id;
private final String name;
@Named("displaytext")
private final String displayText;
private final Date created;
private final String domain;
@Named("domainid")
private final String domainId;
@Named("cpunumber")
private final int cpuNumber;
@Named("cpuspeed")
private final int cpuSpeed;
private final int memory;
@Named("offerha")
private final boolean haSupport;
@Named("storagetype")
private final StorageType storageType;
private final String tags;
@Named("defaultuse")
private final boolean defaultUse;
@Named("hosttags")
private final String hostTags;
@Named("issystem")
private final boolean systemOffering;
@Named("limitcpuuse")
private final boolean cpuUseLimited;
@Named("networkrate")
private final long networkRate;
@Named("systemvmtype")
private final boolean systemVmType;
@ConstructorProperties({

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Date;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.CaseFormat;
@ -261,23 +259,15 @@ public class Snapshot {
private final String account;
private final Date created;
private final String domain;
@Named("domainid")
private final String domainId;
@Named("intervaltype")
private final Snapshot.Interval interval;
@Named("jobid")
private final String jobId;
@Named("jobstatus")
private final String jobStatus;
private final String name;
@Named("snapshottype")
private final Snapshot.Type snapshotType;
private final Snapshot.State state;
@Named("volumeid")
private final String volumeId;
@Named("volumename")
private final String volumeName;
@Named("volumetype")
private final Volume.Type volumeType;
@ConstructorProperties({

View File

@ -22,8 +22,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -33,7 +31,7 @@ import com.google.common.base.Objects.ToStringHelper;
* Class SnapshotPolicy
*
* @author Richard Downer
*/
*/
public class SnapshotPolicy {
public static Builder<?> builder() {
@ -125,13 +123,10 @@ public class SnapshotPolicy {
}
private final String id;
@Named("intervaltype")
private final Snapshot.Interval interval;
@Named("maxsnaps")
private final long numberToRetain;
private final String schedule;
private final String timezone;
@Named("volumeid")
private final String volumeId;
@ConstructorProperties({

View File

@ -28,9 +28,9 @@ import com.google.common.base.Objects.ToStringHelper;
/**
* Describes the schedule of a snapshot policy.
*
* @see org.jclouds.cloudstack.util.SnapshotPolicySchedules
* @author Richard Downer
*/
* @see org.jclouds.cloudstack.util.SnapshotPolicySchedules
*/
public class SnapshotPolicySchedule {
public static Builder<?> builder() {

View File

@ -22,8 +22,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -33,7 +31,7 @@ import com.google.common.base.Objects.ToStringHelper;
* Class SshKeyPair
*
* @author Vijay Kiran
*/
*/
public class SshKeyPair {
public static Builder<?> builder() {
@ -96,7 +94,6 @@ public class SshKeyPair {
private final String fingerprint;
private final String name;
@Named("privatekey")
private final String privateKey;
@ConstructorProperties({

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Date;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.CaseFormat;
@ -35,7 +33,7 @@ import com.google.common.base.Objects.ToStringHelper;
* Represents a storage pool in CloudStack
*
* @author Richard Downer
*/
*/
public class StoragePool implements Comparable<StoragePool> {
public enum State {
@ -304,28 +302,17 @@ public class StoragePool implements Comparable<StoragePool> {
private final String tags;
private final StoragePool.State state;
private final StoragePool.Type type;
@Named("zoneid")
private final String zoneId;
@Named("zonename")
private final String zoneName;
@Named("podid")
private final String podId;
@Named("podname")
private final String podName;
@Named("clusterid")
private final String clusterId;
@Named("clustername")
private final String clusterName;
private final Date created;
@Named("disksizeallocated")
private final long diskSizeAllocated;
@Named("disksizetotal")
private final long diskSizeTotal;
@Named("ipaddress")
private final String ipAddress;
@Named("jobid")
private final String jobId;
@Named("jobstatus")
private final String jobStatus;
@ConstructorProperties({

View File

@ -25,7 +25,6 @@ import org.jclouds.cloudstack.features.OfferingClient;
import com.google.common.base.CaseFormat;
/**
*
* @author Adrian Cole
* @see OfferingClient#listServiceOfferings
*/

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Date;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -32,7 +30,7 @@ import com.google.common.base.Objects.ToStringHelper;
/**
* @author Adrian Cole
*/
*/
public class Template implements Comparable<Template> {
public enum Status {
@ -472,24 +470,16 @@ public class Template implements Comparable<Template> {
}
private final String id;
@Named("displaytext")
private final String displayText;
private final String domain;
@Named("domainid")
private final String domainId;
private final String account;
@Named("accountid")
private final String accountId;
@Named("zonename")
private final String zone;
@Named("zoneid")
private final String zoneId;
@Named("ostypename")
private final String OSType;
@Named("ostypeid")
private final String OSTypeId;
private final String name;
@Named("templatetype")
private final Template.Type type;
private final Template.Status status;
private final Template.Format format;
@ -499,26 +489,17 @@ public class Template implements Comparable<Template> {
private final Date removed;
private final boolean crossZones;
private final boolean bootable;
@Named("isextractable")
private final boolean extractable;
@Named("isfeatured")
private final boolean featured;
private final boolean ispublic;
@Named("isready")
private final boolean ready;
@Named("passwordenabled")
private final boolean passwordEnabled;
@Named("jobid")
private final String jobId;
@Named("jobstatus")
private final String jobStatus;
private final String checksum;
private final String hostId;
@Named("hostname")
private final String hostName;
@Named("sourcetemplateid")
private final String sourceTemplateId;
@Named("templatetag")
private final String templateTag;
@ConstructorProperties({
@ -760,7 +741,7 @@ public class Template implements Comparable<Template> {
/**
* @return shows the current pending asynchronous job ID, or null if current
pending jobs are acting on the template
* pending jobs are acting on the template
*/
@Nullable
public String getJobId() {

View File

@ -23,8 +23,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
import java.beans.ConstructorProperties;
import java.util.Date;
import javax.inject.Named;
import org.jclouds.javax.annotation.Nullable;
import com.google.common.base.Objects;
@ -32,7 +30,7 @@ import com.google.common.base.Objects.ToStringHelper;
/**
* @author Richard Downer
*/
*/
public class TemplateExtraction implements Comparable<TemplateExtraction> {
public static Builder<?> builder() {
@ -194,7 +192,6 @@ public class TemplateExtraction implements Comparable<TemplateExtraction> {
}
private final String id;
@Named("accountid")
private final String accountId;
private final Date created;
private final String extractId;
@ -202,14 +199,10 @@ public class TemplateExtraction implements Comparable<TemplateExtraction> {
private final String name;
private final String state;
private final String status;
@Named("storagetype")
private final String storageType;
@Named("uploadpercentage")
private final int uploadPercentage;
private final String url;
@Named("zoneid")
private final String zoneId;
@Named("zonename")
private final String zoneName;
@ConstructorProperties({

View File

@ -23,7 +23,6 @@ import org.jclouds.cloudstack.features.TemplateClient;
import com.google.common.base.CaseFormat;
/**
*
* @author Adrian Cole
* @see TemplateClient#listTemplates
*/

View File

@ -31,7 +31,7 @@ import com.google.common.base.Objects.ToStringHelper;
* Class TemplateMetadata
*
* @author Richard Downer
*/
*/
public class TemplateMetadata {
public static Builder<?> builder() {

Some files were not shown because too many files have changed in this diff Show More