0

Is it possible to use the servicenet when using the cloud files api in Java? Currently I'm using it as follows:

ContextBuilder cb = ContextBuilder.newBuilder(config.getProvider())
    .credentials(config.getUserName(), config.getApiKey()).modules(modules);
CloudFilesApi cfa = cb.buildApi(CloudFilesApi.class);

I'm asking this because I used to use the python client which has a boolean parameter in order to choose whether to use the public or the service net:

cf = pyrax.connect_to_cloudfiles(region=CDN_REGION, public=CDN_USEPUBLIC)
se7entyse7en
  • 4,310
  • 7
  • 33
  • 50

1 Answers1

0
Iterable<Module> modules = ImmutableSet.<Module> of(new SLF4JLoggingModule(),
        new InternalUrlModule());

ContextBuilder builder = ContextBuilder.newBuilder(PROVIDER)
        .modules(modules)
        .credentials(username, apiKey);
  blobStore = builder.buildView(RegionScopedBlobStoreContext.class).getBlobStore(REGION);
  cloudFiles = blobStore.getContext().unwrapApi(CloudFilesApi.class);

You need to make sure to add the InternalUrlModule to the list of modules. This in turn will make jclouds use the applicable ServiceNet endpoints when connecting to the service.

zacksh
  • 196
  • 5