Skip to main content

JobBuilder

Struct JobBuilder 

Source
pub struct JobBuilder { /* private fields */ }
Expand description

Builder for serial JobCreateRequest pipelines.

For linear jobs, use the fluent task shorthands and let the SDK wire each task to the previous task.

use cloudconvert_sdk::{FileExtension, JobCreateRequest};

let request = JobCreateRequest::linear()
    .import_url("https://example.test/input.docx")
    .convert(FileExtension::Pdf)
    .export_url()
    .build();

let payload = serde_json::to_value(request).unwrap();
assert_eq!(payload["tasks"]["export-url"]["input"], "convert");

Use *_with(...) methods when a task needs options. Use JobCreateRequest::graph when a later task needs a handle to a specific earlier task.

Implementations§

Source§

impl JobBuilder

Source

pub fn new() -> Self

Creates an empty job builder.

Source

pub fn tag(self, tag: impl Into<String>) -> Self

Sets an optional job tag.

Source

pub fn webhook_url(self, webhook_url: impl Into<String>) -> Self

Sets the webhook URL CloudConvert should call for this job.

Source

pub fn redirect(self, redirect: bool) -> Self

Sets whether CloudConvert should redirect on synchronous job completion.

Source

pub fn option(self, key: impl Into<String>, value: impl Into<Value>) -> Self

Adds a custom top-level job field.

Source

pub fn task(self, name: impl Into<String>, task: impl Into<TaskRequest>) -> Self

Adds a task with an explicit CloudConvert task name.

This keeps compatibility with CloudConvert’s keyed task object and with existing code that already depends on task names.

Source

pub fn add_task(&mut self, task: impl Into<TaskRequest>) -> TaskName

Adds a task with a generated name and returns that name as a handle.

Generated names are derived from the task operation, such as import-url, convert, or export-url. Duplicate operation names get numeric suffixes.

use cloudconvert_sdk::{ConvertTask, FileExtension, JobCreateRequest, TaskRequest};

let mut builder = JobCreateRequest::builder();
let import = builder.add_task(TaskRequest::import_url("https://example.test/input.docx"));
let convert = builder.add_task(ConvertTask::new(&import, FileExtension::Pdf));

assert_eq!(import.as_str(), "import-url");
assert_eq!(convert.as_str(), "convert");
Source

pub fn add_named_task( &mut self, name: impl Into<String>, task: impl Into<TaskRequest>, ) -> TaskName

Adds a task with an explicit name and returns that name as a handle.

Source

pub fn import_url(self, url: impl Into<String>) -> Self

Appends an import/url task.

Source

pub fn import_upload(self) -> Self

Appends an import/upload task.

Source

pub fn import_base64( self, file: impl Into<String>, filename: impl Into<String>, ) -> Self

Appends an import/base64 task.

Source

pub fn import_raw( self, file: impl Into<String>, filename: impl Into<String>, ) -> Self

Appends an import/raw task.

Source

pub fn import_s3( self, bucket: impl Into<String>, region: impl Into<String>, access_key_id: impl Into<String>, secret_access_key: impl Into<String>, ) -> Self

Appends an import/s3 task.

Source

pub fn import_azure_blob( self, storage_account: impl Into<String>, container: impl Into<String>, ) -> Self

Appends an import/azure/blob task.

Source

pub fn import_google_cloud_storage( self, project_id: impl Into<String>, bucket: impl Into<String>, client_email: impl Into<String>, private_key: impl Into<String>, ) -> Self

Appends an import/google-cloud-storage task.

Source

pub fn import_openstack( self, auth_url: impl Into<String>, username: impl Into<String>, password: impl Into<String>, region: impl Into<String>, container: impl Into<String>, ) -> Self

Appends an import/openstack task.

Source

pub fn import_sftp( self, host: impl Into<String>, username: impl Into<String>, ) -> Self

Appends an import/sftp task.

Source

pub fn convert(self, output_format: impl Into<String>) -> Self

Appends a convert task using the previous task as input.

Source

pub fn convert_with_input_format( self, input_format: impl Into<String>, output_format: impl Into<String>, ) -> Self

Appends a convert task with an explicit input format.

Source

pub fn optimize(self) -> Self

Appends an optimize task using the previous task as input.

Source

pub fn watermark_text(self, text: impl Into<String>) -> Self

Appends a text watermark task using the previous task as input.

Source

pub fn watermark_image(self, image_task_name: impl Into<String>) -> Self

Appends an image watermark task using the previous task as input.

Source

pub fn capture_website( self, url: impl Into<String>, output_format: impl Into<String>, ) -> Self

