com.cloudconvert.resource.async.AsyncTasksResource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cloudconvert-java Show documentation
Show all versions of cloudconvert-java Show documentation
CloudConvert is an online file converter API - more than 200 different audio, video, document, ebook, archive, image, spreadsheet and presentation formats supported.
package com.cloudconvert.resource.async;
import com.cloudconvert.client.mapper.ObjectMapperProvider;
import com.cloudconvert.client.setttings.SettingsProvider;
import com.cloudconvert.dto.request.*;
import com.cloudconvert.dto.response.OperationResponse;
import com.cloudconvert.dto.response.Pageable;
import com.cloudconvert.dto.response.TaskResponse;
import com.cloudconvert.dto.result.AsyncResult;
import com.cloudconvert.executor.AsyncRequestExecutor;
import com.cloudconvert.resource.AbstractTasksResource;
import com.cloudconvert.resource.params.Filter;
import com.cloudconvert.resource.params.Include;
import com.cloudconvert.resource.params.Pagination;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
@Slf4j
public class AsyncTasksResource extends AbstractTasksResource,
AsyncResult>, AsyncResult, AsyncResult>> {
private final AsyncRequestExecutor asyncRequestExecutor;
public AsyncTasksResource(
final SettingsProvider settingsProvider, final ObjectMapperProvider objectMapperProvider, final AsyncRequestExecutor asyncRequestExecutor,
final AsyncConvertFilesResource asyncConvertFilesResource, final AsyncOptimizeFilesResource asyncOptimizeFilesResource,
final AsyncCaptureWebsitesResource asyncCaptureWebsitesResource, final AsyncMergeFilesResource asyncMergeFilesResource,
final AsyncCreateArchivesResource asyncCreateArchivesResource, final AsyncExecuteCommandsResource asyncExecuteCommandsResource,
final AsyncCreateThumbnailsResource asyncCreateThumbnailsResource
) {
super(settingsProvider, objectMapperProvider, asyncConvertFilesResource, asyncOptimizeFilesResource, asyncCaptureWebsitesResource,
asyncMergeFilesResource, asyncCreateArchivesResource, asyncExecuteCommandsResource, asyncCreateThumbnailsResource);
this.asyncRequestExecutor = asyncRequestExecutor;
}
public AsyncResult show(
@NotNull final String taskId
) throws IOException, URISyntaxException {
return show(taskId, ImmutableList.of());
}
public AsyncResult show(
@NotNull final String taskId, @NotNull final List includes
) throws IOException, URISyntaxException {
return asyncRequestExecutor.execute(getShowHttpUriRequest(taskId, includes), TASK_RESPONSE_TYPE_REFERENCE);
}
public AsyncResult wait(
@NotNull final String taskId
) throws IOException, URISyntaxException {
return asyncRequestExecutor.execute(getWaitHttpUriRequest(taskId), TASK_RESPONSE_TYPE_REFERENCE);
}
public AsyncResult> list() throws IOException, URISyntaxException {
return list(ImmutableMap.of());
}
public AsyncResult> list(
@NotNull final Map filters
) throws IOException, URISyntaxException {
return list(filters, ImmutableList.of());
}
@Override
public AsyncResult> list(
@NotNull final Map filters, @NotNull final List includes
) throws IOException, URISyntaxException {
return list(filters, includes, null);
}
@Override
public AsyncResult> list(
@NotNull final Map filters, @NotNull final List includes, @Nullable final Pagination pagination
) throws IOException, URISyntaxException {
return asyncRequestExecutor.execute(getListHttpUriRequest(filters, includes, pagination), TASK_RESPONSE_PAGEABLE_TYPE_REFERENCE);
}
public AsyncResult cancel(
@NotNull final String taskId
) throws IOException, URISyntaxException {
return asyncRequestExecutor.execute(getCancelHttpUriRequest(taskId), TASK_RESPONSE_TYPE_REFERENCE);
}
public AsyncResult retry(
@NotNull final String taskId
) throws IOException, URISyntaxException {
return asyncRequestExecutor.execute(getRetryHttpUriRequest(taskId), TASK_RESPONSE_TYPE_REFERENCE);
}
public AsyncResult delete(
@NotNull final String taskId
) throws IOException, URISyntaxException {
return asyncRequestExecutor.execute(getDeleteHttpUriRequest(taskId), VOID_TYPE_REFERENCE);
}
public AsyncResult> operations() throws IOException, URISyntaxException {
return operations(ImmutableMap.of());
}
public AsyncResult> operations(
@NotNull final Map filters
) throws IOException, URISyntaxException {
return operations(filters, ImmutableList.of());
}
public AsyncResult> operations(
@NotNull final Map filters, @NotNull final List includes
) throws IOException, URISyntaxException {
return operations(filters, includes, null);
}
public AsyncResult> operations(
@NotNull final Map filters, @NotNull final List includes, @Nullable final Boolean alternative
) throws IOException, URISyntaxException {
return asyncRequestExecutor.execute(getOperationsHttpUriRequest(filters, includes, alternative), OPERATION_RESPONSE_PAGEABLE_TYPE_REFERENCE);
}
@Override
public AsyncResult convert(
@NotNull final ConvertFilesTaskRequest convertFilesTaskRequest
) throws IOException, URISyntaxException {
return getAbstractConvertFilesResource().convert(convertFilesTaskRequest);
}
@Override
public AsyncResult> convertFormats() throws IOException, URISyntaxException {
return getAbstractConvertFilesResource().convertFormats();
}
@Override
public AsyncResult> convertFormats(
@NotNull final Map filters
) throws IOException, URISyntaxException {
return getAbstractConvertFilesResource().convertFormats(filters);
}
@Override
public AsyncResult> convertFormats(
@NotNull final Map filters, @NotNull final List includes
) throws IOException, URISyntaxException {
return getAbstractConvertFilesResource().convertFormats(filters, includes);
}
@Override
public AsyncResult> convertFormats(
@NotNull final Map filters, @NotNull final List includes, @Nullable final Boolean alternative
) throws IOException, URISyntaxException {
return getAbstractConvertFilesResource().convertFormats(filters, includes, alternative);
}
@Override
public AsyncResult optimize(
@NotNull final OptimizeFilesTaskRequest optimizeFilesTaskRequest
) throws IOException, URISyntaxException {
return getAbstractOptimizeFilesResource().optimize(optimizeFilesTaskRequest);
}
@Override
public AsyncResult capture(
@NotNull final CaptureWebsitesTaskRequest captureWebsitesTaskRequest
) throws IOException, URISyntaxException {
return getAbstractCaptureWebsitesResource().capture(captureWebsitesTaskRequest);
}
@Override
public AsyncResult merge(
@NotNull final MergeFilesTaskRequest mergeFilesTaskRequest
) throws IOException, URISyntaxException {
return getAbstractMergeFilesResource().merge(mergeFilesTaskRequest);
}
@Override
public AsyncResult archive(
@NotNull final CreateArchivesTaskRequest createArchivesTaskRequest
) throws IOException, URISyntaxException {
return getAbstractCreateArchivesResource().archive(createArchivesTaskRequest);
}
@Override
public AsyncResult command(
@NotNull final ExecuteCommandsTaskRequest executeCommandsTaskRequest
) throws IOException, URISyntaxException {
return getAbstractExecuteCommandsResource().command(executeCommandsTaskRequest);
}
@Override
public AsyncResult thumbnail(
@NotNull final CreateThumbnailsTaskRequest createThumbnailsTaskRequest
) throws IOException, URISyntaxException {
return getAbstractCreateThumbnailsResource().thumbnail(createThumbnailsTaskRequest);
}
@Override
public void close() throws IOException {
asyncRequestExecutor.close();
super.close();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy