/**
* This file was automatically generated by the Mule Development Kit
*/
package org.mule.modules;
import java.io.IOException;
import org.apache.commons.httpclient.HttpClient;
import org.mule.api.annotations.Configurable;
import org.mule.api.annotations.Connector;
import org.mule.api.annotations.Processor;
import org.mule.api.annotations.rest.HttpMethod;
import org.mule.api.annotations.rest.RestCall;
import org.mule.api.annotations.rest.RestExceptionOn;
import org.mule.api.annotations.rest.RestHttpClient;
import org.mule.api.annotations.rest.RestUriParam;
import org.mule.modules.TranslateException;
/**
* Cloud Connector
*
* @author MuleSoft, Inc.
*/
@Connector(name="restclient", schemaVersion="1.0-SNAPSHOT")
public abstract class RestClientConnector
{
//<start id="lis_13_httpclient"/>
@RestHttpClient
HttpClient client = new HttpClient();
//<end id="lis_13_httpclient"/>
//<start id="lis_13_restcall"/>
@Processor @RestCall(uri =
"https://www.googleapis.com/language/translate/v2" +
"?key={apiKey}&source={sourceLang}&target={destLang}" +
"&q={text}",
method = HttpMethod.GET,
contentType ="application/json")
public abstract Object translate(
@RestUriParam("apiKey") String apiKey,
@RestUriParam("sourceLang") String sourceLang,
@RestUriParam("destLang") String destLang,
@RestUriParam("text") String text)
throws IOException;
//<end id="lis_13_restcall"/>
//<start id="lis_13_configurable-resturi"/>
@RestUriParam("apiKey")
@Configurable
private String apiKey;
//<end id="lis_13_configurable-resturi"/>
//<start id="lis_13_configurable-resturi-exception"/>
@Processor
@RestCall(uri =
"https://www.googleapis.com/language/translate/v2" +
"?key={apiKey}&source={sourceLang}&target={destLang}" +
"&q={text}", method = HttpMethod.GET,
exceptions=
@RestExceptionOn(
exception = TranslateException.class,
expression = "#[header:http.status != 200]"))
//<end id="lis_13_configurable-resturi-exception"/>
public abstract Object translateOrThrow(
@RestUriParam("apiKey") String apiKey,
@RestUriParam("sourceLang") String sourceLang,
@RestUriParam("destLang") String destLang,
@RestUriParam("text") String text)
throws IOException;
public String getApiKey() {
return apiKey;
}
public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}
public HttpClient getClient() {
return client;
}
public void setClient(HttpClient client) {
this.client = client;
}
}