Search in sources :

Example 1 with ApiClient

use of com.haleconnect.api.project.v0_1.ApiClient in project hale by halestudio.

the class BucketServiceHelper method getApiClient.

/**
 * @param resolver the base path resolver
 * @param apiKey JWT for authentication
 * @return ApiClient for the bucket service
 */
public static ApiClient getApiClient(BasePathResolver resolver, String apiKey) {
    ApiClient apiClient = new ApiClient();
    ApiClientHelper.setApiClientProperties(apiClient, HaleConnectServices.BUCKET_SERVICE, resolver, apiKey);
    return apiClient;
}
Also used : ApiClient(com.haleconnect.api.bucket.v1.ApiClient)

Example 2 with ApiClient

use of com.haleconnect.api.project.v0_1.ApiClient in project hale by halestudio.

the class ProjectServiceHelper method getApiClient.

/**
 * @param resolver the base path resolver
 * @param apiKey JWT for authentication
 * @return ApiClient for the project store
 */
public static ApiClient getApiClient(BasePathResolver resolver, String apiKey) {
    ApiClient apiClient = new ApiClient();
    ApiClientHelper.setApiClientProperties(apiClient, HaleConnectServices.BUCKET_SERVICE, resolver, apiKey);
    return apiClient;
}
Also used : ApiClient(com.haleconnect.api.project.v0_1.ApiClient)

Example 3 with ApiClient

use of com.haleconnect.api.project.v0_1.ApiClient in project hale by halestudio.

the class ProjectStoreHelper method getApiClient.

/**
 * @param resolver the base path resolver
 * @param apiKey JWT for authentication
 * @return ApiClient for the project store
 */
public static ApiClient getApiClient(BasePathResolver resolver, String apiKey) {
    ApiClient apiClient = new ApiClient();
    ApiClientHelper.setApiClientProperties(apiClient, HaleConnectServices.PROJECT_STORE, resolver, apiKey);
    return apiClient;
}
Also used : ApiClient(com.haleconnect.api.projectstore.v1.ApiClient)

Example 4 with ApiClient

use of com.haleconnect.api.project.v0_1.ApiClient in project hale by halestudio.

the class ProjectStoreHelper method executePlainTextCallWithFeedback.

/**
 * Execute a REST call with the content type <code>text/plain; charset=utf-8
 * </code>
 *
 * @param method HTTP method (POST, PUT)
 * @param path REST path (without base path)
 * @param body The plain text bdoy
 * @param basePath The REST base path
 * @param apiKey The API key
 * @return the feedback
 * @throws HaleConnectException thrown on any API error
 */
public static Feedback executePlainTextCallWithFeedback(String method, String path, String body, BasePathResolver basePath, String apiKey) throws HaleConnectException {
    ApiClient apiClient = ProjectStoreHelper.getApiClient(basePath, apiKey);
    OkHttpClient httpClient = apiClient.getHttpClient();
    String url = apiClient.buildUrl(path, null);
    Request.Builder reqBuilder = new Request.Builder().url(url);
    Map<String, String> headerParams = new HashMap<String, String>();
    apiClient.updateParamsForAuth(new String[] { "bearer" }, null, headerParams);
    apiClient.processHeaderParams(headerParams, reqBuilder);
    RequestBody reqBody = RequestBody.create(MediaType.parse("text/plain; charset=utf-8"), body);
    Request request = reqBuilder.method(method, reqBody).build();
    Call call = httpClient.newCall(request);
    Feedback feedback;
    try {
        ApiResponse<Feedback> resp = apiClient.execute(call, new TypeToken<Feedback>() {
        }.getType());
        feedback = resp.getData();
    } catch (com.haleconnect.api.projectstore.v1.ApiException e) {
        throw new HaleConnectException(e.getMessage(), e);
    }
    return feedback;
}
Also used : Call(com.squareup.okhttp.Call) OkHttpClient(com.squareup.okhttp.OkHttpClient) HashMap(java.util.HashMap) Request(com.squareup.okhttp.Request) HaleConnectException(eu.esdihumboldt.hale.io.haleconnect.HaleConnectException) ApiClient(com.haleconnect.api.projectstore.v1.ApiClient) Feedback(com.haleconnect.api.projectstore.v1.model.Feedback) TypeToken(com.google.gson.reflect.TypeToken) RequestBody(com.squareup.okhttp.RequestBody)

Example 5 with ApiClient

use of com.haleconnect.api.project.v0_1.ApiClient in project hale by halestudio.

the class UserServiceHelper method getApiClient.

/**
 * @param resolver the base path resolver
 * @param apiKey JWT for authentication
 * @return ApiClient for the user service
 */
public static ApiClient getApiClient(BasePathResolver resolver, String apiKey) {
    ApiClient apiClient = new ApiClient();
    ApiClientHelper.setApiClientProperties(apiClient, HaleConnectServices.USER_SERVICE, resolver, apiKey);
    return apiClient;
}
Also used : ApiClient(com.haleconnect.api.user.v1.ApiClient)

Aggregations

ApiClient (com.haleconnect.api.projectstore.v1.ApiClient)2 TypeToken (com.google.gson.reflect.TypeToken)1 ApiClient (com.haleconnect.api.bucket.v1.ApiClient)1 ApiClient (com.haleconnect.api.project.v0_1.ApiClient)1 Feedback (com.haleconnect.api.projectstore.v1.model.Feedback)1 ApiClient (com.haleconnect.api.user.v1.ApiClient)1 Call (com.squareup.okhttp.Call)1 OkHttpClient (com.squareup.okhttp.OkHttpClient)1 Request (com.squareup.okhttp.Request)1 RequestBody (com.squareup.okhttp.RequestBody)1 HaleConnectException (eu.esdihumboldt.hale.io.haleconnect.HaleConnectException)1 HashMap (java.util.HashMap)1