public Region build() { return new Region(super.id, super.creationTimestamp, super.selfLink, super.name, super.description, status, zones.build(), quotas.build()); }
@Override public Location apply(Region input) { return new LocationBuilder() .description(input.getDescription().orNull()) .metadata(ImmutableMap.of("selfLink", (Object) checkNotNull(input.getSelfLink(), "region URI"))) .id(input.getName()) .scope(LocationScope.REGION) .parent(GOOGLE_PROVIDER_LOCATION) .build(); } }
/** Unlike EC2, you cannot default GCE instances to a region. Hence, we constrain to zones. */ @Override public Iterable<Location> listLocations() { Location provider = justProvider.get().iterator().next(); ImmutableList.Builder<Location> zones = ImmutableList.builder(); for (Region region : concat(api.regions().list())) { Location regionLocation = new LocationBuilder() .scope(LocationScope.REGION) .id(region.name()) .description(region.selfLink().toString()) .parent(provider).build(); for (URI zoneSelfLink : region.zones()) { String zoneName = toName(zoneSelfLink); zones.add(new LocationBuilder() .scope(LocationScope.ZONE) .id(zoneName) .description(zoneSelfLink.toString()) .parent(regionLocation).build()); } } return zones.build(); }
@Override public boolean apply(AtomicReference<Operation> input) { checkNotNull(input, "input"); Operation current = api.getRegionOperationApiForProject(project.get()) .getInRegion(regions.get().get(input.get().getRegion().get()).getName(), input.get().getName()); switch (current.getStatus()) { case DONE: input.set(current); return true; case PENDING: case RUNNING: default: return false; } } }
/** Unlike EC2, you cannot default GCE instances to a region. Hence, we constrain to zones. */ @Override public Iterable<Location> listLocations() { Location provider = justProvider.get().iterator().next(); ImmutableList.Builder<Location> zones = ImmutableList.builder(); for (Region region : concat(api.regions().list())) { Location regionLocation = new LocationBuilder() .scope(LocationScope.REGION) .id(region.name()) .description(region.selfLink().toString()) .parent(provider).build(); for (URI zoneSelfLink : region.zones()) { String zoneName = toName(zoneSelfLink); zones.add(new LocationBuilder() .scope(LocationScope.ZONE) .id(zoneName) .description(zoneSelfLink.toString()) .parent(regionLocation).build()); } } return zones.build(); }
@Override public boolean apply(AtomicReference<Operation> input) { checkNotNull(input, "input"); Operation current = api.getRegionOperationApiForProject(project.get()) .getInRegion(regions.get().get(input.get().getRegion().get()).getName(), input.get().getName()); switch (current.getStatus()) { case DONE: input.set(current); return true; case PENDING: case RUNNING: default: return false; } } }
/** Unlike EC2, you cannot default GCE instances to a region. Hence, we constrain to zones. */ @Override public Iterable<Location> listLocations() { Location provider = justProvider.get().iterator().next(); ImmutableList.Builder<Location> zones = ImmutableList.builder(); for (Region region : concat(api.regions().list())) { Location regionLocation = new LocationBuilder() .scope(LocationScope.REGION) .id(region.name()) .description(region.selfLink().toString()) .parent(provider).build(); for (URI zoneSelfLink : region.zones()) { String zoneName = toName(zoneSelfLink); zones.add(new LocationBuilder() .scope(LocationScope.ZONE) .id(zoneName) .description(zoneSelfLink.toString()) .parent(regionLocation).build()); } } return zones.build(); }
@Override public Location apply(Region input) { return new LocationBuilder() .description(input.getDescription().orNull()) .metadata(ImmutableMap.of("selfLink", (Object) checkNotNull(input.getSelfLink(), "region URI"))) .id(input.getName()) .scope(LocationScope.REGION) .parent(GOOGLE_PROVIDER_LOCATION) .build(); } }
@Test(groups = "live", dependsOnMethods = "testListRegion") public void testGetRegion() { Region region = api().get(this.region.name()); assertNotNull(region); assertRegionEquals(region, this.region); }
public Region build() { return new Region(super.id, super.creationTimestamp, super.selfLink, super.name, super.description, status, zones.build(), quotas.build()); }
/** Unlike EC2, you cannot default GCE instances to a region. Hence, we constrain to zones. */ @Override public Iterable<Location> listLocations() { Location provider = justProvider.get().iterator().next(); ImmutableList.Builder<Location> zones = ImmutableList.builder(); for (Region region : concat(api.regions().list())) { Location regionLocation = new LocationBuilder() .scope(LocationScope.REGION) .id(region.name()) .description(region.selfLink().toString()) .parent(provider).build(); for (URI zoneSelfLink : region.zones()) { String zoneName = toName(zoneSelfLink); zones.add(new LocationBuilder() .scope(LocationScope.ZONE) .id(zoneName) .description(zoneSelfLink.toString()) .parent(regionLocation).build()); } } return zones.build(); }