mirror of https://github.com/apache/jclouds.git
JCLOUDS-393. Move to GCE API v1.
This commit is contained in:
parent
4d7865849a
commit
c7f073ade7
|
@ -37,9 +37,9 @@
|
|||
</test.google-compute-engine.identity>
|
||||
<test.google-compute-engine.credential>Private key (PKCS12 file) associated with the Google API client_id
|
||||
</test.google-compute-engine.credential>
|
||||
<test.google-compute-engine.api-version>v1beta16</test.google-compute-engine.api-version>
|
||||
<test.google-compute-engine.api-version>v1</test.google-compute-engine.api-version>
|
||||
<test.google-compute-engine.build-version/>
|
||||
<test.google-compute-engine.template>osFamily=GCEL,osVersionMatches=1[012].[01][04],locationId=us-central1-a,minRam=2048</test.google-compute-engine.template>
|
||||
<test.google-compute-engine.template>imageId=debian-7-wheezy-v20131120,locationId=us-central1-a,minRam=2048</test.google-compute-engine.template>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -27,7 +27,6 @@ import org.jclouds.googlecomputeengine.features.FirewallApi;
|
|||
import org.jclouds.googlecomputeengine.features.GlobalOperationApi;
|
||||
import org.jclouds.googlecomputeengine.features.ImageApi;
|
||||
import org.jclouds.googlecomputeengine.features.InstanceApi;
|
||||
import org.jclouds.googlecomputeengine.features.KernelApi;
|
||||
import org.jclouds.googlecomputeengine.features.MachineTypeApi;
|
||||
import org.jclouds.googlecomputeengine.features.NetworkApi;
|
||||
import org.jclouds.googlecomputeengine.features.ProjectApi;
|
||||
|
@ -47,7 +46,7 @@ import com.google.common.annotations.Beta;
|
|||
* <p/>
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16">api doc</a>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1">api doc</a>
|
||||
*/
|
||||
@Beta
|
||||
public interface GoogleComputeEngineApi extends Closeable {
|
||||
|
@ -106,15 +105,6 @@ public interface GoogleComputeEngineApi extends Closeable {
|
|||
@Path("/projects/{project}")
|
||||
InstanceApi getInstanceApiForProject(@PathParam("project") String projectName);
|
||||
|
||||
/**
|
||||
* Provides access to Kernel features
|
||||
*
|
||||
* @param projectName the name of the project
|
||||
*/
|
||||
@Delegate
|
||||
@Path("/projects/{project}")
|
||||
KernelApi getKernelApiForProject(@PathParam("project") String projectName);
|
||||
|
||||
/**
|
||||
* Provides access to MachineType features
|
||||
*
|
||||
|
|
|
@ -40,7 +40,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
import com.google.inject.Module;
|
||||
|
||||
/**
|
||||
* Implementation of {@link ApiMetadata} for GoogleCompute v1beta16 API
|
||||
* Implementation of {@link ApiMetadata} for GoogleCompute v1 API
|
||||
*
|
||||
* @author David Alves
|
||||
*/
|
||||
|
@ -80,8 +80,8 @@ public class GoogleComputeEngineApiMetadata extends BaseHttpApiMetadata<GoogleCo
|
|||
.identityName("Email associated with the Google API client_id")
|
||||
.credentialName("Private key literal associated with the Google API client_id")
|
||||
.documentation(URI.create("https://developers.google.com/compute/docs"))
|
||||
.version("v1beta16")
|
||||
.defaultEndpoint("https://www.googleapis.com/compute/v1beta16")
|
||||
.version("v1")
|
||||
.defaultEndpoint("https://www.googleapis.com/compute/v1")
|
||||
.defaultProperties(GoogleComputeEngineApiMetadata.defaultProperties())
|
||||
.view(typeToken(ComputeServiceContext.class))
|
||||
.defaultModules(ImmutableSet.<Class<? extends Module>>builder()
|
||||
|
|
|
@ -34,6 +34,10 @@ public interface GoogleComputeEngineConstants {
|
|||
*/
|
||||
public static final String GOOGLE_PROJECT = "google";
|
||||
|
||||
public static final String CENTOS_PROJECT = "centos-cloud";
|
||||
|
||||
public static final String DEBIAN_PROJECT = "debian-cloud";
|
||||
|
||||
public static final String COMPUTE_SCOPE = "https://www.googleapis.com/auth/compute";
|
||||
|
||||
public static final String COMPUTE_READONLY_SCOPE = "https://www.googleapis.com/auth/compute.readonly";
|
||||
|
@ -58,4 +62,19 @@ public interface GoogleComputeEngineConstants {
|
|||
public static final Location GOOGLE_PROVIDER_LOCATION = new LocationBuilder().scope(LocationScope.PROVIDER).id
|
||||
(GCE_PROVIDER_NAME).description(GCE_PROVIDER_NAME).build();
|
||||
|
||||
|
||||
/**
|
||||
* The key we look for in instance metadata for the URI for the image the instance was created from.
|
||||
*/
|
||||
public static final String GCE_IMAGE_METADATA_KEY = "jclouds-image";
|
||||
|
||||
/**
|
||||
* Metadata key to check for whether we should delete an instance's boot disk when we delete the instance.
|
||||
*/
|
||||
public static final String GCE_DELETE_BOOT_DISK_METADATA_KEY = "jclouds-delete-boot-disk";
|
||||
|
||||
/**
|
||||
* The suffix we append to auto-created boot disk names.
|
||||
*/
|
||||
public static final String GCE_BOOT_DISK_SUFFIX = "boot-disk";
|
||||
}
|
||||
|
|
|
@ -20,14 +20,21 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import static com.google.common.base.Preconditions.checkState;
|
||||
import static com.google.common.collect.Iterables.contains;
|
||||
import static com.google.common.collect.Iterables.filter;
|
||||
import static com.google.common.collect.Iterables.tryFind;
|
||||
import static java.util.concurrent.TimeUnit.MILLISECONDS;
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.GOOGLE_PROJECT;
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.CENTOS_PROJECT;
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.DEBIAN_PROJECT;
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.GCE_BOOT_DISK_SUFFIX;
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.GCE_DELETE_BOOT_DISK_METADATA_KEY;
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.GCE_IMAGE_METADATA_KEY;
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_INTERVAL;
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.OPERATION_COMPLETE_TIMEOUT;
|
||||
import static org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface.AccessConfig.Type;
|
||||
import static org.jclouds.googlecomputeengine.predicates.InstancePredicates.isBootDisk;
|
||||
import static org.jclouds.util.Predicates2.retry;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
@ -36,7 +43,6 @@ import java.util.concurrent.atomic.AtomicReference;
|
|||
import javax.annotation.Resource;
|
||||
import javax.inject.Named;
|
||||
|
||||
import com.google.common.primitives.Ints;
|
||||
import org.jclouds.collect.Memoized;
|
||||
import org.jclouds.compute.ComputeServiceAdapter;
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
|
@ -49,10 +55,15 @@ import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
|
|||
import org.jclouds.googlecomputeengine.compute.functions.FirewallTagNamingConvention;
|
||||
import org.jclouds.googlecomputeengine.compute.options.GoogleComputeEngineTemplateOptions;
|
||||
import org.jclouds.googlecomputeengine.config.UserProject;
|
||||
import org.jclouds.googlecomputeengine.domain.Disk;
|
||||
import org.jclouds.googlecomputeengine.domain.Image;
|
||||
import org.jclouds.googlecomputeengine.domain.Instance;
|
||||
import org.jclouds.googlecomputeengine.domain.Instance.AttachedDisk;
|
||||
import org.jclouds.googlecomputeengine.domain.Instance.PersistentAttachedDisk;
|
||||
import org.jclouds.googlecomputeengine.domain.InstanceInZone;
|
||||
import org.jclouds.googlecomputeengine.domain.InstanceTemplate;
|
||||
import org.jclouds.googlecomputeengine.domain.InstanceTemplate.PersistentDisk;
|
||||
import org.jclouds.googlecomputeengine.domain.InstanceTemplate.PersistentDisk.Mode;
|
||||
import org.jclouds.googlecomputeengine.domain.MachineType;
|
||||
import org.jclouds.googlecomputeengine.domain.MachineTypeInZone;
|
||||
import org.jclouds.googlecomputeengine.domain.Operation;
|
||||
|
@ -64,11 +75,14 @@ import org.jclouds.logging.Logger;
|
|||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.collect.FluentIterable;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.google.common.util.concurrent.Atomics;
|
||||
import com.google.common.util.concurrent.UncheckedTimeoutException;
|
||||
import com.google.inject.Inject;
|
||||
|
@ -85,7 +99,6 @@ public class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<
|
|||
private final GoogleComputeEngineApi api;
|
||||
private final Supplier<String> userProject;
|
||||
private final Supplier<Map<URI, ? extends Location>> zones;
|
||||
private final Supplier<Map<URI, ? extends Hardware>> hardwareMap;
|
||||
private final Function<TemplateOptions, ImmutableMap.Builder<String, String>> metatadaFromTemplateOptions;
|
||||
private final Predicate<AtomicReference<Operation>> retryOperationDonePredicate;
|
||||
private final long operationCompleteCheckInterval;
|
||||
|
@ -101,7 +114,6 @@ public class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<
|
|||
@Named(OPERATION_COMPLETE_INTERVAL) Long operationCompleteCheckInterval,
|
||||
@Named(OPERATION_COMPLETE_TIMEOUT) Long operationCompleteCheckTimeout,
|
||||
@Memoized Supplier<Map<URI, ? extends Location>> zones,
|
||||
@Memoized Supplier<Map<URI, ? extends Hardware>> hardwareMap,
|
||||
FirewallTagNamingConvention.Factory firewallTagNamingConvention) {
|
||||
this.api = checkNotNull(api, "google compute api");
|
||||
this.userProject = checkNotNull(userProject, "user project name");
|
||||
|
@ -110,11 +122,10 @@ public class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<
|
|||
this.operationCompleteCheckInterval = checkNotNull(operationCompleteCheckInterval,
|
||||
"operation completed check interval");
|
||||
this.operationCompleteCheckTimeout = checkNotNull(operationCompleteCheckTimeout,
|
||||
"operation completed check timeout");
|
||||
"operation completed check timeout");
|
||||
this.retryOperationDonePredicate = retry(operationDonePredicate, operationCompleteCheckTimeout,
|
||||
operationCompleteCheckInterval, TimeUnit.MILLISECONDS);
|
||||
operationCompleteCheckInterval, TimeUnit.MILLISECONDS);
|
||||
this.zones = checkNotNull(zones, "zones");
|
||||
this.hardwareMap = checkNotNull(hardwareMap, "hardwareMap");
|
||||
this.firewallTagNamingConvention = checkNotNull(firewallTagNamingConvention, "firewallTagNamingConvention");
|
||||
}
|
||||
|
||||
|
@ -129,6 +140,22 @@ public class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<
|
|||
Hardware hardware = checkNotNull(template.getHardware(), "hardware must be set");
|
||||
|
||||
checkNotNull(hardware.getUri(), "hardware must have a URI");
|
||||
checkNotNull(template.getImage().getUri(), "image URI is null");
|
||||
|
||||
// Note that the ordering is significant here - the first disk must be the boot disk.
|
||||
List<PersistentDisk> disks = Lists.newArrayList();
|
||||
|
||||
if (!tryFind(options.getDisks(), isBootDisk()).isPresent()) {
|
||||
Disk bootDisk = createBootDisk(template, name);
|
||||
|
||||
disks.add(new PersistentDisk(Mode.READ_WRITE,
|
||||
bootDisk.getSelfLink(),
|
||||
null,
|
||||
true,
|
||||
true));
|
||||
}
|
||||
|
||||
disks.addAll(options.getDisks());
|
||||
|
||||
InstanceTemplate instanceTemplate = InstanceTemplate.builder()
|
||||
.forMachineType(hardware.getUri());
|
||||
|
@ -139,12 +166,20 @@ public class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<
|
|||
instanceTemplate.addNetworkInterface(options.getNetwork().get());
|
||||
}
|
||||
|
||||
instanceTemplate.disks(disks);
|
||||
|
||||
LoginCredentials credentials = getFromImageAndOverrideIfRequired(template.getImage(), options);
|
||||
|
||||
ImmutableMap.Builder<String, String> metadataBuilder = metatadaFromTemplateOptions.apply(options);
|
||||
|
||||
metadataBuilder.put(GCE_IMAGE_METADATA_KEY, template.getImage().getUri().toString());
|
||||
|
||||
if (!options.shouldKeepBootDisk()) {
|
||||
metadataBuilder.put(GCE_DELETE_BOOT_DISK_METADATA_KEY, Boolean.TRUE.toString());
|
||||
}
|
||||
|
||||
instanceTemplate.metadata(metadataBuilder.build());
|
||||
instanceTemplate.serviceAccounts(options.getServiceAccounts());
|
||||
instanceTemplate.image(checkNotNull(template.getImage().getUri(), "image URI is null"));
|
||||
|
||||
final InstanceApi instanceApi = api.getInstanceApiForProject(userProject.get());
|
||||
final String zone = template.getLocation().getId();
|
||||
|
@ -199,6 +234,26 @@ public class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<
|
|||
return new NodeAndInitialCredentials<InstanceInZone>(instanceInZone, instanceInZone.slashEncode(), credentials);
|
||||
}
|
||||
|
||||
private Disk createBootDisk(Template template, String instanceName) {
|
||||
URI imageUri = template.getImage().getUri();
|
||||
|
||||
GoogleComputeEngineTemplateOptions options = GoogleComputeEngineTemplateOptions.class.cast(template.getOptions()).clone();
|
||||
|
||||
int diskSize = options.getBootDiskSize().or(10l).intValue();
|
||||
|
||||
String diskName = instanceName + "-" + GCE_BOOT_DISK_SUFFIX;
|
||||
|
||||
Operation diskOperation = api.getDiskApiForProject(userProject.get())
|
||||
.createFromImageWithSizeInZone(imageUri.toString(),
|
||||
diskName,
|
||||
diskSize,
|
||||
template.getLocation().getId());
|
||||
|
||||
waitOperationDone(diskOperation);
|
||||
|
||||
return api.getDiskApiForProject(userProject.get()).getInZone(template.getLocation().getId(),
|
||||
diskName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<MachineTypeInZone> listHardwareProfiles() {
|
||||
|
@ -224,14 +279,17 @@ public class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<
|
|||
public Iterable<Image> listImages() {
|
||||
return ImmutableSet.<Image>builder()
|
||||
.addAll(api.getImageApiForProject(userProject.get()).list().concat())
|
||||
.addAll(api.getImageApiForProject(GOOGLE_PROJECT).list().concat())
|
||||
.addAll(api.getImageApiForProject(DEBIAN_PROJECT).list().concat())
|
||||
.addAll(api.getImageApiForProject(CENTOS_PROJECT).list().concat())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getImage(String id) {
|
||||
return Objects.firstNonNull(api.getImageApiForProject(userProject.get()).get(id),
|
||||
api.getImageApiForProject(GOOGLE_PROJECT).get(id));
|
||||
Objects.firstNonNull(api.getImageApiForProject(DEBIAN_PROJECT).get(id),
|
||||
api.getImageApiForProject(CENTOS_PROJECT).get(id)));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -280,9 +338,33 @@ public class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<
|
|||
@Override
|
||||
public void destroyNode(final String name) {
|
||||
SlashEncodedIds slashEncodedIds = SlashEncodedIds.fromSlashEncoded(name);
|
||||
|
||||
String diskName = null;
|
||||
try {
|
||||
Instance instance = api.getInstanceApiForProject(userProject.get()).getInZone(slashEncodedIds.getFirstId(),
|
||||
slashEncodedIds.getSecondId());
|
||||
if (instance.getMetadata().getItems().get(GCE_DELETE_BOOT_DISK_METADATA_KEY).equals("true")) {
|
||||
Optional<AttachedDisk> disk = tryFind(instance.getDisks(), new Predicate<AttachedDisk>() {
|
||||
@Override
|
||||
public boolean apply(AttachedDisk input) {
|
||||
return PersistentAttachedDisk.class.isInstance(input) &&
|
||||
PersistentAttachedDisk.class.cast(input).isBoot();
|
||||
}
|
||||
});
|
||||
if (disk.isPresent()) {
|
||||
diskName = PersistentAttachedDisk.class.cast(disk.get()).getSourceDiskName();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: what exception actually gets thrown here if the instance doesn't really exist?
|
||||
}
|
||||
waitOperationDone(api.getInstanceApiForProject(userProject.get()).deleteInZone(slashEncodedIds.getFirstId(),
|
||||
slashEncodedIds.getSecondId()));
|
||||
|
||||
if (diskName != null) {
|
||||
waitOperationDone(api.getDiskApiForProject(userProject.get()).deleteInZone(slashEncodedIds.getFirstId(),
|
||||
diskName));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.jclouds.googlecomputeengine.compute.functions;
|
|||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static org.jclouds.compute.util.ComputeServiceUtils.groupFromMapOrName;
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.GCE_IMAGE_METADATA_KEY;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
@ -32,6 +33,8 @@ import org.jclouds.compute.domain.NodeMetadata;
|
|||
import org.jclouds.compute.domain.NodeMetadataBuilder;
|
||||
import org.jclouds.compute.functions.GroupNamingConvention;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
|
||||
import org.jclouds.googlecomputeengine.config.UserProject;
|
||||
import org.jclouds.googlecomputeengine.domain.Instance;
|
||||
import org.jclouds.googlecomputeengine.domain.InstanceInZone;
|
||||
import org.jclouds.googlecomputeengine.domain.SlashEncodedIds;
|
||||
|
@ -55,6 +58,8 @@ public class InstanceInZoneToNodeMetadata implements Function<InstanceInZone, No
|
|||
private final Supplier<Map<URI, ? extends Hardware>> hardwares;
|
||||
private final Supplier<Map<URI, ? extends Location>> locations;
|
||||
private final FirewallTagNamingConvention.Factory firewallTagNamingConvention;
|
||||
private final GoogleComputeEngineApi api;
|
||||
private final Supplier<String> userProject;
|
||||
|
||||
@Inject
|
||||
public InstanceInZoneToNodeMetadata(Map<Instance.Status, NodeMetadata.Status> toPortableNodeStatus,
|
||||
|
@ -62,47 +67,64 @@ public class InstanceInZoneToNodeMetadata implements Function<InstanceInZone, No
|
|||
@Memoized Supplier<Map<URI, ? extends Image>> images,
|
||||
@Memoized Supplier<Map<URI, ? extends Hardware>> hardwares,
|
||||
@Memoized Supplier<Map<URI, ? extends Location>> locations,
|
||||
FirewallTagNamingConvention.Factory firewallTagNamingConvention) {
|
||||
FirewallTagNamingConvention.Factory firewallTagNamingConvention,
|
||||
GoogleComputeEngineApi api,
|
||||
@UserProject Supplier<String> userProject) {
|
||||
this.toPortableNodeStatus = toPortableNodeStatus;
|
||||
this.nodeNamingConvention = namingConvention.createWithoutPrefix();
|
||||
this.images = images;
|
||||
this.hardwares = hardwares;
|
||||
this.locations = locations;
|
||||
this.firewallTagNamingConvention = checkNotNull(firewallTagNamingConvention, "firewallTagNamingConvention");
|
||||
this.api = checkNotNull(api, "api");
|
||||
this.userProject = checkNotNull(userProject, "userProject");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeMetadata apply(InstanceInZone instanceInZone) {
|
||||
Instance input = instanceInZone.getInstance();
|
||||
Map<URI, ? extends Image> imagesMap = images.get();
|
||||
Image image = checkNotNull(imagesMap.get(checkNotNull(input.getImage(), "image")),
|
||||
"no image for %s. images: %s", input.getImage(), imagesMap.values());
|
||||
|
||||
String group = groupFromMapOrName(input.getMetadata().getItems(),
|
||||
input.getName(), nodeNamingConvention);
|
||||
|
||||
input.getName(), nodeNamingConvention);
|
||||
FluentIterable<String> tags = FluentIterable.from(input.getTags().getItems())
|
||||
.filter(Predicates.not(firewallTagNamingConvention.get(group).isFirewallTag()));
|
||||
.filter(Predicates.not(firewallTagNamingConvention.get(group).isFirewallTag()));
|
||||
|
||||
return new NodeMetadataBuilder()
|
||||
.id(SlashEncodedIds.fromTwoIds(checkNotNull(locations.get().get(input.getZone()), "location for %s", input.getZone()).getId(),
|
||||
input.getName()).slashEncode())
|
||||
NodeMetadataBuilder builder = new NodeMetadataBuilder();
|
||||
|
||||
builder.id(SlashEncodedIds.fromTwoIds(checkNotNull(locations.get().get(input.getZone()),
|
||||
"location for %s", input.getZone())
|
||||
.getId(), input.getName()).slashEncode())
|
||||
.name(input.getName())
|
||||
.providerId(input.getId())
|
||||
.hostname(input.getName())
|
||||
.imageId(image.getId())
|
||||
.location(checkNotNull(locations.get().get(input.getZone()), "location for %s", input.getZone()))
|
||||
.hardware(checkNotNull(hardwares.get().get(input.getMachineType()), "hardware type for %s",
|
||||
input.getMachineType().toString()))
|
||||
.operatingSystem(image.getOperatingSystem())
|
||||
input.getMachineType().toString()))
|
||||
.status(toPortableNodeStatus.get(input.getStatus()))
|
||||
.tags(tags)
|
||||
.uri(input.getSelfLink())
|
||||
.userMetadata(input.getMetadata().getItems())
|
||||
.group(group)
|
||||
.privateAddresses(collectPrivateAddresses(input))
|
||||
.publicAddresses(collectPublicAddresses(input))
|
||||
.build();
|
||||
.publicAddresses(collectPublicAddresses(input));
|
||||
|
||||
if (input.getMetadata().getItems().containsKey(GCE_IMAGE_METADATA_KEY)) {
|
||||
try {
|
||||
URI imageUri = URI.create(input.getMetadata().getItems()
|
||||
.get(GCE_IMAGE_METADATA_KEY));
|
||||
|
||||
Map<URI, ? extends Image> imagesMap = images.get();
|
||||
|
||||
Image image = checkNotNull(imagesMap.get(imageUri),
|
||||
"no image for %s. images: %s", imageUri,
|
||||
imagesMap.values());
|
||||
builder.imageId(image.getId());
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Swallow any exception here - it just means we don't actually have a valid image URI, so we skip it.
|
||||
}
|
||||
}
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
|
||||
private Set<String> collectPrivateAddresses(Instance input) {
|
||||
|
|
|
@ -26,6 +26,7 @@ import java.util.Set;
|
|||
import org.jclouds.compute.options.TemplateOptions;
|
||||
import org.jclouds.domain.LoginCredentials;
|
||||
import org.jclouds.googlecomputeengine.domain.Instance;
|
||||
import org.jclouds.googlecomputeengine.domain.InstanceTemplate.PersistentDisk;
|
||||
import org.jclouds.scriptbuilder.domain.Statement;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
@ -42,6 +43,9 @@ public class GoogleComputeEngineTemplateOptions extends TemplateOptions {
|
|||
private Optional<String> networkName = Optional.absent();
|
||||
private Set<Instance.ServiceAccount> serviceAccounts = Sets.newLinkedHashSet();
|
||||
private boolean enableNat = true;
|
||||
private Set<PersistentDisk> disks = Sets.newLinkedHashSet();
|
||||
private Optional<Long> bootDiskSize = Optional.absent();
|
||||
private boolean keepBootDisk = false;
|
||||
|
||||
@Override
|
||||
public GoogleComputeEngineTemplateOptions clone() {
|
||||
|
@ -59,6 +63,8 @@ public class GoogleComputeEngineTemplateOptions extends TemplateOptions {
|
|||
eTo.network(getNetworkName().orNull());
|
||||
eTo.serviceAccounts(getServiceAccounts());
|
||||
eTo.enableNat(isEnableNat());
|
||||
eTo.disks(getDisks());
|
||||
eTo.keepBootDisk(shouldKeepBootDisk());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -96,6 +102,24 @@ public class GoogleComputeEngineTemplateOptions extends TemplateOptions {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #getDisks()
|
||||
* @see org.jclouds.googlecomputeengine.domain.InstanceTemplate.PersistentDisk
|
||||
*/
|
||||
public GoogleComputeEngineTemplateOptions addDisk(PersistentDisk disk) {
|
||||
this.disks.add(disk);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #getDisks()
|
||||
* @see org.jclouds.googlecomputeengine.domain.InstanceTemplate.PersistentDisk
|
||||
*/
|
||||
public GoogleComputeEngineTemplateOptions disks(Set<PersistentDisk> disks) {
|
||||
this.disks = Sets.newLinkedHashSet(disks);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #isEnableNat()
|
||||
*/
|
||||
|
@ -104,6 +128,22 @@ public class GoogleComputeEngineTemplateOptions extends TemplateOptions {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #getBootDiskSize()
|
||||
*/
|
||||
public GoogleComputeEngineTemplateOptions bootDiskSize(Long bootDiskSize) {
|
||||
this.bootDiskSize = fromNullable(bootDiskSize);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #shouldKeepBootDisk()
|
||||
*/
|
||||
public GoogleComputeEngineTemplateOptions keepBootDisk(boolean keepBootDisk) {
|
||||
this.keepBootDisk = keepBootDisk;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
|
@ -279,6 +319,13 @@ public class GoogleComputeEngineTemplateOptions extends TemplateOptions {
|
|||
return serviceAccounts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the PersistentDisks for this instance.
|
||||
*/
|
||||
public Set<PersistentDisk> getDisks() {
|
||||
return disks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the URI of an existing network the instances will be attached to. If no network URI or network name are
|
||||
* provided a new network will be created for the project.
|
||||
|
@ -302,4 +349,18 @@ public class GoogleComputeEngineTemplateOptions extends TemplateOptions {
|
|||
public boolean isEnableNat() {
|
||||
return enableNat;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the boot disk size, if specified. Defaults to 10gb.
|
||||
*/
|
||||
public Optional<Long> getBootDiskSize() {
|
||||
return bootDiskSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return whether we should keep the boot disk around when deleting the instance. Defaults to false.
|
||||
*/
|
||||
public boolean shouldKeepBootDisk() {
|
||||
return keepBootDisk;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ public class GoogleComputeEngineParserModule extends AbstractModule {
|
|||
/**
|
||||
* Parser for operations that unwraps errors avoiding an extra intermediate object.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/operations"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/operations"/>
|
||||
*/
|
||||
@Singleton
|
||||
private static class OperationTypeAdapter implements JsonDeserializer<Operation> {
|
||||
|
@ -208,14 +208,14 @@ public class GoogleComputeEngineParserModule extends AbstractModule {
|
|||
|
||||
private static class InstanceInternal extends Instance {
|
||||
@ConstructorProperties({
|
||||
"id", "creationTimestamp", "selfLink", "name", "description", "tags", "image", "machineType",
|
||||
"id", "creationTimestamp", "selfLink", "name", "description", "tags", "machineType",
|
||||
"status", "statusMessage", "zone", "networkInterfaces", "metadata", "serviceAccounts"
|
||||
})
|
||||
private InstanceInternal(String id, Date creationTimestamp, URI selfLink, String name, String description,
|
||||
Tags tags, URI image, URI machineType, Status status, String statusMessage,
|
||||
Tags tags, URI machineType, Status status, String statusMessage,
|
||||
URI zone, Set<NetworkInterface> networkInterfaces, Metadata metadata,
|
||||
Set<ServiceAccount> serviceAccounts) {
|
||||
super(id, creationTimestamp, selfLink, name, description, tags, image, machineType,
|
||||
super(id, creationTimestamp, selfLink, name, description, tags, machineType,
|
||||
status, statusMessage, zone, networkInterfaces, null, metadata, serviceAccounts);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import com.google.common.base.Objects;
|
|||
* A persistent disk resource
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/disks"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/disks"/>
|
||||
*/
|
||||
@Beta
|
||||
public abstract class AbstractDisk extends Resource {
|
||||
|
|
|
@ -32,7 +32,7 @@ import com.google.common.base.Optional;
|
|||
* Represents an Address resource.
|
||||
*
|
||||
* @author Andrew Bayer
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/addresses"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/addresses"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class Address extends Resource {
|
||||
|
|
|
@ -30,7 +30,7 @@ import com.google.common.base.Objects;
|
|||
* A persistent disk resource
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/disks"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/disks"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class Disk extends AbstractDisk {
|
||||
|
|
|
@ -40,7 +40,7 @@ import com.google.common.collect.TreeRangeSet;
|
|||
* Represents a network firewall
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/firewalls"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/firewalls"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/networking#firewalls"/>
|
||||
*/
|
||||
@Beta
|
||||
|
@ -243,7 +243,7 @@ public final class Firewall extends Resource {
|
|||
* permitted connection.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/firewalls"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/firewalls"/>
|
||||
*/
|
||||
public static final class Rule {
|
||||
|
||||
|
|
|
@ -33,25 +33,23 @@ import com.google.common.base.Optional;
|
|||
* Represents a disk image to use on an instance.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/images"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/images"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class Image extends Resource {
|
||||
|
||||
private final String sourceType;
|
||||
private final Optional<URI> preferredKernel;
|
||||
private final RawDisk rawDisk;
|
||||
private final Optional<Deprecated> deprecated;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "creationTimestamp", "selfLink", "name", "description", "sourceType", "preferredKernel",
|
||||
"id", "creationTimestamp", "selfLink", "name", "description", "sourceType",
|
||||
"rawDisk", "deprecated"
|
||||
})
|
||||
protected Image(String id, Date creationTimestamp, URI selfLink, String name, String description,
|
||||
String sourceType, URI preferredKernel, RawDisk rawDisk, Deprecated deprecated) {
|
||||
String sourceType, RawDisk rawDisk, Deprecated deprecated) {
|
||||
super(Kind.IMAGE, id, creationTimestamp, selfLink, name, description);
|
||||
this.sourceType = checkNotNull(sourceType, "sourceType of %s", name);
|
||||
this.preferredKernel = fromNullable(preferredKernel);
|
||||
this.rawDisk = checkNotNull(rawDisk, "rawDisk of %s", name);
|
||||
this.deprecated = fromNullable(deprecated);
|
||||
}
|
||||
|
@ -63,13 +61,6 @@ public final class Image extends Resource {
|
|||
return sourceType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An optional URL of the preferred kernel for use with this disk image.
|
||||
*/
|
||||
public Optional<URI> getPreferredKernel() {
|
||||
return preferredKernel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the raw disk image parameters.
|
||||
*/
|
||||
|
@ -91,7 +82,6 @@ public final class Image extends Resource {
|
|||
return super.string()
|
||||
.omitNullValues()
|
||||
.add("sourceType", sourceType)
|
||||
.add("preferredKernel", preferredKernel.orNull())
|
||||
.add("rawDisk", rawDisk)
|
||||
.add("deprecated", deprecated.orNull());
|
||||
}
|
||||
|
@ -115,7 +105,6 @@ public final class Image extends Resource {
|
|||
public static final class Builder extends Resource.Builder<Builder> {
|
||||
|
||||
private String sourceType;
|
||||
private URI preferredKernel;
|
||||
private RawDisk rawDisk;
|
||||
private Deprecated deprecated;
|
||||
|
||||
|
@ -127,14 +116,6 @@ public final class Image extends Resource {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Image#getPreferredKernel()
|
||||
*/
|
||||
public Builder preferredKernel(URI preferredKernel) {
|
||||
this.preferredKernel = preferredKernel;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Image#getDeprecated()
|
||||
*/
|
||||
|
@ -158,13 +139,12 @@ public final class Image extends Resource {
|
|||
|
||||
public Image build() {
|
||||
return new Image(super.id, super.creationTimestamp, super.selfLink, super.name,
|
||||
super.description, sourceType, preferredKernel, rawDisk, deprecated);
|
||||
super.description, sourceType, rawDisk, deprecated);
|
||||
}
|
||||
|
||||
public Builder fromImage(Image in) {
|
||||
return super.fromResource(in)
|
||||
.sourceType(in.getSourceType())
|
||||
.preferredKernel(in.getPreferredKernel().orNull())
|
||||
.rawDisk(in.getRawDisk())
|
||||
.deprecated(in.getDeprecated().orNull());
|
||||
}
|
||||
|
@ -175,7 +155,7 @@ public final class Image extends Resource {
|
|||
* A raw disk image, usually the base for an image.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/images"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/images"/>
|
||||
*/
|
||||
public static class RawDisk {
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import static com.google.common.base.Objects.equal;
|
|||
import static com.google.common.base.Objects.toStringHelper;
|
||||
import static com.google.common.base.Optional.fromNullable;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.google.common.collect.Iterables.getLast;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.net.URI;
|
||||
|
@ -31,13 +32,14 @@ import org.jclouds.javax.annotation.Nullable;
|
|||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Represents a virtual machine.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/instances"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/instances"/>
|
||||
*/
|
||||
@Beta
|
||||
public class Instance extends Resource {
|
||||
|
@ -52,7 +54,6 @@ public class Instance extends Resource {
|
|||
}
|
||||
|
||||
protected final Tags tags;
|
||||
protected final URI image;
|
||||
protected final URI machineType;
|
||||
protected final Status status;
|
||||
protected final Optional<String> statusMessage;
|
||||
|
@ -63,12 +64,11 @@ public class Instance extends Resource {
|
|||
protected final Set<ServiceAccount> serviceAccounts;
|
||||
|
||||
protected Instance(String id, Date creationTimestamp, URI selfLink, String name, String description,
|
||||
Tags tags, URI image, URI machineType, Status status, String statusMessage,
|
||||
Tags tags, URI machineType, Status status, String statusMessage,
|
||||
URI zone, Set<NetworkInterface> networkInterfaces, Set<AttachedDisk> disks,
|
||||
Metadata metadata, Set<ServiceAccount> serviceAccounts) {
|
||||
super(Kind.INSTANCE, id, creationTimestamp, selfLink, name, description);
|
||||
this.tags = checkNotNull(tags, "tags");
|
||||
this.image = checkNotNull(image, "image");
|
||||
this.machineType = checkNotNull(machineType, "machineType of %s", name);
|
||||
this.status = checkNotNull(status, "status");
|
||||
this.statusMessage = fromNullable(statusMessage);
|
||||
|
@ -89,13 +89,6 @@ public class Instance extends Resource {
|
|||
return tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the URL of the disk image resource to be to be installed on this instance.
|
||||
*/
|
||||
public URI getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return URL of the machine type resource describing which machine type to use to host the instance.
|
||||
*/
|
||||
|
@ -178,7 +171,6 @@ public class Instance extends Resource {
|
|||
return super.string()
|
||||
.omitNullValues()
|
||||
.add("items", tags)
|
||||
.add("image", image)
|
||||
.add("machineType", machineType)
|
||||
.add("status", status)
|
||||
.add("statusMessage", statusMessage.orNull())
|
||||
|
@ -208,7 +200,6 @@ public class Instance extends Resource {
|
|||
public static final class Builder extends Resource.Builder<Builder> {
|
||||
|
||||
private Tags tags;
|
||||
private URI image;
|
||||
private URI machineType;
|
||||
private Status status;
|
||||
private String statusMessage;
|
||||
|
@ -227,14 +218,6 @@ public class Instance extends Resource {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#getImage()
|
||||
*/
|
||||
public Builder image(URI image) {
|
||||
this.image = image;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see Instance#getMachineType()
|
||||
*/
|
||||
|
@ -331,14 +314,13 @@ public class Instance extends Resource {
|
|||
|
||||
public Instance build() {
|
||||
return new Instance(super.id, super.creationTimestamp, super.selfLink, super.name,
|
||||
super.description, tags, image, machineType, status, statusMessage, zone,
|
||||
super.description, tags, machineType, status, statusMessage, zone,
|
||||
networkInterfaces.build(), disks.build(), metadata, serviceAccounts.build());
|
||||
}
|
||||
|
||||
public Builder fromInstance(Instance in) {
|
||||
return super.fromResource(in)
|
||||
.tags(in.getTags())
|
||||
.image(in.getImage())
|
||||
.machineType(in.getMachineType())
|
||||
.status(in.getStatus())
|
||||
.statusMessage(in.getStatusMessage().orNull())
|
||||
|
@ -469,7 +451,7 @@ public class Instance extends Resource {
|
|||
/**
|
||||
* A disk attached to an Instance.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/instances"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/instances"/>
|
||||
*/
|
||||
public static class AttachedDisk {
|
||||
|
||||
|
@ -537,20 +519,23 @@ public class Instance extends Resource {
|
|||
READ_ONLY;
|
||||
}
|
||||
|
||||
@ConstructorProperties({"mode", "source", "deviceName", "index", "deleteOnTerminate"})
|
||||
@ConstructorProperties({"mode", "source", "deviceName", "index", "deleteOnTerminate",
|
||||
"boot"})
|
||||
public PersistentAttachedDisk(Mode mode, URI source, String deviceName, Integer index,
|
||||
boolean deleteOnTerminate) {
|
||||
boolean deleteOnTerminate, boolean boot) {
|
||||
super(index);
|
||||
this.mode = checkNotNull(mode, "mode");
|
||||
this.source = checkNotNull(source, "source");
|
||||
this.deviceName = fromNullable(deviceName);
|
||||
this.deleteOnTerminate = deleteOnTerminate;
|
||||
this.boot = boot;
|
||||
}
|
||||
|
||||
private final Mode mode;
|
||||
private final URI source;
|
||||
private final boolean deleteOnTerminate;
|
||||
private final Optional<String> deviceName;
|
||||
private final boolean boot;
|
||||
|
||||
@Override
|
||||
public boolean isPersistent() {
|
||||
|
@ -571,6 +556,13 @@ public class Instance extends Resource {
|
|||
return source;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the Name of the persistent disk resource
|
||||
*/
|
||||
public String getSourceDiskName() {
|
||||
return getLast(Splitter.on("/").split(source.toString()), null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Must be unique within the instance when specified. This represents a unique
|
||||
* device name that is reflected into the /dev/ tree of a Linux operating system running within the
|
||||
|
@ -588,10 +580,25 @@ public class Instance extends Resource {
|
|||
return deleteOnTerminate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return If true, this is the boot disk for this instance.
|
||||
*/
|
||||
public boolean isBoot() {
|
||||
return boot;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
protected Objects.ToStringHelper string() {
|
||||
return toStringHelper(this).add("boot", boot);
|
||||
}
|
||||
|
||||
|
||||
public static final class Builder {
|
||||
|
||||
private Mode mode;
|
||||
|
@ -599,6 +606,7 @@ public class Instance extends Resource {
|
|||
private String deviceName;
|
||||
private Integer index;
|
||||
private boolean deleteOnTerminate;
|
||||
private boolean boot;
|
||||
|
||||
/**
|
||||
* @see org.jclouds.googlecomputeengine.domain.Instance.PersistentAttachedDisk#getMode()
|
||||
|
@ -640,9 +648,17 @@ public class Instance extends Resource {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.googlecomputeengine.domain.Instance.PersistentAttachedDisk#isBoot()
|
||||
*/
|
||||
public Builder boot(Boolean boot) {
|
||||
this.boot = boot;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PersistentAttachedDisk build() {
|
||||
return new PersistentAttachedDisk(this.mode, this.source, this.deviceName, this.index,
|
||||
this.deleteOnTerminate);
|
||||
this.deleteOnTerminate, this.boot);
|
||||
}
|
||||
|
||||
public Builder fromPersistentAttachedDisk(PersistentAttachedDisk in) {
|
||||
|
@ -650,7 +666,8 @@ public class Instance extends Resource {
|
|||
.source(in.getSource())
|
||||
.deviceName(in.getDeviceName().orNull())
|
||||
.index(in.getIndex())
|
||||
.deleteOnTerminate(in.isDeleteOnTerminate());
|
||||
.deleteOnTerminate(in.isDeleteOnTerminate())
|
||||
.boot(in.isBoot());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -658,7 +675,7 @@ public class Instance extends Resource {
|
|||
/**
|
||||
* A network interface for an Instance.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/instances"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/instances"/>
|
||||
*/
|
||||
public static final class NetworkInterface {
|
||||
|
||||
|
@ -952,7 +969,7 @@ public class Instance extends Resource {
|
|||
* The output of an instance's serial port;
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/instances/serialPort"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/instances/serialPort"/>
|
||||
*/
|
||||
public static final class SerialPortOutput {
|
||||
|
||||
|
@ -1060,7 +1077,7 @@ public class Instance extends Resource {
|
|||
* A service account for which access tokens are to be made available to the instance through metadata queries.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/instances"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/instances"/>
|
||||
*/
|
||||
public static final class ServiceAccount {
|
||||
|
||||
|
|
|
@ -21,11 +21,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import static org.jclouds.googlecomputeengine.domain.Instance.NetworkInterface.AccessConfig.Type;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
|
@ -42,7 +44,7 @@ public class InstanceTemplate {
|
|||
protected URI image;
|
||||
protected Set<Instance.ServiceAccount> serviceAccounts = Sets.newLinkedHashSet();
|
||||
|
||||
protected transient Set<PersistentDisk> disks = Sets.newLinkedHashSet();
|
||||
protected transient List<PersistentDisk> disks = Lists.newArrayList();
|
||||
protected transient Set<NetworkInterface> networkInterfaces = Sets.newLinkedHashSet();
|
||||
protected transient Map<String, String> metadata = Maps.newLinkedHashMap();
|
||||
protected transient String machineTypeName;
|
||||
|
@ -100,7 +102,15 @@ public class InstanceTemplate {
|
|||
* @see org.jclouds.googlecomputeengine.domain.Instance#getDisks()
|
||||
*/
|
||||
public InstanceTemplate addDisk(PersistentDisk.Mode mode, URI source) {
|
||||
this.disks.add(new PersistentDisk(mode, source, null, null));
|
||||
this.disks.add(new PersistentDisk(mode, source, null, false, false));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.googlecomputeengine.domain.Instance#getDisks()
|
||||
*/
|
||||
public InstanceTemplate addDisk(PersistentDisk.Mode mode, URI source, Boolean deleteOnTerminate) {
|
||||
this.disks.add(new PersistentDisk(mode, source, null, deleteOnTerminate, false));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -108,15 +118,24 @@ public class InstanceTemplate {
|
|||
* @see org.jclouds.googlecomputeengine.domain.Instance#getDisks()
|
||||
*/
|
||||
public InstanceTemplate addDisk(PersistentDisk.Mode mode, URI source, String deviceName, Boolean deleteOnTerminate) {
|
||||
this.disks.add(new PersistentDisk(mode, source, deviceName, deleteOnTerminate));
|
||||
this.disks.add(new PersistentDisk(mode, source, deviceName, deleteOnTerminate, false));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.googlecomputeengine.domain.Instance#getDisks()
|
||||
*/
|
||||
public InstanceTemplate disks(Set<PersistentDisk> disks) {
|
||||
this.disks = Sets.newLinkedHashSet();
|
||||
public InstanceTemplate addDisk(PersistentDisk.Mode mode, URI source, String deviceName,
|
||||
Boolean deleteOnTerminate, Boolean boot) {
|
||||
this.disks.add(new PersistentDisk(mode, source, deviceName, deleteOnTerminate, boot));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.googlecomputeengine.domain.Instance#getDisks()
|
||||
*/
|
||||
public InstanceTemplate disks(List<PersistentDisk> disks) {
|
||||
this.disks = Lists.newArrayList();
|
||||
this.disks.addAll(checkNotNull(disks, "disks"));
|
||||
return this;
|
||||
}
|
||||
|
@ -198,7 +217,7 @@ public class InstanceTemplate {
|
|||
/**
|
||||
* @see org.jclouds.googlecomputeengine.domain.Instance#getDisks()
|
||||
*/
|
||||
public Set<PersistentDisk> getDisks() {
|
||||
public List<PersistentDisk> getDisks() {
|
||||
return disks;
|
||||
}
|
||||
|
||||
|
@ -290,17 +309,20 @@ public class InstanceTemplate {
|
|||
READ_ONLY
|
||||
}
|
||||
|
||||
public PersistentDisk(Mode mode, URI source, String deviceName, Boolean deleteOnTerminate) {
|
||||
public PersistentDisk(Mode mode, URI source, String deviceName, Boolean deleteOnTerminate,
|
||||
Boolean boot) {
|
||||
this.mode = checkNotNull(mode, "mode");
|
||||
this.source = checkNotNull(source, "source");
|
||||
this.deviceName = deviceName;
|
||||
this.deleteOnTerminate = deleteOnTerminate;
|
||||
this.deleteOnTerminate = checkNotNull(deleteOnTerminate, "deleteOnTerminate");
|
||||
this.boot = checkNotNull(boot, "boot");
|
||||
}
|
||||
|
||||
private final Mode mode;
|
||||
private final URI source;
|
||||
private final Boolean deleteOnTerminate;
|
||||
private final String deviceName;
|
||||
private final Boolean boot;
|
||||
|
||||
/**
|
||||
* @return the mode in which to attach this disk, either READ_WRITE or READ_ONLY.
|
||||
|
@ -332,6 +354,13 @@ public class InstanceTemplate {
|
|||
public boolean isDeleteOnTerminate() {
|
||||
return deleteOnTerminate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return If true, boot from this disk.
|
||||
*/
|
||||
public boolean isBoot() {
|
||||
return boot;
|
||||
}
|
||||
}
|
||||
|
||||
public static class NetworkInterface {
|
||||
|
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jclouds.googlecomputeengine.domain;
|
||||
|
||||
import static com.google.common.base.Optional.fromNullable;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
/**
|
||||
* Represents a kernel.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/kernels"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class Kernel extends Resource {
|
||||
private final Optional<Deprecated> deprecated;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "creationTimestamp", "selfLink", "name", "description", "deprecated"
|
||||
})
|
||||
private Kernel(String id, Date creationTimestamp, URI selfLink, String name, String description,
|
||||
Deprecated deprecated) {
|
||||
super(Kind.KERNEL, id, creationTimestamp, selfLink, name, description);
|
||||
this.deprecated = fromNullable(deprecated);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the deprecation information for this kernel
|
||||
*/
|
||||
public Optional<Deprecated> getDeprecated() {
|
||||
return deprecated;
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromKernel(this);
|
||||
}
|
||||
|
||||
public static final class Builder extends Resource.Builder<Builder> {
|
||||
|
||||
private Deprecated deprecated;
|
||||
|
||||
/**
|
||||
* @see Kernel#getDeprecated()
|
||||
*/
|
||||
public Builder deprecated(Deprecated deprecated) {
|
||||
this.deprecated = checkNotNull(deprecated, "deprecated");
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Builder self() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Kernel build() {
|
||||
return new Kernel(super.id, super.creationTimestamp, super.selfLink, super.name,
|
||||
super.description, deprecated);
|
||||
}
|
||||
|
||||
public Builder fromKernel(Kernel in) {
|
||||
return super.fromResource(in)
|
||||
.deprecated(in.getDeprecated().orNull());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -33,7 +33,7 @@ import com.google.common.collect.ImmutableList;
|
|||
* Represents a machine type used to host an instance.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/machineTypes"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/machineTypes"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class MachineType extends Resource {
|
||||
|
|
|
@ -32,7 +32,7 @@ import com.google.common.base.Optional;
|
|||
* Represents a network used to enable instance communication.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/networks"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/networks"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class Network extends Resource {
|
||||
|
|
|
@ -38,7 +38,7 @@ import com.google.common.collect.ImmutableList;
|
|||
* Describes an operation being executed on some Resource
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/operations"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/operations"/>
|
||||
*/
|
||||
@Beta
|
||||
public class Operation extends Resource {
|
||||
|
|
|
@ -27,7 +27,7 @@ import com.google.common.base.Objects.ToStringHelper;
|
|||
/**
|
||||
* Quotas assigned to a given project or region.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/projects#resource"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/projects#resource"/>
|
||||
*/
|
||||
@Beta
|
||||
public class Quota {
|
||||
|
|
|
@ -33,7 +33,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
* Represents a region resource.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/regions"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/regions"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class Region extends Resource {
|
||||
|
|
|
@ -57,8 +57,6 @@ public class Resource {
|
|||
OPERATION_LIST,
|
||||
INSTANCE,
|
||||
INSTANCE_LIST,
|
||||
KERNEL,
|
||||
KERNEL_LIST,
|
||||
MACHINE_TYPE,
|
||||
MACHINE_TYPE_LIST,
|
||||
PROJECT,
|
||||
|
|
|
@ -37,7 +37,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
* Represents a route resource.
|
||||
*
|
||||
* @author Andrew Bayer
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/routes"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/routes"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class Route extends Resource {
|
||||
|
|
|
@ -31,7 +31,7 @@ import com.google.common.base.Optional;
|
|||
* A Persistent Disk Snapshot resource.
|
||||
*
|
||||
* @author Andrew Bayer
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/snapshots"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/snapshots"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class Snapshot extends AbstractDisk {
|
||||
|
|
|
@ -37,7 +37,7 @@ import com.google.common.collect.ImmutableSet;
|
|||
* Represents a zone resource.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/zones"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/zones"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class Zone extends Resource {
|
||||
|
@ -182,7 +182,7 @@ public final class Zone extends Resource {
|
|||
* Scheduled maintenance windows for the zone. When the zone is in a maintenance window,
|
||||
* all resources which reside in the zone will be unavailable.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/zones"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/zones"/>
|
||||
*/
|
||||
public static final class MaintenanceWindow {
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
|
|||
* Provides access to Addresses via their REST API.
|
||||
*
|
||||
* @author Andrew Bayer
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/addresses"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/addresses"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticator.class)
|
||||
|
|
|
@ -55,7 +55,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
|
|||
* Provides access to Disks via their REST API.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/disks"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/disks"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticator.class)
|
||||
|
@ -97,6 +97,50 @@ public interface DiskApi {
|
|||
@PayloadParam("sizeGb") int sizeGb,
|
||||
@PathParam("zone") String zone);
|
||||
|
||||
/**
|
||||
* Creates a persistent disk resource from the specified image, in the specified project,
|
||||
* specifying the size of the disk.
|
||||
*
|
||||
* @param sourceImage fully qualified URL for the image to be copied.
|
||||
* @param diskName the name of disk.
|
||||
* @param sizeGb the size of the disk
|
||||
* @param zone the name of the zone where the disk is to be created.
|
||||
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
|
||||
* you, and look for the status field.
|
||||
*/
|
||||
@Named("Disks:insert")
|
||||
@POST
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/zones/{zone}/disks")
|
||||
@OAuthScopes({COMPUTE_SCOPE})
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
Operation createFromImageWithSizeInZone(@QueryParam("sourceImage") String sourceImage,
|
||||
@PayloadParam("name") String diskName,
|
||||
@PayloadParam("sizeGb") int sizeGb,
|
||||
@PathParam("zone") String zone);
|
||||
|
||||
/**
|
||||
* Creates a persistent disk resource from the specified image, in the specified project,
|
||||
* with the default disk size.
|
||||
*
|
||||
* @param sourceImage fully qualified URL for the image to be copied.
|
||||
* @param diskName the name of disk.
|
||||
* @param zone the name of the zone where the disk is to be created.
|
||||
* @return an Operation resource. To check on the status of an operation, poll the Operations resource returned to
|
||||
* you, and look for the status field.
|
||||
*/
|
||||
@Named("Disks:insert")
|
||||
@POST
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/zones/{zone}/disks")
|
||||
@OAuthScopes({COMPUTE_SCOPE})
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
Operation createFromImageInZone(@QueryParam("sourceImage") String sourceImage,
|
||||
@PayloadParam("name") String diskName,
|
||||
@PathParam("zone") String zone);
|
||||
|
||||
/**
|
||||
* Deletes the specified persistent disk resource.
|
||||
*
|
||||
|
|
|
@ -63,7 +63,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
|
|||
* <p/>
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/firewalls"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/firewalls"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticator.class)
|
||||
|
|
|
@ -49,7 +49,7 @@ import org.jclouds.rest.annotations.Transform;
|
|||
* Provides access to Global Operations via their REST API.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/globalOperations"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/globalOperations"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticator.class)
|
||||
|
|
|
@ -51,7 +51,7 @@ import org.jclouds.rest.annotations.Transform;
|
|||
* <p/>
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/images"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/images"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticator.class)
|
||||
|
|
|
@ -63,7 +63,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
|
|||
* Provides access to Instances via their REST API.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/instances"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/instances"/>
|
||||
* @see InstanceApi
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
|
|
|
@ -1,140 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jclouds.googlecomputeengine.features;
|
||||
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.Fallbacks.EmptyIterableWithMarkerOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.collect.PagedIterable;
|
||||
import org.jclouds.googlecomputeengine.domain.Kernel;
|
||||
import org.jclouds.googlecomputeengine.domain.ListPage;
|
||||
import org.jclouds.googlecomputeengine.functions.internal.ParseKernels;
|
||||
import org.jclouds.googlecomputeengine.options.ListOptions;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.oauth.v2.config.OAuthScopes;
|
||||
import org.jclouds.oauth.v2.filters.OAuthAuthenticator;
|
||||
import org.jclouds.rest.annotations.Fallback;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.ResponseParser;
|
||||
import org.jclouds.rest.annotations.SkipEncoding;
|
||||
import org.jclouds.rest.annotations.Transform;
|
||||
|
||||
/**
|
||||
* Provides access to Kernels via their REST API.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/kernels"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticator.class)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public interface KernelApi {
|
||||
|
||||
/**
|
||||
* Returns the specified kernel resource
|
||||
*
|
||||
* @param kernelName name of the kernel resource to return.
|
||||
* @return If successful, this method returns a Kernel resource
|
||||
*/
|
||||
@Named("Kernels:get")
|
||||
@GET
|
||||
@Path("/global/kernels/{kernel}")
|
||||
@OAuthScopes(COMPUTE_READONLY_SCOPE)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
Kernel get(@PathParam("kernel") String kernelName);
|
||||
|
||||
/**
|
||||
* @see KernelApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
|
||||
*/
|
||||
@Named("Kernels:list")
|
||||
@GET
|
||||
@Path("/global/kernels")
|
||||
@OAuthScopes(COMPUTE_READONLY_SCOPE)
|
||||
@ResponseParser(ParseKernels.class)
|
||||
@Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
|
||||
ListPage<Kernel> listFirstPage();
|
||||
|
||||
/**
|
||||
* @see KernelApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
|
||||
*/
|
||||
@Named("Kernels:list")
|
||||
@GET
|
||||
@Path("/global/kernels")
|
||||
@OAuthScopes(COMPUTE_READONLY_SCOPE)
|
||||
@ResponseParser(ParseKernels.class)
|
||||
@Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
|
||||
ListPage<Kernel> listAtMarker(@QueryParam("pageToken") @Nullable String marker);
|
||||
|
||||
/**
|
||||
* Retrieves the list of kernel resources available to the specified project.
|
||||
* By default the list as a maximum size of 100, if no options are provided or ListOptions#getMaxResults() has not
|
||||
* been set.
|
||||
*
|
||||
* @param marker marks the beginning of the next list page
|
||||
* @param listOptions listing options
|
||||
* @return a page of the list
|
||||
* @see ListOptions
|
||||
* @see org.jclouds.googlecomputeengine.domain.ListPage
|
||||
*/
|
||||
@Named("Kernels:list")
|
||||
@GET
|
||||
@Path("/global/kernels")
|
||||
@OAuthScopes(COMPUTE_READONLY_SCOPE)
|
||||
@ResponseParser(ParseKernels.class)
|
||||
@Fallback(EmptyIterableWithMarkerOnNotFoundOr404.class)
|
||||
ListPage<Kernel> listAtMarker(@QueryParam("pageToken") @Nullable String marker,
|
||||
ListOptions listOptions);
|
||||
|
||||
/**
|
||||
* @see KernelApi#list(org.jclouds.googlecomputeengine.options.ListOptions)
|
||||
*/
|
||||
@Named("Kernels:list")
|
||||
@GET
|
||||
@Path("/global/kernels")
|
||||
@OAuthScopes(COMPUTE_READONLY_SCOPE)
|
||||
@ResponseParser(ParseKernels.class)
|
||||
@Transform(ParseKernels.ToPagedIterable.class)
|
||||
@Fallback(EmptyPagedIterableOnNotFoundOr404.class)
|
||||
PagedIterable<Kernel> list();
|
||||
|
||||
/**
|
||||
* A paged version of KernelApi#list()
|
||||
*
|
||||
* @return a Paged, Fluent Iterable that is able to fetch additional pages when required
|
||||
* @see PagedIterable
|
||||
* @see KernelApi#listAtMarker(String, org.jclouds.googlecomputeengine.options.ListOptions)
|
||||
*/
|
||||
@Named("Kernels:list")
|
||||
@GET
|
||||
@Path("/global/kernels")
|
||||
@OAuthScopes(COMPUTE_READONLY_SCOPE)
|
||||
@ResponseParser(ParseKernels.class)
|
||||
@Transform(ParseKernels.ToPagedIterable.class)
|
||||
@Fallback(EmptyPagedIterableOnNotFoundOr404.class)
|
||||
PagedIterable<Kernel> list(ListOptions listOptions);
|
||||
|
||||
}
|
|
@ -47,7 +47,7 @@ import org.jclouds.rest.annotations.Transform;
|
|||
* Provides access to MachineTypes via their REST API.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/machineTypes"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/machineTypes"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticator.class)
|
||||
|
|
|
@ -55,7 +55,7 @@ import org.jclouds.rest.binders.BindToJsonPayload;
|
|||
* Provides access to Networks via their REST API.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/networks"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/networks"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticator.class)
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.jclouds.rest.annotations.SkipEncoding;
|
|||
* Provides access to Projects via their REST API.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/projects"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/projects"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticator.class)
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.jclouds.rest.annotations.Transform;
|
|||
* Provides access to Regions via their REST API.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/regions"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/regions"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticator.class)
|
||||
|
|
|
@ -49,7 +49,7 @@ import org.jclouds.rest.annotations.Transform;
|
|||
* Provides access to Operations via their REST API.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/operations"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/operations"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticator.class)
|
||||
|
|
|
@ -57,7 +57,7 @@ import org.jclouds.rest.annotations.Transform;
|
|||
* Provides access to Routes via their REST API.
|
||||
*
|
||||
* @author Andrew Bayer
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/routess"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/routess"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticator.class)
|
||||
|
|
|
@ -50,7 +50,7 @@ import org.jclouds.rest.annotations.Transform;
|
|||
* Provides access to Snapshots via their REST API.
|
||||
*
|
||||
* @author Andrew Bayer
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/snapshots"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/snapshots"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticator.class)
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.jclouds.rest.annotations.Transform;
|
|||
* Provides access to Zones via their REST API.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/zones"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/zones"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticator.class)
|
||||
|
|
|
@ -49,7 +49,7 @@ import org.jclouds.rest.annotations.Transform;
|
|||
* Provides access to Operations via their REST API.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/operations"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/operations"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticator.class)
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jclouds.googlecomputeengine.functions.internal;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.jclouds.collect.IterableWithMarker;
|
||||
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
|
||||
import org.jclouds.googlecomputeengine.domain.Kernel;
|
||||
import org.jclouds.googlecomputeengine.domain.ListPage;
|
||||
import org.jclouds.googlecomputeengine.options.ListOptions;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
import org.jclouds.json.Json;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
/**
|
||||
* @author David Alves
|
||||
*/
|
||||
public class ParseKernels extends ParseJson<ListPage<Kernel>> {
|
||||
|
||||
@Inject
|
||||
public ParseKernels(Json json) {
|
||||
super(json, new TypeLiteral<ListPage<Kernel>>() {
|
||||
});
|
||||
}
|
||||
|
||||
public static class ToPagedIterable extends BaseToPagedIterable<Kernel, ToPagedIterable> {
|
||||
|
||||
private final GoogleComputeEngineApi api;
|
||||
|
||||
@Inject
|
||||
protected ToPagedIterable(GoogleComputeEngineApi api) {
|
||||
this.api = checkNotNull(api, "api");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Function<Object, IterableWithMarker<Kernel>> fetchNextPage(final String projectName,
|
||||
final ListOptions options) {
|
||||
return new Function<Object, IterableWithMarker<Kernel>>() {
|
||||
|
||||
@Override
|
||||
public IterableWithMarker<Kernel> apply(Object input) {
|
||||
return api.getKernelApiForProject(projectName).listAtMarker(input.toString(), options);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -24,7 +24,7 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
|
|||
* Allows to optionally specify a filter, max results and a page token for <code>listFirstPage()</code> REST methods.
|
||||
*
|
||||
* @author David Alves
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1beta16/operations/listFirstPage"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/operations/listFirstPage"/>
|
||||
*/
|
||||
public class ListOptions extends BaseHttpRequestOptions {
|
||||
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jclouds.googlecomputeengine.predicates;
|
||||
|
||||
import org.jclouds.googlecomputeengine.domain.InstanceTemplate.PersistentDisk;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
||||
public class InstancePredicates {
|
||||
|
||||
public static Predicate<PersistentDisk> isBootDisk() {
|
||||
return new Predicate<PersistentDisk>() {
|
||||
@Override
|
||||
public boolean apply(PersistentDisk input) {
|
||||
return input.isBoot();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -43,7 +43,7 @@ public class PageSystemExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/images")
|
||||
".com/compute/v1/projects/myproject/global/images")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -66,7 +66,7 @@ public class PageSystemExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/images?maxResults=3")
|
||||
".com/compute/v1/projects/myproject/global/images?maxResults=3")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class PageSystemExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/images?pageToken" +
|
||||
".com/compute/v1/projects/myproject/global/images?pageToken" +
|
||||
"=CgVJTUFHRRIbZ29vZ2xlLmNlbnRvcy02LTItdjIwMTIwNjIx&maxResults=3")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
@ -83,7 +83,7 @@ public class PageSystemExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/images?pageToken" +
|
||||
".com/compute/v1/projects/myproject/global/images?pageToken" +
|
||||
"=CgVJTUFHRRIbZ29vZ2xlLmdjZWwtMTAtMDQtdjIwMTIxMTA2&maxResults=3")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
|
|
@ -19,10 +19,13 @@ package org.jclouds.googlecomputeengine.compute;
|
|||
import static com.google.common.collect.Iterables.getOnlyElement;
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.GCE_BOOT_DISK_SUFFIX;
|
||||
import static org.jclouds.googlecomputeengine.features.GlobalOperationApiExpectTest.GET_GLOBAL_OPERATION_REQUEST;
|
||||
import static org.jclouds.googlecomputeengine.features.GlobalOperationApiExpectTest.GET_GLOBAL_OPERATION_RESPONSE;
|
||||
import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_GOOGLE_IMAGES_REQUEST;
|
||||
import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_GOOGLE_IMAGES_RESPONSE;
|
||||
import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_DEBIAN_IMAGES_REQUEST;
|
||||
import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_DEBIAN_IMAGES_RESPONSE;
|
||||
import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_CENTOS_IMAGES_REQUEST;
|
||||
import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_CENTOS_IMAGES_RESPONSE;
|
||||
import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_PROJECT_IMAGES_REQUEST;
|
||||
import static org.jclouds.googlecomputeengine.features.ImageApiExpectTest.LIST_PROJECT_IMAGES_RESPONSE;
|
||||
import static org.jclouds.googlecomputeengine.features.InstanceApiExpectTest.LIST_CENTRAL1B_INSTANCES_REQUEST;
|
||||
|
@ -55,6 +58,7 @@ import javax.ws.rs.core.MediaType;
|
|||
import org.jclouds.compute.ComputeService;
|
||||
import org.jclouds.compute.RunNodesException;
|
||||
import org.jclouds.compute.domain.Hardware;
|
||||
import org.jclouds.compute.domain.NodeMetadata;
|
||||
import org.jclouds.compute.domain.Template;
|
||||
import org.jclouds.domain.Location;
|
||||
import org.jclouds.googlecomputeengine.compute.options.GoogleComputeEngineTemplateOptions;
|
||||
|
@ -82,7 +86,7 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
private HttpRequest INSERT_NETWORK_REQUEST = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/networks")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromStringWithContentType("{\"name\":\"jclouds-test\",\"IPv4Range\":\"10.0.0.0/8\"}",
|
||||
|
@ -92,11 +96,11 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
private HttpRequest INSERT_FIREWALL_REQUEST = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/firewalls")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromStringWithContentType("{\"name\":\"jclouds-test\",\"network\":\"https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/networks/jclouds-test\"," +
|
||||
".com/compute/v1/projects/myproject/global/networks/jclouds-test\"," +
|
||||
"\"sourceRanges\":[\"10.0.0.0/8\",\"0.0.0.0/0\"],\"sourceTags\":[\"aTag\"],\"allowed\":[{\"IPProtocol\":\"tcp\"," +
|
||||
"\"ports\":[\"22\"]}," +
|
||||
"{\"IPProtocol\":\"udp\",\"ports\":[\"22\"]}]}",
|
||||
|
@ -109,7 +113,7 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
" \"id\": \"13024414170909937976\",\n" +
|
||||
" \"creationTimestamp\": \"2012-10-24T20:13:19.967\",\n" +
|
||||
" \"selfLink\": \"https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/networks/jclouds-test\",\n" +
|
||||
".com/compute/v1/projects/myproject/global/networks/jclouds-test\",\n" +
|
||||
" \"name\": \"jclouds-test\",\n" +
|
||||
" \"description\": \"test network\",\n" +
|
||||
" \"IPv4Range\": \"10.0.0.0/8\",\n" +
|
||||
|
@ -121,7 +125,7 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
|
||||
private HttpRequest SET_TAGS_REQUEST = HttpRequest.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances/test-1/setTags")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/setTags")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromStringWithContentType("{\"items\":[\"aTag\"],\"fingerprint\":\"abcd\"}",
|
||||
|
@ -151,38 +155,83 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
"application/json")).build();
|
||||
}
|
||||
|
||||
private String replaceInstanceNameNetworkAndStatusOnResource(String resourceName, String instanceName,
|
||||
String networkName, String status) {
|
||||
private HttpResponse getDiskResponseForInstance(String instanceName) {
|
||||
return HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromStringWithContentType(
|
||||
replaceDiskNameOnResource("/disk_get.json", instanceName + "-" + GCE_BOOT_DISK_SUFFIX),
|
||||
"application/json")).build();
|
||||
}
|
||||
|
||||
private String replaceDiskNameOnResource(String resourceName, String diskName) {
|
||||
try {
|
||||
return Strings2.toStringAndClose(this.getClass().getResourceAsStream(resourceName)).replace("test-0",
|
||||
instanceName).replace("default", networkName).replace("RUNNING", status);
|
||||
return Strings2.toStringAndClose(this.getClass().getResourceAsStream(resourceName))
|
||||
.replace("testimage1", diskName);
|
||||
} catch (IOException e) {
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
private String replaceInstanceNameNetworkAndStatusOnResource(String resourceName, String instanceName,
|
||||
String networkName, String status) {
|
||||
try {
|
||||
return Strings2.toStringAndClose(this.getClass().getResourceAsStream(resourceName)).replace("test-0",
|
||||
instanceName).replace("default", networkName).replace("RUNNING", status);
|
||||
} catch (IOException e) {
|
||||
throw Throwables.propagate(e);
|
||||
}
|
||||
}
|
||||
|
||||
private HttpRequest createDiskRequestForInstance(String instanceName) {
|
||||
return HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks"
|
||||
+ "?sourceImage=https%3A//www.googleapis.com/compute/v1/projects/centos-cloud/global/images/gcel-12-04-v20121106")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromStringWithContentType("{\"name\":\"" + instanceName + "-" + GCE_BOOT_DISK_SUFFIX + "\","
|
||||
+ "\"sizeGb\":10}",
|
||||
MediaType.APPLICATION_JSON)).build();
|
||||
}
|
||||
|
||||
private HttpRequest getDiskRequestForInstance(String instanceName) {
|
||||
return HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/disks/"
|
||||
+ instanceName + "-" + GCE_BOOT_DISK_SUFFIX)
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private HttpRequest createInstanceRequestForInstance(String instanceName, String groupName,
|
||||
String networkName, String publicKey) {
|
||||
return HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromStringWithContentType("{\"name\":\"" + instanceName + "\"," +
|
||||
"\"machineType\":\"https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1\"," +
|
||||
"\"image\":\"https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/google/global/images/gcel-12-04-v20121106\"," +
|
||||
"\"serviceAccounts\":[]," +
|
||||
"\"networkInterfaces\":[{\"network\":\"https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/networks/" + networkName + "\"," +
|
||||
"\"accessConfigs\":[{\"type\":\"ONE_TO_ONE_NAT\"}]}]," +
|
||||
"\"metadata\":{\"kind\":\"compute#metadata\",\"items\":[{\"key\":\"sshKeys\"," +
|
||||
"\"value\":\"jclouds:" +
|
||||
publicKey + " jclouds@localhost\"},{\"key\":\"jclouds-group\"," +
|
||||
"\"value\":\"" + groupName + "\"}]}}",
|
||||
MediaType.APPLICATION_JSON)).build();
|
||||
"\"machineType\":\"https://www.googleapis" +
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1\"," +
|
||||
"\"serviceAccounts\":[]," +
|
||||
"\"networkInterfaces\":[{\"network\":\"https://www.googleapis" +
|
||||
".com/compute/v1/projects/myproject/global/networks/" + networkName + "\"," +
|
||||
"\"accessConfigs\":[{\"type\":\"ONE_TO_ONE_NAT\"}]}]," +
|
||||
"\"disks\":[{\"mode\":\"READ_WRITE\",\"source\":\"https://www.googleapis.com/" +
|
||||
"compute/v1/projects/myproject/zones/us-central1-a/disks/" + instanceName +
|
||||
"-" + GCE_BOOT_DISK_SUFFIX + "\",\"deleteOnTerminate\":true,\"boot\":true,\"type\":\"PERSISTENT\"}]," +
|
||||
"\"metadata\":{\"kind\":\"compute#metadata\",\"items\":[{\"key\":\"sshKeys\"," +
|
||||
"\"value\":\"jclouds:" +
|
||||
publicKey + " jclouds@localhost\"},{\"key\":\"jclouds-group\"," +
|
||||
"\"value\":\"" + groupName + "\"},{\"key\":\"jclouds-image\",\"value\":\"https://www.googleapis" +
|
||||
".com/compute/v1/projects/centos-cloud/global/images/gcel-12-04-v20121106\"}," +
|
||||
"{\"key\":\"jclouds-delete-boot-disk\",\"value\":\"true\"}]}}",
|
||||
MediaType.APPLICATION_JSON)).build();
|
||||
}
|
||||
|
||||
private HttpRequest getInstanceRequestForInstance(String instanceName) {
|
||||
|
@ -190,7 +239,7 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances/" + instanceName)
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/instances/" + instanceName)
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
}
|
||||
|
@ -230,7 +279,8 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
.put(GET_PROJECT_REQUEST, GET_PROJECT_RESPONSE)
|
||||
.put(LIST_ZONES_REQ, LIST_ZONES_RESPONSE)
|
||||
.put(LIST_PROJECT_IMAGES_REQUEST, LIST_PROJECT_IMAGES_RESPONSE)
|
||||
.put(LIST_GOOGLE_IMAGES_REQUEST, LIST_GOOGLE_IMAGES_RESPONSE)
|
||||
.put(LIST_DEBIAN_IMAGES_REQUEST, LIST_DEBIAN_IMAGES_RESPONSE)
|
||||
.put(LIST_CENTOS_IMAGES_REQUEST, LIST_CENTOS_IMAGES_RESPONSE)
|
||||
.put(LIST_MACHINE_TYPES_REQUEST, LIST_MACHINE_TYPES_RESPONSE)
|
||||
.put(LIST_CENTRAL1B_MACHINE_TYPES_REQUEST, LIST_CENTRAL1B_MACHINE_TYPES_RESPONSE)
|
||||
.build();
|
||||
|
@ -259,21 +309,21 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
HttpRequest deleteNodeRequest = HttpRequest.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances/test-delete-networks")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-delete-networks")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpRequest deleteFirewallRequest = HttpRequest.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/firewalls/jclouds-test-delete")
|
||||
".com/compute/v1/projects/myproject/global/firewalls/jclouds-test-delete")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpRequest getNetworkRequest = HttpRequest.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/networks/jclouds-test-delete")
|
||||
".com/compute/v1/projects/myproject/global/networks/jclouds-test-delete")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -283,7 +333,7 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
HttpRequest listFirewallsRequest = HttpRequest.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/firewalls")
|
||||
".com/compute/v1/projects/myproject/global/firewalls")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -293,21 +343,32 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
HttpRequest deleteNetworkReqquest = HttpRequest.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/networks/jclouds-test-delete")
|
||||
".com/compute/v1/projects/myproject/global/networks/jclouds-test-delete")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpRequest deleteDiskRequest= HttpRequest.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/disks/test")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
List<HttpRequest> orderedRequests = ImmutableList.<HttpRequest>builder()
|
||||
.add(requestForScopes(COMPUTE_READONLY_SCOPE))
|
||||
.add(GET_PROJECT_REQUEST)
|
||||
.add(getInstanceRequestForInstance("test-delete-networks"))
|
||||
.add(LIST_PROJECT_IMAGES_REQUEST)
|
||||
.add(LIST_GOOGLE_IMAGES_REQUEST)
|
||||
.add(LIST_ZONES_REQ)
|
||||
.add(LIST_MACHINE_TYPES_REQUEST)
|
||||
.add(LIST_PROJECT_IMAGES_REQUEST)
|
||||
.add(LIST_DEBIAN_IMAGES_REQUEST)
|
||||
.add(LIST_CENTOS_IMAGES_REQUEST)
|
||||
.add(getInstanceRequestForInstance("test-delete-networks"))
|
||||
.add(requestForScopes(COMPUTE_SCOPE))
|
||||
.add(deleteNodeRequest)
|
||||
.add(GET_ZONE_OPERATION_REQUEST)
|
||||
.add(deleteDiskRequest)
|
||||
.add(GET_ZONE_OPERATION_REQUEST)
|
||||
.add(getInstanceRequestForInstance("test-delete-networks"))
|
||||
.add(LIST_INSTANCES_REQUEST)
|
||||
.add(getNetworkRequest)
|
||||
|
@ -324,13 +385,18 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
.add(GET_PROJECT_RESPONSE)
|
||||
.add(getInstanceResponseForInstanceAndNetworkAndStatus("test-delete-networks", "test-network", Instance
|
||||
.Status.RUNNING.name()))
|
||||
.add(LIST_PROJECT_IMAGES_RESPONSE)
|
||||
.add(LIST_GOOGLE_IMAGES_RESPONSE)
|
||||
.add(LIST_ZONES_SHORT_RESPONSE)
|
||||
.add(LIST_MACHINE_TYPES_RESPONSE)
|
||||
.add(LIST_PROJECT_IMAGES_RESPONSE)
|
||||
.add(LIST_DEBIAN_IMAGES_RESPONSE)
|
||||
.add(LIST_CENTOS_IMAGES_RESPONSE)
|
||||
.add(getInstanceResponseForInstanceAndNetworkAndStatus("test-delete-networks", "test-network", Instance
|
||||
.Status.RUNNING.name()))
|
||||
.add(TOKEN_RESPONSE)
|
||||
.add(SUCESSFULL_OPERATION_RESPONSE)
|
||||
.add(GET_ZONE_OPERATION_RESPONSE)
|
||||
.add(SUCESSFULL_OPERATION_RESPONSE)
|
||||
.add(GET_ZONE_OPERATION_RESPONSE)
|
||||
.add(getInstanceResponseForInstanceAndNetworkAndStatus("test-delete-networks", "test-network", Instance
|
||||
.Status.TERMINATED.name()))
|
||||
.add(getListInstancesResponseForSingleInstanceAndNetworkAndStatus("test-delete-networks",
|
||||
|
@ -359,7 +425,8 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
.put(LIST_INSTANCES_REQUEST, LIST_INSTANCES_RESPONSE)
|
||||
.put(LIST_CENTRAL1B_INSTANCES_REQUEST, LIST_CENTRAL1B_INSTANCES_RESPONSE)
|
||||
.put(LIST_PROJECT_IMAGES_REQUEST, LIST_PROJECT_IMAGES_RESPONSE)
|
||||
.put(LIST_GOOGLE_IMAGES_REQUEST, LIST_GOOGLE_IMAGES_RESPONSE)
|
||||
.put(LIST_DEBIAN_IMAGES_REQUEST, LIST_DEBIAN_IMAGES_RESPONSE)
|
||||
.put(LIST_CENTOS_IMAGES_REQUEST, LIST_CENTOS_IMAGES_RESPONSE)
|
||||
.put(LIST_MACHINE_TYPES_REQUEST, LIST_MACHINE_TYPES_RESPONSE)
|
||||
.put(LIST_CENTRAL1B_MACHINE_TYPES_REQUEST, LIST_CENTRAL1B_MACHINE_TYPES_RESPONSE)
|
||||
.build();
|
||||
|
@ -392,18 +459,18 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/firewalls/jclouds-test-port-22")
|
||||
".com/compute/v1/projects/myproject/global/firewalls/jclouds-test-port-22")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpRequest insertFirewallRequest = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/firewalls")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromStringWithContentType("{\"name\":\"jclouds-test-port-22\",\"network\":\"https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/networks/jclouds-test\"," +
|
||||
".com/compute/v1/projects/myproject/global/networks/jclouds-test\"," +
|
||||
"\"sourceRanges\":[\"10.0.0.0/8\",\"0.0.0.0/0\"],\"sourceTags\":[\"aTag\"],\"targetTags\":[\"jclouds-test-port-22\"],\"allowed\":[{\"IPProtocol\":\"tcp\"," +
|
||||
"\"ports\":[\"22\"]}," +
|
||||
"{\"IPProtocol\":\"udp\",\"ports\":[\"22\"]}]}",
|
||||
|
@ -413,7 +480,7 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
HttpRequest setTagsRequest = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances/test-1/setTags")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/setTags")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromStringWithContentType("{\"items\":[\"jclouds-test-port-22\"],\"fingerprint\":\"abcd\"}",
|
||||
|
@ -425,7 +492,8 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
.add(GET_PROJECT_REQUEST)
|
||||
.add(LIST_ZONES_REQ)
|
||||
.add(LIST_PROJECT_IMAGES_REQUEST)
|
||||
.add(LIST_GOOGLE_IMAGES_REQUEST)
|
||||
.add(LIST_DEBIAN_IMAGES_REQUEST)
|
||||
.add(LIST_CENTOS_IMAGES_REQUEST)
|
||||
.add(LIST_ZONES_REQ)
|
||||
.add(LIST_MACHINE_TYPES_REQUEST)
|
||||
.add(GET_NETWORK_REQUEST)
|
||||
|
@ -438,9 +506,13 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
.add(insertFirewallRequest)
|
||||
.add(GET_GLOBAL_OPERATION_REQUEST)
|
||||
.add(LIST_INSTANCES_REQUEST)
|
||||
.add(LIST_PROJECT_IMAGES_REQUEST)
|
||||
.add(LIST_GOOGLE_IMAGES_REQUEST)
|
||||
.add(LIST_MACHINE_TYPES_REQUEST)
|
||||
.add(LIST_PROJECT_IMAGES_REQUEST)
|
||||
.add(LIST_DEBIAN_IMAGES_REQUEST)
|
||||
.add(LIST_CENTOS_IMAGES_REQUEST)
|
||||
.add(createDiskRequestForInstance("test-1"))
|
||||
.add(GET_ZONE_OPERATION_REQUEST)
|
||||
.add(getDiskRequestForInstance("test-1"))
|
||||
.add(createInstanceRequestForInstance("test-1", "test", "jclouds-test", openSshKey))
|
||||
.add(GET_ZONE_OPERATION_REQUEST)
|
||||
.add(getInstanceRequestForInstance("test-1"))
|
||||
|
@ -448,6 +520,9 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
.add(GET_ZONE_OPERATION_REQUEST)
|
||||
.add(getInstanceRequestForInstance("test-1"))
|
||||
.add(setTagsRequest)
|
||||
.add(LIST_PROJECT_IMAGES_REQUEST)
|
||||
.add(LIST_DEBIAN_IMAGES_REQUEST)
|
||||
.add(LIST_CENTOS_IMAGES_REQUEST)
|
||||
.add(setTagsRequest)
|
||||
.build();
|
||||
|
||||
|
@ -456,7 +531,8 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
.add(GET_PROJECT_RESPONSE)
|
||||
.add(LIST_ZONES_SHORT_RESPONSE)
|
||||
.add(LIST_PROJECT_IMAGES_RESPONSE)
|
||||
.add(LIST_GOOGLE_IMAGES_RESPONSE)
|
||||
.add(LIST_DEBIAN_IMAGES_RESPONSE)
|
||||
.add(LIST_CENTOS_IMAGES_RESPONSE)
|
||||
.add(LIST_ZONES_SHORT_RESPONSE)
|
||||
.add(LIST_MACHINE_TYPES_RESPONSE)
|
||||
.add(HttpResponse.builder().statusCode(404).build())
|
||||
|
@ -469,9 +545,13 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
.add(SUCESSFULL_OPERATION_RESPONSE)
|
||||
.add(GET_GLOBAL_OPERATION_RESPONSE)
|
||||
.add(LIST_INSTANCES_RESPONSE)
|
||||
.add(LIST_PROJECT_IMAGES_RESPONSE)
|
||||
.add(LIST_GOOGLE_IMAGES_RESPONSE)
|
||||
.add(LIST_MACHINE_TYPES_RESPONSE)
|
||||
.add(LIST_PROJECT_IMAGES_RESPONSE)
|
||||
.add(LIST_DEBIAN_IMAGES_RESPONSE)
|
||||
.add(LIST_CENTOS_IMAGES_RESPONSE)
|
||||
.add(SUCESSFULL_OPERATION_RESPONSE)
|
||||
.add(GET_ZONE_OPERATION_RESPONSE)
|
||||
.add(getDiskResponseForInstance("test-1"))
|
||||
.add(SUCESSFULL_OPERATION_RESPONSE)
|
||||
.add(GET_ZONE_OPERATION_RESPONSE)
|
||||
.add(getInstanceResponse)
|
||||
|
@ -479,6 +559,9 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
.add(GET_ZONE_OPERATION_RESPONSE)
|
||||
.add(getInstanceResponse)
|
||||
.add(SUCESSFULL_OPERATION_RESPONSE)
|
||||
.add(LIST_PROJECT_IMAGES_RESPONSE)
|
||||
.add(LIST_DEBIAN_IMAGES_RESPONSE)
|
||||
.add(LIST_CENTOS_IMAGES_RESPONSE)
|
||||
.add(SUCESSFULL_OPERATION_RESPONSE)
|
||||
.build();
|
||||
|
||||
|
@ -487,7 +570,8 @@ public class GoogleComputeEngineServiceExpectTest extends BaseGoogleComputeEngin
|
|||
|
||||
GoogleComputeEngineTemplateOptions options = computeService.templateOptions().as(GoogleComputeEngineTemplateOptions.class);
|
||||
options.tags(ImmutableSet.of("aTag"));
|
||||
getOnlyElement(computeService.createNodesInGroup("test", 1, options));
|
||||
NodeMetadata node = getOnlyElement(computeService.createNodesInGroup("test", 1, options));
|
||||
assertEquals(node.getImageId(), "gcel-12-04-v20121106");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,8 +62,8 @@ public class FirewallToIpPermissionTest {
|
|||
.addPort(33).build());
|
||||
builder.addAllowed(Firewall.Rule.builder().IpProtocol(IpProtocol.ICMP).build());
|
||||
builder.id("abcd");
|
||||
builder.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/firewalls/jclouds-test"));
|
||||
builder.network(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks/jclouds-test"));
|
||||
builder.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/jclouds-test"));
|
||||
builder.network(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test"));
|
||||
builder.creationTimestamp(new Date());
|
||||
builder.name("jclouds-test");
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public class NetworkToSecurityGroupTest {
|
|||
Network.Builder builder = Network.builder();
|
||||
|
||||
builder.id("abcd");
|
||||
builder.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks/jclouds-test"));
|
||||
builder.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test"));
|
||||
builder.creationTimestamp(new Date());
|
||||
builder.description("some description");
|
||||
builder.gatewayIPv4("1.2.3.4");
|
||||
|
@ -82,7 +82,7 @@ public class NetworkToSecurityGroupTest {
|
|||
SecurityGroup group = netToSg.apply(network);
|
||||
|
||||
assertEquals(group.getId(), "jclouds-test");
|
||||
assertEquals(group.getUri(), URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks/jclouds-test"));
|
||||
assertEquals(group.getUri(), URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test"));
|
||||
assertEquals(group.getIpPermissions().size(), 3);
|
||||
assertTrue(Iterables.any(group.getIpPermissions(), Predicates.and(hasProtocol(IpProtocol.TCP),
|
||||
hasStartAndEndPort(1, 10))), "No permission found for TCP, ports 1-10");
|
||||
|
|
|
@ -52,7 +52,7 @@ public class FindNetworkOrCreateTest {
|
|||
|
||||
Network network = Network.builder().IPv4Range("0.0.0.0/0")
|
||||
.id("abcd").name("this-network")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks/this-network"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network"))
|
||||
.build();
|
||||
|
||||
final Supplier<String> userProject = new Supplier<String>() {
|
||||
|
@ -94,7 +94,7 @@ public class FindNetworkOrCreateTest {
|
|||
|
||||
Network network = Network.builder().IPv4Range("0.0.0.0/0")
|
||||
.id("abcd").name("this-network")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks/this-network"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network"))
|
||||
.build();
|
||||
|
||||
Operation createOp = createMock(Operation.class);
|
||||
|
|
|
@ -42,7 +42,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpRequest get = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/regions/us-central1/addresses/test-ip1")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip1")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpRequest get = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/regions/us-central1/addresses/test-ip1")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip1")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -76,7 +76,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpRequest insert = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/regions/us-central1/addresses")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromResourceWithContentType("/address_insert.json", MediaType.APPLICATION_JSON))
|
||||
|
@ -97,7 +97,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/regions/us-central1/addresses/test-ip1")
|
||||
".com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip1")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -116,7 +116,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/regions/us-central1/addresses/test-ip1")
|
||||
".com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip1")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -133,7 +133,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/regions/us-central1/addresses")
|
||||
".com/compute/v1/projects/myproject/regions/us-central1/addresses")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -152,7 +152,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/regions/us-central1/addresses")
|
||||
".com/compute/v1/projects/myproject/regions/us-central1/addresses")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
|
|
@ -37,12 +37,13 @@ import org.testng.annotations.Test;
|
|||
*/
|
||||
@Test(groups = "unit")
|
||||
public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
||||
public static final String IMAGE_URL = "https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/images/foo";
|
||||
|
||||
public void testGetDiskResponseIs2xx() throws Exception {
|
||||
HttpRequest get = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/disks/testimage1")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -60,7 +61,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpRequest get = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/disks/testimage1")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -76,7 +77,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpRequest insert = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/disks")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromResourceWithContentType("/disk_insert.json", MediaType.APPLICATION_JSON))
|
||||
|
@ -92,11 +93,32 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
assertEquals(api.createInZone("testimage1", 1, "us-central1-a"), new ParseOperationTest().expected());
|
||||
}
|
||||
|
||||
public void testInsertDiskFromImageResponseIs2xx() {
|
||||
HttpRequest insert = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks"
|
||||
+ "?sourceImage=" + IMAGE_URL.replaceAll(":", "%3A"))
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromResourceWithContentType("/disk_insert.json", MediaType.APPLICATION_JSON))
|
||||
.build();
|
||||
|
||||
HttpResponse insertDiskResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/zone_operation.json")).build();
|
||||
|
||||
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, insert,
|
||||
insertDiskResponse).getDiskApiForProject("myproject");
|
||||
|
||||
assertEquals(api.createFromImageWithSizeInZone(IMAGE_URL, "testimage1", 1, "us-central1-a"), new ParseOperationTest().expected());
|
||||
}
|
||||
|
||||
public void testCreateSnapshotResponseIs2xx() {
|
||||
HttpRequest createSnapshotRequest = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/disks"
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks"
|
||||
+ "/testimage1/createSnapshot")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
|
@ -117,7 +139,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpRequest createSnapshotRequest = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/disks"
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks"
|
||||
+ "/testimage1/createSnapshot")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
|
@ -138,7 +160,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/disks/testimage1")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -157,7 +179,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/disks/testimage1")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -174,7 +196,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/disks")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/disks")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -193,7 +215,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/disks")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/disks")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/firewalls/jclouds-test")
|
||||
".com/compute/v1/projects/myproject/global/firewalls/jclouds-test")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -108,7 +108,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/firewalls/jclouds-test")
|
||||
".com/compute/v1/projects/myproject/global/firewalls/jclouds-test")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -125,7 +125,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
HttpRequest request = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/firewalls")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(firewallPayloadFirewallOfName(
|
||||
|
@ -144,7 +144,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
TOKEN_RESPONSE, request, insertFirewallResponse).getFirewallApiForProject("myproject");
|
||||
|
||||
assertEquals(api.createInNetwork("myfw", URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/networks/default"),
|
||||
".com/compute/v1/projects/myproject/global/networks/default"),
|
||||
new FirewallOptions()
|
||||
.addAllowedRule(Firewall.Rule.builder()
|
||||
.IpProtocol(IpProtocol.TCP)
|
||||
|
@ -160,7 +160,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
HttpRequest update = HttpRequest
|
||||
.builder()
|
||||
.method("PUT")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/firewalls/myfw")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/myfw")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(firewallPayloadFirewallOfName(
|
||||
|
@ -183,7 +183,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
new FirewallOptions()
|
||||
.name("myfw")
|
||||
.network(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/networks/default"))
|
||||
".com/compute/v1/projects/myproject/global/networks/default"))
|
||||
.addAllowedRule(Firewall.Rule.builder()
|
||||
.IpProtocol(IpProtocol.TCP)
|
||||
.addPort(22)
|
||||
|
@ -197,7 +197,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
HttpRequest update = HttpRequest
|
||||
.builder()
|
||||
.method("PATCH")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/firewalls/myfw")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/myfw")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(firewallPayloadFirewallOfName(
|
||||
|
@ -220,7 +220,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
new FirewallOptions()
|
||||
.name("myfw")
|
||||
.network(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/networks/default"))
|
||||
".com/compute/v1/projects/myproject/global/networks/default"))
|
||||
.addAllowedRule(Firewall.Rule.builder()
|
||||
.IpProtocol(IpProtocol.TCP)
|
||||
.addPort(22)
|
||||
|
@ -235,7 +235,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/firewalls/default-allow-internal")
|
||||
".com/compute/v1/projects/myproject/global/firewalls/default-allow-internal")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -254,7 +254,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/firewalls/default-allow-internal")
|
||||
".com/compute/v1/projects/myproject/global/firewalls/default-allow-internal")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -271,7 +271,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/firewalls")
|
||||
".com/compute/v1/projects/myproject/global/firewalls")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -290,7 +290,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/firewalls")
|
||||
".com/compute/v1/projects/myproject/global/firewalls")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.testng.annotations.Test;
|
|||
public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
||||
|
||||
private static final String OPERATIONS_URL_PREFIX = "https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/operations";
|
||||
".com/compute/v1/projects/myproject/global/operations";
|
||||
|
||||
public static final HttpRequest GET_GLOBAL_OPERATION_REQUEST = HttpRequest
|
||||
.builder()
|
||||
|
|
|
@ -40,30 +40,40 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/images")
|
||||
".com/compute/v1/projects/myproject/global/images")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
public static final HttpResponse LIST_PROJECT_IMAGES_RESPONSE = HttpResponse.builder().statusCode(200)
|
||||
.payload(staticPayloadFromResource("/image_list.json")).build();
|
||||
|
||||
public static final HttpRequest LIST_GOOGLE_IMAGES_REQUEST = HttpRequest
|
||||
public static final HttpRequest LIST_CENTOS_IMAGES_REQUEST = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/google/global/images")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
public static final HttpResponse LIST_GOOGLE_IMAGES_RESPONSE = HttpResponse.builder().statusCode(200)
|
||||
public static final HttpResponse LIST_CENTOS_IMAGES_RESPONSE = HttpResponse.builder().statusCode(200)
|
||||
.payload(staticPayloadFromResource("/image_list_single_page.json")).build();
|
||||
|
||||
public static final HttpRequest LIST_DEBIAN_IMAGES_REQUEST = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
public static final HttpResponse LIST_DEBIAN_IMAGES_RESPONSE =
|
||||
HttpResponse.builder().statusCode(200)
|
||||
.payload(staticPayloadFromResource("/image_list_empty.json")).build();
|
||||
|
||||
public void testGetImageResponseIs2xx() throws Exception {
|
||||
HttpRequest get = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/google/global/images/centos-6-2-v20120326")
|
||||
".com/compute/v1/projects/centos-cloud/global/images/centos-6-2-v20120326")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -71,7 +81,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.payload(payloadFromResource("/image_get.json")).build();
|
||||
|
||||
ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getImageApiForProject("google");
|
||||
TOKEN_RESPONSE, get, operationResponse).getImageApiForProject("centos-cloud");
|
||||
|
||||
assertEquals(imageApi.get("centos-6-2-v20120326"),
|
||||
new ParseImageTest().expected());
|
||||
|
@ -82,14 +92,14 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/google/global/images/centos-6-2-v20120326")
|
||||
".com/compute/v1/projects/centos-cloud/global/images/centos-6-2-v20120326")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getImageApiForProject("google");
|
||||
TOKEN_RESPONSE, get, operationResponse).getImageApiForProject("centos-cloud");
|
||||
|
||||
assertNull(imageApi.get("centos-6-2-v20120326"));
|
||||
}
|
||||
|
@ -99,7 +109,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/images/centos-6-2-v20120326")
|
||||
".com/compute/v1/projects/myproject/global/images/centos-6-2-v20120326")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -118,7 +128,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/images/centos-6-2-v20120326")
|
||||
".com/compute/v1/projects/myproject/global/images/centos-6-2-v20120326")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
private Image image;
|
||||
|
||||
private ImageApi api() {
|
||||
return api.getImageApiForProject("google");
|
||||
return api.getImageApiForProject("centos-cloud");
|
||||
}
|
||||
|
||||
@Test(groups = "live")
|
||||
|
|
|
@ -55,7 +55,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances/test-1")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/instances")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-b/instances")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-b/instances")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -113,7 +113,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances/test-1/serialPort")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/serialPort")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -131,7 +131,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
HttpRequest insert = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromResourceWithContentType("/instance_insert_simple.json", MediaType.APPLICATION_JSON))
|
||||
|
@ -144,9 +144,8 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
CREATE_INSTANCE_RESPONSE)).getInstanceApiForProject("myproject");
|
||||
|
||||
InstanceTemplate options = InstanceTemplate.builder().forMachineType("us-central1-a/n1-standard-1")
|
||||
.image(URI.create("https://www.googleapis.com/compute/v1beta16/projects/google/global/images/gcel-12-04-v20121106"))
|
||||
.addNetworkInterface(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/networks/default"));
|
||||
".com/compute/v1/projects/myproject/global/networks/default"));
|
||||
|
||||
assertEquals(api.createInZone("test-1", "us-central1-a", options), new ParseOperationTest().expected());
|
||||
}
|
||||
|
@ -155,7 +154,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
HttpRequest insert = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromResourceWithContentType("/instance_insert.json", MediaType.APPLICATION_JSON))
|
||||
|
@ -171,12 +170,11 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
|
||||
InstanceTemplate options = InstanceTemplate.builder().forMachineType("us-central1-a/n1-standard-1")
|
||||
.addNetworkInterface(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/networks/default"), Instance.NetworkInterface.AccessConfig.Type.ONE_TO_ONE_NAT)
|
||||
".com/compute/v1/projects/myproject/global/networks/default"), Instance.NetworkInterface.AccessConfig.Type.ONE_TO_ONE_NAT)
|
||||
.description("desc")
|
||||
.image(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/google/global/images/gcel-12-04-v20121106"))
|
||||
.addDisk(InstanceTemplate.PersistentDisk.Mode.READ_WRITE,
|
||||
create("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/disks/test"))
|
||||
create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/test"),
|
||||
true)
|
||||
.addServiceAccount(Instance.ServiceAccount.builder().email("default").addScopes("myscope").build())
|
||||
.addMetadata("aKey", "aValue");
|
||||
|
||||
|
@ -189,7 +187,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances/test-1")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -208,7 +206,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances/test-1")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -235,7 +233,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/instances")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -252,7 +250,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances/test-1/setMetadata")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/setMetadata")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromResourceWithContentType("/instance_set_metadata.json", MediaType.APPLICATION_JSON))
|
||||
|
@ -273,7 +271,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances/test-1/setMetadata")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/setMetadata")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromResourceWithContentType("/instance_set_metadata.json", MediaType.APPLICATION_JSON))
|
||||
|
@ -292,7 +290,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances/test-1/reset")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/reset")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -311,7 +309,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances/test-1/reset")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/reset")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -328,7 +326,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances/test-1/attachDisk")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/attachDisk")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromResourceWithContentType("/instance_attach_disk.json", MediaType.APPLICATION_JSON))
|
||||
|
@ -343,7 +341,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
assertEquals(api.attachDiskInZone("us-central1-a", "test-1",
|
||||
new AttachDiskOptions()
|
||||
.mode(DiskMode.READ_ONLY)
|
||||
.source(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/disks/testimage1"))
|
||||
.source(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1"))
|
||||
.type(DiskType.PERSISTENT)),
|
||||
new ParseOperationTest().expected());
|
||||
}
|
||||
|
@ -353,7 +351,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances/test-1/attachDisk")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/attachDisk")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromResourceWithContentType("/instance_attach_disk.json", MediaType.APPLICATION_JSON))
|
||||
|
@ -367,7 +365,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
assertNull(api.attachDiskInZone("us-central1-a", "test-1",
|
||||
new AttachDiskOptions()
|
||||
.mode(DiskMode.READ_ONLY)
|
||||
.source(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/disks/testimage1"))
|
||||
.source(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1"))
|
||||
.type(DiskType.PERSISTENT)));
|
||||
|
||||
}
|
||||
|
@ -377,7 +375,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances/test-1/detachDisk" +
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/detachDisk" +
|
||||
"?deviceName=test-disk-1")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
|
@ -398,7 +396,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances/test-1/detachDisk" +
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-1/detachDisk" +
|
||||
"?deviceName=test-disk-1")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.jclouds.googlecomputeengine.options.AttachDiskOptions;
|
|||
import org.jclouds.googlecomputeengine.options.AttachDiskOptions.DiskMode;
|
||||
import org.jclouds.googlecomputeengine.options.AttachDiskOptions.DiskType;
|
||||
import org.jclouds.googlecomputeengine.options.ListOptions;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
|
@ -51,6 +52,7 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
|
||||
private static final String INSTANCE_NETWORK_NAME = "instance-api-live-test-network";
|
||||
private static final String INSTANCE_NAME = "instance-api-live-test-instance";
|
||||
private static final String BOOT_DISK_NAME = INSTANCE_NAME + "-boot-disk";
|
||||
private static final String DISK_NAME = "instance-live-test-disk";
|
||||
private static final String IPV4_RANGE = "10.0.0.0/8";
|
||||
private static final String METADATA_ITEM_KEY = "instanceLiveTestTestProp";
|
||||
|
@ -65,29 +67,27 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
@Override
|
||||
protected GoogleComputeEngineApi create(Properties props, Iterable<Module> modules) {
|
||||
GoogleComputeEngineApi api = super.create(props, modules);
|
||||
URI imageUri = api.getImageApiForProject("google")
|
||||
.list(new ListOptions.Builder().filter("name eq gcel.*"))
|
||||
.concat()
|
||||
.filter(new Predicate<Image>() {
|
||||
@Override
|
||||
public boolean apply(Image input) {
|
||||
// filter out only images with deprecation state other than "DEPRECATED"
|
||||
if (input.getDeprecated().isPresent() && input.getDeprecated().get().getState().isPresent()) {
|
||||
return input.getDeprecated().get().getState().get().equals("DEPRECATED");
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
})
|
||||
.first()
|
||||
.get()
|
||||
.getSelfLink();
|
||||
URI imageUri = api.getImageApiForProject("centos-cloud")
|
||||
.list(new ListOptions.Builder().filter("name eq centos.*"))
|
||||
.concat()
|
||||
.filter(new Predicate<Image>() {
|
||||
@Override
|
||||
public boolean apply(Image input) {
|
||||
// filter out all deprecated images
|
||||
return !(input.getDeprecated().isPresent() && input.getDeprecated().get().getState().isPresent());
|
||||
}
|
||||
})
|
||||
.first()
|
||||
.get()
|
||||
.getSelfLink();
|
||||
instance = InstanceTemplate.builder()
|
||||
.forMachineType(getDefaultMachineTypeUrl(userProject.get()))
|
||||
.addNetworkInterface(getNetworkUrl(userProject.get(), INSTANCE_NETWORK_NAME),
|
||||
Instance.NetworkInterface.AccessConfig.Type.ONE_TO_ONE_NAT)
|
||||
Instance.NetworkInterface.AccessConfig.Type.ONE_TO_ONE_NAT)
|
||||
.addMetadata("mykey", "myvalue")
|
||||
.description("a description")
|
||||
.addDisk(InstanceTemplate.PersistentDisk.Mode.READ_WRITE, getDiskUrl(userProject.get(), BOOT_DISK_NAME),
|
||||
null, true, true)
|
||||
.addDisk(InstanceTemplate.PersistentDisk.Mode.READ_WRITE, getDiskUrl(userProject.get(), DISK_NAME))
|
||||
.image(imageUri);
|
||||
|
||||
|
@ -109,6 +109,14 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).createInIPv4Range
|
||||
(INSTANCE_NETWORK_NAME, IPV4_RANGE), TIME_WAIT);
|
||||
|
||||
|
||||
assertZoneOperationDoneSucessfully(api.getDiskApiForProject(userProject.get())
|
||||
.createFromImageInZone(instance.getImage().toString(),
|
||||
BOOT_DISK_NAME,
|
||||
DEFAULT_ZONE_NAME),
|
||||
TIME_WAIT);
|
||||
|
||||
|
||||
assertZoneOperationDoneSucessfully(diskApi().createInZone
|
||||
("instance-live-test-disk", 10, DEFAULT_ZONE_NAME), TIME_WAIT);
|
||||
|
||||
|
@ -161,7 +169,8 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
@Override
|
||||
public boolean apply(AttachedDisk disk) {
|
||||
return disk instanceof PersistentAttachedDisk &&
|
||||
((PersistentAttachedDisk) disk).getDeviceName().orNull().equals(ATTACH_DISK_DEVICE_NAME);
|
||||
((PersistentAttachedDisk) disk).getDeviceName().isPresent() &&
|
||||
((PersistentAttachedDisk) disk).getDeviceName().get().equals(ATTACH_DISK_DEVICE_NAME);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
@ -205,6 +214,8 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
assertZoneOperationDoneSucessfully(api().deleteInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME), TIME_WAIT);
|
||||
assertZoneOperationDoneSucessfully(api.getDiskApiForProject(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME),
|
||||
TIME_WAIT);
|
||||
assertZoneOperationDoneSucessfully(api.getDiskApiForProject(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, BOOT_DISK_NAME),
|
||||
TIME_WAIT);
|
||||
assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).delete
|
||||
(INSTANCE_NETWORK_NAME), TIME_WAIT);
|
||||
}
|
||||
|
@ -213,4 +224,20 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
assertEquals(result.getName(), expected.getName());
|
||||
assertEquals(result.getMetadata().getItems(), expected.getMetadata());
|
||||
}
|
||||
|
||||
@AfterClass(groups = { "integration", "live" })
|
||||
protected void tearDownContext() {
|
||||
try {
|
||||
waitZoneOperationDone(api().deleteInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME), TIME_WAIT);
|
||||
waitZoneOperationDone(api.getDiskApiForProject(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME),
|
||||
TIME_WAIT);
|
||||
waitZoneOperationDone(api.getDiskApiForProject(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, BOOT_DISK_NAME),
|
||||
TIME_WAIT);
|
||||
waitGlobalOperationDone(api.getNetworkApiForProject(userProject.get()).delete
|
||||
(INSTANCE_NETWORK_NAME), TIME_WAIT);
|
||||
} catch (Exception e) {
|
||||
// we don't really care about any exception here, so just delete away.
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,109 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jclouds.googlecomputeengine.features;
|
||||
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
|
||||
import org.jclouds.googlecomputeengine.parse.ParseKernelListTest;
|
||||
import org.jclouds.googlecomputeengine.parse.ParseKernelTest;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author David Alves
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class KernelApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
||||
|
||||
public void testGetKernelResponseIs2xx() throws Exception {
|
||||
HttpRequest get = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/kernels/12941177846308850718")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/kernel.json")).build();
|
||||
|
||||
KernelApi kernelApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getKernelApiForProject("myproject");
|
||||
|
||||
assertEquals(kernelApi.get("12941177846308850718"),
|
||||
new ParseKernelTest().expected());
|
||||
}
|
||||
|
||||
public void testGetKernelResponseIs4xx() throws Exception {
|
||||
HttpRequest get = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/kernels/12941177846308850718")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
KernelApi kernelApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getKernelApiForProject("myproject");
|
||||
|
||||
assertNull(kernelApi.get("12941177846308850718"));
|
||||
}
|
||||
|
||||
public void testListKernelNoOptionsResponseIs2xx() throws Exception {
|
||||
HttpRequest list = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/kernels")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/kernel_list.json")).build();
|
||||
|
||||
KernelApi kernelApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list, operationResponse).getKernelApiForProject("myproject");
|
||||
|
||||
assertEquals(kernelApi.listFirstPage().toString(),
|
||||
new ParseKernelListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListKernelsResponseIs4xx() {
|
||||
HttpRequest list = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/kernels")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
KernelApi kernelApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list, operationResponse).getKernelApiForProject("myproject");
|
||||
|
||||
assertTrue(kernelApi.list().concat().isEmpty());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jclouds.googlecomputeengine.features;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertSame;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.jclouds.collect.IterableWithMarker;
|
||||
import org.jclouds.collect.PagedIterable;
|
||||
import org.jclouds.googlecomputeengine.domain.Kernel;
|
||||
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
|
||||
import org.jclouds.googlecomputeengine.options.ListOptions;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
/**
|
||||
* @author David Alves
|
||||
*/
|
||||
public class KernelApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
||||
|
||||
private Kernel kernel;
|
||||
|
||||
private KernelApi api() {
|
||||
return api.getKernelApiForProject("google");
|
||||
}
|
||||
|
||||
@Test(groups = "live")
|
||||
public void testListKernel() {
|
||||
|
||||
PagedIterable<Kernel> kernels = api().list(new ListOptions.Builder()
|
||||
.maxResults(1));
|
||||
|
||||
Iterator<IterableWithMarker<Kernel>> pageIterator = kernels.iterator();
|
||||
assertTrue(pageIterator.hasNext());
|
||||
|
||||
IterableWithMarker<Kernel> singlePageIterator = pageIterator.next();
|
||||
List<Kernel> kernelAsList = Lists.newArrayList(singlePageIterator);
|
||||
|
||||
assertSame(kernelAsList.size(), 1);
|
||||
|
||||
this.kernel = Iterables.getOnlyElement(kernelAsList);
|
||||
}
|
||||
|
||||
|
||||
@Test(groups = "live", dependsOnMethods = "testListKernel")
|
||||
public void testGetKernel() {
|
||||
Kernel kernel = api().get(this.kernel.getName());
|
||||
assertNotNull(kernel);
|
||||
assertKernelEquals(kernel, this.kernel);
|
||||
}
|
||||
|
||||
private void assertKernelEquals(Kernel result, Kernel expected) {
|
||||
assertEquals(result.getName(), expected.getName());
|
||||
}
|
||||
|
||||
}
|
|
@ -37,7 +37,7 @@ public class MachineTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTe
|
|||
public static final HttpRequest LIST_MACHINE_TYPES_REQUEST = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/machineTypes")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class MachineTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTe
|
|||
public static final HttpRequest LIST_CENTRAL1B_MACHINE_TYPES_REQUEST = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-b/machineTypes")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-b/machineTypes")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class MachineTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTe
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class MachineTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTe
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1")
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
public static final HttpRequest GET_NETWORK_REQUEST = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks/jclouds-test")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpRequest get = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks/jclouds-test")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -77,7 +77,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpRequest insert = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/networks")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromResourceWithContentType("/network_insert.json", MediaType.APPLICATION_JSON))
|
||||
|
@ -98,7 +98,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/networks/jclouds-test")
|
||||
".com/compute/v1/projects/myproject/global/networks/jclouds-test")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -117,7 +117,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/networks/jclouds-test")
|
||||
".com/compute/v1/projects/myproject/global/networks/jclouds-test")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -134,7 +134,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/networks")
|
||||
".com/compute/v1/projects/myproject/global/networks")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -153,7 +153,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/networks")
|
||||
".com/compute/v1/projects/myproject/global/networks")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ import org.testng.annotations.Test;
|
|||
@Test(groups = "unit")
|
||||
public class ProjectApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
||||
|
||||
public static final String PROJECTS_URL_PREFIX = "https://www.googleapis.com/compute/v1beta16/projects";
|
||||
public static final String PROJECTS_URL_PREFIX = "https://www.googleapis.com/compute/v1/projects";
|
||||
|
||||
public static final HttpRequest GET_PROJECT_REQUEST = HttpRequest
|
||||
.builder()
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.testng.annotations.Test;
|
|||
@Test(groups = "unit")
|
||||
public class RegionApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
||||
|
||||
public static final String REGIONS_URL_PREFIX = "https://www.googleapis.com/compute/v1beta16/projects/myproject/regions";
|
||||
public static final String REGIONS_URL_PREFIX = "https://www.googleapis.com/compute/v1/projects/myproject/regions";
|
||||
|
||||
public static final HttpRequest GET_REGION_REQ = HttpRequest
|
||||
.builder()
|
||||
|
|
|
@ -41,10 +41,10 @@ import org.testng.annotations.Test;
|
|||
public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
||||
|
||||
private static final String OPERATIONS_URL_PREFIX = "https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/regions/us-central1/operations";
|
||||
".com/compute/v1/projects/myproject/regions/us-central1/operations";
|
||||
|
||||
private static final String DELETE_OPERATIONS_URL_PREFIX = "https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/regions/us-central1/operations";
|
||||
".com/compute/v1/projects/myproject/regions/us-central1/operations";
|
||||
|
||||
public static final HttpRequest GET_OPERATION_REQUEST = HttpRequest
|
||||
.builder()
|
||||
|
@ -60,11 +60,11 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
|
|||
SimpleDateFormatDateService dateService = new SimpleDateFormatDateService();
|
||||
return Operation.builder().id("13053095055850848306")
|
||||
.selfLink(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/regions/us-central1/operations/operation-1354084865060-4cf88735faeb8" +
|
||||
".com/compute/v1/projects/myproject/regions/us-central1/operations/operation-1354084865060-4cf88735faeb8" +
|
||||
"-bbbb12cb"))
|
||||
.name("operation-1354084865060-4cf88735faeb8-bbbb12cb")
|
||||
.targetLink(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/regions/us-central1/addresses/test-address"))
|
||||
".com/compute/v1/projects/myproject/regions/us-central1/addresses/test-address"))
|
||||
.targetId("13053094017547040099")
|
||||
.status(Operation.Status.DONE)
|
||||
.user("user@developer.gserviceaccount.com")
|
||||
|
@ -73,7 +73,7 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
|
|||
.startTime(dateService.iso8601DateParse("2012-11-28T06:41:05.142"))
|
||||
.endTime(dateService.iso8601DateParse("2012-11-28T06:41:06.142"))
|
||||
.operationType("insert")
|
||||
.region(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/regions/us-central1"))
|
||||
.region(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1"))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -81,7 +81,7 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
|
|||
return ListPage.<Operation>builder()
|
||||
.kind(Resource.Kind.OPERATION_LIST)
|
||||
.id("projects/myproject/regions/us-central1/operations")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/regions/us-central1/operations"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/operations"))
|
||||
.addItem(expected())
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ public class RouteApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpRequest get = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/routes/default-route-c99ebfbed0e1f375")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/routes/default-route-c99ebfbed0e1f375")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class RouteApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpRequest get = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/routes/default-route-c99ebfbed0e1f375")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/routes/default-route-c99ebfbed0e1f375")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -80,7 +80,7 @@ public class RouteApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/routes")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/routes")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromResourceWithContentType("/route_insert.json", MediaType.APPLICATION_JSON))
|
||||
|
@ -94,13 +94,13 @@ public class RouteApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
insertRouteResponse).getRouteApiForProject("myproject");
|
||||
|
||||
assertEquals(api.createInNetwork("default-route-c99ebfbed0e1f375",
|
||||
URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks/default"),
|
||||
URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default"),
|
||||
new RouteOptions().addTag("fooTag")
|
||||
.addTag("barTag")
|
||||
.description("Default route to the virtual network.")
|
||||
.destRange("10.240.0.0/16")
|
||||
.priority(1000)
|
||||
.nextHopNetwork(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks/default"))
|
||||
.nextHopNetwork(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default"))
|
||||
), new ParseOperationTest().expected());
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ public class RouteApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/routes/default-route-c99ebfbed0e1f375")
|
||||
".com/compute/v1/projects/myproject/global/routes/default-route-c99ebfbed0e1f375")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -128,7 +128,7 @@ public class RouteApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/routes/default-route-c99ebfbed0e1f375")
|
||||
".com/compute/v1/projects/myproject/global/routes/default-route-c99ebfbed0e1f375")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -145,7 +145,7 @@ public class RouteApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/routes")
|
||||
".com/compute/v1/projects/myproject/global/routes")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
@ -164,7 +164,7 @@ public class RouteApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/routes")
|
||||
".com/compute/v1/projects/myproject/global/routes")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.testng.annotations.Test;
|
|||
@Test(groups = "unit")
|
||||
public class SnapshotApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
||||
|
||||
public static final String SNAPSHOT_URL_PREFIX = "https://www.googleapis.com/compute/v1beta16/projects/myproject/global/snapshots";
|
||||
public static final String SNAPSHOT_URL_PREFIX = "https://www.googleapis.com/compute/v1/projects/myproject/global/snapshots";
|
||||
|
||||
public static final HttpRequest GET_SNAPSHOT_REQ = HttpRequest
|
||||
.builder()
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.testng.annotations.Test;
|
|||
@Test(groups = "unit")
|
||||
public class ZoneApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
||||
|
||||
public static final String ZONES_URL_PREFIX = "https://www.googleapis.com/compute/v1beta16/projects/myproject/zones";
|
||||
public static final String ZONES_URL_PREFIX = "https://www.googleapis.com/compute/v1/projects/myproject/zones";
|
||||
|
||||
public static final HttpRequest GET_ZONE_REQ = HttpRequest
|
||||
.builder()
|
||||
|
|
|
@ -41,7 +41,7 @@ import org.testng.annotations.Test;
|
|||
public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
||||
|
||||
private static final String OPERATIONS_URL_PREFIX = "https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/operations";
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/operations";
|
||||
|
||||
public static final HttpRequest GET_ZONE_OPERATION_REQUEST = HttpRequest
|
||||
.builder()
|
||||
|
@ -57,11 +57,11 @@ public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpect
|
|||
SimpleDateFormatDateService dateService = new SimpleDateFormatDateService();
|
||||
return Operation.builder().id("13053095055850848306")
|
||||
.selfLink(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/operations/operation-1354084865060-4cf88735faeb8" +
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/operations/operation-1354084865060-4cf88735faeb8" +
|
||||
"-bbbb12cb"))
|
||||
.name("operation-1354084865060-4cf88735faeb8-bbbb12cb")
|
||||
.targetLink(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances/instance-api-live-test-instance"))
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/instances/instance-api-live-test-instance"))
|
||||
.targetId("13053094017547040099")
|
||||
.status(Operation.Status.DONE)
|
||||
.user("user@developer.gserviceaccount.com")
|
||||
|
@ -70,7 +70,7 @@ public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpect
|
|||
.startTime(dateService.iso8601DateParse("2012-11-28T06:41:05.142"))
|
||||
.endTime(dateService.iso8601DateParse("2012-11-28T06:41:06.142"))
|
||||
.operationType("insert")
|
||||
.zone(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a"))
|
||||
.zone(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a"))
|
||||
.build();
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ public class ZoneOperationApiExpectTest extends BaseGoogleComputeEngineApiExpect
|
|||
return ListPage.<Operation>builder()
|
||||
.kind(Resource.Kind.OPERATION_LIST)
|
||||
.id("projects/myproject/zones/us-central1-a/operations")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/operations"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/operations"))
|
||||
.addItem(expected())
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class CreateNetworkIfNeededTest {
|
|||
|
||||
Network network = Network.builder().IPv4Range("0.0.0.0/0")
|
||||
.id("abcd").name("this-network")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks/this-network"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network"))
|
||||
.build();
|
||||
|
||||
Operation createOp = createMock(Operation.class);
|
||||
|
@ -95,7 +95,7 @@ public class CreateNetworkIfNeededTest {
|
|||
|
||||
Network network = Network.builder().IPv4Range("0.0.0.0/0")
|
||||
.id("abcd").name("this-network").gatewayIPv4("1.2.3.4")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks/this-network"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network"))
|
||||
.build();
|
||||
|
||||
Operation createOp = createMock(Operation.class);
|
||||
|
|
|
@ -40,7 +40,7 @@ public class GoogleComputeEngineErrorHandlerTest {
|
|||
public void test409MakesIllegalStateException() {
|
||||
assertCodeMakes(
|
||||
"POST",
|
||||
URI.create("https://www.googleapis.com/compute/v1beta16"),
|
||||
URI.create("https://www.googleapis.com/compute/v1"),
|
||||
409,
|
||||
"HTTP/1.1 409 Conflict",
|
||||
"\"{\"code\":\"InvalidState\",\"message\":\"An incompatible transition has already been queued for this" +
|
||||
|
|
|
@ -45,7 +45,7 @@ import com.google.inject.name.Names;
|
|||
*/
|
||||
public class BaseGoogleComputeEngineApiLiveTest extends BaseApiLiveTest<GoogleComputeEngineApi> {
|
||||
|
||||
protected static final String API_URL_PREFIX = "https://www.googleapis.com/compute/v1beta16/projects/";
|
||||
protected static final String API_URL_PREFIX = "https://www.googleapis.com/compute/v1/projects/";
|
||||
protected static final String ZONE_API_URL_SUFFIX = "/zones/";
|
||||
protected static final String DEFAULT_ZONE_NAME = "us-central1-a";
|
||||
|
||||
|
|
|
@ -47,17 +47,17 @@ public class ParseAddressListTest extends BaseGoogleComputeEngineParseTest<ListP
|
|||
return ListPage.<Address>builder()
|
||||
.kind(Kind.ADDRESS_LIST)
|
||||
.id("projects/myproject/regions/us-central1/addresses")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/regions/us-central1/addresses"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses"))
|
||||
.items(ImmutableSet.of(new ParseAddressTest().expected(),
|
||||
Address.builder()
|
||||
.id("4881363978908129158")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2013-07-26T14:08:21.552-07:00"))
|
||||
.status("RESERVED")
|
||||
.region(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/regions/us-central1"))
|
||||
.region(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1"))
|
||||
.name("test-ip2")
|
||||
.description("")
|
||||
.address("173.255.118.115")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/regions/us-central1/addresses/test-ip2"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip2"))
|
||||
.build())
|
||||
).build();
|
||||
}
|
||||
|
|
|
@ -44,11 +44,11 @@ public class ParseAddressTest extends BaseGoogleComputeEngineParseTest<Address>
|
|||
.id("4439373783165447583")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2013-07-26T13:57:20.204-07:00"))
|
||||
.status("RESERVED")
|
||||
.region(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/regions/us-central1"))
|
||||
.region(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1"))
|
||||
.name("test-ip1")
|
||||
.description("")
|
||||
.address("173.255.115.190")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/regions/us-central1/addresses/test-ip1"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/addresses/test-ip1"))
|
||||
.build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,16 +47,16 @@ public class ParseDiskListTest extends BaseGoogleComputeEngineParseTest<ListPage
|
|||
return ListPage.<Disk>builder()
|
||||
.kind(Resource.Kind.DISK_LIST)
|
||||
.id("projects/myproject/zones/us-central1-a/disks")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/disks"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks"))
|
||||
.items(ImmutableSet.of(Disk.builder()
|
||||
.id("13050421646334304115")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T01:38:48.306"))
|
||||
.selfLink(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/disks/testimage1"))
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1"))
|
||||
.name("testimage1")
|
||||
.sizeGb(1)
|
||||
.zone(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a"))
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a"))
|
||||
.status("READY")
|
||||
.build())
|
||||
).build();
|
||||
|
|
|
@ -43,10 +43,10 @@ public class ParseDiskTest extends BaseGoogleComputeEngineParseTest<Disk> {
|
|||
return Disk.builder()
|
||||
.id("13050421646334304115")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T01:38:48.306"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/disks/testimage1"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1"))
|
||||
.name("testimage1")
|
||||
.sizeGb(1)
|
||||
.zone(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a"))
|
||||
.zone(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a"))
|
||||
.status("READY")
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -48,18 +48,18 @@ public class ParseFirewallListTest extends BaseGoogleComputeEngineParseTest<List
|
|||
return ListPage.<Firewall>builder()
|
||||
.kind(Resource.Kind.FIREWALL_LIST)
|
||||
.id("projects/google/firewalls")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/google/global/firewalls"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/google/global/firewalls"))
|
||||
.items(ImmutableSet.of(
|
||||
new ParseFirewallTest().expected()
|
||||
, Firewall.builder()
|
||||
.id("12862241067393040785")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-04-13T03:05:04.365"))
|
||||
.selfLink(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/google/global/firewalls/default-ssh"))
|
||||
".com/compute/v1/projects/google/global/firewalls/default-ssh"))
|
||||
.name("default-ssh")
|
||||
.description("SSH allowed from anywhere")
|
||||
.network(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/google/global/networks/default"))
|
||||
".com/compute/v1/projects/google/global/networks/default"))
|
||||
.addSourceRange("0.0.0.0/0")
|
||||
.addAllowed(Firewall.Rule.builder()
|
||||
.IpProtocol(IpProtocol.TCP)
|
||||
|
|
|
@ -44,10 +44,10 @@ public class ParseFirewallTest extends BaseGoogleComputeEngineParseTest<Firewall
|
|||
return Firewall.builder()
|
||||
.id("12862241031274216284")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-04-13T03:05:02.855"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/firewalls/jclouds-test"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/jclouds-test"))
|
||||
.name("jclouds-test")
|
||||
.description("Internal traffic from default allowed")
|
||||
.network(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks/jclouds-test"))
|
||||
.network(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test"))
|
||||
.addSourceRange("10.0.0.0/8")
|
||||
.addAllowed(Firewall.Rule.builder()
|
||||
.IpProtocol(IpProtocol.TCP)
|
||||
|
|
|
@ -47,21 +47,19 @@ public class ParseImageListTest extends BaseGoogleComputeEngineParseTest<ListPag
|
|||
public ListPage<Image> expected() {
|
||||
return ListPage.<Image>builder()
|
||||
.kind(Resource.Kind.IMAGE_LIST)
|
||||
.id("projects/google/global/images")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/google/global/images"))
|
||||
.id("projects/centos-cloud/global/images")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images"))
|
||||
.items(ImmutableSet.of(Image.builder()
|
||||
.id("12941197498378735318")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-07-16T22:16:13.468"))
|
||||
.selfLink(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/google/global/images/centos-6-2-v20120326"))
|
||||
".com/compute/v1/projects/centos-cloud/global/images/centos-6-2-v20120326"))
|
||||
.name("centos-6-2-v20120326")
|
||||
.description("DEPRECATED. CentOS 6.2 image; Created Mon, 26 Mar 2012 21:19:09 +0000")
|
||||
.sourceType("RAW")
|
||||
.preferredKernel(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/google/kernels/gce-20120326"))
|
||||
.deprecated(Deprecated.builder()
|
||||
.state("DEPRECATED")
|
||||
.replacement(URI.create("https://www.googleapis.com/compute/v1beta16/projects/google/global/images/centos-6-v20130104"))
|
||||
.replacement(URI.create("https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-v20130104"))
|
||||
.build())
|
||||
.rawDisk(
|
||||
Image.RawDisk.builder()
|
||||
|
|
|
@ -43,13 +43,11 @@ public class ParseImageTest extends BaseGoogleComputeEngineParseTest<Image> {
|
|||
return Image.builder()
|
||||
.id("12941197498378735318")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-07-16T22:16:13.468"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/google/global/images/centos-6-2" +
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/centos-6-2" +
|
||||
"-v20120326"))
|
||||
.name("centos-6-2-v20120326")
|
||||
.description("DEPRECATED. CentOS 6.2 image; Created Mon, 26 Mar 2012 21:19:09 +0000")
|
||||
.sourceType("RAW")
|
||||
.preferredKernel(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/google/kernels/gce-20120326"))
|
||||
.rawDisk(
|
||||
Image.RawDisk.builder()
|
||||
.source("")
|
||||
|
|
|
@ -44,7 +44,7 @@ public class ParseInstanceListTest extends BaseGoogleComputeEngineParseTest<List
|
|||
return ListPage.<Instance>builder()
|
||||
.kind(Resource.Kind.INSTANCE_LIST)
|
||||
.id("projects/myproject/zones/us-central1-a/instances")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/instances"))
|
||||
.items(ImmutableSet.of(new ParseInstanceTest().expected()))
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -45,21 +45,19 @@ public class ParseInstanceTest extends BaseGoogleComputeEngineParseTest<Instance
|
|||
.id("13051190678907570425")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-11-25T23:48:20.758"))
|
||||
.selfLink(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/instances/test-0"))
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/instances/test-0"))
|
||||
.description("desc")
|
||||
.name("test-0")
|
||||
.image(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/google/global/images/gcel-12-04-v20121106"))
|
||||
.machineType(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/machineTypes/n1" +
|
||||
.machineType(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1" +
|
||||
"-standard-1"))
|
||||
.status(Instance.Status.RUNNING)
|
||||
.zone(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a"))
|
||||
.zone(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a"))
|
||||
.addNetworkInterface(
|
||||
Instance.NetworkInterface.builder()
|
||||
.name("nic0")
|
||||
.networkIP("10.240.121.115")
|
||||
.network(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/networks/default"))
|
||||
".com/compute/v1/projects/myproject/global/networks/default"))
|
||||
.build()
|
||||
)
|
||||
.addDisk(
|
||||
|
@ -68,12 +66,16 @@ public class ParseInstanceTest extends BaseGoogleComputeEngineParseTest<Instance
|
|||
.mode(Instance.PersistentAttachedDisk.Mode.READ_WRITE)
|
||||
.deviceName("test")
|
||||
.source(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/disks/test"))
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/disks/test"))
|
||||
.boot(true)
|
||||
.build()
|
||||
)
|
||||
.tags(Instance.Tags.builder().fingerprint("abcd").addItem("aTag").build())
|
||||
.metadata(Metadata.builder()
|
||||
.items(ImmutableMap.of("aKey", "aValue"))
|
||||
.items(ImmutableMap.of("aKey", "aValue",
|
||||
"jclouds-image",
|
||||
"https://www.googleapis.com/compute/v1/projects/centos-cloud/global/images/gcel-12-04-v20121106",
|
||||
"jclouds-delete-boot-disk", "true"))
|
||||
.fingerprint("efgh")
|
||||
.build())
|
||||
.addServiceAccount(Instance.ServiceAccount.builder().email("default").addScopes("myscope").build())
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jclouds.googlecomputeengine.parse;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.googlecomputeengine.domain.Kernel;
|
||||
import org.jclouds.googlecomputeengine.domain.ListPage;
|
||||
import org.jclouds.googlecomputeengine.domain.Resource;
|
||||
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* @author David Alves
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ParseKernelListTest extends BaseGoogleComputeEngineParseTest<ListPage<Kernel>> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/kernel_list.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public ListPage<Kernel> expected() {
|
||||
return ListPage.<Kernel>builder()
|
||||
.kind(Resource.Kind.KERNEL_LIST)
|
||||
.id("projects/google/global/kernels")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/google/global/kernels"))
|
||||
.items(ImmutableSet.of(
|
||||
Kernel.builder()
|
||||
.id("12941177846308850718")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse
|
||||
("2012-07-16T21:42:16.950"))
|
||||
.selfLink(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/google/global/kernels/gce-20110524"))
|
||||
.name("gce-20110524")
|
||||
.description("DEPRECATED. Created Tue, 24 May 2011 00:48:22 +0000").build(),
|
||||
Kernel.builder()
|
||||
.id("12941177983348179280")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse
|
||||
("2012-07-16T21:42:31.166"))
|
||||
.selfLink(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/google/global/kernels/gce-20110728"))
|
||||
.name("gce-20110728")
|
||||
.description("DEPRECATED. Created Thu, 28 Jul 2011 16:44:38 +0000")
|
||||
.deprecated(org.jclouds.googlecomputeengine.domain.Deprecated.builder()
|
||||
.state("OBSOLETE")
|
||||
.replacement(URI.create("https://www.googleapis.com/compute/v1beta16/projects/google/global/kernels/gce-v20130603"))
|
||||
.build())
|
||||
.build()
|
||||
)).build();
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jclouds.googlecomputeengine.parse;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.date.internal.SimpleDateFormatDateService;
|
||||
import org.jclouds.googlecomputeengine.domain.Kernel;
|
||||
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineParseTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* @author David Alves
|
||||
*/
|
||||
@Test(groups = "unit")
|
||||
public class ParseKernelTest extends BaseGoogleComputeEngineParseTest<Kernel> {
|
||||
|
||||
@Override
|
||||
public String resource() {
|
||||
return "/kernel.json";
|
||||
}
|
||||
|
||||
@Override
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Kernel expected() {
|
||||
return Kernel.builder()
|
||||
.id("12941177846308850718")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-07-16T21:42:16.950"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/google/global/kernels/gce-20110524"))
|
||||
.name("gce-20110524")
|
||||
.description("DEPRECATED. Created Tue, 24 May 2011 00:48:22 +0000")
|
||||
.build();
|
||||
}
|
||||
}
|
|
@ -46,12 +46,12 @@ public class ParseMachineTypeListTest extends BaseGoogleComputeEngineParseTest<L
|
|||
return ListPage.<MachineType>builder()
|
||||
.kind(MACHINE_TYPE_LIST)
|
||||
.id("projects/myproject/machineTypes")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/machineTypes"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes"))
|
||||
.addItem(MachineType.builder()
|
||||
.id("4618642685664990776")
|
||||
.creationTimestamp(dateService.iso8601DateParse("2013-04-25T13:32:49.088-07:00"))
|
||||
.selfLink(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/machineTypes/f1-micro"))
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/f1-micro"))
|
||||
.zone("us-central1-a")
|
||||
.name("f1-micro")
|
||||
.description("1 vCPU (shared physical core) and 0.6 GB RAM")
|
||||
|
@ -65,7 +65,7 @@ public class ParseMachineTypeListTest extends BaseGoogleComputeEngineParseTest<L
|
|||
.id("12907738072351752276")
|
||||
.creationTimestamp(dateService.iso8601DateParse("2012-06-07T20:48:14.670"))
|
||||
.selfLink(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1"))
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-1"))
|
||||
.zone("us-central1-a")
|
||||
.name("n1-standard-1")
|
||||
.description("1 vCPU, 3.75 GB RAM, and a 10 GB ephemeral root disk")
|
||||
|
@ -79,7 +79,7 @@ public class ParseMachineTypeListTest extends BaseGoogleComputeEngineParseTest<L
|
|||
.id("12908560709887590691")
|
||||
.creationTimestamp(dateService.iso8601DateParse("2012-06-07T20:51:19.936"))
|
||||
.selfLink(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-8-d"))
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1-standard-8-d"))
|
||||
.zone("us-central1-a")
|
||||
.name("n1-standard-8-d")
|
||||
.description("8 vCPUs, 30 GB RAM, a 10 GB ephemeral root disk, " +
|
||||
|
|
|
@ -43,7 +43,7 @@ public class ParseMachineTypeTest extends BaseGoogleComputeEngineParseTest<Machi
|
|||
return MachineType.builder()
|
||||
.id("12907738072351752276")
|
||||
.creationTimestamp(dateService.iso8601DateParse("2012-06-07T20:48:14.670"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/machineTypes/n1" +
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/machineTypes/n1" +
|
||||
"-standard-1"))
|
||||
.zone("us-central1-a")
|
||||
.name("n1-standard-1")
|
||||
|
|
|
@ -44,7 +44,7 @@ public class ParseNetworkListTest extends BaseGoogleComputeEngineParseTest<ListP
|
|||
return ListPage.<Network>builder()
|
||||
.kind(Resource.Kind.NETWORK_LIST)
|
||||
.id("projects/myproject/networks")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/networks"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/networks"))
|
||||
.items(ImmutableSet.of(new ParseNetworkTest().expected()))
|
||||
.build();
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class ParseNetworkTest extends BaseGoogleComputeEngineParseTest<Network>
|
|||
return Network.builder()
|
||||
.id("13024414170909937976")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-10-24T20:13:19.967"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/networks/jclouds-test"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/networks/jclouds-test"))
|
||||
.name("default")
|
||||
.description("Default network for the project")
|
||||
.IPv4Range("10.0.0.0/8")
|
||||
|
|
|
@ -42,7 +42,7 @@ public class ParseOperationListTest extends BaseGoogleComputeEngineParseTest<Lis
|
|||
return ListPage.<Operation>builder()
|
||||
.kind(Resource.Kind.OPERATION_LIST)
|
||||
.id("projects/myproject/global/operations")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/operations"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/operations"))
|
||||
.addItem(new ParseOperationTest().expected())
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -43,11 +43,11 @@ public class ParseOperationTest extends BaseGoogleComputeEngineParseTest<Operati
|
|||
SimpleDateFormatDateService dateService = new SimpleDateFormatDateService();
|
||||
return Operation.builder().id("13053095055850848306")
|
||||
.selfLink(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/operations/operation-1354084865060-4cf88735faeb8" +
|
||||
".com/compute/v1/projects/myproject/global/operations/operation-1354084865060-4cf88735faeb8" +
|
||||
"-bbbb12cb"))
|
||||
.name("operation-1354084865060-4cf88735faeb8-bbbb12cb")
|
||||
.targetLink(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/firewalls/jclouds-test-delete"))
|
||||
".com/compute/v1/projects/myproject/global/firewalls/jclouds-test-delete"))
|
||||
.targetId("13053094017547040099")
|
||||
.status(Operation.Status.DONE)
|
||||
.user("user@developer.gserviceaccount.com")
|
||||
|
|
|
@ -46,7 +46,7 @@ public class ParseProjectTest extends BaseGoogleComputeEngineParseTest<Project>
|
|||
return Project.builder()
|
||||
.id("13024414184846275913")
|
||||
.creationTimestamp(new Date(Long.parseLong("1351109596252")))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject"))
|
||||
.name("myproject")
|
||||
.description("")
|
||||
.commonInstanceMetadata(Metadata.builder()
|
||||
|
|
|
@ -47,7 +47,7 @@ public class ParseRegionListTest extends BaseGoogleComputeEngineParseTest<ListPa
|
|||
return ListPage.<Region>builder()
|
||||
.kind(Resource.Kind.REGION_LIST)
|
||||
.id("projects/myproject/regions")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/regions"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions"))
|
||||
.items(ImmutableSet.of(
|
||||
new ParseRegionTest().expected(),
|
||||
Region.builder()
|
||||
|
@ -55,11 +55,11 @@ public class ParseRegionListTest extends BaseGoogleComputeEngineParseTest<ListPa
|
|||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse
|
||||
("2013-07-08T14:40:37.939-07:00"))
|
||||
.selfLink(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/regions/us-central2"))
|
||||
".com/compute/v1/projects/myproject/regions/us-central2"))
|
||||
.name("us-central2")
|
||||
.description("us-central2")
|
||||
.status(Region.Status.UP)
|
||||
.zone(URI.create("https://www.googleapis.com/compute/v1beta16/zones/us-central2-a"))
|
||||
.zone(URI.create("https://www.googleapis.com/compute/v1/zones/us-central2-a"))
|
||||
.addQuota("INSTANCES", 0, 8)
|
||||
.addQuota("CPUS", 0, 8)
|
||||
.addQuota("EPHEMERAL_ADDRESSES", 0, 8)
|
||||
|
|
|
@ -45,12 +45,12 @@ public class ParseRegionTest extends BaseGoogleComputeEngineParseTest<Region> {
|
|||
return Region.builder()
|
||||
.id("12912210600542709766")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2013-07-08T14:40:37.939-07:00"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/regions/us-central1"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1"))
|
||||
.name("us-central1")
|
||||
.description("us-central1")
|
||||
.status(Region.Status.UP)
|
||||
.zones(ImmutableSet.of(URI.create("https://www.googleapis.com/compute/v1beta16/zones/us-central1-a"),
|
||||
URI.create("https://www.googleapis.com/compute/v1beta16/zones/us-central1-b")))
|
||||
.zones(ImmutableSet.of(URI.create("https://www.googleapis.com/compute/v1/zones/us-central1-a"),
|
||||
URI.create("https://www.googleapis.com/compute/v1/zones/us-central1-b")))
|
||||
.addQuota("INSTANCES", 0, 8)
|
||||
.addQuota("CPUS", 0, 8)
|
||||
.addQuota("EPHEMERAL_ADDRESSES", 0, 8)
|
||||
|
|
|
@ -47,18 +47,18 @@ public class ParseRouteListTest extends BaseGoogleComputeEngineParseTest<ListPag
|
|||
return ListPage.<Route>builder()
|
||||
.kind(Kind.ROUTE_LIST)
|
||||
.id("projects/myproject/global/routes")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/routes"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/routes"))
|
||||
.items(ImmutableSet.of(new ParseRouteTest().expected(),
|
||||
Route.builder()
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/routes/default-route-fc92a41ecb5a8d17"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/routes/default-route-fc92a41ecb5a8d17"))
|
||||
.id("507025480040058551")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2013-07-08T14:40:38.502-07:00"))
|
||||
.name("default-route-fc92a41ecb5a8d17")
|
||||
.description("Default route to the Internet.")
|
||||
.network(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks/default"))
|
||||
.network(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default"))
|
||||
.destRange("0.0.0.0/0")
|
||||
.priority(1000)
|
||||
.nextHopGateway(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/gateways/default-internet-gateway"))
|
||||
.nextHopGateway(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/gateways/default-internet-gateway"))
|
||||
.build())
|
||||
).build();
|
||||
}
|
||||
|
|
|
@ -43,15 +43,15 @@ public class ParseRouteTest extends BaseGoogleComputeEngineParseTest<Route> {
|
|||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Route expected() {
|
||||
return Route.builder()
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/routes/default-route-c99ebfbed0e1f375"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/routes/default-route-c99ebfbed0e1f375"))
|
||||
.id("7241926205630356071")
|
||||
.name("default-route-c99ebfbed0e1f375")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2013-07-08T14:40:38.502-07:00"))
|
||||
.description("Default route to the virtual network.")
|
||||
.network(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks/default"))
|
||||
.network(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default"))
|
||||
.destRange("10.240.0.0/16")
|
||||
.priority(1000)
|
||||
.nextHopNetwork(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks/default"))
|
||||
.nextHopNetwork(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default"))
|
||||
.tags(ImmutableSet.of("fooTag", "barTag"))
|
||||
.build();
|
||||
|
||||
|
|
|
@ -47,17 +47,17 @@ public class ParseSnapshotListTest extends BaseGoogleComputeEngineParseTest<List
|
|||
return ListPage.<Snapshot>builder()
|
||||
.kind(Kind.SNAPSHOT_LIST)
|
||||
.id("projects/myproject/global/snapshots")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/snapshots"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/snapshots"))
|
||||
.items(ImmutableSet.of(
|
||||
new ParseSnapshotTest().expected(), Snapshot.builder()
|
||||
.selfLink(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/global/snapshots/test-snap2"))
|
||||
".com/compute/v1/projects/myproject/global/snapshots/test-snap2"))
|
||||
.id("13895715048576107883")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse
|
||||
("2013-07-26T12:57:01.927-07:00"))
|
||||
.status("READY")
|
||||
.sizeGb(10)
|
||||
.sourceDisk(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/disks/testimage1"))
|
||||
.sourceDisk(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1"))
|
||||
.name("test-snap2")
|
||||
.description("")
|
||||
.sourceDiskId("8243603669926824540")
|
||||
|
|
|
@ -41,12 +41,12 @@ public class ParseSnapshotTest extends BaseGoogleComputeEngineParseTest<Snapshot
|
|||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public Snapshot expected() {
|
||||
return Snapshot.builder()
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/snapshots/test-snap"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/snapshots/test-snap"))
|
||||
.id("9734455566806191190")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2013-07-26T12:54:23.173-07:00"))
|
||||
.status("READY")
|
||||
.sizeGb(10)
|
||||
.sourceDisk(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a/disks/testimage1"))
|
||||
.sourceDisk(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a/disks/testimage1"))
|
||||
.name("test-snap")
|
||||
.description("")
|
||||
.sourceDiskId("8243603669926824540")
|
||||
|
|
|
@ -47,7 +47,7 @@ public class ParseZoneListTest extends BaseGoogleComputeEngineParseTest<ListPage
|
|||
return ListPage.<Zone>builder()
|
||||
.kind(Resource.Kind.ZONE_LIST)
|
||||
.id("projects/myproject/zones")
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones"))
|
||||
.items(ImmutableSet.of(
|
||||
new ParseZoneTest().expected()
|
||||
, Zone.builder()
|
||||
|
@ -55,7 +55,7 @@ public class ParseZoneListTest extends BaseGoogleComputeEngineParseTest<ListPage
|
|||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse
|
||||
("2012-10-24T20:13:19.271"))
|
||||
.selfLink(URI.create("https://www.googleapis" +
|
||||
".com/compute/v1beta16/projects/myproject/zones/us-central1-b"))
|
||||
".com/compute/v1/projects/myproject/zones/us-central1-b"))
|
||||
.name("us-central1-b")
|
||||
.description("us-central1-b")
|
||||
.status(Zone.Status.UP)
|
||||
|
|
|
@ -43,7 +43,7 @@ public class ParseZoneTest extends BaseGoogleComputeEngineParseTest<Zone> {
|
|||
return Zone.builder()
|
||||
.id("13020128040171887099")
|
||||
.creationTimestamp(new SimpleDateFormatDateService().iso8601DateParse("2012-10-19T16:42:54.131"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/zones/us-central1-a"))
|
||||
.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/zones/us-central1-a"))
|
||||
.name("us-central1-a")
|
||||
.description("us-central1-a")
|
||||
.status(Zone.Status.DOWN)
|
||||
|
|
|
@ -42,8 +42,8 @@ public class NetworkFirewallPredicatesTest {
|
|||
public static Firewall getFwForTestSourceTags() {
|
||||
Firewall.Builder builder = Firewall.builder();
|
||||
|
||||
builder.network(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks/jclouds-test"));
|
||||
builder.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/firewalls/jclouds-test"));
|
||||
builder.network(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test"));
|
||||
builder.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/jclouds-test"));
|
||||
builder.addSourceTag("tag-1");
|
||||
builder.addAllowed(Firewall.Rule.builder().IpProtocol(IpProtocol.TCP)
|
||||
.addPortRange(1, 10).build());
|
||||
|
@ -60,8 +60,8 @@ public class NetworkFirewallPredicatesTest {
|
|||
public static Firewall getFwForTestSourceTagsExact() {
|
||||
Firewall.Builder builder = Firewall.builder();
|
||||
|
||||
builder.network(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks/jclouds-test"));
|
||||
builder.selfLink(URI.create("https://www.googleapis.com/compute/v1beta16/projects/myproject/global/firewalls/jclouds-test"));
|
||||
builder.network(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test"));
|
||||
builder.selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/jclouds-test"));
|
||||
builder.addSourceTag("tag-1");
|
||||
builder.addAllowed(Firewall.Rule.builder().IpProtocol(IpProtocol.TCP)
|
||||
.addPortRange(1, 10).build());
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
{
|
||||
"kind": "compute#firewallList",
|
||||
"id": "projects/google/firewalls",
|
||||
"selfLink": "https://www.googleapis.com/compute/v1beta16/projects/google/global/firewalls",
|
||||
"selfLink": "https://www.googleapis.com/compute/v1/projects/google/global/firewalls",
|
||||
"items": [
|
||||
{
|
||||
|
||||
"kind": "compute#firewall",
|
||||
"id": "12862241031274216284",
|
||||
"creationTimestamp": "2012-04-13T03:05:02.855",
|
||||
"selfLink": "https://www.googleapis.com/compute/v1beta16/projects/myproject/global/firewalls/jclouds-test-delete",
|
||||
"selfLink": "https://www.googleapis.com/compute/v1/projects/myproject/global/firewalls/jclouds-test-delete",
|
||||
"name": "jclouds-test-delete",
|
||||
"description": "Internal traffic from default allowed",
|
||||
"network": "https://www.googleapis.com/compute/v1beta16/projects/myproject/global/networks/jclouds-test-delete",
|
||||
"network": "https://www.googleapis.com/compute/v1/projects/myproject/global/networks/jclouds-test-delete",
|
||||
"sourceRanges": [
|
||||
"10.0.0.0/8"
|
||||
],
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue