mirror of
https://github.com/apache/jclouds.git
synced 2025-03-04 07:19:07 +00:00
update to latest snapshot
This commit is contained in:
parent
73c5ff84d9
commit
13406f433c
@ -22,7 +22,7 @@ import java.util.NoSuchElementException;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jclouds.ContextBuilder;
|
||||
import org.jclouds.Wrapper;
|
||||
import org.jclouds.View;
|
||||
import org.jclouds.apis.Apis;
|
||||
import org.jclouds.javax.annotation.Nullable;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
@ -122,8 +122,8 @@ public class ChefContextFactory {
|
||||
Object context = builder.build();
|
||||
if (context instanceof ChefContext) {
|
||||
return ChefContext.class.cast(context);
|
||||
} else if (context instanceof Wrapper) {
|
||||
Wrapper tctx = Wrapper.class.cast(context);
|
||||
} else if (context instanceof View) {
|
||||
View tctx = View.class.cast(context);
|
||||
return tctx.unwrap(TypeToken.of(ChefContext.class));
|
||||
} else {
|
||||
throw new IllegalArgumentException("provider " + providerOrApi + " contains an unknown context type: "
|
||||
|
@ -33,7 +33,7 @@ import org.jclouds.rest.binders.BindToStringPayload;
|
||||
public class BindClientnameToJsonPayload extends BindToStringPayload {
|
||||
|
||||
@Override
|
||||
public HttpRequest bindToRequest( HttpRequest request, Object payload ) {
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Object payload ) {
|
||||
super.bindToRequest(request, String.format("{\"clientname\":\"%s\"}", payload));
|
||||
request.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_JSON);
|
||||
return request;
|
||||
|
@ -33,7 +33,7 @@ import org.jclouds.rest.binders.BindToStringPayload;
|
||||
public class BindGenerateKeyForClientToJsonPayload extends BindToStringPayload {
|
||||
|
||||
@Override
|
||||
public HttpRequest bindToRequest( HttpRequest request, Object payload ) {
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Object payload ) {
|
||||
super.bindToRequest(request, String.format("{\"clientname\":\"%s\", \"private_key\": true}",
|
||||
payload));
|
||||
request.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_JSON);
|
||||
|
@ -33,8 +33,8 @@ import org.jclouds.rest.binders.BindToStringPayload;
|
||||
public class BindIsCompletedToJsonPayload extends BindToStringPayload {
|
||||
|
||||
@Override
|
||||
public HttpRequest bindToRequest( HttpRequest request, Object value ) {
|
||||
super.bindToRequest(request, String.format("{\"is_completed\":\"%s\"}", value));
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Object payload ) {
|
||||
super.bindToRequest(request, String.format("{\"is_completed\":\"%s\"}", payload));
|
||||
request.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_JSON);
|
||||
return request;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ import org.jclouds.rest.binders.BindToStringPayload;
|
||||
public class BindNameToJsonPayload extends BindToStringPayload {
|
||||
|
||||
@Override
|
||||
public HttpRequest bindToRequest( HttpRequest request, Object payload ) {
|
||||
public <R extends HttpRequest> R bindToRequest(R request, Object payload ) {
|
||||
super.bindToRequest(request, String.format("{\"name\":\"%s\"}", payload));
|
||||
request.getPayload().getContentMetadata().setContentType(MediaType.APPLICATION_JSON);
|
||||
return request;
|
||||
|
@ -18,7 +18,6 @@
|
||||
*/
|
||||
package org.jclouds.chef.config;
|
||||
|
||||
import static org.jclouds.Constants.PROPERTY_CREDENTIAL;
|
||||
import static org.jclouds.Constants.PROPERTY_SESSION_INTERVAL;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -43,10 +42,12 @@ import org.jclouds.http.annotation.Redirection;
|
||||
import org.jclouds.http.annotation.ServerError;
|
||||
import org.jclouds.io.InputSuppliers;
|
||||
import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.rest.annotations.Credential;
|
||||
import org.jclouds.rest.config.RestClientModule;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
/**
|
||||
@ -57,11 +58,11 @@ import com.google.inject.Provides;
|
||||
@ConfiguresRestClient
|
||||
public class BaseChefRestClientModule<S, A> extends RestClientModule<S, A> {
|
||||
|
||||
protected BaseChefRestClientModule(Class<S> syncClientType, Class<A> asyncClientType) {
|
||||
protected BaseChefRestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType) {
|
||||
super(syncClientType, asyncClientType);
|
||||
}
|
||||
|
||||
protected BaseChefRestClientModule(Class<S> syncClientType, Class<A> asyncClientType,
|
||||
protected BaseChefRestClientModule(TypeToken<S> syncClientType, TypeToken<A> asyncClientType,
|
||||
Map<Class<?>, Class<?>> delegates) {
|
||||
super(syncClientType, asyncClientType, delegates);
|
||||
}
|
||||
@ -87,7 +88,7 @@ public class BaseChefRestClientModule<S, A> extends RestClientModule<S, A> {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
public PrivateKey provideKey(Crypto crypto, @Named(PROPERTY_CREDENTIAL) String pem) throws InvalidKeySpecException,
|
||||
public PrivateKey provideKey(Crypto crypto, @Credential String pem) throws InvalidKeySpecException,
|
||||
IOException {
|
||||
return crypto.rsaKeyFactory().generatePrivate(Pems.privateKeySpec(InputSuppliers.of(pem)));
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ import org.jclouds.rest.ConfiguresRestClient;
|
||||
import org.jclouds.scriptbuilder.domain.Statement;
|
||||
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.name.Names;
|
||||
|
||||
@ -45,7 +46,7 @@ import com.google.inject.name.Names;
|
||||
public class ChefRestClientModule extends BaseChefRestClientModule<ChefClient, ChefAsyncClient> {
|
||||
|
||||
public ChefRestClientModule() {
|
||||
super(ChefClient.class, ChefAsyncClient.class);
|
||||
super(TypeToken.of(ChefClient.class), TypeToken.of(ChefAsyncClient.class));
|
||||
}
|
||||
|
||||
@Provides
|
||||
|
@ -19,7 +19,6 @@
|
||||
package org.jclouds.chef.filters;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkArgument;
|
||||
import static org.jclouds.Constants.PROPERTY_IDENTITY;
|
||||
|
||||
import java.security.PrivateKey;
|
||||
import java.util.NoSuchElementException;
|
||||
@ -47,6 +46,7 @@ import org.jclouds.io.payloads.MultipartForm;
|
||||
import org.jclouds.io.payloads.Part;
|
||||
import org.jclouds.io.payloads.RSAEncryptingPayload;
|
||||
import org.jclouds.logging.Logger;
|
||||
import org.jclouds.rest.annotations.Identity;
|
||||
import org.jclouds.util.Strings2;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
@ -82,7 +82,7 @@ public class SignedHeaderAuth implements HttpRequestFilter {
|
||||
Logger signatureLog = Logger.NULL;
|
||||
|
||||
@Inject
|
||||
public SignedHeaderAuth(SignatureWire signatureWire, @Named(PROPERTY_IDENTITY) String userId, PrivateKey privateKey,
|
||||
public SignedHeaderAuth(SignatureWire signatureWire, @Identity String userId, PrivateKey privateKey,
|
||||
@TimeStamp Provider<String> timeStampProvider, Crypto crypto, HttpUtils utils) {
|
||||
this.signatureWire = signatureWire;
|
||||
this.userId = userId;
|
||||
|
@ -18,10 +18,6 @@
|
||||
*/
|
||||
package org.jclouds.chef.internal;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@ -29,17 +25,12 @@ import org.jclouds.chef.ChefAsyncClient;
|
||||
import org.jclouds.chef.ChefClient;
|
||||
import org.jclouds.chef.ChefContext;
|
||||
import org.jclouds.chef.ChefService;
|
||||
import org.jclouds.domain.Credentials;
|
||||
import org.jclouds.lifecycle.Closer;
|
||||
import org.jclouds.location.Iso3166;
|
||||
import org.jclouds.location.Provider;
|
||||
import org.jclouds.providers.ProviderMetadata;
|
||||
import org.jclouds.rest.Utils;
|
||||
import org.jclouds.rest.annotations.ApiVersion;
|
||||
import org.jclouds.rest.annotations.BuildVersion;
|
||||
import org.jclouds.rest.annotations.Identity;
|
||||
import org.jclouds.rest.internal.RestContextImpl;
|
||||
|
||||
import com.google.common.base.Supplier;
|
||||
import com.google.inject.Injector;
|
||||
import com.google.inject.TypeLiteral;
|
||||
|
||||
@ -51,13 +42,10 @@ public class ChefContextImpl extends RestContextImpl<ChefClient, ChefAsyncClient
|
||||
private final ChefService chefService;
|
||||
|
||||
@Inject
|
||||
protected ChefContextImpl(Closer closer, Map<String, Credentials> credentialStore, Utils utils, Injector injector,
|
||||
@Provider Supplier<URI> endpoint, @Provider String provider, @Identity String identity,
|
||||
@ApiVersion String apiVersion, @BuildVersion String buildVersion, @Iso3166 Set<String> iso3166Codes,
|
||||
ChefService chefService) {
|
||||
super(closer, credentialStore, utils, injector, TypeLiteral.get(ChefClient.class), TypeLiteral
|
||||
.get(ChefAsyncClient.class), endpoint, buildVersion, buildVersion, buildVersion, buildVersion,
|
||||
iso3166Codes);
|
||||
protected ChefContextImpl(ProviderMetadata providerMetadata, @Identity String identity, Utils utils, Closer closer,
|
||||
Injector injector, ChefService chefService) {
|
||||
super(providerMetadata, identity, utils, closer, injector, TypeLiteral.get(ChefClient.class), TypeLiteral
|
||||
.get(ChefAsyncClient.class));
|
||||
this.chefService = chefService;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class ListClientsImpl implements ListClients {
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Client> execute(Iterable<String> toGet) {
|
||||
return transformParallel(toGet, new Function<String, Future<Client>>() {
|
||||
return transformParallel(toGet, new Function<String, Future<? extends Client>>() {
|
||||
|
||||
@Override
|
||||
public Future<Client> apply(String from) {
|
||||
|
@ -87,7 +87,7 @@ public class ListCookbookVersionsImpl implements ListCookbookVersions {
|
||||
public Iterable<? extends CookbookVersion> apply(final String cookbook) {
|
||||
// TODO getting each version could also go parallel
|
||||
return transformParallel(chefClient.getVersionsOfCookbook(cookbook),
|
||||
new Function<String, Future<CookbookVersion>>() {
|
||||
new Function<String, Future<? extends CookbookVersion>>() {
|
||||
|
||||
@Override
|
||||
public Future<CookbookVersion> apply(String version) {
|
||||
|
@ -79,7 +79,7 @@ public class ListNodesImpl implements ListNodes {
|
||||
|
||||
@Override
|
||||
public Iterable<? extends Node> execute(Iterable<String> toGet) {
|
||||
return transformParallel(toGet, new Function<String, Future<Node>>() {
|
||||
return transformParallel(toGet, new Function<String, Future<? extends Node>>() {
|
||||
|
||||
@Override
|
||||
public Future<Node> apply(String from) {
|
||||
|
@ -41,6 +41,7 @@ import org.jclouds.scriptbuilder.domain.Statement;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.inject.Module;
|
||||
import com.google.inject.Provides;
|
||||
import com.google.inject.name.Names;
|
||||
@ -52,7 +53,7 @@ import com.google.inject.name.Names;
|
||||
public class TransientChefClientModule extends BaseChefRestClientModule<TransientChefClient, ChefAsyncClient> {
|
||||
|
||||
public TransientChefClientModule() {
|
||||
super(TransientChefClient.class, ChefAsyncClient.class);
|
||||
super(TypeToken.of(TransientChefClient.class), TypeToken.of(ChefAsyncClient.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.jclouds.chef;
|
||||
|
||||
import org.jclouds.Wrapper;
|
||||
import org.jclouds.View;
|
||||
import org.jclouds.rest.internal.BaseRestApiMetadataTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -34,6 +34,6 @@ public class ChefApiMetadataTest extends BaseRestApiMetadataTest {
|
||||
|
||||
// no config management abstraction, yet
|
||||
public ChefApiMetadataTest() {
|
||||
super(new ChefApiMetadata(), ImmutableSet.<TypeToken<? extends Wrapper>> of());
|
||||
super(new ChefApiMetadata(), ImmutableSet.<TypeToken<? extends View>> of());
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
package org.jclouds.chef.test;
|
||||
|
||||
import org.jclouds.Wrapper;
|
||||
import org.jclouds.View;
|
||||
import org.jclouds.rest.internal.BaseRestApiMetadataTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -34,6 +34,6 @@ public class TransientChefApiMetadataTest extends BaseRestApiMetadataTest {
|
||||
|
||||
// no config management abstraction, yet
|
||||
public TransientChefApiMetadataTest() {
|
||||
super(new TransientChefApiMetadata(), ImmutableSet.<TypeToken<? extends Wrapper>> of());
|
||||
super(new TransientChefApiMetadata(), ImmutableSet.<TypeToken<? extends View>> of());
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user