Class AsyncJobsResource
- All Implemented Interfaces:
Closeable,AutoCloseable
-
Field Summary
Fields inherited from class com.cloudconvert.resource.AbstractJobsResource
PATH_SEGMENT_JOBS, PATH_SEGMENT_WAITFields inherited from class com.cloudconvert.resource.AbstractResource
BEARER, HEADER_AUTHORIZATION, HEADER_USER_AGENT, INPUT_STREAM_TYPE_REFERENCE, JOB_RESPONSE_PAGEABLE_TYPE_REFERENCE, JOB_RESPONSE_TYPE_REFERENCE, MAP_STRING_TO_OBJECT_TYPE_REFERENCE, OPERATION_RESPONSE_PAGEABLE_TYPE_REFERENCE, TASK_RESPONSE_PAGEABLE_TYPE_REFERENCE, TASK_RESPONSE_TYPE_REFERENCE, USER_RESPONSE_TYPE_REFERENCE, V2, VALUE_USER_AGENT, VOID_TYPE_REFERENCE, WEBHOOKS_RESPONSE_PAGEABLE_TYPE_REFERENCE, WEBHOOKS_RESPONSE_TYPE_REFERENCE -
Constructor Summary
ConstructorsConstructorDescriptionAsyncJobsResource(SettingsProvider settingsProvider, ObjectMapperProvider objectMapperProvider, AsyncRequestExecutor asyncRequestExecutor) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()create(@NotNull Map<String, TaskRequest> tasks) Create a job with one ore more tasks.create(@NotNull Map<String, TaskRequest> tasks, @NotNull String tag) Create a job with one ore more tasks.Delete a job, including all tasks and data.list()List all jobs.List all jobs.List all jobs.list(@NotNull Map<Filter, String> filters, @NotNull List<Include> includes, @Nullable Pagination pagination) List all jobs.Show a job.Wait until the job status is finished or error.Methods inherited from class com.cloudconvert.resource.AbstractJobsResource
getCreateHttpUriRequest, getDeleteHttpUriRequest, getListHttpUriRequest, getShowHttpUriRequest, getWaitHttpUriRequestMethods inherited from class com.cloudconvert.resource.AbstractResource
getHttpEntity, getHttpEntity, getHttpUriRequest, getHttpUriRequest, getJson, getSyncUri, getSyncUri, getUri, getUri, requestToMap
-
Constructor Details
-
AsyncJobsResource
public AsyncJobsResource(SettingsProvider settingsProvider, ObjectMapperProvider objectMapperProvider, AsyncRequestExecutor asyncRequestExecutor)
-
-
Method Details
-
create
public AsyncResult<JobResponse> create(@NotNull @NotNull Map<String, TaskRequest> tasks) throws IOException, URISyntaxExceptionDescription copied from class:AbstractJobsResourceCreate a job with one ore more tasks. Requires the task.write scope.- Specified by:
createin classAbstractJobsResource<AsyncResult<JobResponse>,AsyncResult<Pageable<JobResponse>>, AsyncResult<Void>> - Parameters:
tasks- The example on the right consists of three tasks: import-my-file, convert-my-file and export-my-file. You can name these tasks however you want, but only alphanumeric characters, - and _ are allowed in the task names.Each task has a operation, which is the endpoint for creating the task (for example: convert, import/s3 or export/s3). The other parameters are the same as for creating the task using their direct endpoint. The input parameter allows it to directly reference the name of another task, created with the same job request.
- Returns:
AbstractJobsResource- Throws:
IOExceptionURISyntaxException
-
create
public AsyncResult<JobResponse> create(@NotNull @NotNull Map<String, TaskRequest> tasks, @NotNull @NotNull String tag) throws IOException, URISyntaxExceptionDescription copied from class:AbstractJobsResourceCreate a job with one ore more tasks. Requires the task.write scope.- Specified by:
createin classAbstractJobsResource<AsyncResult<JobResponse>,AsyncResult<Pageable<JobResponse>>, AsyncResult<Void>> - Parameters:
tasks- The example on the right consists of three tasks: import-my-file, convert-my-file and export-my-file. You can name these tasks however you want, but only alphanumeric characters, - and _ are allowed in the task names.Each task has a operation, which is the endpoint for creating the task (for example: convert, import/s3 or export/s3). The other parameters are the same as for creating the task using their direct endpoint. The input parameter allows it to directly reference the name of another task, created with the same job request.
tag- An arbitrary string to identify the job. Does not have any effect and can be used to associate the job with an ID in your application.- Returns:
AbstractJobsResource- Throws:
IOExceptionURISyntaxException
-
show
public AsyncResult<JobResponse> show(@NotNull @NotNull String jobId) throws IOException, URISyntaxException Description copied from class:AbstractJobsResourceShow a job. Requires the task.read scope.- Specified by:
showin classAbstractJobsResource<AsyncResult<JobResponse>,AsyncResult<Pageable<JobResponse>>, AsyncResult<Void>> - Parameters:
jobId- job id- Returns:
AbstractJobsResource- Throws:
IOExceptionURISyntaxException
-
wait
public AsyncResult<JobResponse> wait(@NotNull @NotNull String jobId) throws IOException, URISyntaxException Description copied from class:AbstractJobsResourceWait until the job status is finished or error. This makes the request block until the job has been completed. Requires the task.read scope.We do not recommend using this for long running jobs (e.g. video encodings). Your system might automatically time out requests if there is not data transferred for a longer time.
In general, please avoid to block your application until a CloudConvert job completes. There might be cases in which we need to queue your job which results in longer processing times than usual. Using an asynchronous approach with webhooks is beneficial in such cases.
- Specified by:
waitin classAbstractJobsResource<AsyncResult<JobResponse>,AsyncResult<Pageable<JobResponse>>, AsyncResult<Void>> - Parameters:
jobId- job id- Returns:
AbstractJobsResource- Throws:
IOExceptionURISyntaxException
-
list
Description copied from class:AbstractJobsResourceList all jobs. Requires the task.read scope.- Specified by:
listin classAbstractJobsResource<AsyncResult<JobResponse>,AsyncResult<Pageable<JobResponse>>, AsyncResult<Void>> - Returns:
AbstractJobsResource- Throws:
IOExceptionURISyntaxException
-
list
public AsyncResult<Pageable<JobResponse>> list(@NotNull @NotNull Map<Filter, String> filters) throws IOException, URISyntaxExceptionDescription copied from class:AbstractJobsResourceList all jobs. Requires the task.read scope.- Specified by:
listin classAbstractJobsResource<AsyncResult<JobResponse>,AsyncResult<Pageable<JobResponse>>, AsyncResult<Void>> - Parameters:
filters- (optional) Filters: - status - The result will be filtered to include only jobs with a specific status (processing, finished or error). - tag - The result will be filtered to include only jobs with a tag.- Returns:
AbstractJobsResource- Throws:
IOExceptionURISyntaxException
-
list
public AsyncResult<Pageable<JobResponse>> list(@NotNull @NotNull Map<Filter, String> filters, @NotNull @NotNull List<Include> includes) throws IOException, URISyntaxExceptionDescription copied from class:AbstractJobsResourceList all jobs. Requires the task.read scope.- Specified by:
listin classAbstractJobsResource<AsyncResult<JobResponse>,AsyncResult<Pageable<JobResponse>>, AsyncResult<Void>> - Parameters:
filters- (optional) Filters: - status - The result will be filtered to include only jobs with a specific status (processing, finished or error). - tag - The result will be filtered to include only jobs with a tag.includes- (optional) Include tasks in the result.- Returns:
AbstractJobsResource- Throws:
IOExceptionURISyntaxException
-
list
public AsyncResult<Pageable<JobResponse>> list(@NotNull @NotNull Map<Filter, String> filters, @NotNull @NotNull List<Include> includes, @Nullable @Nullable Pagination pagination) throws IOException, URISyntaxExceptionDescription copied from class:AbstractJobsResourceList all jobs. Requires the task.read scope.- Specified by:
listin classAbstractJobsResource<AsyncResult<JobResponse>,AsyncResult<Pageable<JobResponse>>, AsyncResult<Void>> - Parameters:
filters- (optional) Filters: - status - The result will be filtered to include only jobs with a specific status (processing, finished or error). - tag - The result will be filtered to include only jobs with a tag.includes- (optional) Include tasks in the result.pagination- (optional) Pagination: - per_page - Number of tasks per page, defaults to 100. - page - The result page to show.- Returns:
AbstractJobsResource- Throws:
IOExceptionURISyntaxException
-
delete
public AsyncResult<Void> delete(@NotNull @NotNull String jobId) throws IOException, URISyntaxException Description copied from class:AbstractJobsResourceDelete a job, including all tasks and data. Requires the task.write scope. Jobs are deleted automatically 24 hours after they have ended.- Specified by:
deletein classAbstractJobsResource<AsyncResult<JobResponse>,AsyncResult<Pageable<JobResponse>>, AsyncResult<Void>> - Parameters:
jobId- job id- Returns:
AbstractJobsResource- Throws:
IOExceptionURISyntaxException
-
close
- Throws:
IOException
-