Appends a capture-website task.

Source

pub fn thumbnail(self, output_format: impl Into<String>) -> Self

Appends a thumbnail task using the previous task as input.

Source

pub fn metadata(self) -> Self

Appends a metadata task using the previous task as input.

Source

pub fn metadata_write(self) -> Self

Appends a metadata/write task using the previous task as input.

Source

pub fn merge(self, output_format: impl Into<String>) -> Self

Appends a merge task using the previous task as input.

Source

pub fn archive(self, output_format: impl Into<String>) -> Self

Appends an archive task using the previous task as input.

Source

pub fn command( self, engine: impl Into<String>, command: impl Into<String>, arguments: impl Into<String>, ) -> Self

Appends a command task using the previous task as input.

Source

pub fn pdf_a(self) -> Self

Appends a PDF operation task using the previous task as input.

Source

pub fn pdf_a_with<F>(self, configure: F) -> Self
where F: FnOnce(PdfATask) -> PdfATask,

Appends and configures a PDF operation task using the previous task as input.

Source

pub fn pdf_x(self) -> Self

Appends a PDF operation task using the previous task as input.

Source

pub fn pdf_x_with<F>(self, configure: F) -> Self
where F: FnOnce(PdfXTask) -> PdfXTask,

Appends and configures a PDF operation task using the previous task as input.

Source

pub fn pdf_ocr(self) -> Self

Appends a PDF operation task using the previous task as input.

Source

pub fn pdf_ocr_with<F>(self, configure: F) -> Self

Appends and configures a PDF operation task using the previous task as input.

Source

pub fn pdf_encrypt(self) -> Self

Appends a PDF operation task using the previous task as input.

Source

pub fn pdf_encrypt_with<F>(self, configure: F) -> Self

Appends and configures a PDF operation task using the previous task as input.

Source

pub fn pdf_decrypt(self) -> Self

Appends a PDF operation task using the previous task as input.

Source

pub fn pdf_decrypt_with<F>(self, configure: F) -> Self

Appends and configures a PDF operation task using the previous task as input.

Source

pub fn pdf_split_pages(self) -> Self

Appends a PDF operation task using the previous task as input.

Source

pub fn pdf_split_pages_with<F>(self, configure: F) -> Self

Appends and configures a PDF operation task using the previous task as input.

Source

pub fn pdf_extract_pages(self) -> Self

Appends a PDF operation task using the previous task as input.

Source

pub fn pdf_extract_pages_with<F>(self, configure: F) -> Self

Appends and configures a PDF operation task using the previous task as input.

Source

pub fn pdf_rotate_pages(self) -> Self

Appends a PDF operation task using the previous task as input.

Source

pub fn pdf_rotate_pages_with<F>(self, configure: F) -> Self

Appends and configures a PDF operation task using the previous task as input.

Source

pub fn export_url(self) -> Self

Appends an export/url task using the previous task as input.

Source

pub fn export_s3( self, bucket: impl Into<String>, region: impl Into<String>, access_key_id: impl Into<String>, secret_access_key: impl Into<String>, ) -> Self

Appends an export/s3 task using the previous task as input.

Source

pub fn export_azure_blob( self, storage_account: impl Into<String>, container: impl Into<String>, ) -> Self

Appends an export/azure/blob task using the previous task as input.

Source

pub fn export_google_cloud_storage( self, project_id: impl Into<String>, bucket: impl Into<String>, client_email: impl Into<String>, private_key: impl Into<String>, ) -> Self

Appends an export/google-cloud-storage task using the previous task as input.

Source

pub fn export_openstack( self, auth_url: impl Into<String>, username: impl Into<String>, password: impl Into<String>, region: impl Into<String>, container: impl Into<String>, ) -> Self

Appends an export/openstack task using the previous task as input.

Source

pub fn export_sftp( self, host: impl Into<String>, username: impl Into<String>, ) -> Self

Appends an export/sftp task using the previous task as input.

Source

pub fn export_upload(self, url: impl Into<String>) -> Self

Appends an export/upload task using the previous task as input.

Source

pub fn import_url_with<F>(self, url: impl Into<String>, configure: F) -> Self

Appends and configures an import/url task.

Source

pub fn import_upload_with<F>(self, configure: F) -> Self

Appends and configures an import/upload task.

Source

pub fn import_s3_with<F>( self, bucket: impl Into<String>, region: impl Into<String>, access_key_id: impl Into<String>, secret_access_key: impl Into<String>, configure: F, ) -> Self

Appends and configures an import/s3 task.

Source

pub fn import_azure_blob_with<F>( self, storage_account: impl Into<String>, container: impl Into<String>, configure: F, ) -> Self

