use of com.google.api.services.translate.model.LanguagesResource in project google-cloud-java by GoogleCloudPlatform.
the class HttpTranslateRpc method listSupportedLanguages.
@Override
public List<LanguagesResource> listSupportedLanguages(Map<Option, ?> optionMap) {
try {
Map<String, ?> content = ImmutableMap.of("target", firstNonNull(Option.TARGET_LANGUAGE.getString(optionMap), options.getTargetLanguage()));
HttpRequest httpRequest = translate.getRequestFactory().buildPostRequest(buildTargetUrl("languages"), new JsonHttpContent(translate.getJsonFactory(), content)).setParser(translate.getObjectParser());
List<LanguagesResource> languages = httpRequest.execute().parseAs(LanguagesListResponse.class).getLanguages();
// .execute().getLanguages();
return languages != null ? languages : ImmutableList.<LanguagesResource>of();
} catch (IOException ex) {
throw translate(ex);
}
}
Aggregations