@Override public Set<? extends Location> get() { return ImmutableSet.of(new LocationBuilder().scope(LocationScope.PROVIDER).id(providerName) .description(endpointSupplier.get().toASCIIString()).iso3166Codes(isoCodesSupplier).build()); }
@Override public Set<? extends Location> get() { return ImmutableSet.of(new LocationBuilder().scope(LocationScope.PROVIDER).id(providerName) .description(endpointSupplier.get().toASCIIString()).iso3166Codes(isoCodesSupplier).build()); }
@Override public Location apply(Datacenter from) { return new LocationBuilder().scope(LocationScope.ZONE).id(from.id + "").description(from.name).parent( provider.get().get()).build(); }
@Override public Location apply(Option from) { LocationBuilder builder = new LocationBuilder().scope(LocationScope.ZONE).id(from.getId() + "").description( from.getDescription()).parent(provider); Map<String, Supplier<Set<String>>> isoCodesById = isoCodesByIdSupplier.get(); if (isoCodesById.containsKey(from.getId() + "")) builder.iso3166Codes(isoCodesById.get(from.getId() + "").get()); return builder.build(); } }
@Override public Location apply(Option from) { LocationBuilder builder = new LocationBuilder().scope(LocationScope.ZONE).id(from.getId() + "").description( from.getDescription()).parent(provider); Map<String, Supplier<Set<String>>> isoCodesById = isoCodesByIdSupplier.get(); if (isoCodesById.containsKey(from.getId() + "")) builder.iso3166Codes(isoCodesById.get(from.getId() + "").get()); return builder.build(); } }
@Override public Location apply(Zone input) { return new LocationBuilder() .description(input.getDescription().orNull()) .metadata(ImmutableMap.of("selfLink", (Object) checkNotNull(input.getSelfLink(), "zone URI"))) .id(input.getName()) .scope(LocationScope.ZONE) .parent(GOOGLE_PROVIDER_LOCATION) .build(); } }
@Override public Location apply(Realm from) { return new LocationBuilder().scope(LocationScope.ZONE).id(from.getHref().toASCIIString()).description(from.getName()).parent( new LocationBuilder().scope(LocationScope.PROVIDER).iso3166Codes(isoCodes).id(providerName).description( endpoint.get().toASCIIString()).parent(null).build()).build(); } }
@Override public Location apply(String datacenter) { return new LocationBuilder().scope(LocationScope.ZONE).description(datacenter).id(datacenter) // TODO: iso3166Codes .parent(Iterables.getOnlyElement(provider.get())).build(); }
@Override public Location apply(Zone zone) { return new LocationBuilder().scope(LocationScope.ZONE).metadata(ImmutableMap.<String, Object> of()) .description(zone.getName()).id(zone.getId()) .parent(Iterables.getOnlyElement(provider.get())).build(); }
private static Location createRegionLocation( BlobStoreProperties config, Location provider ) { return config.location != null ? new LocationBuilder() .scope( LocationScope.REGION ) .id( config.location ) .description( config.location ) .parent( provider ) .build() : null; }
@Override public Location apply(Datacenter datacenter) { return new LocationBuilder().scope(LocationScope.ZONE) .metadata(ImmutableMap.<String, Object>of()) .description(datacenter.getLongName()) .id(Long.toString(datacenter.getId())) .iso3166Codes(createIso3166Codes(datacenter.getLocationAddress())) .parent(Iterables.getOnlyElement(provider.get())) .build(); }
@Test public void test() throws SecurityException, NoSuchMethodException { JustProvider fn = new JustProvider("servo", Suppliers.ofInstance(URI.create("http://servo")), ImmutableSet.of("US")); assertEquals( fn.get(), ImmutableSet.of(new LocationBuilder().scope(LocationScope.PROVIDER).id("servo").description("http://servo") .iso3166Codes(ImmutableSet.of("US")).build())); }
@Override public Location apply(Datacenter datacenter) { return new LocationBuilder().scope(LocationScope.ZONE) .metadata(ImmutableMap.<String, Object>of()) .description(datacenter.getLongName()) .id(Long.toString(datacenter.getId())) .iso3166Codes(createIso3166Codes(datacenter.getLocationAddress())) .parent(Iterables.getOnlyElement(provider.get())) .build(); }
@Override public Location apply(Datacenter datacenter) { return new LocationBuilder().id(datacenter.getName()) .description(datacenter.getLongName()) .scope(LocationScope.ZONE) .iso3166Codes(createIso3166Codes(datacenter.getLocationAddress())) .parent(Iterables.getOnlyElement(provider.get())) .metadata(ImmutableMap.<String, Object>of("name", datacenter.getName())) .build(); }
public void testMatchWhenIdIsHref() { Location location = new LocationBuilder().id("http://foo").description("description") .scope(LocationScope.PROVIDER).build(); FindLocationForResource converter = new FindLocationForResource( Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(location))); assertEquals(converter.apply(new ReferenceTypeImpl("name", "type", URI.create("http://foo"))), location); }
@Override public Location apply(Datacenter datacenter) { return new LocationBuilder().id(datacenter.getName()) .description(datacenter.getLongName()) .scope(LocationScope.ZONE) .iso3166Codes(createIso3166Codes(datacenter.getLocationAddress())) .parent(Iterables.getOnlyElement(provider.get())) .metadata(ImmutableMap.<String, Object>of("name", datacenter.getName())) .build(); }
@Override public Location apply(Datacenter datacenter) { return new LocationBuilder().id(datacenter.getName()) .description(datacenter.getLongName()) .scope(LocationScope.ZONE) .iso3166Codes(createIso3166Codes(datacenter.getLocationAddress())) .parent(Iterables.getOnlyElement(provider.get())) .metadata(ImmutableMap.<String, Object>of("name", datacenter.getName())) .build(); }
@Test(expectedExceptions = NoSuchElementException.class) public void testGracefulWhenHrefIsntLocationId() { FindLocationForResource converter = new FindLocationForResource( Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(new LocationBuilder() .id("http://bar").description("description").scope(LocationScope.PROVIDER).build()))); converter.apply(new ReferenceTypeImpl("name", "type", URI.create("http://foo"))); }
@Test(expectedExceptions = NoSuchElementException.class) public void testGracefulWhenLocationIdIsntURI() { FindLocationForResource converter = new FindLocationForResource( Suppliers.<Set<? extends Location>> ofInstance(ImmutableSet.<Location> of(new LocationBuilder().id("1") .description("description").scope(LocationScope.PROVIDER).build()))); converter.apply(new ReferenceTypeImpl("name", "type", URI.create("http://foo"))); } }
@Override public ListenableFuture<Boolean> putBucketInRegion(@Nullable String region, String name, PutBucketOptions... optionsList) { region = region == null ? Region.US_STANDARD : region; final PutBucketOptions options = (optionsList.length == 0) ? new PutBucketOptions() : optionsList[0]; keyToAcl.put(name, options.getAcl()); return blobStore.createContainerInLocation(new LocationBuilder().scope(LocationScope.REGION).id(region) .description(region).build(), name); }