Appends and configures an import/azure/blob task.

Source

pub fn import_google_cloud_storage_with<F>( self, project_id: impl Into<String>, bucket: impl Into<String>, client_email: impl Into<String>, private_key: impl Into<String>, configure: F, ) -> Self

Appends and configures an import/google-cloud-storage task.

Source

pub fn import_openstack_with<F>( self, auth_url: impl Into<String>, username: impl Into<String>, password: impl Into<String>, region: impl Into<String>, container: impl Into<String>, configure: F, ) -> Self

Appends and configures an import/openstack task.

Source

pub fn import_sftp_with<F>( self, host: impl Into<String>, username: impl Into<String>, configure: F, ) -> Self

Appends and configures an import/sftp task.

Source

pub fn convert_with<F>( self, output_format: impl Into<String>, configure: F, ) -> Self

Appends and configures a convert task using the previous task as input.

Source

pub fn optimize_with<F>(self, configure: F) -> Self

Appends and configures an optimize task using the previous task as input.

Source

pub fn watermark_text_with<F>( self, text: impl Into<String>, configure: F, ) -> Self

Appends and configures a text watermark task using the previous task as input.

Source

pub fn watermark_image_with<F>( self, image_task_name: impl Into<String>, configure: F, ) -> Self

Appends and configures an image watermark task using the previous task as input.

Source

pub fn capture_website_with<F>( self, url: impl Into<String>, output_format: impl Into<String>, configure: F, ) -> Self

Appends and configures a capture-website task.

Source

pub fn thumbnail_with<F>( self, output_format: impl Into<String>, configure: F, ) -> Self

Appends and configures a thumbnail task using the previous task as input.

Source

pub fn metadata_with<F>(self, configure: F) -> Self

Appends and configures a metadata task using the previous task as input.

Source

pub fn metadata_write_with<F>(self, configure: F) -> Self

Appends and configures a metadata/write task using the previous task as input.

Source

pub fn merge_with<F>( self, output_format: impl Into<String>, configure: F, ) -> Self
where F: FnOnce(MergeTask) -> MergeTask,

Appends and configures a merge task using the previous task as input.

Source

pub fn archive_with<F>( self, output_format: impl Into<String>, configure: F, ) -> Self

Appends and configures an archive task using the previous task as input.

Source

pub fn command_with<F>( self, engine: impl Into<String>, command: impl Into<String>, arguments: impl Into<String>, configure: F, ) -> Self

Appends and configures a command task using the previous task as input.

Source

pub fn export_url_with<F>(self, configure: F) -> Self

Appends and configures an export/url task using the previous task as input.

Source

pub fn export_s3_with<F>( self, bucket: impl Into<String>, region: impl Into<String>, access_key_id: impl Into<String>, secret_access_key: impl Into<String>, configure: F, ) -> Self

Appends and configures an export/s3 task using the previous task as input.

Source

pub fn export_azure_blob_with<F>( self, storage_account: impl Into<String>, container: impl Into<String>, configure: F, ) -> Self

Appends and configures an export/azure/blob task using the previous task as input.

Source

pub fn export_google_cloud_storage_with<F>( self, project_id: impl Into<String>, bucket: impl Into<String>, client_email: impl Into<String>, private_key: impl Into<String>, configure: F, ) -> Self

Appends and configures an export/google-cloud-storage task using the previous task as input.

Source

pub fn export_openstack_with<F>( self, auth_url: impl Into<String>, username: impl Into<String>, password: impl Into<String>, region: impl Into<String>, container: impl Into<String>, configure: F, ) -> Self

Appends and configures an export/openstack task using the previous task as input.

Source

pub fn export_sftp_with<F>( self, host: impl Into<String>, username: impl Into<String>, configure: F, ) -> Self

Appends and configures an export/sftp task using the previous task as input.

Source

pub fn export_upload_with<F>(self, url: impl Into<String>, configure: F) -> Self

Appends and configures an export/upload task using the previous task as input.

Source

pub fn build(self) -> JobCreateRequest

Finishes the builder and returns the job creation request.

Trait Implementations§

Source§

impl Clone for JobBuilder

Source§

fn clone(&self) -> JobBuilder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for JobBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for JobBuilder

Source§

fn default() -> JobBuilder

Returns the “default value” for a type. Read more
Source§

impl From<JobBuilder> for JobCreateRequest

Source§

fn from(builder: JobBuilder) -> Self

Converts to this type from the input type.
Source§

impl From<JobGraphBuilder> for JobBuilder

Source§

fn from(builder: JobGraphBuilder) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more