mirror of https://github.com/apache/jclouds.git
initial commit to support GCE LB
add support targetPools, forwardingRules and httpHealthChecks API add expectedTests and LiveTests for the above API
This commit is contained in:
parent
d9649c7e1e
commit
4a9255a00a
|
@ -16,16 +16,14 @@
|
|||
*/
|
||||
package org.jclouds.googlecomputeengine;
|
||||
|
||||
import java.io.Closeable;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import org.jclouds.googlecomputeengine.features.AddressApi;
|
||||
import org.jclouds.googlecomputeengine.features.DiskApi;
|
||||
import org.jclouds.googlecomputeengine.features.DiskTypeApi;
|
||||
import org.jclouds.googlecomputeengine.features.FirewallApi;
|
||||
import org.jclouds.googlecomputeengine.features.ForwardingRuleApi;
|
||||
import org.jclouds.googlecomputeengine.features.GlobalOperationApi;
|
||||
import org.jclouds.googlecomputeengine.features.HttpHealthCheckApi;
|
||||
import org.jclouds.googlecomputeengine.features.ImageApi;
|
||||
import org.jclouds.googlecomputeengine.features.InstanceApi;
|
||||
import org.jclouds.googlecomputeengine.features.MachineTypeApi;
|
||||
|
@ -35,11 +33,14 @@ import org.jclouds.googlecomputeengine.features.RegionApi;
|
|||
import org.jclouds.googlecomputeengine.features.RegionOperationApi;
|
||||
import org.jclouds.googlecomputeengine.features.RouteApi;
|
||||
import org.jclouds.googlecomputeengine.features.SnapshotApi;
|
||||
import org.jclouds.googlecomputeengine.features.TargetPoolApi;
|
||||
import org.jclouds.googlecomputeengine.features.ZoneApi;
|
||||
import org.jclouds.googlecomputeengine.features.ZoneOperationApi;
|
||||
import org.jclouds.rest.annotations.Delegate;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import java.io.Closeable;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -58,7 +59,7 @@ public interface GoogleComputeEngineApi extends Closeable {
|
|||
*/
|
||||
@Delegate
|
||||
@Path("/projects/{project}")
|
||||
AddressApi getAddressApiForProject(@PathParam("project") String projectName);
|
||||
AddressApi getAddressApi(@PathParam("project") String projectName);
|
||||
|
||||
/**
|
||||
* Provides access to Disk features
|
||||
|
@ -67,7 +68,7 @@ public interface GoogleComputeEngineApi extends Closeable {
|
|||
*/
|
||||
@Delegate
|
||||
@Path("/projects/{project}")
|
||||
DiskApi getDiskApiForProject(@PathParam("project") String projectName);
|
||||
DiskApi getDiskApi(@PathParam("project") String projectName);
|
||||
|
||||
/**
|
||||
* Provides access to DiskType features
|
||||
|
@ -85,7 +86,17 @@ public interface GoogleComputeEngineApi extends Closeable {
|
|||
*/
|
||||
@Delegate
|
||||
@Path("/projects/{project}")
|
||||
FirewallApi getFirewallApiForProject(@PathParam("project") String projectName);
|
||||
FirewallApi getFirewallApi(@PathParam("project") String projectName);
|
||||
|
||||
/**
|
||||
* Provides access to ForwardingRule features
|
||||
*
|
||||
* @param projectName the name of the project
|
||||
* @param region the name of the region scoping this request.
|
||||
*/
|
||||
@Delegate
|
||||
@Path("/projects/{project}/regions/{region}")
|
||||
ForwardingRuleApi getForwardingRuleApi(@PathParam("project") String projectName, @PathParam("region") String region);
|
||||
|
||||
/**
|
||||
* Provides access to Global Operation features
|
||||
|
@ -94,7 +105,16 @@ public interface GoogleComputeEngineApi extends Closeable {
|
|||
*/
|
||||
@Delegate
|
||||
@Path("/projects/{project}")
|
||||
GlobalOperationApi getGlobalOperationApiForProject(@PathParam("project") String projectName);
|
||||
GlobalOperationApi getGlobalOperationApi(@PathParam("project") String projectName);
|
||||
|
||||
/**
|
||||
* Provides access to HttpHealthCheck features
|
||||
*
|
||||
* @param projectName the name of the project
|
||||
*/
|
||||
@Delegate
|
||||
@Path("/projects/{project}/global/httpHealthChecks")
|
||||
HttpHealthCheckApi getHttpHealthCheckApi(@PathParam("project") String projectName);
|
||||
|
||||
/**
|
||||
* Provides access to Image features
|
||||
|
@ -103,7 +123,7 @@ public interface GoogleComputeEngineApi extends Closeable {
|
|||
*/
|
||||
@Delegate
|
||||
@Path("/projects/{project}")
|
||||
ImageApi getImageApiForProject(@PathParam("project") String projectName);
|
||||
ImageApi getImageApi(@PathParam("project") String projectName);
|
||||
|
||||
/**
|
||||
* Provides access to Instance features
|
||||
|
@ -112,7 +132,7 @@ public interface GoogleComputeEngineApi extends Closeable {
|
|||
*/
|
||||
@Delegate
|
||||
@Path("/projects/{project}")
|
||||
InstanceApi getInstanceApiForProject(@PathParam("project") String projectName);
|
||||
InstanceApi getInstanceApi(@PathParam("project") String projectName);
|
||||
|
||||
/**
|
||||
* Provides access to MachineType features
|
||||
|
@ -121,7 +141,7 @@ public interface GoogleComputeEngineApi extends Closeable {
|
|||
*/
|
||||
@Delegate
|
||||
@Path("/projects/{project}")
|
||||
MachineTypeApi getMachineTypeApiForProject(@PathParam("project") String projectName);
|
||||
MachineTypeApi getMachineTypeApi(@PathParam("project") String projectName);
|
||||
|
||||
/**
|
||||
* Provides access to Network features
|
||||
|
@ -130,7 +150,7 @@ public interface GoogleComputeEngineApi extends Closeable {
|
|||
*/
|
||||
@Delegate
|
||||
@Path("/projects/{project}")
|
||||
NetworkApi getNetworkApiForProject(@PathParam("project") String projectName);
|
||||
NetworkApi getNetworkApi(@PathParam("project") String projectName);
|
||||
|
||||
/**
|
||||
* Provides access to Project features
|
||||
|
@ -145,7 +165,7 @@ public interface GoogleComputeEngineApi extends Closeable {
|
|||
*/
|
||||
@Delegate
|
||||
@Path("/projects/{project}")
|
||||
RegionApi getRegionApiForProject(@PathParam("project") String projectName);
|
||||
RegionApi getRegionApi(@PathParam("project") String projectName);
|
||||
|
||||
/**
|
||||
* Provides access to Region Operation features
|
||||
|
@ -154,7 +174,7 @@ public interface GoogleComputeEngineApi extends Closeable {
|
|||
*/
|
||||
@Delegate
|
||||
@Path("/projects/{project}")
|
||||
RegionOperationApi getRegionOperationApiForProject(@PathParam("project") String projectName);
|
||||
RegionOperationApi getRegionOperationApi(@PathParam("project") String projectName);
|
||||
|
||||
/**
|
||||
* Provides access to Route features
|
||||
|
@ -163,7 +183,7 @@ public interface GoogleComputeEngineApi extends Closeable {
|
|||
*/
|
||||
@Delegate
|
||||
@Path("/projects/{project}")
|
||||
RouteApi getRouteApiForProject(@PathParam("project") String projectName);
|
||||
RouteApi getRouteApi(@PathParam("project") String projectName);
|
||||
|
||||
/**
|
||||
* Provides access to Snapshot features
|
||||
|
@ -172,7 +192,17 @@ public interface GoogleComputeEngineApi extends Closeable {
|
|||
*/
|
||||
@Delegate
|
||||
@Path("/projects/{project}")
|
||||
SnapshotApi getSnapshotApiForProject(@PathParam("project") String projectName);
|
||||
SnapshotApi getSnapshotApi(@PathParam("project") String projectName);
|
||||
|
||||
/**
|
||||
* Provides access to TargetPool features
|
||||
*
|
||||
* @param projectName the name of the project
|
||||
* @param region the name of the region scoping this request.
|
||||
*/
|
||||
@Delegate
|
||||
@Path("/projects/{project}/regions/{region}")
|
||||
TargetPoolApi getTargetPoolApi(@PathParam("project") String projectName, @PathParam("region") String region);
|
||||
|
||||
/**
|
||||
* Provides access to Zone features
|
||||
|
@ -181,7 +211,7 @@ public interface GoogleComputeEngineApi extends Closeable {
|
|||
*/
|
||||
@Delegate
|
||||
@Path("/projects/{project}")
|
||||
ZoneApi getZoneApiForProject(@PathParam("project") String projectName);
|
||||
ZoneApi getZoneApi(@PathParam("project") String projectName);
|
||||
|
||||
/**
|
||||
* Provides access to Zone Operation features
|
||||
|
@ -190,6 +220,6 @@ public interface GoogleComputeEngineApi extends Closeable {
|
|||
*/
|
||||
@Delegate
|
||||
@Path("/projects/{project}")
|
||||
ZoneOperationApi getZoneOperationApiForProject(@PathParam("project") String projectName);
|
||||
ZoneOperationApi getZoneOperationApi(@PathParam("project") String projectName);
|
||||
|
||||
}
|
||||
|
|
|
@ -152,8 +152,8 @@ public class GoogleComputeEngineService extends BaseComputeService {
|
|||
|
||||
protected void cleanUpNetworksAndFirewallsForGroup(final String groupName) {
|
||||
String resourceName = namingConvention.create().sharedNameForGroup(groupName);
|
||||
final Network network = api.getNetworkApiForProject(project.get()).get(resourceName);
|
||||
FirewallApi firewallApi = api.getFirewallApiForProject(project.get());
|
||||
final Network network = api.getNetworkApi(project.get()).get(resourceName);
|
||||
FirewallApi firewallApi = api.getFirewallApi(project.get());
|
||||
Predicate<Firewall> firewallBelongsToNetwork = new Predicate<Firewall>() {
|
||||
@Override
|
||||
public boolean apply(Firewall input) {
|
||||
|
@ -177,7 +177,7 @@ public class GoogleComputeEngineService extends BaseComputeService {
|
|||
}
|
||||
}
|
||||
|
||||
AtomicReference<Operation> operation = Atomics.newReference(api.getNetworkApiForProject(project.get()).delete(resourceName));
|
||||
AtomicReference<Operation> operation = Atomics.newReference(api.getNetworkApi(project.get()).delete(resourceName));
|
||||
|
||||
retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
|
||||
MILLISECONDS).apply(operation);
|
||||
|
|
|
@ -179,7 +179,7 @@ public class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<
|
|||
instanceTemplate.metadata(metadataBuilder.build());
|
||||
instanceTemplate.serviceAccounts(options.getServiceAccounts());
|
||||
|
||||
final InstanceApi instanceApi = api.getInstanceApiForProject(userProject.get());
|
||||
final InstanceApi instanceApi = api.getInstanceApi(userProject.get());
|
||||
final String zone = template.getLocation().getId();
|
||||
Operation operation = instanceApi.createInZone(name, zone, instanceTemplate);
|
||||
|
||||
|
@ -242,7 +242,7 @@ public class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<
|
|||
String diskName = instanceName + "-" + GCE_BOOT_DISK_SUFFIX;
|
||||
|
||||
DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(imageUri);
|
||||
Operation diskOperation = api.getDiskApiForProject(userProject.get())
|
||||
Operation diskOperation = api.getDiskApi(userProject.get())
|
||||
.createInZone(diskName,
|
||||
diskSize,
|
||||
template.getLocation().getId(),
|
||||
|
@ -250,7 +250,7 @@ public class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<
|
|||
|
||||
waitOperationDone(diskOperation);
|
||||
|
||||
return api.getDiskApiForProject(userProject.get()).getInZone(template.getLocation().getId(),
|
||||
return api.getDiskApi(userProject.get()).getInZone(template.getLocation().getId(),
|
||||
diskName);
|
||||
}
|
||||
|
||||
|
@ -259,7 +259,7 @@ public class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<
|
|||
ImmutableSet.Builder<MachineTypeInZone> builder = ImmutableSet.builder();
|
||||
|
||||
for (final Location zone : zones.get().values()) {
|
||||
builder.addAll(api.getMachineTypeApiForProject(userProject.get())
|
||||
builder.addAll(api.getMachineTypeApi(userProject.get())
|
||||
.listInZone(zone.getId())
|
||||
.concat()
|
||||
.filter(new Predicate<MachineType>() {
|
||||
|
@ -283,30 +283,31 @@ public class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<
|
|||
@Override
|
||||
public Iterable<Image> listImages() {
|
||||
return ImmutableSet.<Image>builder()
|
||||
.addAll(api.getImageApiForProject(userProject.get()).list().concat())
|
||||
.addAll(api.getImageApiForProject(DEBIAN_PROJECT).list().concat())
|
||||
.addAll(api.getImageApiForProject(CENTOS_PROJECT).list().concat())
|
||||
.addAll(api.getImageApi(userProject.get()).list().concat())
|
||||
.addAll(api.getImageApi(DEBIAN_PROJECT).list().concat())
|
||||
.addAll(api.getImageApi(CENTOS_PROJECT).list().concat())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public Image getImage(String id) {
|
||||
return Objects.firstNonNull(api.getImageApiForProject(userProject.get()).get(id),
|
||||
Objects.firstNonNull(api.getImageApiForProject(DEBIAN_PROJECT).get(id),
|
||||
api.getImageApiForProject(CENTOS_PROJECT).get(id)));
|
||||
return Objects.firstNonNull(api.getImageApi(userProject.get()).get(id),
|
||||
Objects.firstNonNull(api.getImageApi(DEBIAN_PROJECT).get(id),
|
||||
api.getImageApi(CENTOS_PROJECT).get(id)));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterable<Zone> listLocations() {
|
||||
return api.getZoneApiForProject(userProject.get()).list().concat();
|
||||
return api.getZoneApi(userProject.get()).list().concat();
|
||||
}
|
||||
|
||||
@Override
|
||||
public InstanceInZone getNode(String name) {
|
||||
SlashEncodedIds slashEncodedIds = SlashEncodedIds.fromSlashEncoded(name);
|
||||
|
||||
Instance instance = api.getInstanceApiForProject(userProject.get()).getInZone(slashEncodedIds.getFirstId(),
|
||||
Instance instance = api.getInstanceApi(userProject.get()).getInZone(slashEncodedIds.getFirstId(),
|
||||
slashEncodedIds.getSecondId());
|
||||
|
||||
return instance == null ? null : new InstanceInZone(instance, slashEncodedIds.getFirstId());
|
||||
|
@ -317,7 +318,7 @@ public class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<
|
|||
return FluentIterable.from(zones.get().values()).transformAndConcat(new Function<Location, ImmutableSet<InstanceInZone>>() {
|
||||
@Override
|
||||
public ImmutableSet<InstanceInZone> apply(final Location input) {
|
||||
return api.getInstanceApiForProject(userProject.get()).listInZone(input.getId()).concat()
|
||||
return api.getInstanceApi(userProject.get()).listInZone(input.getId()).concat()
|
||||
.transform(new Function<Instance, InstanceInZone>() {
|
||||
|
||||
@Override
|
||||
|
@ -345,7 +346,7 @@ public class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<
|
|||
SlashEncodedIds slashEncodedIds = SlashEncodedIds.fromSlashEncoded(name);
|
||||
String diskName = null;
|
||||
try {
|
||||
Instance instance = api.getInstanceApiForProject(userProject.get()).getInZone(slashEncodedIds.getFirstId(),
|
||||
Instance instance = api.getInstanceApi(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>() {
|
||||
|
@ -362,11 +363,11 @@ public class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<
|
|||
} 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(),
|
||||
waitOperationDone(api.getInstanceApi(userProject.get()).deleteInZone(slashEncodedIds.getFirstId(),
|
||||
slashEncodedIds.getSecondId()));
|
||||
|
||||
if (diskName != null) {
|
||||
waitOperationDone(api.getDiskApiForProject(userProject.get()).deleteInZone(slashEncodedIds.getFirstId(),
|
||||
waitOperationDone(api.getDiskApi(userProject.get()).deleteInZone(slashEncodedIds.getFirstId(),
|
||||
diskName));
|
||||
}
|
||||
|
||||
|
@ -376,7 +377,7 @@ public class GoogleComputeEngineServiceAdapter implements ComputeServiceAdapter<
|
|||
public void rebootNode(final String name) {
|
||||
SlashEncodedIds slashEncodedIds = SlashEncodedIds.fromSlashEncoded(name);
|
||||
|
||||
waitOperationDone(api.getInstanceApiForProject(userProject.get()).resetInZone(slashEncodedIds.getFirstId(),
|
||||
waitOperationDone(api.getInstanceApi(userProject.get()).resetInZone(slashEncodedIds.getFirstId(),
|
||||
slashEncodedIds.getSecondId()));
|
||||
}
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@ public class GoogleComputeEngineServiceContextModule
|
|||
new Supplier<Map<URI, ? extends Location>>() {
|
||||
@Override
|
||||
public Map<URI, ? extends Location> get() {
|
||||
return uniqueIndex(transform(api.getZoneApiForProject(userProject.get()).list().concat(), zoneToLocation),
|
||||
return uniqueIndex(transform(api.getZoneApi(userProject.get()).list().concat(), zoneToLocation),
|
||||
new Function<Location, URI>() {
|
||||
@Override
|
||||
public URI apply(Location input) {
|
||||
|
@ -236,7 +236,7 @@ public class GoogleComputeEngineServiceContextModule
|
|||
new Supplier<Map<URI, Region>>() {
|
||||
@Override
|
||||
public Map<URI, Region> get() {
|
||||
return uniqueIndex(api.getRegionApiForProject(userProject.get()).list().concat(),
|
||||
return uniqueIndex(api.getRegionApi(userProject.get()).list().concat(),
|
||||
new Function<Region, URI>() {
|
||||
@Override
|
||||
public URI apply(Region input) {
|
||||
|
|
|
@ -100,7 +100,7 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
|
|||
|
||||
@Override
|
||||
public Set<SecurityGroup> listSecurityGroups() {
|
||||
return api.getNetworkApiForProject(userProject.get()).list().concat().transform(groupConverter).toSet();
|
||||
return api.getNetworkApi(userProject.get()).list().concat().transform(groupConverter).toSet();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -112,7 +112,7 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
|
|||
public Set<SecurityGroup> listSecurityGroupsForNode(String id) {
|
||||
SlashEncodedIds slashEncodedIds = SlashEncodedIds.fromSlashEncoded(id);
|
||||
|
||||
Instance instance = api.getInstanceApiForProject(userProject.get()).getInZone(slashEncodedIds.getFirstId(),
|
||||
Instance instance = api.getInstanceApi(userProject.get()).getInZone(slashEncodedIds.getFirstId(),
|
||||
slashEncodedIds.getSecondId());
|
||||
|
||||
if (instance == null) {
|
||||
|
@ -124,7 +124,7 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
|
|||
|
||||
for (NetworkInterface nwInterface : instance.getNetworkInterfaces()) {
|
||||
String networkUrl = nwInterface.getNetwork().getPath();
|
||||
Network nw = api.getNetworkApiForProject(userProject.get()).get(networkUrl.substring(networkUrl.lastIndexOf('/') + 1));
|
||||
Network nw = api.getNetworkApi(userProject.get()).get(networkUrl.substring(networkUrl.lastIndexOf('/') + 1));
|
||||
|
||||
SecurityGroup grp = groupForTagsInNetwork(nw, instance.getTags().getItems());
|
||||
if (grp != null) {
|
||||
|
@ -138,7 +138,7 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
|
|||
@Override
|
||||
public SecurityGroup getSecurityGroupById(String id) {
|
||||
checkNotNull(id, "id");
|
||||
Network network = api.getNetworkApiForProject(userProject.get()).get(id);
|
||||
Network network = api.getNetworkApi(userProject.get()).get(id);
|
||||
|
||||
if (network == null) {
|
||||
return null;
|
||||
|
@ -165,16 +165,16 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
|
|||
@Override
|
||||
public boolean removeSecurityGroup(String id) {
|
||||
checkNotNull(id, "id");
|
||||
if (api.getNetworkApiForProject(userProject.get()).get(id) == null) {
|
||||
if (api.getNetworkApi(userProject.get()).get(id) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ListOptions options = new ListOptions.Builder().filter("network eq .*/" + id);
|
||||
|
||||
FluentIterable<Firewall> fws = api.getFirewallApiForProject(userProject.get()).list(options).concat();
|
||||
FluentIterable<Firewall> fws = api.getFirewallApi(userProject.get()).list(options).concat();
|
||||
|
||||
for (Firewall fw : fws) {
|
||||
AtomicReference<Operation> operation = Atomics.newReference(api.getFirewallApiForProject(userProject.get())
|
||||
AtomicReference<Operation> operation = Atomics.newReference(api.getFirewallApi(userProject.get())
|
||||
.delete(fw.getName()));
|
||||
|
||||
retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
|
||||
|
@ -184,12 +184,12 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
|
|||
}
|
||||
|
||||
AtomicReference<Operation> operation = Atomics.newReference(
|
||||
api.getNetworkApiForProject(userProject.get()).delete(id));
|
||||
api.getNetworkApi(userProject.get()).delete(id));
|
||||
|
||||
retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
|
||||
MILLISECONDS).apply(operation);
|
||||
|
||||
checkState(!operation.get().getHttpError().isPresent(), "Could not create network, operation failed" + operation);
|
||||
checkState(!operation.get().getHttpError().isPresent(), "Could not insert network, operation failed" + operation);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -199,11 +199,11 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
|
|||
checkNotNull(group, "group");
|
||||
checkNotNull(ipPermission, "ipPermission");
|
||||
|
||||
checkNotNull(api.getNetworkApiForProject(userProject.get()).get(group.getId()) == null, "network for group is null");
|
||||
checkNotNull(api.getNetworkApi(userProject.get()).get(group.getId()) == null, "network for group is null");
|
||||
|
||||
ListOptions options = new ListOptions.Builder().filter("network eq .*/" + group.getName());
|
||||
|
||||
if (api.getFirewallApiForProject(userProject.get()).list(options).concat().anyMatch(providesIpPermission(ipPermission))) {
|
||||
if (api.getFirewallApi(userProject.get()).list(options).concat().anyMatch(providesIpPermission(ipPermission))) {
|
||||
// Permission already exists.
|
||||
return group;
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
|
|||
}
|
||||
fwOptions.addAllowedRule(ruleBuilder.build());
|
||||
|
||||
AtomicReference<Operation> operation = Atomics.newReference(api.getFirewallApiForProject(userProject
|
||||
AtomicReference<Operation> operation = Atomics.newReference(api.getFirewallApi(userProject
|
||||
.get()).createInNetwork(
|
||||
uniqueFwName,
|
||||
group.getUri(),
|
||||
|
@ -238,7 +238,7 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
|
|||
retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
|
||||
MILLISECONDS).apply(operation);
|
||||
|
||||
checkState(!operation.get().getHttpError().isPresent(), "Could not create firewall, operation failed" + operation);
|
||||
checkState(!operation.get().getHttpError().isPresent(), "Could not insert firewall, operation failed" + operation);
|
||||
|
||||
return getSecurityGroupById(group.getId());
|
||||
}
|
||||
|
@ -264,15 +264,15 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
|
|||
checkNotNull(group, "group");
|
||||
checkNotNull(ipPermission, "ipPermission");
|
||||
|
||||
checkNotNull(api.getNetworkApiForProject(userProject.get()).get(group.getId()) == null, "network for group is null");
|
||||
checkNotNull(api.getNetworkApi(userProject.get()).get(group.getId()) == null, "network for group is null");
|
||||
|
||||
ListOptions options = new ListOptions.Builder().filter("network eq .*/" + group.getName());
|
||||
|
||||
FluentIterable<Firewall> fws = api.getFirewallApiForProject(userProject.get()).list(options).concat();
|
||||
FluentIterable<Firewall> fws = api.getFirewallApi(userProject.get()).list(options).concat();
|
||||
|
||||
for (Firewall fw : fws) {
|
||||
if (equalsIpPermission(ipPermission).apply(fw)) {
|
||||
AtomicReference<Operation> operation = Atomics.newReference(api.getFirewallApiForProject(userProject.get())
|
||||
AtomicReference<Operation> operation = Atomics.newReference(api.getFirewallApi(userProject.get())
|
||||
.delete(fw.getName()));
|
||||
|
||||
retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
|
||||
|
@ -328,7 +328,7 @@ public class GoogleComputeEngineSecurityGroupExtension implements SecurityGroupE
|
|||
|
||||
private SecurityGroup groupForTagsInNetwork(Network nw, final Set <String> tags) {
|
||||
ListOptions opts = new Builder().filter("network eq .*/" + nw.getName());
|
||||
Set<Firewall> fws = api.getFirewallApiForProject(userProject.get()).list(opts).concat()
|
||||
Set<Firewall> fws = api.getFirewallApi(userProject.get()).list(opts).concat()
|
||||
.filter(new Predicate<Firewall>() {
|
||||
@Override
|
||||
public boolean apply(final Firewall input) {
|
||||
|
|
|
@ -70,7 +70,7 @@ public class NetworkToSecurityGroup implements Function<Network, SecurityGroup>
|
|||
|
||||
ListOptions options = new ListOptions.Builder().filter("network eq .*/" + network.getName());
|
||||
|
||||
for (Firewall fw : api.getFirewallApiForProject(project.get()).list(options).concat()) {
|
||||
for (Firewall fw : api.getFirewallApi(project.get()).list(options).concat()) {
|
||||
permBuilder.addAll(firewallToPerms.apply(fw));
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public class FindNetworkOrCreate extends CacheLoader<NetworkAndAddressRange, Net
|
|||
|
||||
@Override
|
||||
public Network load(NetworkAndAddressRange in) {
|
||||
Network network = api.getNetworkApiForProject(userProject.get()).get(in.getName());
|
||||
Network network = api.getNetworkApi(userProject.get()).get(in.getName());
|
||||
if (network != null) {
|
||||
return network;
|
||||
} else {
|
||||
|
|
|
@ -118,7 +118,7 @@ public class CreateNodesWithGroupEncodedIntoNameThenAddToSet extends
|
|||
.getOptions());
|
||||
assert template.getOptions().equals(templateOptions) : "options didn't clone properly";
|
||||
|
||||
// get or create the network and create a firewall with the users configuration
|
||||
// get or insert the network and insert a firewall with the users configuration
|
||||
Network network = getOrCreateNetwork(templateOptions, sharedResourceName);
|
||||
getOrCreateFirewalls(templateOptions, network, firewallTagNamingConvention.get(group));
|
||||
templateOptions.network(network.getSelfLink());
|
||||
|
@ -149,9 +149,10 @@ public class CreateNodesWithGroupEncodedIntoNameThenAddToSet extends
|
|||
FirewallTagNamingConvention naming) {
|
||||
|
||||
String projectName = userProject.get();
|
||||
FirewallApi firewallApi = api.getFirewallApiForProject(projectName);
|
||||
FirewallApi firewallApi = api.getFirewallApi(projectName);
|
||||
Set<AtomicReference<Operation>> operations = Sets.newLinkedHashSet();
|
||||
|
||||
|
||||
for (Integer port : templateOptions.getInboundPorts()) {
|
||||
String name = naming.name(port);
|
||||
Firewall firewall = firewallApi.get(name);
|
||||
|
@ -176,7 +177,7 @@ public class CreateNodesWithGroupEncodedIntoNameThenAddToSet extends
|
|||
retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
|
||||
MILLISECONDS).apply(operation);
|
||||
checkState(!operation.get().getHttpError().isPresent(),
|
||||
"Could not create firewall, operation failed" + operation);
|
||||
"Could not insert firewall, operation failed" + operation);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ import com.google.inject.Inject;
|
|||
import com.google.inject.Singleton;
|
||||
|
||||
/**
|
||||
* GCE needs the credentials to create the node so the node credentials already take the Image credentials into account,
|
||||
* GCE needs the credentials to insert the node so the node credentials already take the Image credentials into account,
|
||||
* as such only overriding the TemplateOptions credentials is required.
|
||||
*/
|
||||
@Singleton
|
||||
|
|
|
@ -16,30 +16,6 @@
|
|||
*/
|
||||
package org.jclouds.googlecomputeengine.config;
|
||||
|
||||
import static org.jclouds.googlecomputeengine.domain.Firewall.Rule;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.jclouds.googlecomputeengine.domain.Firewall;
|
||||
import org.jclouds.googlecomputeengine.domain.Instance;
|
||||
import org.jclouds.googlecomputeengine.domain.InstanceTemplate;
|
||||
import org.jclouds.googlecomputeengine.domain.Metadata;
|
||||
import org.jclouds.googlecomputeengine.domain.Operation;
|
||||
import org.jclouds.googlecomputeengine.domain.Project;
|
||||
import org.jclouds.googlecomputeengine.domain.Quota;
|
||||
import org.jclouds.googlecomputeengine.options.FirewallOptions;
|
||||
import org.jclouds.googlecomputeengine.options.RouteOptions;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.net.domain.IpProtocol;
|
||||
import org.jclouds.oauth.v2.config.OAuthParserModule;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.Range;
|
||||
import com.google.gson.JsonArray;
|
||||
|
@ -54,6 +30,29 @@ import com.google.gson.JsonSerializer;
|
|||
import com.google.gson.TypeAdapterFactory;
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
import org.jclouds.googlecomputeengine.domain.Firewall;
|
||||
import org.jclouds.googlecomputeengine.domain.Instance;
|
||||
import org.jclouds.googlecomputeengine.domain.InstanceTemplate;
|
||||
import org.jclouds.googlecomputeengine.domain.Metadata;
|
||||
import org.jclouds.googlecomputeengine.domain.Operation;
|
||||
import org.jclouds.googlecomputeengine.domain.Project;
|
||||
import org.jclouds.googlecomputeengine.domain.Quota;
|
||||
import org.jclouds.googlecomputeengine.options.FirewallOptions;
|
||||
import org.jclouds.googlecomputeengine.options.RouteOptions;
|
||||
import org.jclouds.json.config.GsonModule;
|
||||
import org.jclouds.net.domain.IpProtocol;
|
||||
import org.jclouds.oauth.v2.config.OAuthParserModule;
|
||||
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.jclouds.googlecomputeengine.domain.Firewall.Rule;
|
||||
|
||||
public class GoogleComputeEngineParserModule extends AbstractModule {
|
||||
|
||||
|
|
|
@ -26,8 +26,6 @@ import com.google.common.base.Objects;
|
|||
|
||||
/**
|
||||
* A persistent disk resource
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/disks"/>
|
||||
*/
|
||||
@Beta
|
||||
public abstract class AbstractDisk extends Resource {
|
||||
|
|
|
@ -16,10 +16,6 @@
|
|||
*/
|
||||
package org.jclouds.googlecomputeengine.domain;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
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;
|
||||
|
@ -28,10 +24,12 @@ import com.google.common.annotations.Beta;
|
|||
import com.google.common.base.Objects;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Optional.fromNullable;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
/**
|
||||
* Represents an Address resource.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/addresses"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class Address extends Resource {
|
||||
|
@ -100,6 +98,7 @@ public final class Address extends Resource {
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
protected Objects.ToStringHelper string() {
|
||||
return super.string()
|
||||
|
|
|
@ -32,8 +32,6 @@ import com.google.common.base.Optional;
|
|||
|
||||
/**
|
||||
* A persistent disk resource
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/disks"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class Disk extends AbstractDisk {
|
||||
|
|
|
@ -38,9 +38,6 @@ import com.google.common.collect.TreeRangeSet;
|
|||
|
||||
/**
|
||||
* Represents a network firewall
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/firewalls"/>
|
||||
* @see <a href="https://developers.google.com/compute/docs/networking#firewalls"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class Firewall extends Resource {
|
||||
|
|
|
@ -0,0 +1,198 @@
|
|||
/*
|
||||
* 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 com.google.common.annotations.Beta;
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Optional.fromNullable;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
@Beta
|
||||
public class ForwardingRule extends Resource {
|
||||
|
||||
private final URI region;
|
||||
private final Optional<String> ipAddress;
|
||||
private final Optional<String> ipProtocol;
|
||||
private final Optional<String> portRange;
|
||||
private final URI target;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "creationTimestamp", "selfLink", "name", "description", "region", "IPAddress", "IPProtocol",
|
||||
"portRange", "target"
|
||||
})
|
||||
private ForwardingRule(String id, Date creationTimestamp, URI selfLink, String name, String description,
|
||||
URI region, @Nullable String ipAddress, @Nullable String ipProtocol, @Nullable String portRange,
|
||||
URI target) {
|
||||
super(Kind.FORWARDING_RULE, id, creationTimestamp, selfLink, name, description);
|
||||
this.region = checkNotNull(region, "region of %s", name);
|
||||
this.ipAddress = fromNullable(ipAddress);
|
||||
this.ipProtocol = fromNullable(ipProtocol);
|
||||
this.portRange = fromNullable(portRange);
|
||||
this.target = checkNotNull(target, "target of %s", name);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return URL of the region where the forwarding rule resides.
|
||||
*/
|
||||
public URI getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the external IP address that this forwarding rule is serving on behalf of. If this is a reserved
|
||||
* address, the address must live in the same region as the forwarding rule. By default,
|
||||
* this field is empty and an ephemeral IP is assigned to the ForwardingRule.
|
||||
*/
|
||||
public Optional<String> getIpAddress() {
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the IP protocol to which this rule applies. If left empty, the default value used is TCP.
|
||||
*/
|
||||
public Optional<String> getIpProtocol() {
|
||||
return ipProtocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return If IPProtocol is TCP or UDP, packets addressed to ports in the specified range will be forwarded to
|
||||
* backend. By default, this is empty and all ports are allowed.
|
||||
*/
|
||||
public Optional<String> getPortRange() {
|
||||
return portRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the URL of the target resource to receive the matched traffic. The target resource must live in the
|
||||
* same region as this forwarding rule.
|
||||
*/
|
||||
public URI getTarget() {
|
||||
return target;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
ForwardingRule that = ForwardingRule.class.cast(obj);
|
||||
return equal(this.kind, that.kind)
|
||||
&& equal(this.name, that.name)
|
||||
&& equal(this.region, that.region);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected MoreObjects.ToStringHelper string() {
|
||||
return super.string()
|
||||
.omitNullValues()
|
||||
.add("region", region)
|
||||
.add("ipAddress", ipAddress.orNull())
|
||||
.add("ipProtocol", ipProtocol.orNull())
|
||||
.add("portRange", portRange.orNull())
|
||||
.add("target", target);
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromForwardingRule(this);
|
||||
}
|
||||
|
||||
public static final class Builder extends Resource.Builder<Builder> {
|
||||
private URI region;
|
||||
private String ipAddress;
|
||||
private String ipProtocol;
|
||||
private String portRange;
|
||||
private URI target;
|
||||
|
||||
/**
|
||||
* @see ForwardingRule#getRegion()
|
||||
*/
|
||||
public Builder region(URI region) {
|
||||
this.region = region;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.googlecomputeengine.domain.ForwardingRule#getIpAddress()
|
||||
*/
|
||||
public Builder ipAddress(String ipAddress) {
|
||||
this.ipAddress = ipAddress;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.googlecomputeengine.domain.ForwardingRule#getIpProtocol()
|
||||
*/
|
||||
public Builder ipProtocol(String ipProtocol) {
|
||||
this.ipProtocol = ipProtocol;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.googlecomputeengine.domain.ForwardingRule#getPortRange()
|
||||
*/
|
||||
public Builder portRange(String portRange) {
|
||||
this.portRange = portRange;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.googlecomputeengine.domain.ForwardingRule#getTarget()
|
||||
*/
|
||||
public Builder target(URI target) {
|
||||
this.target = target;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Builder self() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ForwardingRule build() {
|
||||
return new ForwardingRule(super.id, super.creationTimestamp, super.selfLink, super.name, super.description,
|
||||
region, ipAddress, ipProtocol, portRange, target);
|
||||
}
|
||||
|
||||
public Builder fromForwardingRule(ForwardingRule in) {
|
||||
return super.fromResource(in)
|
||||
.region(in.getRegion())
|
||||
.ipAddress(in.getIpAddress().orNull())
|
||||
.ipProtocol(in.getIpProtocol().orNull())
|
||||
.portRange(in.getPortRange().orNull())
|
||||
.target(in.getTarget());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,235 @@
|
|||
/*
|
||||
* 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 com.google.common.annotations.Beta;
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Optional.fromNullable;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
@Beta
|
||||
public class HttpHealthCheck extends Resource {
|
||||
private final Optional<String> host;
|
||||
private final Optional<String> requestPath;
|
||||
private final Optional<Integer> port;
|
||||
private final Optional<Integer> checkIntervalSec;
|
||||
private final Optional<Integer> timeoutSec;
|
||||
private final Optional<Integer> unhealthyThreshold;
|
||||
private final Optional<Integer> healthyThreshold;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "creationTimestamp", "selfLink", "name", "description", "host", "requestPath", "port",
|
||||
"checkIntervalSec", "timeoutSec", "unhealthyThreshold", "healthyThreshold"
|
||||
})
|
||||
private HttpHealthCheck(String id, Date creationTimestamp, URI selfLink, String name, String description,
|
||||
@Nullable String host, @Nullable String requestPath, int port, int checkIntervalSec,
|
||||
int timeoutSec, int unhealthyThreshold, int healthyThreshold) {
|
||||
super(Kind.HTTP_HEALTH_CHECK, id, creationTimestamp, selfLink, name, description);
|
||||
this.host = fromNullable(host);
|
||||
this.requestPath = fromNullable(requestPath);
|
||||
this.port = fromNullable(port);
|
||||
this.checkIntervalSec = fromNullable(checkIntervalSec);
|
||||
this.timeoutSec = fromNullable(timeoutSec);
|
||||
this.unhealthyThreshold = fromNullable(unhealthyThreshold);
|
||||
this.healthyThreshold = fromNullable(healthyThreshold);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the value of the host header in the HTTP health check request. If left empty (default value),
|
||||
* the public IP on behalf of which this health check is performed will be used.
|
||||
*/
|
||||
public Optional<String> getHost() {
|
||||
return host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the request path of the HTTP health check request. The default value is /.
|
||||
*/
|
||||
public Optional<String> getRequestPath() {
|
||||
return requestPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the TCP port number for the HTTP health check request. The default value is 80.
|
||||
*/
|
||||
public Optional<Integer> getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return how often (in seconds) to send a health check. The default value is 5 seconds.
|
||||
*/
|
||||
public Optional<Integer> getCheckIntervalSec() {
|
||||
return checkIntervalSec;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return how long (in seconds) to wait before claiming failure. The default value is 5 seconds.
|
||||
*/
|
||||
public Optional<Integer> getTimeoutSec() {
|
||||
return timeoutSec;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a so-far healthy VM will be marked unhealthy after this many consecutive failures.
|
||||
* The default value is 2.
|
||||
*/
|
||||
public Optional<Integer> getUnhealthyThreshold() {
|
||||
return unhealthyThreshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an unhealthy VM will be marked healthy after this many consecutive successes. The default value is 2.
|
||||
*/
|
||||
public Optional<Integer> getHealthyThreshold() {
|
||||
return healthyThreshold;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
HttpHealthCheck that = HttpHealthCheck.class.cast(obj);
|
||||
return equal(this.kind, that.kind)
|
||||
&& equal(this.name, that.name)
|
||||
&& equal(this.host, that.host);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected MoreObjects.ToStringHelper string() {
|
||||
return super.string()
|
||||
.omitNullValues()
|
||||
.add("host", host.orNull())
|
||||
.add("requestPath", requestPath.orNull())
|
||||
.add("port", port.orNull())
|
||||
.add("checkIntervalSec", checkIntervalSec.orNull())
|
||||
.add("timeoutSec", timeoutSec.orNull())
|
||||
.add("unhealthyThreshold", unhealthyThreshold.orNull())
|
||||
.add("healthyThreshold", healthyThreshold.orNull());
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromHttpHealthCheck(this);
|
||||
}
|
||||
|
||||
public static final class Builder extends Resource.Builder<Builder> {
|
||||
private String host;
|
||||
private String requestPath;
|
||||
private int port;
|
||||
private int checkIntervalSec;
|
||||
private int timeoutSec;
|
||||
private int unhealthyThreshold;
|
||||
private int healthyThreshold;
|
||||
|
||||
/**
|
||||
* @see HttpHealthCheck#getHost()
|
||||
*/
|
||||
public Builder host(String host) {
|
||||
this.host = host;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.googlecomputeengine.domain.HttpHealthCheck#getRequestPath()
|
||||
*/
|
||||
public Builder requestPath(String requestPath) {
|
||||
this.requestPath = requestPath;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.googlecomputeengine.domain.HttpHealthCheck#getPort()
|
||||
*/
|
||||
public Builder port(int port) {
|
||||
this.port = port;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.googlecomputeengine.domain.HttpHealthCheck#getCheckIntervalSec()
|
||||
*/
|
||||
public Builder checkIntervalSec(int checkIntervalSec) {
|
||||
this.checkIntervalSec = checkIntervalSec;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.jclouds.googlecomputeengine.domain.HttpHealthCheck#getTimeoutSec()
|
||||
*/
|
||||
public Builder timeoutSec(int timeoutSec) {
|
||||
this.timeoutSec = timeoutSec;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpHealthCheck#getUnhealthyThreshold()
|
||||
*/
|
||||
public Builder unhealthyThreshold(int unhealthyThreshold) {
|
||||
this.unhealthyThreshold = unhealthyThreshold;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see HttpHealthCheck#getHealthyThreshold()
|
||||
*/
|
||||
public Builder healthyThreshold(int healthyThreshold) {
|
||||
this.healthyThreshold = healthyThreshold;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Builder self() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public HttpHealthCheck build() {
|
||||
return new HttpHealthCheck(super.id, super.creationTimestamp, super.selfLink, super.name,
|
||||
super.description, host, requestPath, port, checkIntervalSec, timeoutSec, unhealthyThreshold,
|
||||
healthyThreshold);
|
||||
}
|
||||
|
||||
public Builder fromHttpHealthCheck(HttpHealthCheck in) {
|
||||
return super.fromResource(in)
|
||||
.host(in.getHost().orNull())
|
||||
.requestPath(in.getRequestPath().orNull())
|
||||
.port(in.getPort().orNull())
|
||||
.checkIntervalSec(in.getCheckIntervalSec().orNull())
|
||||
.timeoutSec(in.getTimeoutSec().orNull())
|
||||
.unhealthyThreshold(in.getUnhealthyThreshold().orNull())
|
||||
.healthyThreshold(in.getHealthyThreshold().orNull());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -31,8 +31,6 @@ import com.google.common.base.Optional;
|
|||
|
||||
/**
|
||||
* Represents a disk image to use on an instance.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/images"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class Image extends Resource {
|
||||
|
|
|
@ -37,8 +37,6 @@ import com.google.common.collect.ImmutableSet;
|
|||
|
||||
/**
|
||||
* Represents a virtual machine.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/instances"/>
|
||||
*/
|
||||
@Beta
|
||||
public class Instance extends Resource {
|
||||
|
|
|
@ -35,8 +35,6 @@ import com.google.common.collect.ImmutableList;
|
|||
|
||||
/**
|
||||
* Represents a machine type used to host an instance.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/machineTypes"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class MachineType extends Resource {
|
||||
|
|
|
@ -30,8 +30,6 @@ import com.google.common.base.Optional;
|
|||
|
||||
/**
|
||||
* Represents a network used to enable instance communication.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/networks"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class Network extends Resource {
|
||||
|
|
|
@ -36,8 +36,6 @@ import com.google.common.collect.ImmutableList;
|
|||
|
||||
/**
|
||||
* Describes an operation being executed on some Resource
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/operations"/>
|
||||
*/
|
||||
@Beta
|
||||
public class Operation extends Resource {
|
||||
|
|
|
@ -30,8 +30,6 @@ import com.google.common.collect.ImmutableSet;
|
|||
|
||||
/**
|
||||
* A Project resource is the root collection and settings resource for all Google Compute Engine resources.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/projects"/>
|
||||
*/
|
||||
@Beta
|
||||
public class Project extends Resource {
|
||||
|
|
|
@ -26,8 +26,6 @@ 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/v1/projects#resource"/>
|
||||
*/
|
||||
@Beta
|
||||
public class Quota {
|
||||
|
|
|
@ -31,8 +31,6 @@ import com.google.common.collect.ImmutableSet;
|
|||
|
||||
/**
|
||||
* Represents a region resource.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/regions"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class Region extends Resource {
|
||||
|
|
|
@ -16,18 +16,10 @@
|
|||
*/
|
||||
package org.jclouds.googlecomputeengine.domain;
|
||||
|
||||
import static com.google.common.base.Objects.ToStringHelper;
|
||||
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 java.beans.ConstructorProperties;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import com.google.common.base.CaseFormat;
|
||||
import com.google.common.base.Joiner;
|
||||
|
@ -36,6 +28,12 @@ import com.google.common.base.Optional;
|
|||
import com.google.common.base.Splitter;
|
||||
import com.google.common.collect.Iterables;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* Base class for Google Compute Engine resources.
|
||||
*/
|
||||
|
@ -51,6 +49,10 @@ public class Resource {
|
|||
DISK_TYPE_LIST,
|
||||
FIREWALL,
|
||||
FIREWALL_LIST,
|
||||
FORWARDING_RULE,
|
||||
FORWARDING_RULE_LIST,
|
||||
HTTP_HEALTH_CHECK,
|
||||
HTTP_HEALTH_CHECK_LIST,
|
||||
IMAGE,
|
||||
IMAGE_LIST,
|
||||
OPERATION,
|
||||
|
@ -68,6 +70,8 @@ public class Resource {
|
|||
ROUTE_LIST,
|
||||
SNAPSHOT,
|
||||
SNAPSHOT_LIST,
|
||||
TARGET_POOL,
|
||||
TARGET_POOL_LIST,
|
||||
ZONE,
|
||||
ZONE_LIST;
|
||||
|
||||
|
@ -171,8 +175,9 @@ public class Resource {
|
|||
&& equal(this.name, that.name);
|
||||
}
|
||||
|
||||
protected ToStringHelper string() {
|
||||
return toStringHelper(this)
|
||||
@SuppressWarnings("deprecation")
|
||||
protected Objects.ToStringHelper string() {
|
||||
return Objects.toStringHelper(this)
|
||||
.omitNullValues()
|
||||
.add("kind", kind)
|
||||
.add("id", id)
|
||||
|
|
|
@ -35,8 +35,6 @@ import com.google.common.collect.ImmutableSet;
|
|||
|
||||
/**
|
||||
* Represents a route resource.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/routes"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class Route extends Resource {
|
||||
|
|
|
@ -29,8 +29,6 @@ import com.google.common.base.Optional;
|
|||
|
||||
/**
|
||||
* A Persistent Disk Snapshot resource.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/snapshots"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class Snapshot extends AbstractDisk {
|
||||
|
@ -50,7 +48,7 @@ public final class Snapshot extends AbstractDisk {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return The source disk used to create this snapshot. Once the source disk
|
||||
* @return The source disk used to insert this snapshot. Once the source disk
|
||||
* has been deleted from the system, this field will be cleared, and will
|
||||
* not be set even if a disk with the same name has been re-created (output only).
|
||||
*/
|
||||
|
@ -59,7 +57,7 @@ public final class Snapshot extends AbstractDisk {
|
|||
}
|
||||
|
||||
/**
|
||||
* @return The ID value of the disk used to create this snapshot. This value
|
||||
* @return The ID value of the disk used to insert this snapshot. This value
|
||||
* may be used to determine whether the snapshot was taken from the current
|
||||
* or a previous instance of a given disk name.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,237 @@
|
|||
/*
|
||||
* 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 com.google.common.annotations.Beta;
|
||||
import com.google.common.base.MoreObjects;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import java.beans.ConstructorProperties;
|
||||
import java.net.URI;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.google.common.base.Objects.equal;
|
||||
import static com.google.common.base.Optional.fromNullable;
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Represents an TargetPool resource.
|
||||
*/
|
||||
@Beta
|
||||
public final class TargetPool extends Resource {
|
||||
|
||||
private final URI region;
|
||||
private final Set<URI> healthChecks;
|
||||
private final Set<URI> instances;
|
||||
private final Optional<String> sessionAffinity;
|
||||
private final float failoverRatio;
|
||||
private final Optional<String> backupPool;
|
||||
|
||||
@ConstructorProperties({
|
||||
"id", "creationTimestamp", "selfLink", "name", "description", "region", "healthChecks", "instances",
|
||||
"sessionAffinity", "failoverRatio", "backupPool"
|
||||
})
|
||||
private TargetPool(String id, Date creationTimestamp, URI selfLink, String name, String description,
|
||||
URI region, Set<URI> healthChecks, Set<URI> instances, @Nullable String sessionAffinity,
|
||||
float failoverRatio, @Nullable String backupPool) {
|
||||
super(Kind.TARGET_POOL, id, creationTimestamp, selfLink, name, description);
|
||||
this.region = checkNotNull(region, "region of %s", name);
|
||||
this.healthChecks = healthChecks == null ? ImmutableSet.<URI>of() : healthChecks;
|
||||
this.instances = instances == null ? ImmutableSet.<URI>of() : instances;
|
||||
this.sessionAffinity = fromNullable(sessionAffinity);
|
||||
this.failoverRatio = failoverRatio;
|
||||
this.backupPool = fromNullable(backupPool);
|
||||
}
|
||||
|
||||
public static Builder builder() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return URL of the region where the forwarding pool resides.
|
||||
*/
|
||||
public URI getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The A URL to one HttpHealthCheck resource. A member VM in this pool is considered healthy if and only if
|
||||
* the specified health checks pass. An empty list means all member virtual machines will be considered healthy at
|
||||
* all times but the health status of this target pool will be marked as unhealthy to indicate that no health checks
|
||||
* are being performed.
|
||||
*/
|
||||
public Set<URI> getHealthChecks() {
|
||||
return healthChecks;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return A list of resource URLs to the member VMs serving this pool. They must live in zones contained in the same
|
||||
* region as this pool.
|
||||
*/
|
||||
public Set<URI> getInstances() {
|
||||
return instances;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the session affinity option, determines the hash method that Google Compute Engine uses to
|
||||
* distribute traffic.
|
||||
*/
|
||||
public Optional<String> getSessionAffinity() {
|
||||
return sessionAffinity;
|
||||
}
|
||||
|
||||
/**
|
||||
* This field is applicable only when the target pool is serving a forwarding rule as the primary pool.
|
||||
* The value of the a float between [0, 1]. If set, backupPool must also be set. Together,
|
||||
* they define the fallback behavior of the primary target pool. If the ratio of the healthy VMs in the primary
|
||||
* pool is at or below this number, traffic arriving at the load-balanced IP will be directed to the backup pool.
|
||||
* In case where failoverRatio is not set or all the VMs in the backup pool are unhealthy,
|
||||
* the traffic will be directed back to the primary pool in the force mode, where traffic will be spread to the
|
||||
* healthy VMs with the best effort, or to all VMs when no VM is healthy.
|
||||
* @return the failover ratio
|
||||
*/
|
||||
public float getFailoverRatio() {
|
||||
return failoverRatio;
|
||||
}
|
||||
|
||||
/**
|
||||
* This field is applicable only when the target pool is serving a forwarding rule as the primary pool.
|
||||
* Must be a fully-qualified URL to a target pool that is in the same region as the primary target pool.
|
||||
* If set, failoverRatio must also be set. Together, they define the fallback behavior of the primary target pool.
|
||||
* If the ratio of the healthy VMs in the primary pool is at or below this number,
|
||||
* traffic arriving at the load-balanced IP will be directed to the backup pool. In case where failoverRatio is
|
||||
* not set or all the VMs in the backup pool are unhealthy, the traffic will be directed back to the primary pool
|
||||
* in the force mode, where traffic will be spread to the healthy VMs with the best effort,
|
||||
* or to all VMs when no VM is healthy.
|
||||
* @return the backup pool
|
||||
*/
|
||||
public Optional<String> getBackupPool() {
|
||||
return backupPool;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (obj == null || getClass() != obj.getClass()) return false;
|
||||
TargetPool that = TargetPool.class.cast(obj);
|
||||
return equal(this.kind, that.kind)
|
||||
&& equal(this.name, that.name)
|
||||
&& equal(this.region, that.region);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
protected MoreObjects.ToStringHelper string() {
|
||||
return super.string()
|
||||
.omitNullValues()
|
||||
.add("region", region)
|
||||
.add("healthChecks", healthChecks)
|
||||
.add("instances", instances)
|
||||
.add("sessionAffinity", sessionAffinity.orNull())
|
||||
.add("failoverRatio", failoverRatio)
|
||||
.add("backupPool", backupPool.orNull());
|
||||
}
|
||||
|
||||
public Builder toBuilder() {
|
||||
return new Builder().fromTargetPool(this);
|
||||
}
|
||||
|
||||
public static final class Builder extends Resource.Builder<Builder> {
|
||||
private URI region;
|
||||
private ImmutableSet.Builder<URI> healthChecks = ImmutableSet.builder();
|
||||
private ImmutableSet.Builder<URI> instances = ImmutableSet.builder();
|
||||
private String sessionAffinity;
|
||||
private float failoverRatio;
|
||||
private String backupPool;
|
||||
|
||||
/**
|
||||
* @see TargetPool#getRegion()
|
||||
*/
|
||||
public Builder region(URI region) {
|
||||
this.region = region;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TargetPool#getHealthChecks()
|
||||
*/
|
||||
public Builder healthChecks(Set<URI> healthChecks) {
|
||||
this.healthChecks.addAll(healthChecks);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TargetPool#getInstances()
|
||||
*/
|
||||
public Builder instances(Set<URI> instances) {
|
||||
this.instances.addAll(instances);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TargetPool#getSessionAffinity()
|
||||
*/
|
||||
public Builder sessionAffinity(String sessionAffinity) {
|
||||
this.sessionAffinity = sessionAffinity;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see TargetPool#getFailoverRatio()
|
||||
*/
|
||||
public Builder failoverRatio(float failoverRatio) {
|
||||
this.failoverRatio = failoverRatio;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder backupPool(String backupPool) {
|
||||
this.backupPool = backupPool;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Builder self() {
|
||||
return this;
|
||||
}
|
||||
|
||||
public TargetPool build() {
|
||||
return new TargetPool(super.id, super.creationTimestamp, super.selfLink, super.name,
|
||||
super.description, region, healthChecks.build(), instances.build(),
|
||||
sessionAffinity, failoverRatio, backupPool);
|
||||
}
|
||||
|
||||
public Builder fromTargetPool(TargetPool in) {
|
||||
return super.fromResource(in)
|
||||
.region(in.getRegion())
|
||||
.healthChecks(in.getHealthChecks())
|
||||
.instances(in.getInstances())
|
||||
.sessionAffinity(in.getSessionAffinity().orNull())
|
||||
.failoverRatio(in.getFailoverRatio())
|
||||
.backupPool(in.getBackupPool().orNull());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -35,8 +35,6 @@ import com.google.common.collect.ImmutableSet;
|
|||
|
||||
/**
|
||||
* Represents a zone resource.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/zones"/>
|
||||
*/
|
||||
@Beta
|
||||
public final class Zone extends Resource {
|
||||
|
|
|
@ -53,8 +53,6 @@ import org.jclouds.rest.binders.BindToJsonPayload;
|
|||
|
||||
/**
|
||||
* Provides access to Addresses via their REST API.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/addresses"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticationFilter.class)
|
||||
|
|
|
@ -55,8 +55,6 @@ import org.jclouds.rest.binders.BindToJsonPayload;
|
|||
|
||||
/**
|
||||
* Provides access to Disks via their REST API.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/disks"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticationFilter.class)
|
||||
|
|
|
@ -60,9 +60,6 @@ import org.jclouds.rest.binders.BindToJsonPayload;
|
|||
|
||||
/**
|
||||
* Provides access to Firewalls via their REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/firewalls"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticationFilter.class)
|
||||
|
|
|
@ -0,0 +1,197 @@
|
|||
/*
|
||||
* 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 org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.collect.IterableWithMarker;
|
||||
import org.jclouds.collect.PagedIterable;
|
||||
import org.jclouds.googlecomputeengine.domain.ForwardingRule;
|
||||
import org.jclouds.googlecomputeengine.domain.Operation;
|
||||
import org.jclouds.googlecomputeengine.functions.internal.ParseForwardingRules;
|
||||
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.MapBinder;
|
||||
import org.jclouds.rest.annotations.PayloadParam;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.ResponseParser;
|
||||
import org.jclouds.rest.annotations.SkipEncoding;
|
||||
import org.jclouds.rest.annotations.Transform;
|
||||
import org.jclouds.rest.binders.BindToJsonPayload;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
|
||||
|
||||
/**
|
||||
* Provides access to ForwardingRules via their REST API.
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticator.class)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public interface ForwardingRuleApi {
|
||||
|
||||
/**
|
||||
* Returns the specified ForwardingRule resource.
|
||||
*
|
||||
* @param forwardingRule the name of the ForwardingRule resource to return.
|
||||
* @return a ForwardingRule resource.
|
||||
*/
|
||||
@Named("ForwardingRules:get")
|
||||
@GET
|
||||
@Path("/forwardingRules/{forwardingRule}")
|
||||
@OAuthScopes(COMPUTE_READONLY_SCOPE)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
ForwardingRule get(@PathParam("forwardingRule") String forwardingRule);
|
||||
|
||||
/**
|
||||
* Creates a ForwardingRule resource in the specified project and region using the data included in the request.
|
||||
*
|
||||
* @param forwardingRuleName the name of the forwarding rule.
|
||||
* @param targetSelfLink the URL of the target resource to receive the matched traffic. The target resource must live
|
||||
* in the same region as this forwarding rule.
|
||||
* @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("ForwardingRules:insert")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/forwardingRules")
|
||||
@OAuthScopes(COMPUTE_SCOPE)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
Operation create(@PayloadParam("name") String forwardingRuleName,
|
||||
@PayloadParam("target") URI targetSelfLink);
|
||||
|
||||
/**
|
||||
* Creates a ForwardingRule resource in the specified project and region using the data included in the request.
|
||||
*
|
||||
* @param forwardingRuleName the name of the forwarding rule.
|
||||
* @param targetSelfLink the URL of the target resource to receive the matched traffic. The target resource must live
|
||||
* in the same region as this forwarding rule.
|
||||
* @param portRange If IPProtocol is TCP or UDP, packets addressed to ports in the specified range will be
|
||||
* forwarded to backend. By default, this is empty and all ports are allowed.
|
||||
* @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("ForwardingRules:insert")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/forwardingRules")
|
||||
@OAuthScopes(COMPUTE_SCOPE)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
Operation create(@PayloadParam("name") String forwardingRuleName,
|
||||
@PayloadParam("target") URI targetSelfLink,
|
||||
@PayloadParam("portRange") String portRange);
|
||||
|
||||
/**
|
||||
* Creates a ForwardingRule resource in the specified project and region using the data included in the request.
|
||||
*
|
||||
* @param forwardingRuleName the name of the forwarding rule.
|
||||
* @param targetSelfLink the URL of the target resource to receive the matched traffic. The target resource must live
|
||||
* in the same region as this forwarding rule.
|
||||
* @param portRange If IPProtocol is TCP or UDP, packets addressed to ports in the specified range will be
|
||||
* forwarded to backend. By default, this is empty and all ports are allowed.
|
||||
* @param ipAddress the external IP address that this forwarding rule is serving on behalf of. If this is a
|
||||
* reserved address, the address must live in the same region as the forwarding rule. By default, this field is empty and an ephemeral IP is assigned to the ForwardingRule.
|
||||
* @param ipProtocol the IP protocol to which this rule applies. If left empty, the default value used is TCP.
|
||||
* @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("ForwardingRules:insert")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/forwardingRules")
|
||||
@OAuthScopes(COMPUTE_SCOPE)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
Operation create(@PayloadParam("name") String forwardingRuleName,
|
||||
@PayloadParam("target") URI targetSelfLink,
|
||||
@PayloadParam("portRange") String portRange,
|
||||
@PayloadParam("IPAddress") String ipAddress,
|
||||
@PayloadParam("IPProtocol") String ipProtocol);
|
||||
|
||||
/**
|
||||
* Deletes the specified TargetPool resource.
|
||||
*
|
||||
* @param forwardingRule name of the persistent forwarding rule resource to delete.
|
||||
* @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("ForwardingRules:delete")
|
||||
@DELETE
|
||||
@Path("/forwardingRules/{forwardingRule}")
|
||||
@OAuthScopes(COMPUTE_SCOPE)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
Operation delete(@PathParam("forwardingRule") String forwardingRule);
|
||||
|
||||
|
||||
/**
|
||||
* @return a Paged, Fluent Iterable that is able to fetch additional pages when required
|
||||
* @see org.jclouds.collect.PagedIterable
|
||||
*/
|
||||
@Named("ForwardingRules:list")
|
||||
@GET
|
||||
@Path("/forwardingRules")
|
||||
@OAuthScopes(COMPUTE_READONLY_SCOPE)
|
||||
@ResponseParser(ParseForwardingRules.class)
|
||||
@Transform(ParseForwardingRules.ToPagedIterable.class)
|
||||
@Fallback(EmptyPagedIterableOnNotFoundOr404.class)
|
||||
PagedIterable<ForwardingRule> list();
|
||||
|
||||
@Named("ForwardingRules:list")
|
||||
@GET
|
||||
@Path("/forwardingRules")
|
||||
@OAuthScopes(COMPUTE_READONLY_SCOPE)
|
||||
@ResponseParser(ParseForwardingRules.class)
|
||||
@Fallback(EmptyPagedIterableOnNotFoundOr404.class)
|
||||
IterableWithMarker<ForwardingRule> list(ListOptions options);
|
||||
|
||||
/**
|
||||
* Changes the target url for a forwarding rule.
|
||||
*
|
||||
* @param forwardingRule the name of the ForwardingRule resource in which target is to be set.
|
||||
* @param target The URL of the target resource to receive traffic from this forwarding rule.
|
||||
* It must live in the same region as this forwarding rule.
|
||||
*
|
||||
* @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("ForwardingRules:setTarget")
|
||||
@POST
|
||||
@Path("/forwardingRules/{forwardingRule}/setTarget")
|
||||
@OAuthScopes(COMPUTE_SCOPE)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
@Nullable
|
||||
Operation setTarget(@PathParam("forwardingRule") String forwardingRule,
|
||||
@PayloadParam("target") String target);
|
||||
}
|
|
@ -47,8 +47,6 @@ import org.jclouds.rest.annotations.Transform;
|
|||
|
||||
/**
|
||||
* Provides access to Global Operations via their REST API.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/globalOperations"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticationFilter.class)
|
||||
|
|
|
@ -0,0 +1,160 @@
|
|||
/*
|
||||
* 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 org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.collect.IterableWithMarker;
|
||||
import org.jclouds.collect.PagedIterable;
|
||||
import org.jclouds.googlecomputeengine.domain.HttpHealthCheck;
|
||||
import org.jclouds.googlecomputeengine.domain.Operation;
|
||||
import org.jclouds.googlecomputeengine.functions.internal.ParseHttpHealthChecks;
|
||||
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.MapBinder;
|
||||
import org.jclouds.rest.annotations.PATCH;
|
||||
import org.jclouds.rest.annotations.PayloadParam;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.ResponseParser;
|
||||
import org.jclouds.rest.annotations.SkipEncoding;
|
||||
import org.jclouds.rest.annotations.Transform;
|
||||
import org.jclouds.rest.binders.BindToJsonPayload;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
|
||||
|
||||
/**
|
||||
* Provides access to HttpHealthChecks via their REST API.
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticator.class)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public interface HttpHealthCheckApi {
|
||||
|
||||
/**
|
||||
* Returns the specified HttpHealthCheck resource.
|
||||
*
|
||||
* @param httpHealthCheck the name of the HttpHealthCheck resource to return.
|
||||
* @return a HttpHealthCheck resource.
|
||||
*/
|
||||
@Named("HttpHealthChecks:get")
|
||||
@GET
|
||||
@Path("/{httpHealthCheck}")
|
||||
@OAuthScopes(COMPUTE_READONLY_SCOPE)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
HttpHealthCheck get(@PathParam("httpHealthCheck") String httpHealthCheck);
|
||||
|
||||
/**
|
||||
* Creates a HttpHealthCheck resource in the specified project and region using the data included in the request.
|
||||
*
|
||||
* @param httpHealthCheckName the name of the forwarding rule.
|
||||
* @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("HttpHealthChecks:insert")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@OAuthScopes(COMPUTE_SCOPE)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
Operation insert(@PayloadParam("name") String httpHealthCheckName);
|
||||
|
||||
/**
|
||||
* Creates a HttpHealthCheck resource in the specified project and region using the data included in the request.
|
||||
*
|
||||
* @param httpHealthCheckName the name of the forwarding rule.
|
||||
* @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("HttpHealthChecks:insert")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@OAuthScopes(COMPUTE_SCOPE)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
Operation insert(@PayloadParam("name") String httpHealthCheckName, @PayloadParam("timeoutSec") int
|
||||
timeoutSec, @PayloadParam("unhealthyThreshold") int unhealthyThreshold);
|
||||
|
||||
/**
|
||||
* Deletes the specified TargetPool resource.
|
||||
*
|
||||
* @param httpHealthCheck name of the persistent forwarding rule resource to delete.
|
||||
* @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("HttpHealthChecks:delete")
|
||||
@DELETE
|
||||
@Path("/{httpHealthCheck}")
|
||||
@OAuthScopes(COMPUTE_SCOPE)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
Operation delete(@PathParam("httpHealthCheck") String httpHealthCheck);
|
||||
|
||||
/**
|
||||
* @return a Paged, Fluent Iterable that is able to fetch additional pages when required
|
||||
* @see org.jclouds.collect.PagedIterable
|
||||
*/
|
||||
@Named("HttpHealthChecks:list")
|
||||
@GET
|
||||
@OAuthScopes(COMPUTE_READONLY_SCOPE)
|
||||
@ResponseParser(ParseHttpHealthChecks.class)
|
||||
@Transform(ParseHttpHealthChecks.ToPagedIterable.class)
|
||||
@Fallback(EmptyPagedIterableOnNotFoundOr404.class)
|
||||
PagedIterable<HttpHealthCheck> list();
|
||||
|
||||
/**
|
||||
* @param options @see org.jclouds.googlecomputeengine.options.ListOptions
|
||||
* @return IterableWithMarker
|
||||
*/
|
||||
@Named("HttpHealthChecks:list")
|
||||
@GET
|
||||
@OAuthScopes(COMPUTE_READONLY_SCOPE)
|
||||
@ResponseParser(ParseHttpHealthChecks.class)
|
||||
@Fallback(EmptyPagedIterableOnNotFoundOr404.class)
|
||||
IterableWithMarker<HttpHealthCheck> list(ListOptions options);
|
||||
|
||||
/**
|
||||
* Changes target url for forwarding rule.
|
||||
*
|
||||
* @param httpHealthCheck the name of the HttpHealthCheck resource to update.
|
||||
*
|
||||
* @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("HttpHealthChecks:patch")
|
||||
@PATCH
|
||||
@Path("/{httpHealthCheck}")
|
||||
@OAuthScopes(COMPUTE_SCOPE)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
@Nullable
|
||||
Operation patch(@PathParam("httpHealthCheck") String httpHealthCheck);
|
||||
}
|
|
@ -53,9 +53,6 @@ import org.jclouds.rest.binders.BindToJsonPayload;
|
|||
|
||||
/**
|
||||
* Provides access to Images via their REST API.
|
||||
* <p/>
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/images"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticationFilter.class)
|
||||
|
|
|
@ -61,8 +61,6 @@ import org.jclouds.rest.binders.BindToJsonPayload;
|
|||
|
||||
/**
|
||||
* Provides access to Instances via their REST API.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/instances"/>
|
||||
* @see InstanceApi
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
|
|
|
@ -45,8 +45,6 @@ import org.jclouds.rest.annotations.Transform;
|
|||
|
||||
/**
|
||||
* Provides access to MachineTypes via their REST API.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/machineTypes"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticationFilter.class)
|
||||
|
|
|
@ -53,8 +53,6 @@ import org.jclouds.rest.binders.BindToJsonPayload;
|
|||
|
||||
/**
|
||||
* Provides access to Networks via their REST API.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/networks"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticationFilter.class)
|
||||
|
|
|
@ -44,8 +44,6 @@ import org.jclouds.rest.annotations.SkipEncoding;
|
|||
|
||||
/**
|
||||
* Provides access to Projects via their REST API.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/projects"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticationFilter.class)
|
||||
|
|
|
@ -43,8 +43,6 @@ import org.jclouds.rest.annotations.Transform;
|
|||
|
||||
/**
|
||||
* Provides access to Regions via their REST API.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/regions"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticationFilter.class)
|
||||
|
|
|
@ -47,8 +47,6 @@ import org.jclouds.rest.annotations.Transform;
|
|||
|
||||
/**
|
||||
* Provides access to Operations via their REST API.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/operations"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticationFilter.class)
|
||||
|
@ -144,7 +142,7 @@ public interface RegionOperationApi {
|
|||
PagedIterable<Operation> listInRegion(@PathParam("region") String region);
|
||||
|
||||
/**
|
||||
* A paged version of RegionOperationApi#listFirstPageInRegion(String)
|
||||
* A paged version of RegionOperationApi#listFirstPage(String)
|
||||
*
|
||||
* @return a Paged, Fluent Iterable that is able to fetch additional pages when required
|
||||
* @see org.jclouds.collect.PagedIterable
|
||||
|
|
|
@ -55,8 +55,6 @@ import org.jclouds.rest.annotations.Transform;
|
|||
|
||||
/**
|
||||
* Provides access to Routes via their REST API.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/routess"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticationFilter.class)
|
||||
|
|
|
@ -48,8 +48,6 @@ import org.jclouds.rest.annotations.Transform;
|
|||
|
||||
/**
|
||||
* Provides access to Snapshots via their REST API.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/snapshots"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticationFilter.class)
|
||||
|
|
|
@ -0,0 +1,272 @@
|
|||
/*
|
||||
* 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 org.jclouds.Fallbacks.EmptyPagedIterableOnNotFoundOr404;
|
||||
import org.jclouds.Fallbacks.NullOnNotFoundOr404;
|
||||
import org.jclouds.collect.IterableWithMarker;
|
||||
import org.jclouds.collect.PagedIterable;
|
||||
import org.jclouds.googlecomputeengine.domain.Operation;
|
||||
import org.jclouds.googlecomputeengine.domain.TargetPool;
|
||||
import org.jclouds.googlecomputeengine.functions.internal.ParseTargetPools;
|
||||
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.MapBinder;
|
||||
import org.jclouds.rest.annotations.PayloadParam;
|
||||
import org.jclouds.rest.annotations.RequestFilters;
|
||||
import org.jclouds.rest.annotations.ResponseParser;
|
||||
import org.jclouds.rest.annotations.SkipEncoding;
|
||||
import org.jclouds.rest.annotations.Transform;
|
||||
import org.jclouds.rest.binders.BindToJsonPayload;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.net.URI;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
|
||||
|
||||
/**
|
||||
* Provides access to TargetPools via their REST API.
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticator.class)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public interface TargetPoolApi {
|
||||
|
||||
/**
|
||||
* Returns the specified TargetPool resource.
|
||||
*
|
||||
* @param targetPool the name of the TargetPool resource to return.
|
||||
* @return a TargetPool resource.
|
||||
*/
|
||||
@Named("TargetPools:get")
|
||||
@GET
|
||||
@Path("/targetPools/{targetPool}")
|
||||
@OAuthScopes(COMPUTE_READONLY_SCOPE)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
TargetPool get(@PathParam("targetPool") String targetPool);
|
||||
|
||||
/**
|
||||
* Creates a TargetPool resource in the specified project and region using the data included in the request.
|
||||
*
|
||||
* @param targetPoolName the name of the targetPool.
|
||||
* @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("TargetPools:insert")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/targetPools")
|
||||
@OAuthScopes(COMPUTE_SCOPE)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
Operation create(@PayloadParam("name") String targetPoolName);
|
||||
|
||||
/**
|
||||
* Creates a TargetPool resource in the specified project and region using the data included in the request.
|
||||
*
|
||||
* @param targetPoolName the name of the targetPool.
|
||||
* @param instances A list of resource URLs to the member VMs serving this pool. They must live in zones
|
||||
* contained in the same region as this pool.
|
||||
* @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("TargetPools:insert")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/targetPools")
|
||||
@OAuthScopes(COMPUTE_SCOPE)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
Operation create(@PayloadParam("name") String targetPoolName, @PayloadParam("instances") List<URI> instances);
|
||||
|
||||
/**
|
||||
* Creates a TargetPool resource in the specified project and region using the data included in the request.
|
||||
*
|
||||
* @param targetPoolName the name of the targetPool.
|
||||
* @param instances A list of resource URLs to the member VMs serving this pool. They must live in zones
|
||||
* contained in the same region as this pool.
|
||||
* @param healthChecks A URL to one HttpHealthCheck resource. A member VM in this pool is considered healthy if
|
||||
* and only if the specified health checks pass. An empty list means all member virtual
|
||||
* machines will be considered healthy at all times but the health status of this target
|
||||
* pool will be marked as unhealthy to indicate that no health checks are being performed.
|
||||
* @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("TargetPools:insert")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/targetPools")
|
||||
@OAuthScopes(COMPUTE_SCOPE)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
Operation create(@PayloadParam("name") String targetPoolName, @PayloadParam("instances") List<URI> instances,
|
||||
@PayloadParam("healthChecks") List<URI> healthChecks);
|
||||
|
||||
/**
|
||||
* Creates a TargetPool resource in the specified project and region using the data included in the request.
|
||||
*
|
||||
* @param targetPoolName the name of the targetPool.
|
||||
* @param instances A list of resource URLs to the member VMs serving this pool. They must live in zones
|
||||
* contained in the same region as this pool.
|
||||
* @param healthChecks A URL to one HttpHealthCheck resource. A member VM in this pool is considered healthy if
|
||||
* and only if the specified health checks pass. An empty list means all member virtual
|
||||
* machines will be considered healthy at all times but the health status of this target
|
||||
* pool will be marked as unhealthy to indicate that no health checks are being performed.
|
||||
* @param backupPool it is applicable only when the target pool is serving a forwarding rule as the primary pool.
|
||||
* Must be a fully-qualified URL to a target pool that is in the same region as the primary
|
||||
* target pool.
|
||||
* @param sessionAffinity Defines the session affinity option. Session affinity determines the hash method that
|
||||
* Google Compute Engine uses to distribute traffic. Acceptable values are:
|
||||
* "CLIENT_IP": Connections from the same client IP are guaranteed to go to the same VM in the pool while that VM remains healthy.
|
||||
* "CLIENT_IP_PROTO": Connections from the same client IP and port are guaranteed to go to the same VM in the pool while that VM remains healthy.
|
||||
* "NONE": Connections from the same client IP may go to any VM in the pool.
|
||||
* @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("TargetPools:insert")
|
||||
@POST
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/targetPools")
|
||||
@OAuthScopes(COMPUTE_SCOPE)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
Operation create(@PayloadParam("name") String targetPoolName, @PayloadParam("instances") List<URI> instances,
|
||||
@PayloadParam("healthChecks") List<URI> healthChecks, @PayloadParam("backupPool") String backupPool,
|
||||
@PayloadParam("sessionAffinity") String sessionAffinity);
|
||||
|
||||
/**
|
||||
* Deletes the specified TargetPool resource.
|
||||
*
|
||||
* @param targetPool name of the persistent target pool resource to delete.
|
||||
* @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("TargetPools:delete")
|
||||
@DELETE
|
||||
@Path("/targetPools/{targetPool}")
|
||||
@OAuthScopes(COMPUTE_SCOPE)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@Nullable
|
||||
Operation delete(@PathParam("targetPool") String targetPool);
|
||||
|
||||
/**
|
||||
* @return a Paged, Fluent Iterable that is able to fetch additional pages when required
|
||||
* @see org.jclouds.collect.PagedIterable
|
||||
*/
|
||||
@Named("TargetPools:list")
|
||||
@GET
|
||||
@Path("/targetPools")
|
||||
@OAuthScopes(COMPUTE_READONLY_SCOPE)
|
||||
@ResponseParser(ParseTargetPools.class)
|
||||
@Transform(ParseTargetPools.ToPagedIterable.class)
|
||||
@Fallback(EmptyPagedIterableOnNotFoundOr404.class)
|
||||
PagedIterable<TargetPool> list();
|
||||
|
||||
/**
|
||||
* @param options @see org.jclouds.googlecomputeengine.options.ListOptions
|
||||
* @return IterableWithMarker
|
||||
*/
|
||||
@Named("TargetPools:list")
|
||||
@GET
|
||||
@Path("/targetPools")
|
||||
@OAuthScopes(COMPUTE_READONLY_SCOPE)
|
||||
@ResponseParser(ParseTargetPools.class)
|
||||
@Fallback(EmptyPagedIterableOnNotFoundOr404.class)
|
||||
IterableWithMarker<TargetPool> list(ListOptions options);
|
||||
|
||||
/**
|
||||
* Adds instance to the targetPool.
|
||||
*
|
||||
* @param targetPool the name of the target pool.
|
||||
* @param instanceName the name for the instance to be added to targetPool.
|
||||
*
|
||||
* @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("TargetPools:addInstance")
|
||||
@POST
|
||||
@Path("/targetPools/{targetPool}/addInstance")
|
||||
@OAuthScopes(COMPUTE_SCOPE)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
@Nullable
|
||||
Operation addInstance(@PathParam("targetPool") String targetPool, @PayloadParam("instance") String instanceName);
|
||||
|
||||
/**
|
||||
* Adds health check URL to targetPool.
|
||||
*
|
||||
* @param targetPool the name of the target pool.
|
||||
* @param healthCheck the name for the healthCheck to be added to targetPool.
|
||||
*
|
||||
* @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("TargetPools:addHealthCheck")
|
||||
@POST
|
||||
@Path("/targetPools/{targetPool}/addHealthCheck")
|
||||
@OAuthScopes(COMPUTE_SCOPE)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
@Nullable
|
||||
Operation addHealthCheck(@PathParam("targetPool") String targetPool, @PayloadParam("healthCheck") String healthCheck);
|
||||
|
||||
/**
|
||||
* Removes instance URL from targetPool.
|
||||
*
|
||||
* @param targetPool the name of the target pool.
|
||||
* @param instanceName the name for the instance to be removed from targetPool.
|
||||
*
|
||||
* @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("TargetPools:removeInstance")
|
||||
@POST
|
||||
@Path("/targetPools/{targetPool}/removeInstance")
|
||||
@OAuthScopes(COMPUTE_SCOPE)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
@Nullable
|
||||
Operation removeInstance(@PathParam("targetPool") String targetPool, @PayloadParam("instanceName") String instanceName);
|
||||
|
||||
/**
|
||||
* Changes backup pool configurations.
|
||||
*
|
||||
* @param targetPool the name of the target pool.
|
||||
* @param target the URL of target pool for which you want to use as backup.
|
||||
*
|
||||
* @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("TargetPools:setBackup")
|
||||
@POST
|
||||
@Path("/targetPools/{targetPool}/setBackup")
|
||||
@OAuthScopes(COMPUTE_SCOPE)
|
||||
@Fallback(NullOnNotFoundOr404.class)
|
||||
@MapBinder(BindToJsonPayload.class)
|
||||
@Nullable
|
||||
Operation setBackup(@PathParam("targetPool") String targetPool, @PayloadParam("target") String target);
|
||||
}
|
|
@ -43,8 +43,6 @@ import org.jclouds.rest.annotations.Transform;
|
|||
|
||||
/**
|
||||
* Provides access to Zones via their REST API.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/zones"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticationFilter.class)
|
||||
|
|
|
@ -47,8 +47,6 @@ import org.jclouds.rest.annotations.Transform;
|
|||
|
||||
/**
|
||||
* Provides access to Operations via their REST API.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/operations"/>
|
||||
*/
|
||||
@SkipEncoding({'/', '='})
|
||||
@RequestFilters(OAuthAuthenticationFilter.class)
|
||||
|
|
|
@ -74,27 +74,27 @@ public class CreateNetworkIfNeeded implements Function<NetworkAndAddressRange, N
|
|||
public Network apply(NetworkAndAddressRange input) {
|
||||
checkNotNull(input, "input");
|
||||
|
||||
Network nw = api.getNetworkApiForProject(userProject.get()).get(input.getName());
|
||||
Network nw = api.getNetworkApi(userProject.get()).get(input.getName());
|
||||
if (nw != null) {
|
||||
return nw;
|
||||
}
|
||||
|
||||
if (input.getGateway().isPresent()) {
|
||||
AtomicReference<Operation> operation = Atomics.newReference(api.getNetworkApiForProject(userProject
|
||||
AtomicReference<Operation> operation = Atomics.newReference(api.getNetworkApi(userProject
|
||||
.get()).createInIPv4RangeWithGateway(input.getName(), input.getIpV4Range(), input.getGateway().get()));
|
||||
retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
|
||||
MILLISECONDS).apply(operation);
|
||||
|
||||
checkState(!operation.get().getHttpError().isPresent(), "Could not create network, operation failed" + operation);
|
||||
checkState(!operation.get().getHttpError().isPresent(), "Could not insert network, operation failed" + operation);
|
||||
} else {
|
||||
AtomicReference<Operation> operation = Atomics.newReference(api.getNetworkApiForProject(userProject
|
||||
AtomicReference<Operation> operation = Atomics.newReference(api.getNetworkApi(userProject
|
||||
.get()).createInIPv4Range(input.getName(), input.getIpV4Range()));
|
||||
retry(operationDonePredicate, operationCompleteCheckTimeout, operationCompleteCheckInterval,
|
||||
MILLISECONDS).apply(operation);
|
||||
|
||||
checkState(!operation.get().getHttpError().isPresent(), "Could not create network, operation failed" + operation);
|
||||
checkState(!operation.get().getHttpError().isPresent(), "Could not insert network, operation failed" + operation);
|
||||
}
|
||||
return checkNotNull(api.getNetworkApiForProject(userProject.get()).get(input.getName()),
|
||||
return checkNotNull(api.getNetworkApi(userProject.get()).get(input.getName()),
|
||||
"no network with name %s was found", input.getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ public class ParseAddresses extends ParseJson<ListPage<Address>> {
|
|||
|
||||
@Override
|
||||
public IterableWithMarker<Address> apply(Object input) {
|
||||
return api.getAddressApiForProject(projectName)
|
||||
return api.getAddressApi(projectName)
|
||||
.listAtMarkerInRegion(regionName, input.toString(), options);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -58,7 +58,7 @@ public class ParseDisks extends ParseJson<ListPage<Disk>> {
|
|||
|
||||
@Override
|
||||
public IterableWithMarker<Disk> apply(Object input) {
|
||||
return api.getDiskApiForProject(projectName)
|
||||
return api.getDiskApi(projectName)
|
||||
.listAtMarkerInZone(zoneName, input.toString(), options);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ParseFirewalls extends ParseJson<ListPage<Firewall>> {
|
|||
|
||||
@Override
|
||||
public IterableWithMarker<Firewall> apply(Object input) {
|
||||
return api.getFirewallApiForProject(projectName).listAtMarker(input.toString(), options);
|
||||
return api.getFirewallApi(projectName).listAtMarker(input.toString(), options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* 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 com.google.common.base.Function;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import org.jclouds.collect.IterableWithMarker;
|
||||
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
|
||||
import org.jclouds.googlecomputeengine.domain.ForwardingRule;
|
||||
import org.jclouds.googlecomputeengine.domain.ListPage;
|
||||
import org.jclouds.googlecomputeengine.options.ListOptions;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
import org.jclouds.json.Json;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Singleton
|
||||
public class ParseForwardingRules extends ParseJson<ListPage<ForwardingRule>> {
|
||||
|
||||
@Inject
|
||||
public ParseForwardingRules(Json json) {
|
||||
super(json, new TypeLiteral<ListPage<ForwardingRule>>() {
|
||||
});
|
||||
}
|
||||
|
||||
public static class ToPagedIterable extends BaseWithRegionToPagedIterable<ForwardingRule, ToPagedIterable> {
|
||||
|
||||
private final GoogleComputeEngineApi api;
|
||||
|
||||
@Inject
|
||||
protected ToPagedIterable(GoogleComputeEngineApi api) {
|
||||
this.api = checkNotNull(api, "api");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Function<Object, IterableWithMarker<ForwardingRule>> fetchNextPage(final String projectName,
|
||||
final String regionName,
|
||||
final ListOptions options) {
|
||||
return new Function<Object, IterableWithMarker<ForwardingRule>>() {
|
||||
|
||||
@Override
|
||||
public IterableWithMarker<ForwardingRule> apply(Object input) {
|
||||
return api.getForwardingRuleApi(projectName, regionName).list(options);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -55,7 +55,7 @@ public class ParseGlobalOperations extends ParseJson<ListPage<Operation>> {
|
|||
|
||||
@Override
|
||||
public IterableWithMarker<Operation> apply(Object input) {
|
||||
return api.getGlobalOperationApiForProject(projectName).listAtMarker(input.toString(), options);
|
||||
return api.getGlobalOperationApi(projectName).listAtMarker(input.toString(), options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* 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 com.google.common.base.Function;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import org.jclouds.collect.IterableWithMarker;
|
||||
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
|
||||
import org.jclouds.googlecomputeengine.domain.HttpHealthCheck;
|
||||
import org.jclouds.googlecomputeengine.domain.ListPage;
|
||||
import org.jclouds.googlecomputeengine.options.ListOptions;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
import org.jclouds.json.Json;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Singleton
|
||||
public class ParseHttpHealthChecks extends ParseJson<ListPage<HttpHealthCheck>> {
|
||||
|
||||
@Inject
|
||||
public ParseHttpHealthChecks(Json json) {
|
||||
super(json, new TypeLiteral<ListPage<HttpHealthCheck>>() {
|
||||
});
|
||||
}
|
||||
|
||||
public static class ToPagedIterable extends BaseToPagedIterable<HttpHealthCheck, ToPagedIterable> {
|
||||
|
||||
private final GoogleComputeEngineApi api;
|
||||
|
||||
@Inject
|
||||
protected ToPagedIterable(GoogleComputeEngineApi api) {
|
||||
this.api = checkNotNull(api, "api");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Function<Object, IterableWithMarker<HttpHealthCheck>> fetchNextPage(final String projectName,
|
||||
final ListOptions options) {
|
||||
return new Function<Object, IterableWithMarker<HttpHealthCheck>>() {
|
||||
|
||||
@Override
|
||||
public IterableWithMarker<HttpHealthCheck> apply(Object input) {
|
||||
return api.getHttpHealthCheckApi(projectName).list(options);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -55,7 +55,7 @@ public class ParseImages extends ParseJson<ListPage<Image>> {
|
|||
|
||||
@Override
|
||||
public IterableWithMarker<Image> apply(Object input) {
|
||||
return api.getImageApiForProject(projectName).listAtMarker(input.toString(), options);
|
||||
return api.getImageApi(projectName).listAtMarker(input.toString(), options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public class ParseInstances extends ParseJson<ListPage<Instance>> {
|
|||
|
||||
@Override
|
||||
public IterableWithMarker<Instance> apply(Object input) {
|
||||
return api.getInstanceApiForProject(project)
|
||||
return api.getInstanceApi(project)
|
||||
.listAtMarkerInZone(zone, input.toString(), options);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ParseMachineTypes extends ParseJson<ListPage<MachineType>> {
|
|||
|
||||
@Override
|
||||
public IterableWithMarker<MachineType> apply(Object input) {
|
||||
return api.getMachineTypeApiForProject(project)
|
||||
return api.getMachineTypeApi(project)
|
||||
.listAtMarkerInZone(zone, input.toString(), options);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ParseNetworks extends ParseJson<ListPage<Network>> {
|
|||
|
||||
@Override
|
||||
public IterableWithMarker<Network> apply(Object input) {
|
||||
return api.getNetworkApiForProject(projectName).listAtMarker(input.toString(), options);
|
||||
return api.getNetworkApi(projectName).listAtMarker(input.toString(), options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ public class ParseRegionOperations extends ParseJson<ListPage<Operation>> {
|
|||
|
||||
@Override
|
||||
public IterableWithMarker<Operation> apply(Object input) {
|
||||
return api.getRegionOperationApiForProject(projectName)
|
||||
return api.getRegionOperationApi(projectName)
|
||||
.listAtMarkerInRegion(regionName, input.toString(), options);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ParseRegions extends ParseJson<ListPage<Region>> {
|
|||
|
||||
@Override
|
||||
public IterableWithMarker<Region> apply(Object input) {
|
||||
return api.getRegionApiForProject(projectName).listAtMarker(input.toString(), options);
|
||||
return api.getRegionApi(projectName).listAtMarker(input.toString(), options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ParseRoutes extends ParseJson<ListPage<Route>> {
|
|||
|
||||
@Override
|
||||
public IterableWithMarker<Route> apply(Object input) {
|
||||
return api.getRouteApiForProject(projectName).listAtMarker(input.toString(), options);
|
||||
return api.getRouteApi(projectName).listAtMarker(input.toString(), options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class ParseSnapshots extends ParseJson<ListPage<Snapshot>> {
|
|||
|
||||
@Override
|
||||
public IterableWithMarker<Snapshot> apply(Object input) {
|
||||
return api.getSnapshotApiForProject(projectName)
|
||||
return api.getSnapshotApi(projectName)
|
||||
.listAtMarker(input.toString(), options);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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 com.google.common.base.Function;
|
||||
import com.google.inject.TypeLiteral;
|
||||
import org.jclouds.collect.IterableWithMarker;
|
||||
import org.jclouds.googlecomputeengine.GoogleComputeEngineApi;
|
||||
import org.jclouds.googlecomputeengine.domain.ListPage;
|
||||
import org.jclouds.googlecomputeengine.domain.TargetPool;
|
||||
import org.jclouds.googlecomputeengine.options.ListOptions;
|
||||
import org.jclouds.http.functions.ParseJson;
|
||||
import org.jclouds.json.Json;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@Singleton
|
||||
public class ParseTargetPools extends ParseJson<ListPage<TargetPool>> {
|
||||
|
||||
@Inject
|
||||
public ParseTargetPools(Json json) {
|
||||
super(json, new TypeLiteral<ListPage<TargetPool>>() {
|
||||
});
|
||||
}
|
||||
|
||||
public static class ToPagedIterable extends BaseWithZoneToPagedIterable<TargetPool, ToPagedIterable> {
|
||||
|
||||
private final GoogleComputeEngineApi api;
|
||||
|
||||
@Inject
|
||||
protected ToPagedIterable(GoogleComputeEngineApi api) {
|
||||
this.api = checkNotNull(api, "api");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Function<Object, IterableWithMarker<TargetPool>> fetchNextPage(final String projectName,
|
||||
final String regionName,
|
||||
final ListOptions options) {
|
||||
return new Function<Object, IterableWithMarker<TargetPool>>() {
|
||||
|
||||
@Override
|
||||
public IterableWithMarker<TargetPool> apply(Object input) {
|
||||
return api.getTargetPoolApi(projectName, regionName)
|
||||
.list(options);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
|
@ -56,7 +56,7 @@ public class ParseZoneOperations extends ParseJson<ListPage<Operation>> {
|
|||
|
||||
@Override
|
||||
public IterableWithMarker<Operation> apply(Object input) {
|
||||
return api.getZoneOperationApiForProject(projectName)
|
||||
return api.getZoneOperationApi(projectName)
|
||||
.listAtMarkerInZone(zoneName, input.toString(), options);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -55,7 +55,7 @@ public class ParseZones extends ParseJson<ListPage<Zone>> {
|
|||
|
||||
@Override
|
||||
public IterableWithMarker<Zone> apply(Object input) {
|
||||
return api.getZoneApiForProject(projectName).listAtMarker(input.toString(), options);
|
||||
return api.getZoneApi(projectName).listAtMarker(input.toString(), options);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.jclouds.googlecomputeengine.domain.Firewall;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Options to create a firewall.
|
||||
* Options to insert a firewall.
|
||||
*
|
||||
* @see Firewall
|
||||
*/
|
||||
|
|
|
@ -22,8 +22,6 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
|
|||
|
||||
/**
|
||||
* Allows to optionally specify a filter, max results and a page token for <code>listFirstPage()</code> REST methods.
|
||||
*
|
||||
* @see <a href="https://developers.google.com/compute/docs/reference/v1/operations/listFirstPage"/>
|
||||
*/
|
||||
public class ListOptions extends BaseHttpRequestOptions {
|
||||
|
||||
|
@ -72,6 +70,14 @@ public class ListOptions extends BaseHttpRequestOptions {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the beginning of the next list page
|
||||
*/
|
||||
public ListOptions marker(String marker) {
|
||||
this.queryParameters.put("pageToken", checkNotNull(marker, "marker"));
|
||||
return this;
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
/**
|
||||
|
@ -87,5 +93,12 @@ public class ListOptions extends BaseHttpRequestOptions {
|
|||
public ListOptions maxResults(Integer maxResults) {
|
||||
return new ListOptions().maxResults(maxResults);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ListOptions#marker(String)
|
||||
*/
|
||||
public ListOptions marker(String marker) {
|
||||
return new ListOptions().marker(marker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Set;
|
|||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
/**
|
||||
* Options to create a route.
|
||||
* Options to insert a route.
|
||||
*
|
||||
* @see org.jclouds.googlecomputeengine.domain.Route
|
||||
*/
|
||||
|
|
|
@ -45,7 +45,7 @@ public class GlobalOperationDonePredicate implements Predicate<AtomicReference<O
|
|||
@Override
|
||||
public boolean apply(AtomicReference<Operation> input) {
|
||||
checkNotNull(input, "input");
|
||||
Operation current = api.getGlobalOperationApiForProject(project.get()).get(input.get().getName());
|
||||
Operation current = api.getGlobalOperationApi(project.get()).get(input.get().getName());
|
||||
switch (current.getStatus()) {
|
||||
case DONE:
|
||||
input.set(current);
|
||||
|
|
|
@ -53,7 +53,7 @@ public class RegionOperationDonePredicate implements Predicate<AtomicReference<O
|
|||
public boolean apply(AtomicReference<Operation> input) {
|
||||
checkNotNull(input, "input");
|
||||
|
||||
Operation current = api.getRegionOperationApiForProject(project.get())
|
||||
Operation current = api.getRegionOperationApi(project.get())
|
||||
.getInRegion(regions.get().get(input.get().getRegion().get()).getName(),
|
||||
input.get().getName());
|
||||
switch (current.getStatus()) {
|
||||
|
|
|
@ -52,7 +52,7 @@ public class ZoneOperationDonePredicate implements Predicate<AtomicReference<Ope
|
|||
@Override
|
||||
public boolean apply(AtomicReference<Operation> input) {
|
||||
checkNotNull(input, "input");
|
||||
Operation current = api.getZoneOperationApiForProject(project.get())
|
||||
Operation current = api.getZoneOperationApi(project.get())
|
||||
.getInZone(zones.get().get(input.get().getZone().get()).getId(),
|
||||
input.get().getName());
|
||||
switch (current.getStatus()) {
|
||||
|
|
|
@ -49,7 +49,7 @@ public class PageSystemExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.payload(payloadFromResource("/image_list_single_page.json")).build();
|
||||
|
||||
ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list, operationResponse).getImageApiForProject("myproject");
|
||||
TOKEN_RESPONSE, list, operationResponse).getImageApi("myproject");
|
||||
|
||||
PagedIterable<Image> images = imageApi.list();
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class PageSystemExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
|
||||
ImageApi imageApi = orderedRequestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list1, list1response, list2, list2Response, list3, list3Response)
|
||||
.getImageApiForProject("myproject");
|
||||
.getImageApi("myproject");
|
||||
|
||||
PagedIterable<Image> images = imageApi.list(new ListOptions.Builder().maxResults(3));
|
||||
|
||||
|
|
|
@ -65,7 +65,7 @@ public class GoogleComputeEngineServiceLiveTest extends BaseComputeServiceLiveTe
|
|||
Supplier<String> userProject = context.utils().injector().getInstance(Key.get(new TypeLiteral<Supplier<String>>() {
|
||||
}, UserProject.class));
|
||||
ImmutableSet.Builder<String> deprecatedMachineTypes = ImmutableSet.builder();
|
||||
for (MachineType machine : api.getMachineTypeApiForProject(userProject.get())
|
||||
for (MachineType machine : api.getMachineTypeApi(userProject.get())
|
||||
.listInZone(DEFAULT_ZONE_NAME).concat()) {
|
||||
if (machine.getDeprecated().isPresent()) {
|
||||
deprecatedMachineTypes.add(machine.getId());
|
||||
|
|
|
@ -60,7 +60,7 @@ public class NetworkToSecurityGroupTest {
|
|||
FirewallApi fwApi = createMock(FirewallApi.class);
|
||||
|
||||
ListOptions options = new Builder().filter("network eq .*/jclouds-test");
|
||||
expect(api.getFirewallApiForProject(projectSupplier.get()))
|
||||
expect(api.getFirewallApi(projectSupplier.get()))
|
||||
.andReturn(fwApi);
|
||||
expect(fwApi.list(options)).andReturn(PagedIterables.of(IterableWithMarkers.from(ImmutableSet.of(FirewallToIpPermissionTest.fwForTest()))));
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ public class FindNetworkOrCreateTest {
|
|||
}
|
||||
};
|
||||
|
||||
expect(api.getNetworkApiForProject(userProject.get())).andReturn(nwApi).atLeastOnce();
|
||||
expect(api.getNetworkApi(userProject.get())).andReturn(nwApi).atLeastOnce();
|
||||
|
||||
expect(nwApi.get("this-network")).andReturn(network);
|
||||
|
||||
|
@ -103,18 +103,18 @@ public class FindNetworkOrCreateTest {
|
|||
}
|
||||
};
|
||||
|
||||
expect(api.getNetworkApiForProject(userProject.get())).andReturn(nwApi).atLeastOnce();
|
||||
expect(api.getGlobalOperationApiForProject(userProject.get())).andReturn(globalApi).atLeastOnce();
|
||||
expect(api.getNetworkApi(userProject.get())).andReturn(nwApi).atLeastOnce();
|
||||
expect(api.getGlobalOperationApi(userProject.get())).andReturn(globalApi).atLeastOnce();
|
||||
|
||||
expect(nwApi.createInIPv4Range("this-network", "0.0.0.0/0"))
|
||||
.andReturn(createOp);
|
||||
expect(globalApi.get("create-op")).andReturn(createOp);
|
||||
expect(globalApi.get("insert-op")).andReturn(createOp);
|
||||
// pre-creation
|
||||
expect(nwApi.get("this-network")).andReturn(null).times(2);
|
||||
// post-creation
|
||||
expect(nwApi.get("this-network")).andReturn(network);
|
||||
|
||||
expect(createOp.getName()).andReturn("create-op");
|
||||
expect(createOp.getName()).andReturn("insert-op");
|
||||
expect(createOp.getStatus()).andReturn(Operation.Status.DONE);
|
||||
expect(createOp.getHttpError()).andReturn(fromNullable((HttpResponse)null));
|
||||
replay(api, nwApi, createOp, globalApi);
|
||||
|
|
|
@ -47,7 +47,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.payload(payloadFromResource("/address_get.json")).build();
|
||||
|
||||
AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getAddressApiForProject("myproject");
|
||||
TOKEN_RESPONSE, get, operationResponse).getAddressApi("myproject");
|
||||
|
||||
assertEquals(api.getInRegion("us-central1", "test-ip1"),
|
||||
new ParseAddressTest().expected());
|
||||
|
@ -64,7 +64,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getAddressApiForProject("myproject");
|
||||
TOKEN_RESPONSE, get, operationResponse).getAddressApi("myproject");
|
||||
|
||||
assertNull(api.getInRegion("us-central1", "test-ip1"));
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
|
||||
AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, insert,
|
||||
insertAddressResponse).getAddressApiForProject("myproject");
|
||||
insertAddressResponse).getAddressApi("myproject");
|
||||
|
||||
assertEquals(api.createInRegion("us-central1", "test-ip1"), new ParseOperationTest().expected());
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.payload(payloadFromResource("/region_operation.json")).build();
|
||||
|
||||
AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getAddressApiForProject("myproject");
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getAddressApi("myproject");
|
||||
|
||||
assertEquals(api.deleteInRegion("us-central1", "test-ip1"),
|
||||
new ParseOperationTest().expected());
|
||||
|
@ -120,7 +120,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getAddressApiForProject("myproject");
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getAddressApi("myproject");
|
||||
|
||||
assertNull(api.deleteInRegion("us-central1", "test-ip1"));
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.payload(payloadFromResource("/address_list.json")).build();
|
||||
|
||||
AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list, operationResponse).getAddressApiForProject("myproject");
|
||||
TOKEN_RESPONSE, list, operationResponse).getAddressApi("myproject");
|
||||
|
||||
assertEquals(api.listFirstPageInRegion("us-central1").toString(),
|
||||
new ParseAddressListTest().expected().toString());
|
||||
|
@ -156,7 +156,7 @@ public class AddressApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
AddressApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list, operationResponse).getAddressApiForProject("myproject");
|
||||
TOKEN_RESPONSE, list, operationResponse).getAddressApi("myproject");
|
||||
|
||||
assertTrue(api.listInRegion("us-central1").concat().isEmpty());
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class AddressApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
private static final int TIME_WAIT = 30;
|
||||
|
||||
private AddressApi api() {
|
||||
return api.getAddressApiForProject(userProject.get());
|
||||
return api.getAddressApi(userProject.get());
|
||||
}
|
||||
|
||||
@Test(groups = "live")
|
||||
|
|
|
@ -53,7 +53,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.payload(payloadFromResource("/disk_get.json")).build();
|
||||
|
||||
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getDiskApiForProject("myproject");
|
||||
TOKEN_RESPONSE, get, operationResponse).getDiskApi("myproject");
|
||||
|
||||
assertEquals(api.getInZone("us-central1-a", "testimage1"),
|
||||
new ParseDiskTest().expected());
|
||||
|
@ -70,7 +70,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getDiskApiForProject("myproject");
|
||||
TOKEN_RESPONSE, get, operationResponse).getDiskApi("myproject");
|
||||
|
||||
assertNull(api.getInZone("us-central1-a", "testimage1"));
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
|
||||
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, insert,
|
||||
insertDiskResponse).getDiskApiForProject("myproject");
|
||||
insertDiskResponse).getDiskApi("myproject");
|
||||
|
||||
assertEquals(api.createInZone("testimage1", 1, "us-central1-a"), new ParseOperationTest().expected());
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
|
||||
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, insert,
|
||||
insertDiskResponse).getDiskApiForProject("myproject");
|
||||
insertDiskResponse).getDiskApi("myproject");
|
||||
|
||||
DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(URI.create(IMAGE_URL));
|
||||
assertEquals(api.createInZone("testimage1", 1, "us-central1-a", diskCreationOptions), new ParseOperationTest().expected());
|
||||
|
@ -131,7 +131,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
|
||||
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, insert,
|
||||
insertDiskResponse).getDiskApiForProject("myproject");
|
||||
insertDiskResponse).getDiskApi("myproject");
|
||||
|
||||
DiskCreationOptions diskCreationOptions = new DiskCreationOptions().type(URI.create(SSD_URL));
|
||||
assertEquals(api.createInZone("testimage1", 1,
|
||||
|
@ -154,7 +154,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
|
||||
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, createSnapshotRequest,
|
||||
createSnapshotResponse).getDiskApiForProject("myproject");
|
||||
createSnapshotResponse).getDiskApi("myproject");
|
||||
|
||||
assertEquals(api.createSnapshotInZone("us-central1-a", "testimage1", "test-snap"), new ParseOperationTest().expected());
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
|
||||
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, createSnapshotRequest,
|
||||
createSnapshotResponse).getDiskApiForProject("myproject");
|
||||
createSnapshotResponse).getDiskApi("myproject");
|
||||
|
||||
api.createSnapshotInZone("us-central1-a", "testimage1", "test-snap");
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.payload(payloadFromResource("/zone_operation.json")).build();
|
||||
|
||||
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getDiskApiForProject("myproject");
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getDiskApi("myproject");
|
||||
|
||||
assertEquals(api.deleteInZone("us-central1-a", "testimage1"),
|
||||
new ParseOperationTest().expected());
|
||||
|
@ -211,7 +211,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getDiskApiForProject("myproject");
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getDiskApi("myproject");
|
||||
|
||||
assertNull(api.deleteInZone("us-central1-a", "testimage1"));
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.payload(payloadFromResource("/disk_list.json")).build();
|
||||
|
||||
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list, operationResponse).getDiskApiForProject("myproject");
|
||||
TOKEN_RESPONSE, list, operationResponse).getDiskApi("myproject");
|
||||
|
||||
assertEquals(api.listFirstPageInZone("us-central1-a").toString(),
|
||||
new ParseDiskListTest().expected().toString());
|
||||
|
@ -247,7 +247,7 @@ public class DiskApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
DiskApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list, operationResponse).getDiskApiForProject("myproject");
|
||||
TOKEN_RESPONSE, list, operationResponse).getDiskApi("myproject");
|
||||
|
||||
assertTrue(api.listInZone("us-central1-a").concat().isEmpty());
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class DiskApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
public static final int sizeGb = 1;
|
||||
|
||||
private DiskApi api() {
|
||||
return api.getDiskApiForProject(userProject.get());
|
||||
return api.getDiskApi(userProject.get());
|
||||
}
|
||||
|
||||
@Test(groups = "live")
|
||||
|
|
|
@ -65,7 +65,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
public void testGetFirewallResponseIs2xx() throws Exception {
|
||||
|
||||
FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, GET_FIREWALL_REQUEST, GET_FIREWALL_RESPONSE).getFirewallApiForProject("myproject");
|
||||
TOKEN_RESPONSE, GET_FIREWALL_REQUEST, GET_FIREWALL_RESPONSE).getFirewallApi("myproject");
|
||||
|
||||
assertEquals(api.get("jclouds-test"), new ParseFirewallTest().expected());
|
||||
}
|
||||
|
@ -112,7 +112,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getFirewallApiForProject("myproject");
|
||||
TOKEN_RESPONSE, get, operationResponse).getFirewallApi("myproject");
|
||||
|
||||
assertNull(api.get("jclouds-test"));
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.payload(payloadFromResource("/operation.json")).build();
|
||||
|
||||
FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, request, insertFirewallResponse).getFirewallApiForProject("myproject");
|
||||
TOKEN_RESPONSE, request, insertFirewallResponse).getFirewallApi("myproject");
|
||||
|
||||
assertEquals(api.createInNetwork("myfw", URI.create("https://www.googleapis" +
|
||||
".com/compute/v1/projects/myproject/global/networks/default"),
|
||||
|
@ -174,7 +174,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
|
||||
FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, update,
|
||||
updateFirewallResponse).getFirewallApiForProject("myproject");
|
||||
updateFirewallResponse).getFirewallApi("myproject");
|
||||
|
||||
assertEquals(api.update("myfw",
|
||||
new FirewallOptions()
|
||||
|
@ -211,7 +211,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
|
||||
FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, update,
|
||||
updateFirewallResponse).getFirewallApiForProject("myproject");
|
||||
updateFirewallResponse).getFirewallApi("myproject");
|
||||
|
||||
assertEquals(api.patch("myfw",
|
||||
new FirewallOptions()
|
||||
|
@ -240,7 +240,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.payload(payloadFromResource("/operation.json")).build();
|
||||
|
||||
FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getFirewallApiForProject("myproject");
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getFirewallApi("myproject");
|
||||
|
||||
assertEquals(api.delete("default-allow-internal"),
|
||||
new ParseOperationTest().expected());
|
||||
|
@ -258,7 +258,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getFirewallApiForProject("myproject");
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getFirewallApi("myproject");
|
||||
|
||||
assertNull(api.delete("default-allow-internal"));
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.payload(payloadFromResource("/firewall_list.json")).build();
|
||||
|
||||
FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list, operationResponse).getFirewallApiForProject("myproject");
|
||||
TOKEN_RESPONSE, list, operationResponse).getFirewallApi("myproject");
|
||||
|
||||
assertEquals(api.listFirstPage().toString(),
|
||||
new ParseFirewallListTest().expected().toString());
|
||||
|
@ -294,7 +294,7 @@ public class FirewallApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
FirewallApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list, operationResponse).getFirewallApiForProject("myproject");
|
||||
TOKEN_RESPONSE, list, operationResponse).getFirewallApi("myproject");
|
||||
|
||||
assertTrue(api.list().concat().isEmpty());
|
||||
}
|
||||
|
|
|
@ -42,14 +42,14 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
private static final int TIME_WAIT = 30;
|
||||
|
||||
private FirewallApi api() {
|
||||
return api.getFirewallApiForProject(userProject.get());
|
||||
return api.getFirewallApi(userProject.get());
|
||||
}
|
||||
|
||||
@Test(groups = "live")
|
||||
public void testInsertFirewall() {
|
||||
|
||||
// need to create the network first
|
||||
assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).createInIPv4Range
|
||||
// need to insert the network first
|
||||
assertGlobalOperationDoneSucessfully(api.getNetworkApi(userProject.get()).createInIPv4Range
|
||||
(FIREWALL_NETWORK_NAME, IPV4_RANGE), TIME_WAIT);
|
||||
|
||||
FirewallOptions firewall = new FirewallOptions()
|
||||
|
@ -149,7 +149,7 @@ public class FirewallApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
public void testDeleteFirewall() {
|
||||
|
||||
assertGlobalOperationDoneSucessfully(api().delete(FIREWALL_NAME), TIME_WAIT);
|
||||
assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).delete
|
||||
assertGlobalOperationDoneSucessfully(api.getNetworkApi(userProject.get()).delete
|
||||
(FIREWALL_NETWORK_NAME), TIME_WAIT);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,167 @@
|
|||
/*
|
||||
* 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 org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
|
||||
import org.jclouds.googlecomputeengine.parse.ParseRegionOperationTest;
|
||||
import org.jclouds.googlecomputeengine.parse.ParseForwardingRuleListTest;
|
||||
import org.jclouds.googlecomputeengine.parse.ParseForwardingRuleTest;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_READONLY_SCOPE;
|
||||
import static org.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.AssertJUnit.assertNull;
|
||||
|
||||
@Test(groups = "unit")
|
||||
public class ForwardingRuleApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
||||
|
||||
public void testGetForwardingRuleResponseIs2xx() throws Exception {
|
||||
HttpRequest get = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1/projects/myproject/regions/us-central1/forwardingRules/test-forwarding-rule")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/forwardingrule_get.json")).build();
|
||||
|
||||
ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getForwardingRuleApi("myproject", "us-central1");
|
||||
|
||||
assertEquals(api.get("test-forwarding-rule"),
|
||||
new ParseForwardingRuleTest().expected());
|
||||
}
|
||||
|
||||
public void testGetForwardingRuleResponseIs4xx() throws Exception {
|
||||
HttpRequest get = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1/projects/myproject/regions/us-central1/forwardingRules/test-forwarding-rule")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getForwardingRuleApi("myproject", "us-central1");
|
||||
|
||||
assertNull(api.get("test-forwarding-rule"));
|
||||
}
|
||||
|
||||
public void testInsertForwardingRuleResponseIs2xx() {
|
||||
HttpRequest insert = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/forwardingRules")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromResourceWithContentType("/forwardingrule_insert.json", MediaType.APPLICATION_JSON))
|
||||
.build();
|
||||
|
||||
HttpResponse insertForwardingRuleResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/region_operation.json")).build();
|
||||
|
||||
ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, insert,
|
||||
insertForwardingRuleResponse).getForwardingRuleApi("myproject", "us-central1");
|
||||
assertEquals(api.create("test-forwarding-rule",
|
||||
URI.create("https://www.googleapis.com/compute/v1/projects/myproject/regions/europe-west1/" +
|
||||
"targetPools/test-target-pool")), new ParseRegionOperationTest().expected());
|
||||
}
|
||||
|
||||
public void testDeleteForwardingRuleResponseIs2xx() {
|
||||
HttpRequest delete = HttpRequest
|
||||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1/projects/myproject/regions/us-central1/forwardingRules/test-forwarding-rule")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/region_operation.json")).build();
|
||||
|
||||
ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getForwardingRuleApi("myproject", "us-central1");
|
||||
|
||||
assertEquals(api.delete("test-forwarding-rule"),
|
||||
new ParseRegionOperationTest().expected());
|
||||
}
|
||||
|
||||
public void testDeleteForwardingRuleResponseIs4xx() {
|
||||
HttpRequest delete = HttpRequest
|
||||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis" +
|
||||
".com/compute/v1/projects/myproject/regions/us-central1/forwardingRules/test-targetPool")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getForwardingRuleApi("myproject", "us-central1");
|
||||
|
||||
assertNull(api.delete("test-targetPool"));
|
||||
}
|
||||
|
||||
public void testListForwardingRulesResponseIs2xx() {
|
||||
HttpRequest list = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/forwardingRules")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/forwardingrule_list.json")).build();
|
||||
|
||||
ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list, operationResponse).getForwardingRuleApi("myproject", "us-central1");
|
||||
|
||||
assertEquals(api.list().toString(),
|
||||
new ParseForwardingRuleListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListForwardingRulesResponseIs4xx() {
|
||||
HttpRequest list = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/regions/us-central1/forwardingRules")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
ForwardingRuleApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list, operationResponse).getForwardingRuleApi("myproject", "us-central1");
|
||||
|
||||
assertTrue(api.list().concat().isEmpty());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,85 @@
|
|||
/*
|
||||
* 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 org.jclouds.collect.IterableWithMarker;
|
||||
import org.jclouds.googlecomputeengine.domain.ForwardingRule;
|
||||
import org.jclouds.googlecomputeengine.domain.TargetPool;
|
||||
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
|
||||
import org.jclouds.googlecomputeengine.options.ListOptions;
|
||||
import org.testng.annotations.AfterClass;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
public class ForwardingRuleApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
||||
|
||||
private static final String FORWARDING_RULE_NAME = "forwarding-rule-api-live-test";
|
||||
private static final String TARGETPOOL_NAME = "forwarding-rule-api-live-test-targetpool";
|
||||
private static final int TIME_WAIT = 30;
|
||||
private TargetPool targetPool;
|
||||
|
||||
/**
|
||||
* The API under test
|
||||
* @return
|
||||
*/
|
||||
private ForwardingRuleApi api() {
|
||||
return api.getForwardingRuleApi(userProject.get(), DEFAULT_REGION_NAME);
|
||||
}
|
||||
|
||||
private TargetPoolApi targetPoolApi() {
|
||||
return api.getTargetPoolApi(userProject.get(), DEFAULT_REGION_NAME);
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public void init() {
|
||||
assertRegionOperationDoneSucessfully(targetPoolApi().create(TARGETPOOL_NAME), TIME_WAIT);
|
||||
targetPool = targetPoolApi().get(TARGETPOOL_NAME);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public void tearDown() {
|
||||
assertRegionOperationDoneSucessfully(targetPoolApi().delete(TARGETPOOL_NAME), TIME_WAIT);
|
||||
}
|
||||
|
||||
@Test(groups = "live")
|
||||
public void testInsertForwardingRule() {
|
||||
assertRegionOperationDoneSucessfully(api().create(FORWARDING_RULE_NAME, targetPool.getSelfLink()), TIME_WAIT);
|
||||
}
|
||||
|
||||
@Test(groups = "live", dependsOnMethods = "testInsertForwardingRule")
|
||||
public void testGetForwardingRule() {
|
||||
ForwardingRule forwardingRule = api().get(FORWARDING_RULE_NAME);
|
||||
assertNotNull(forwardingRule);
|
||||
assertEquals(forwardingRule.getName(), FORWARDING_RULE_NAME);
|
||||
}
|
||||
|
||||
@Test(groups = "live", dependsOnMethods = "testGetForwardingRule")
|
||||
public void testListForwardingRule() {
|
||||
|
||||
IterableWithMarker<ForwardingRule> forwardingRule = api().list(new ListOptions.Builder()
|
||||
.filter("name eq " + FORWARDING_RULE_NAME));
|
||||
assertEquals(forwardingRule.toList().size(), 1);
|
||||
}
|
||||
|
||||
@Test(groups = "live", dependsOnMethods = "testListForwardingRule")
|
||||
public void testDeleteForwardingRule() {
|
||||
assertRegionOperationDoneSucessfully(api().delete(FORWARDING_RULE_NAME), TIME_WAIT);
|
||||
}
|
||||
}
|
|
@ -49,7 +49,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
|
|||
public void testGetOperationResponseIs2xx() throws Exception {
|
||||
|
||||
GlobalOperationApi operationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, GET_GLOBAL_OPERATION_REQUEST, GET_GLOBAL_OPERATION_RESPONSE).getGlobalOperationApiForProject("myproject");
|
||||
TOKEN_RESPONSE, GET_GLOBAL_OPERATION_REQUEST, GET_GLOBAL_OPERATION_RESPONSE).getGlobalOperationApi("myproject");
|
||||
|
||||
assertEquals(operationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb"),
|
||||
new ParseOperationTest().expected());
|
||||
|
@ -60,7 +60,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, GET_GLOBAL_OPERATION_REQUEST, operationResponse).getGlobalOperationApiForProject("myproject");
|
||||
TOKEN_RESPONSE, GET_GLOBAL_OPERATION_REQUEST, operationResponse).getGlobalOperationApi("myproject");
|
||||
|
||||
assertNull(globalOperationApi.get("operation-1354084865060-4cf88735faeb8-bbbb12cb"));
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(204).build();
|
||||
|
||||
GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, operationResponse).getGlobalOperationApiForProject("myproject");
|
||||
TOKEN_RESPONSE, delete, operationResponse).getGlobalOperationApi("myproject");
|
||||
|
||||
globalOperationApi.delete("operation-1352178598164-4cdcc9d031510-4aa46279");
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, operationResponse).getGlobalOperationApiForProject("myproject");
|
||||
TOKEN_RESPONSE, delete, operationResponse).getGlobalOperationApi("myproject");
|
||||
|
||||
globalOperationApi.delete("operation-1352178598164-4cdcc9d031510-4aa46279");
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
|
|||
.payload(payloadFromResource("/global_operation_list.json")).build();
|
||||
|
||||
GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApiForProject("myproject");
|
||||
TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApi("myproject");
|
||||
|
||||
assertEquals(globalOperationApi.listFirstPage().toString(),
|
||||
new ParseOperationListTest().expected().toString());
|
||||
|
@ -130,7 +130,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
|
|||
.payload(payloadFromResource("/global_operation_list.json")).build();
|
||||
|
||||
GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApiForProject("myproject");
|
||||
TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApi("myproject");
|
||||
|
||||
assertEquals(globalOperationApi.listAtMarker("CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" +
|
||||
"I0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz",
|
||||
|
@ -149,7 +149,7 @@ public class GlobalOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
GlobalOperationApi globalOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApiForProject("myproject");
|
||||
TOKEN_RESPONSE, get, operationResponse).getGlobalOperationApi("myproject");
|
||||
|
||||
assertTrue(globalOperationApi.list().concat().isEmpty());
|
||||
}
|
||||
|
|
|
@ -41,13 +41,13 @@ public class GlobalOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
|
|||
private Operation deleteOperation;
|
||||
|
||||
private GlobalOperationApi api() {
|
||||
return api.getGlobalOperationApiForProject(userProject.get());
|
||||
return api.getGlobalOperationApi(userProject.get());
|
||||
}
|
||||
|
||||
|
||||
@Test(groups = "live")
|
||||
public void testCreateOperations() {
|
||||
//create some operations by adding and deleting metadata items
|
||||
//insert some operations by adding and deleting metadata items
|
||||
// this will make sure there is stuff to listFirstPage
|
||||
addOperation = assertGlobalOperationDoneSucessfully(addItemToMetadata(api.getProjectApi(),
|
||||
userProject.get(), METADATA_ITEM_KEY, METADATA_ITEM_VALUE), 20);
|
||||
|
|
|
@ -0,0 +1,177 @@
|
|||
/*
|
||||
* 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.jclouds.googlecomputeengine.GoogleComputeEngineConstants.COMPUTE_SCOPE;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.AssertJUnit.assertNull;
|
||||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiExpectTest;
|
||||
import org.jclouds.googlecomputeengine.parse.ParseHttpHealthCheckListTest;
|
||||
import org.jclouds.googlecomputeengine.parse.ParseHttpHealthCheckTest;
|
||||
import org.jclouds.googlecomputeengine.parse.ParseRegionOperationTest;
|
||||
import org.jclouds.http.HttpRequest;
|
||||
import org.jclouds.http.HttpResponse;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test(groups = "unit")
|
||||
public class HttpHealthCheckApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
||||
|
||||
public void testGetHttpHealthCheckResponseIs2xx() throws Exception {
|
||||
HttpRequest get = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks/http-health-check-api-live-test")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/httphealthcheck_get.json")).build();
|
||||
|
||||
HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getHttpHealthCheckApi("myproject");
|
||||
|
||||
assertEquals(api.get("http-health-check-api-live-test"),
|
||||
new ParseHttpHealthCheckTest().expected());
|
||||
}
|
||||
|
||||
public void testGetHttpHealthCheckResponseIs4xx() throws Exception {
|
||||
HttpRequest get = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks/http-health-check-test")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getHttpHealthCheckApi("myproject");
|
||||
|
||||
assertNull(api.get("http-health-check-test"));
|
||||
}
|
||||
|
||||
public void testInsertHttpHealthCheckResponseIs2xx() {
|
||||
HttpRequest insert = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromResourceWithContentType("/httphealthcheck_insert.json", MediaType.APPLICATION_JSON))
|
||||
.build();
|
||||
|
||||
HttpResponse insertHttpHealthCheckResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/global_operation.json")).build();
|
||||
|
||||
HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, insert,
|
||||
insertHttpHealthCheckResponse).getHttpHealthCheckApi("myproject");
|
||||
assertEquals(api.insert("http-health-check", 0, 0), new ParseRegionOperationTest().expected());
|
||||
}
|
||||
|
||||
public void testInsertHttpHealthCheckResponseIs4xx() {
|
||||
HttpRequest create = HttpRequest
|
||||
.builder()
|
||||
.method("POST")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN)
|
||||
.payload(payloadFromResourceWithContentType("/httphealthcheck_insert.json", MediaType.APPLICATION_JSON))
|
||||
.build();
|
||||
|
||||
HttpResponse insertHttpHealthCheckResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, create, insertHttpHealthCheckResponse).getHttpHealthCheckApi("myproject");
|
||||
|
||||
assertNull(api.insert("http-health-check", 0, 0));
|
||||
}
|
||||
|
||||
public void testDeleteHttpHealthCheckResponseIs2xx() {
|
||||
HttpRequest delete = HttpRequest
|
||||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks/http-health-check")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/global_operation.json")).build();
|
||||
|
||||
HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getHttpHealthCheckApi("myproject");
|
||||
|
||||
assertEquals(api.delete("http-health-check"),
|
||||
new ParseRegionOperationTest().expected());
|
||||
}
|
||||
|
||||
public void testDeleteHttpHealthCheckResponseIs4xx() {
|
||||
HttpRequest delete = HttpRequest
|
||||
.builder()
|
||||
.method("DELETE")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks/http-health-check")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getHttpHealthCheckApi("myproject");
|
||||
|
||||
assertNull(api.delete("http-health-check"));
|
||||
}
|
||||
|
||||
public void testListHttpHealthChecksResponseIs2xx() {
|
||||
HttpRequest list = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpResponse operationResponse = HttpResponse.builder().statusCode(200)
|
||||
.payload(payloadFromResource("/httphealthcheck_list.json")).build();
|
||||
|
||||
HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list, operationResponse).getHttpHealthCheckApi("myproject");
|
||||
|
||||
assertEquals(api.list().toString(),
|
||||
new ParseHttpHealthCheckListTest().expected().toString());
|
||||
}
|
||||
|
||||
public void testListHttpHealthChecksResponseIs4xx() {
|
||||
HttpRequest list = HttpRequest
|
||||
.builder()
|
||||
.method("GET")
|
||||
.endpoint("https://www.googleapis.com/compute/v1/projects/myproject/global/httpHealthChecks")
|
||||
.addHeader("Accept", "application/json")
|
||||
.addHeader("Authorization", "Bearer " + TOKEN).build();
|
||||
|
||||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
HttpHealthCheckApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list, operationResponse).getHttpHealthCheckApi("myproject");
|
||||
|
||||
assertTrue(api.list().concat().isEmpty());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* 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 org.jclouds.collect.IterableWithMarker;
|
||||
import org.jclouds.googlecomputeengine.domain.HttpHealthCheck;
|
||||
import org.jclouds.googlecomputeengine.internal.BaseGoogleComputeEngineApiLiveTest;
|
||||
import org.jclouds.googlecomputeengine.options.ListOptions;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
public class HttpHealthCheckApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
||||
|
||||
private static final String HTTP_HEALTH_CHECK_NAME = "http-health-check-api-live-test";
|
||||
private static final int TIME_WAIT = 60;
|
||||
|
||||
private HttpHealthCheckApi api() {
|
||||
return api.getHttpHealthCheckApi(userProject.get());
|
||||
}
|
||||
|
||||
@Test(groups = "live")
|
||||
public void testInsertHttpHealthCheck() {
|
||||
assertGlobalOperationDoneSucessfully(api().insert(HTTP_HEALTH_CHECK_NAME), TIME_WAIT);
|
||||
}
|
||||
|
||||
@Test(groups = "live", dependsOnMethods = "testInsertHttpHealthCheck")
|
||||
public void testGetHttpHealthCheck() {
|
||||
HttpHealthCheck httpHealthCheck = api().get(HTTP_HEALTH_CHECK_NAME);
|
||||
assertNotNull(httpHealthCheck);
|
||||
assertEquals(httpHealthCheck.getName(), HTTP_HEALTH_CHECK_NAME);
|
||||
}
|
||||
|
||||
@Test(groups = "live", dependsOnMethods = "testGetHttpHealthCheck")
|
||||
public void testListHttpHealthCheck() {
|
||||
IterableWithMarker<HttpHealthCheck> httpHealthCheck = api().list(new ListOptions.Builder()
|
||||
.filter("name eq " + HTTP_HEALTH_CHECK_NAME));
|
||||
assertEquals(httpHealthCheck.toList().size(), 1);
|
||||
}
|
||||
|
||||
@Test(groups = "live", dependsOnMethods = "testListHttpHealthCheck")
|
||||
public void testDeleteHttpHealthCheck() {
|
||||
assertGlobalOperationDoneSucessfully(api().delete(HTTP_HEALTH_CHECK_NAME), TIME_WAIT);
|
||||
}
|
||||
}
|
|
@ -79,7 +79,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.payload(payloadFromResource("/image_get.json")).build();
|
||||
|
||||
ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getImageApiForProject("centos-cloud");
|
||||
TOKEN_RESPONSE, get, operationResponse).getImageApi("centos-cloud");
|
||||
|
||||
assertEquals(imageApi.get("centos-6-2-v20120326"),
|
||||
new ParseImageTest().expected());
|
||||
|
@ -97,7 +97,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getImageApiForProject("centos-cloud");
|
||||
TOKEN_RESPONSE, get, operationResponse).getImageApi("centos-cloud");
|
||||
|
||||
assertNull(imageApi.get("centos-6-2-v20120326"));
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.payload(payloadFromResource("/operation.json")).build();
|
||||
|
||||
ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getImageApiForProject("myproject");
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getImageApi("myproject");
|
||||
|
||||
assertEquals(imageApi.delete("centos-6-2-v20120326"),
|
||||
new ParseOperationTest().expected());
|
||||
|
@ -133,7 +133,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getImageApiForProject("myproject");
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getImageApi("myproject");
|
||||
|
||||
assertNull(imageApi.delete("centos-6-2-v20120326"));
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
public void testListImagesResponseIs2xx() {
|
||||
|
||||
ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, LIST_PROJECT_IMAGES_REQUEST, LIST_PROJECT_IMAGES_RESPONSE).getImageApiForProject
|
||||
TOKEN_RESPONSE, LIST_PROJECT_IMAGES_REQUEST, LIST_PROJECT_IMAGES_RESPONSE).getImageApi
|
||||
("myproject");
|
||||
|
||||
assertEquals(imageApi.listFirstPage().toString(),
|
||||
|
@ -153,7 +153,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, LIST_PROJECT_IMAGES_REQUEST, operationResponse).getImageApiForProject("myproject");
|
||||
TOKEN_RESPONSE, LIST_PROJECT_IMAGES_REQUEST, operationResponse).getImageApi("myproject");
|
||||
|
||||
assertTrue(imageApi.list().concat().isEmpty());
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.payload(payloadFromResource("/operation.json")).build();
|
||||
|
||||
ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, createImage, createImageResponse).getImageApiForProject("myproject");
|
||||
TOKEN_RESPONSE, createImage, createImageResponse).getImageApi("myproject");
|
||||
|
||||
assertEquals(imageApi.createImageFromPD("my-image", "https://www.googleapis.com/" +
|
||||
"compute/v1/projects/myproject/zones/us-central1-a/disks/mydisk"),
|
||||
|
@ -195,7 +195,7 @@ public class ImageApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpResponse createImageResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
ImageApi imageApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, createImage, createImageResponse).getImageApiForProject("myproject");
|
||||
TOKEN_RESPONSE, createImage, createImageResponse).getImageApi("myproject");
|
||||
|
||||
imageApi.createImageFromPD("my-image", "https://www.googleapis.com/" +
|
||||
"compute/v1/projects/myproject/zones/us-central1-a/disks/mydisk");
|
||||
|
|
|
@ -47,15 +47,15 @@ public class ImageApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
private URI diskURI;
|
||||
|
||||
private ImageApi api() {
|
||||
return api.getImageApiForProject("centos-cloud");
|
||||
return api.getImageApi("centos-cloud");
|
||||
}
|
||||
|
||||
private ImageApi imageApi(){
|
||||
return api.getImageApiForProject(userProject.get());
|
||||
return api.getImageApi(userProject.get());
|
||||
}
|
||||
|
||||
private DiskApi diskApi() {
|
||||
return api.getDiskApiForProject(userProject.get());
|
||||
return api.getDiskApi(userProject.get());
|
||||
}
|
||||
|
||||
@Test(groups = "live")
|
||||
|
|
|
@ -92,7 +92,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
|
||||
InstanceApi api = requestsSendResponses(
|
||||
requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE,
|
||||
GET_INSTANCE_REQUEST, GET_INSTANCE_RESPONSE).getInstanceApiForProject("myproject");
|
||||
GET_INSTANCE_REQUEST, GET_INSTANCE_RESPONSE).getInstanceApi("myproject");
|
||||
|
||||
assertEquals(api.getInZone("us-central1-a", "test-1"), new ParseInstanceTest().expected());
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, GET_INSTANCE_REQUEST, operationResponse).getInstanceApiForProject("myproject");
|
||||
TOKEN_RESPONSE, GET_INSTANCE_REQUEST, operationResponse).getInstanceApi("myproject");
|
||||
|
||||
assertNull(api.getInZone("us-central1-a", "test-1"));
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
|
||||
|
||||
InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getInstanceApiForProject("myproject");
|
||||
TOKEN_RESPONSE, get, operationResponse).getInstanceApi("myproject");
|
||||
|
||||
assertEquals(api.getSerialPortOutputInZone("us-central1-a", "test-1"), new ParseInstanceSerialOutputTest().expected());
|
||||
}
|
||||
|
@ -140,7 +140,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
TOKEN_RESPONSE, GET_PROJECT_REQUEST, GET_PROJECT_RESPONSE,
|
||||
requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, insert,
|
||||
CREATE_INSTANCE_RESPONSE)).getInstanceApiForProject("myproject");
|
||||
CREATE_INSTANCE_RESPONSE)).getInstanceApi("myproject");
|
||||
|
||||
InstanceTemplate options = InstanceTemplate.builder().forMachineType("us-central1-a/n1-standard-1")
|
||||
.addNetworkInterface(URI.create("https://www.googleapis" +
|
||||
|
@ -165,7 +165,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
InstanceApi api = requestsSendResponses(ImmutableMap.of(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, GET_PROJECT_REQUEST, GET_PROJECT_RESPONSE,
|
||||
requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, insert, insertInstanceResponse)).getInstanceApiForProject("myproject");
|
||||
TOKEN_RESPONSE, insert, insertInstanceResponse)).getInstanceApi("myproject");
|
||||
|
||||
InstanceTemplate options = InstanceTemplate.builder().forMachineType("us-central1-a/n1-standard-1")
|
||||
.addNetworkInterface(URI.create("https://www.googleapis" +
|
||||
|
@ -194,7 +194,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.payload(payloadFromResource("/zone_operation.json")).build();
|
||||
|
||||
InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getInstanceApiForProject("myproject");
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getInstanceApi("myproject");
|
||||
|
||||
assertEquals(api.deleteInZone("us-central1-a", "test-1"),
|
||||
new ParseOperationTest().expected());
|
||||
|
@ -212,7 +212,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getInstanceApiForProject("myproject");
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getInstanceApi("myproject");
|
||||
|
||||
assertNull(api.deleteInZone("us-central1-a", "test-1"));
|
||||
}
|
||||
|
@ -221,7 +221,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
|
||||
InstanceApi api = requestsSendResponses(
|
||||
requestForScopes(COMPUTE_READONLY_SCOPE), TOKEN_RESPONSE,
|
||||
LIST_INSTANCES_REQUEST, LIST_INSTANCES_RESPONSE).getInstanceApiForProject("myproject");
|
||||
LIST_INSTANCES_REQUEST, LIST_INSTANCES_RESPONSE).getInstanceApi("myproject");
|
||||
|
||||
assertEquals(api.listFirstPageInZone("us-central1-a").toString(),
|
||||
new ParseInstanceListTest().expected().toString());
|
||||
|
@ -239,7 +239,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list, operationResponse).getInstanceApiForProject("myproject");
|
||||
TOKEN_RESPONSE, list, operationResponse).getInstanceApi("myproject");
|
||||
|
||||
assertTrue(api.listInZone("us-central1-a").concat().isEmpty());
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.payload(payloadFromResource("/zone_operation.json")).build();
|
||||
|
||||
InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, setMetadata, setMetadataResponse).getInstanceApiForProject("myproject");
|
||||
TOKEN_RESPONSE, setMetadata, setMetadataResponse).getInstanceApi("myproject");
|
||||
|
||||
assertEquals(api.setMetadataInZone("us-central1-a", "test-1", ImmutableMap.of("foo", "bar"), "efgh"),
|
||||
new ParseOperationTest().expected());
|
||||
|
@ -280,7 +280,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
HttpResponse setMetadataResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, setMetadata, setMetadataResponse).getInstanceApiForProject("myproject");
|
||||
TOKEN_RESPONSE, setMetadata, setMetadataResponse).getInstanceApi("myproject");
|
||||
|
||||
api.setMetadataInZone("us-central1-a", "test-1", ImmutableMap.of("foo", "bar"), "efgh");
|
||||
}
|
||||
|
@ -300,7 +300,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.payload(payloadFromResource("/zone_operation.json")).build();
|
||||
|
||||
InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, setTags, setTagsResponse).getInstanceApiForProject("myproject");
|
||||
TOKEN_RESPONSE, setTags, setTagsResponse).getInstanceApi("myproject");
|
||||
|
||||
assertEquals(api.setTagsInZone("us-central1-a", "test-1", ImmutableSet.of("foo", "bar"), "efgh"),
|
||||
new ParseOperationTest().expected());
|
||||
|
@ -321,7 +321,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
HttpResponse setTagsResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, setTags, setTagsResponse).getInstanceApiForProject("myproject");
|
||||
TOKEN_RESPONSE, setTags, setTagsResponse).getInstanceApi("myproject");
|
||||
|
||||
api.setTagsInZone("us-central1-a", "test-1", ImmutableSet.of("foo", "bar"), "efgh");
|
||||
}
|
||||
|
@ -339,7 +339,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.payload(payloadFromResource("/zone_operation.json")).build();
|
||||
|
||||
InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, reset, resetResponse).getInstanceApiForProject("myproject");
|
||||
TOKEN_RESPONSE, reset, resetResponse).getInstanceApi("myproject");
|
||||
|
||||
assertEquals(api.resetInZone("us-central1-a", "test-1"),
|
||||
new ParseOperationTest().expected());
|
||||
|
@ -358,7 +358,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
HttpResponse resetResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, reset, resetResponse).getInstanceApiForProject("myproject");
|
||||
TOKEN_RESPONSE, reset, resetResponse).getInstanceApi("myproject");
|
||||
|
||||
api.resetInZone("us-central1-a", "test-1");
|
||||
}
|
||||
|
@ -378,7 +378,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.payload(payloadFromResource("/zone_operation.json")).build();
|
||||
|
||||
InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, attach, attachResponse).getInstanceApiForProject("myproject");
|
||||
TOKEN_RESPONSE, attach, attachResponse).getInstanceApi("myproject");
|
||||
|
||||
assertEquals(api.attachDiskInZone("us-central1-a", "test-1",
|
||||
new AttachDiskOptions()
|
||||
|
@ -403,7 +403,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
HttpResponse attachResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, attach, attachResponse).getInstanceApiForProject("myproject");
|
||||
TOKEN_RESPONSE, attach, attachResponse).getInstanceApi("myproject");
|
||||
|
||||
api.attachDiskInZone("us-central1-a", "test-1",
|
||||
new AttachDiskOptions()
|
||||
|
@ -428,7 +428,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
.payload(payloadFromResource("/zone_operation.json")).build();
|
||||
|
||||
InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, detach, detachResponse).getInstanceApiForProject("myproject");
|
||||
TOKEN_RESPONSE, detach, detachResponse).getInstanceApi("myproject");
|
||||
|
||||
assertEquals(api.detachDiskInZone("us-central1-a", "test-1", "test-disk-1"),
|
||||
new ParseOperationTest().expected());
|
||||
|
@ -449,7 +449,7 @@ public class InstanceApiExpectTest extends BaseGoogleComputeEngineApiExpectTest
|
|||
HttpResponse detachResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
InstanceApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, detach, detachResponse).getInstanceApiForProject("myproject");
|
||||
TOKEN_RESPONSE, detach, detachResponse).getInstanceApi("myproject");
|
||||
|
||||
api.detachDiskInZone("us-central1-a", "test-1", "test-disk-1");
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
@Override
|
||||
protected GoogleComputeEngineApi create(Properties props, Iterable<Module> modules) {
|
||||
GoogleComputeEngineApi api = super.create(props, modules);
|
||||
URI imageUri = api.getImageApiForProject("centos-cloud")
|
||||
URI imageUri = api.getImageApi("centos-cloud")
|
||||
.list(new ListOptions.Builder().filter("name eq centos.*"))
|
||||
.concat()
|
||||
.filter(new Predicate<Image>() {
|
||||
|
@ -98,22 +98,22 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
}
|
||||
|
||||
private InstanceApi api() {
|
||||
return api.getInstanceApiForProject(userProject.get());
|
||||
return api.getInstanceApi(userProject.get());
|
||||
}
|
||||
|
||||
private DiskApi diskApi() {
|
||||
return api.getDiskApiForProject(userProject.get());
|
||||
return api.getDiskApi(userProject.get());
|
||||
}
|
||||
|
||||
@Test(groups = "live")
|
||||
public void testInsertInstance() {
|
||||
|
||||
// need to create the network first
|
||||
assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).createInIPv4Range
|
||||
// need to insert the network first
|
||||
assertGlobalOperationDoneSucessfully(api.getNetworkApi(userProject.get()).createInIPv4Range
|
||||
(INSTANCE_NETWORK_NAME, IPV4_RANGE), TIME_WAIT);
|
||||
|
||||
DiskCreationOptions diskCreationOptions = new DiskCreationOptions().sourceImage(instance.getImage());
|
||||
assertZoneOperationDoneSucessfully(api.getDiskApiForProject(userProject.get())
|
||||
assertZoneOperationDoneSucessfully(api.getDiskApi(userProject.get())
|
||||
.createInZone(BOOT_DISK_NAME, DEFAULT_DISK_SIZE_GB, DEFAULT_ZONE_NAME, diskCreationOptions),
|
||||
TIME_WAIT);
|
||||
|
||||
|
@ -225,11 +225,11 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
public void testDeleteInstance() {
|
||||
|
||||
assertZoneOperationDoneSucessfully(api().deleteInZone(DEFAULT_ZONE_NAME, INSTANCE_NAME), TIME_WAIT);
|
||||
assertZoneOperationDoneSucessfully(api.getDiskApiForProject(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME),
|
||||
assertZoneOperationDoneSucessfully(api.getDiskApi(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME),
|
||||
TIME_WAIT);
|
||||
assertZoneOperationDoneSucessfully(api.getDiskApiForProject(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, BOOT_DISK_NAME),
|
||||
assertZoneOperationDoneSucessfully(api.getDiskApi(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, BOOT_DISK_NAME),
|
||||
TIME_WAIT);
|
||||
assertGlobalOperationDoneSucessfully(api.getNetworkApiForProject(userProject.get()).delete
|
||||
assertGlobalOperationDoneSucessfully(api.getNetworkApi(userProject.get()).delete
|
||||
(INSTANCE_NETWORK_NAME), TIME_WAIT);
|
||||
}
|
||||
|
||||
|
@ -242,11 +242,11 @@ public class InstanceApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
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),
|
||||
waitZoneOperationDone(api.getDiskApi(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, DISK_NAME),
|
||||
TIME_WAIT);
|
||||
waitZoneOperationDone(api.getDiskApiForProject(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, BOOT_DISK_NAME),
|
||||
waitZoneOperationDone(api.getDiskApi(userProject.get()).deleteInZone(DEFAULT_ZONE_NAME, BOOT_DISK_NAME),
|
||||
TIME_WAIT);
|
||||
waitGlobalOperationDone(api.getNetworkApiForProject(userProject.get()).delete
|
||||
waitGlobalOperationDone(api.getNetworkApi(userProject.get()).delete
|
||||
(INSTANCE_NETWORK_NAME), TIME_WAIT);
|
||||
} catch (Exception e) {
|
||||
// we don't really care about any exception here, so just delete away.
|
||||
|
|
|
@ -68,7 +68,7 @@ public class MachineTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTe
|
|||
.payload(payloadFromResource("/machinetype.json")).build();
|
||||
|
||||
MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getMachineTypeApiForProject("myproject");
|
||||
TOKEN_RESPONSE, get, operationResponse).getMachineTypeApi("myproject");
|
||||
|
||||
assertEquals(machineTypeApi.getInZone("us-central1-a", "n1-standard-1"),
|
||||
new ParseMachineTypeTest().expected());
|
||||
|
@ -86,7 +86,7 @@ public class MachineTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTe
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getMachineTypeApiForProject("myproject");
|
||||
TOKEN_RESPONSE, get, operationResponse).getMachineTypeApi("myproject");
|
||||
|
||||
assertNull(machineTypeApi.getInZone("us-central1-a", "n1-standard-1"));
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public class MachineTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTe
|
|||
public void testListMachineTypeNoOptionsResponseIs2xx() throws Exception {
|
||||
|
||||
MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, LIST_MACHINE_TYPES_REQUEST, LIST_MACHINE_TYPES_RESPONSE).getMachineTypeApiForProject
|
||||
TOKEN_RESPONSE, LIST_MACHINE_TYPES_REQUEST, LIST_MACHINE_TYPES_RESPONSE).getMachineTypeApi
|
||||
("myproject");
|
||||
|
||||
assertEquals(machineTypeApi.listFirstPageInZone("us-central1-a").toString(),
|
||||
|
@ -106,7 +106,7 @@ public class MachineTypeApiExpectTest extends BaseGoogleComputeEngineApiExpectTe
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
MachineTypeApi machineTypeApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, LIST_MACHINE_TYPES_REQUEST, operationResponse).getMachineTypeApiForProject("myproject");
|
||||
TOKEN_RESPONSE, LIST_MACHINE_TYPES_REQUEST, operationResponse).getMachineTypeApi("myproject");
|
||||
|
||||
assertTrue(machineTypeApi.listInZone("us-central1-a").concat().isEmpty());
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class MachineTypeApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
private MachineType machineType;
|
||||
|
||||
private MachineTypeApi api() {
|
||||
return api.getMachineTypeApiForProject(userProject.get());
|
||||
return api.getMachineTypeApi(userProject.get());
|
||||
}
|
||||
|
||||
@Test(groups = "live")
|
||||
|
|
|
@ -48,7 +48,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
public void testGetNetworkResponseIs2xx() throws Exception {
|
||||
|
||||
NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, GET_NETWORK_REQUEST, GET_NETWORK_RESPONSE).getNetworkApiForProject("myproject");
|
||||
TOKEN_RESPONSE, GET_NETWORK_REQUEST, GET_NETWORK_RESPONSE).getNetworkApi("myproject");
|
||||
|
||||
assertEquals(api.get("jclouds-test"),
|
||||
new ParseNetworkTest().expected());
|
||||
|
@ -65,7 +65,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getNetworkApiForProject("myproject");
|
||||
TOKEN_RESPONSE, get, operationResponse).getNetworkApi("myproject");
|
||||
|
||||
assertNull(api.get("jclouds-test"));
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
|
||||
NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, insert,
|
||||
insertNetworkResponse).getNetworkApiForProject("myproject");
|
||||
insertNetworkResponse).getNetworkApi("myproject");
|
||||
|
||||
assertEquals(api.createInIPv4Range("test-network", "10.0.0.0/8"), new ParseOperationTest().expected());
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.payload(payloadFromResource("/operation.json")).build();
|
||||
|
||||
NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getNetworkApiForProject("myproject");
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getNetworkApi("myproject");
|
||||
|
||||
assertEquals(api.delete("jclouds-test"),
|
||||
new ParseOperationTest().expected());
|
||||
|
@ -121,7 +121,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getNetworkApiForProject("myproject");
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getNetworkApi("myproject");
|
||||
|
||||
assertNull(api.delete("jclouds-test"));
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.payload(payloadFromResource("/network_list.json")).build();
|
||||
|
||||
NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list, operationResponse).getNetworkApiForProject("myproject");
|
||||
TOKEN_RESPONSE, list, operationResponse).getNetworkApi("myproject");
|
||||
|
||||
assertEquals(api.listFirstPage().toString(),
|
||||
new ParseNetworkListTest().expected().toString());
|
||||
|
@ -157,7 +157,7 @@ public class NetworkApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
NetworkApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list, operationResponse).getNetworkApiForProject("myproject");
|
||||
TOKEN_RESPONSE, list, operationResponse).getNetworkApi("myproject");
|
||||
|
||||
assertTrue(api.list().concat().isEmpty());
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public class NetworkApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
private static final int TIME_WAIT = 10;
|
||||
|
||||
private NetworkApi api() {
|
||||
return api.getNetworkApiForProject(userProject.get());
|
||||
return api.getNetworkApi(userProject.get());
|
||||
}
|
||||
|
||||
@Test(groups = "live")
|
||||
|
|
|
@ -57,7 +57,7 @@ public class RegionApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.payload(payloadFromResource("/region_get.json")).build();
|
||||
|
||||
RegionApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, GET_REGION_REQ, operationResponse).getRegionApiForProject("myproject");
|
||||
TOKEN_RESPONSE, GET_REGION_REQ, operationResponse).getRegionApi("myproject");
|
||||
|
||||
assertEquals(api.get("us-central1"),
|
||||
new ParseRegionTest().expected());
|
||||
|
@ -68,7 +68,7 @@ public class RegionApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
RegionApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, GET_REGION_REQ, operationResponse).getRegionApiForProject("myproject");
|
||||
TOKEN_RESPONSE, GET_REGION_REQ, operationResponse).getRegionApi("myproject");
|
||||
|
||||
assertNull(api.get("us-central1"));
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ public class RegionApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
public void testListRegionNoOptionsResponseIs2xx() throws Exception {
|
||||
|
||||
RegionApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, LIST_REGIONS_REQ, LIST_REGIONS_RESPONSE).getRegionApiForProject("myproject");
|
||||
TOKEN_RESPONSE, LIST_REGIONS_REQ, LIST_REGIONS_RESPONSE).getRegionApi("myproject");
|
||||
|
||||
assertEquals(api.listFirstPage().toString(),
|
||||
new ParseRegionListTest().expected().toString());
|
||||
|
@ -87,7 +87,7 @@ public class RegionApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
RegionApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, LIST_REGIONS_REQ, operationResponse).getRegionApiForProject("myproject");
|
||||
TOKEN_RESPONSE, LIST_REGIONS_REQ, operationResponse).getRegionApi("myproject");
|
||||
|
||||
assertTrue(api.list().concat().isEmpty());
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class RegionApiLiveTest extends BaseGoogleComputeEngineApiLiveTest {
|
|||
private Region region;
|
||||
|
||||
private RegionApi api() {
|
||||
return api.getRegionApiForProject(userProject.get());
|
||||
return api.getRegionApi(userProject.get());
|
||||
}
|
||||
|
||||
@Test(groups = "live")
|
||||
|
|
|
@ -84,7 +84,7 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
|
|||
public void testGetOperationResponseIs2xx() throws Exception {
|
||||
|
||||
RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, GET_OPERATION_REQUEST, GET_OPERATION_RESPONSE).getRegionOperationApiForProject("myproject");
|
||||
TOKEN_RESPONSE, GET_OPERATION_REQUEST, GET_OPERATION_RESPONSE).getRegionOperationApi("myproject");
|
||||
|
||||
assertEquals(regionOperationApi.getInRegion("us-central1", "operation-1354084865060-4cf88735faeb8-bbbb12cb"),
|
||||
expected());
|
||||
|
@ -95,7 +95,7 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, GET_OPERATION_REQUEST, operationResponse).getRegionOperationApiForProject("myproject");
|
||||
TOKEN_RESPONSE, GET_OPERATION_REQUEST, operationResponse).getRegionOperationApi("myproject");
|
||||
|
||||
assertNull(regionOperationApi.getInRegion("us-central1", "operation-1354084865060-4cf88735faeb8-bbbb12cb"));
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(204).build();
|
||||
|
||||
RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, operationResponse).getRegionOperationApiForProject("myproject");
|
||||
TOKEN_RESPONSE, delete, operationResponse).getRegionOperationApi("myproject");
|
||||
|
||||
regionOperationApi.deleteInRegion("us-central1", "operation-1352178598164-4cdcc9d031510-4aa46279");
|
||||
}
|
||||
|
@ -125,7 +125,7 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, operationResponse).getRegionOperationApiForProject("myproject");
|
||||
TOKEN_RESPONSE, delete, operationResponse).getRegionOperationApi("myproject");
|
||||
|
||||
regionOperationApi.deleteInRegion("us-central1", "operation-1352178598164-4cdcc9d031510-4aa46279");
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
|
|||
.payload(payloadFromResource("/region_operation_list.json")).build();
|
||||
|
||||
RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getRegionOperationApiForProject("myproject");
|
||||
TOKEN_RESPONSE, get, operationResponse).getRegionOperationApi("myproject");
|
||||
|
||||
assertEquals(regionOperationApi.listFirstPageInRegion("us-central1").toString(),
|
||||
expectedList().toString());
|
||||
|
@ -165,7 +165,7 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
|
|||
.payload(payloadFromResource("/region_operation_list.json")).build();
|
||||
|
||||
RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getRegionOperationApiForProject("myproject");
|
||||
TOKEN_RESPONSE, get, operationResponse).getRegionOperationApi("myproject");
|
||||
|
||||
assertEquals(regionOperationApi.listAtMarkerInRegion("us-central1", "CglPUEVSQVRJT04SOzU5MDQyMTQ4Nzg1Mi5vcGVyYXRpb24tMTM1Mj" +
|
||||
"I0NDI1ODAzMC00Y2RkYmU2YTJkNmIwLWVkMzIyMzQz",
|
||||
|
@ -184,7 +184,7 @@ public class RegionOperationApiExpectTest extends BaseGoogleComputeEngineApiExpe
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
RegionOperationApi regionOperationApi = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getRegionOperationApiForProject("myproject");
|
||||
TOKEN_RESPONSE, get, operationResponse).getRegionOperationApi("myproject");
|
||||
|
||||
assertTrue(regionOperationApi.listInRegion("us-central1").concat().isEmpty());
|
||||
}
|
||||
|
|
|
@ -38,16 +38,16 @@ public class RegionOperationApiLiveTest extends BaseGoogleComputeEngineApiLiveTe
|
|||
private Operation deleteOperation;
|
||||
|
||||
private RegionOperationApi api() {
|
||||
return api.getRegionOperationApiForProject(userProject.get());
|
||||
return api.getRegionOperationApi(userProject.get());
|
||||
}
|
||||
|
||||
private AddressApi addressApi() {
|
||||
return api.getAddressApiForProject(userProject.get());
|
||||
return api.getAddressApi(userProject.get());
|
||||
}
|
||||
|
||||
@Test(groups = "live")
|
||||
public void testCreateOperations() {
|
||||
//create some operations by adding and deleting metadata items
|
||||
//insert some operations by adding and deleting metadata items
|
||||
// this will make sure there is stuff to listFirstPage
|
||||
addOperation = assertRegionOperationDoneSucessfully(addressApi().createInRegion(DEFAULT_REGION_NAME,
|
||||
ADDRESS_NAME), 20);
|
||||
|
|
|
@ -50,7 +50,7 @@ public class RouteApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.payload(payloadFromResource("/route_get.json")).build();
|
||||
|
||||
RouteApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getRouteApiForProject("myproject");
|
||||
TOKEN_RESPONSE, get, operationResponse).getRouteApi("myproject");
|
||||
|
||||
assertEquals(api.get("default-route-c99ebfbed0e1f375"),
|
||||
new ParseRouteTest().expected());
|
||||
|
@ -67,7 +67,7 @@ public class RouteApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
RouteApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, get, operationResponse).getRouteApiForProject("myproject");
|
||||
TOKEN_RESPONSE, get, operationResponse).getRouteApi("myproject");
|
||||
|
||||
assertNull(api.get("default-route-c99ebfbed0e1f375"));
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class RouteApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
|
||||
RouteApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, insert,
|
||||
insertRouteResponse).getRouteApiForProject("myproject");
|
||||
insertRouteResponse).getRouteApi("myproject");
|
||||
|
||||
assertEquals(api.createInNetwork("default-route-c99ebfbed0e1f375",
|
||||
URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/default"),
|
||||
|
@ -114,7 +114,7 @@ public class RouteApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.payload(payloadFromResource("/global_operation.json")).build();
|
||||
|
||||
RouteApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getRouteApiForProject("myproject");
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getRouteApi("myproject");
|
||||
|
||||
assertEquals(api.delete("default-route-c99ebfbed0e1f375"),
|
||||
new ParseOperationTest().expected());
|
||||
|
@ -132,7 +132,7 @@ public class RouteApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpResponse deleteResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
RouteApi api = requestsSendResponses(requestForScopes(COMPUTE_SCOPE),
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getRouteApiForProject("myproject");
|
||||
TOKEN_RESPONSE, delete, deleteResponse).getRouteApi("myproject");
|
||||
|
||||
assertNull(api.delete("default-route-c99ebfbed0e1f375"));
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ public class RouteApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
.payload(payloadFromResource("/route_list.json")).build();
|
||||
|
||||
RouteApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list, operationResponse).getRouteApiForProject("myproject");
|
||||
TOKEN_RESPONSE, list, operationResponse).getRouteApi("myproject");
|
||||
|
||||
assertEquals(api.listFirstPage().toString(),
|
||||
new ParseRouteListTest().expected().toString());
|
||||
|
@ -168,7 +168,7 @@ public class RouteApiExpectTest extends BaseGoogleComputeEngineApiExpectTest {
|
|||
HttpResponse operationResponse = HttpResponse.builder().statusCode(404).build();
|
||||
|
||||
RouteApi api = requestsSendResponses(requestForScopes(COMPUTE_READONLY_SCOPE),
|
||||
TOKEN_RESPONSE, list, operationResponse).getRouteApiForProject("myproject");
|
||||
TOKEN_RESPONSE, list, operationResponse).getRouteApi("myproject");
|
||||
|
||||
assertTrue(api.list().concat().isEmpty());
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue