com.cloudconvert.resource.sync.TasksResource 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.sync;
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.Result;
import com.cloudconvert.executor.RequestExecutor;
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.URI;
import java.net.URISyntaxException;
import java.util.List;
import java.util.Map;
@Slf4j
public class TasksResource extends AbstractTasksResource,
Result>, Result, Result>> {
private final RequestExecutor requestExecutor;
public TasksResource(
final SettingsProvider settingsProvider,
final ObjectMapperProvider objectMapperProvider, final RequestExecutor requestExecutor,
final ConvertFilesResource convertFilesResource, final OptimizeFilesResource optimizeFilesResource,
final CaptureWebsitesResource captureWebsitesResource, final MergeFilesResource mergeFilesResource,
final CreateArchivesResource createArchivesResource, final ExecuteCommandsResource executeCommandsResource,
final CreateThumbnailsResource createThumbnailsResource
) {
super(settingsProvider, objectMapperProvider, convertFilesResource, optimizeFilesResource, captureWebsitesResource,
mergeFilesResource, createArchivesResource, executeCommandsResource, createThumbnailsResource);
this.requestExecutor = requestExecutor;
}
public Result show(
@NotNull final String taskId
) throws IOException, URISyntaxException {
return show(taskId, ImmutableList.of());
}
public Result show(
@NotNull final String taskId, @NotNull final List includes
) throws IOException, URISyntaxException {
return requestExecutor.execute(getShowHttpUriRequest(taskId, includes), TASK_RESPONSE_TYPE_REFERENCE);
}
public Result wait(
@NotNull final String taskId
) throws IOException, URISyntaxException {
final URI uri = getUri(ImmutableList.of(PATH_SEGMENT_TASKS, taskId, PATH_SEGMENT_WAIT));
return requestExecutor.execute(getWaitHttpUriRequest(taskId), TASK_RESPONSE_TYPE_REFERENCE);
}
public Result> list() throws IOException, URISyntaxException {
return list(ImmutableMap.of());
}
public Result> list(
@NotNull final Map filters
) throws IOException, URISyntaxException {
return list(filters, ImmutableList.of());
}
@Override
public Result> list(
@NotNull final Map filters, @NotNull final List includes
) throws IOException, URISyntaxException {
return list(filters, includes, null);
}
@Override
public Result> list(
@NotNull final Map filters, @NotNull final List includes, @Nullable final Pagination pagination
) throws IOException, URISyntaxException {
return requestExecutor.execute(getListHttpUriRequest(filters, includes, pagination), TASK_RESPONSE_PAGEABLE_TYPE_REFERENCE);
}
public Result cancel(
@NotNull final String taskId
) throws IOException, URISyntaxException {
return requestExecutor.execute(getCancelHttpUriRequest(taskId), TASK_RESPONSE_TYPE_REFERENCE);
}
public Result retry(
@NotNull final String taskId
) throws IOException, URISyntaxException {
return requestExecutor.execute(getRetryHttpUriRequest(taskId), TASK_RESPONSE_TYPE_REFERENCE);
}
public Result delete(
@NotNull final String taskId
) throws IOException, URISyntaxException {
return requestExecutor.execute(getDeleteHttpUriRequest(taskId), VOID_TYPE_REFERENCE);
}
public Result> operations() throws IOException, URISyntaxException {
return operations(ImmutableMap.of());
}
public Result> operations(
@NotNull final Map filters
) throws IOException, URISyntaxException {
return operations(filters, ImmutableList.of());
}
public Result> operations(
@NotNull final Map filters, @NotNull final List includes
) throws IOException, URISyntaxException {
return operations(filters, includes, null);
}
public Result> operations(
@NotNull final Map filters, @NotNull final List includes, @Nullable final Boolean alternative
) throws IOException, URISyntaxException {
return requestExecutor.execute(getOperationsHttpUriRequest(filters, includes, alternative), OPERATION_RESPONSE_PAGEABLE_TYPE_REFERENCE);
}
@Override
public Result convert(
@NotNull final ConvertFilesTaskRequest convertFilesTaskRequest
) throws IOException, URISyntaxException {
return getAbstractConvertFilesResource().convert(convertFilesTaskRequest);
}
@Override
public Result> convertFormats() throws IOException, URISyntaxException {
return getAbstractConvertFilesResource().convertFormats();
}
@Override
public Result> convertFormats(
@NotNull final Map filters
) throws IOException, URISyntaxException {
return getAbstractConvertFilesResource().convertFormats(filters);
}
@Override
public Result> convertFormats(
@NotNull final Map filters, @NotNull final List includes
) throws IOException, URISyntaxException {
return getAbstractConvertFilesResource().convertFormats(filters, includes);
}
@Override
public Result> convertFormats(
@NotNull final Map filters, @NotNull final List includes, @Nullable final Boolean alternative
) throws IOException, URISyntaxException {
return getAbstractConvertFilesResource().convertFormats(filters, includes, alternative);
}
@Override
public Result optimize(
@NotNull final OptimizeFilesTaskRequest optimizeFilesTaskRequest
) throws IOException, URISyntaxException {
return getAbstractOptimizeFilesResource().optimize(optimizeFilesTaskRequest);
}
@Override
public Result capture(
@NotNull final CaptureWebsitesTaskRequest captureWebsitesTaskRequest
) throws IOException, URISyntaxException {
return getAbstractCaptureWebsitesResource().capture(captureWebsitesTaskRequest);
}
@Override
public Result merge(
@NotNull final MergeFilesTaskRequest mergeFilesTaskRequest
) throws IOException, URISyntaxException {
return getAbstractMergeFilesResource().merge(mergeFilesTaskRequest);
}
@Override
public Result archive(
@NotNull final CreateArchivesTaskRequest createArchivesTaskRequest
) throws IOException, URISyntaxException {
return getAbstractCreateArchivesResource().archive(createArchivesTaskRequest);
}
@Override
public Result command(
@NotNull final ExecuteCommandsTaskRequest executeCommandsTaskRequest
) throws IOException, URISyntaxException {
return getAbstractExecuteCommandsResource().command(executeCommandsTaskRequest);
}
@Override
public Result thumbnail(@NotNull CreateThumbnailsTaskRequest createThumbnailsTaskRequest
) throws IOException, URISyntaxException {
return getAbstractCreateThumbnailsResource().thumbnail(createThumbnailsTaskRequest);
}
@Override
public void close() throws IOException {
requestExecutor.close();
super.close();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy