Class JobQueryBuilder
- Namespace
- CivitaiSharp.Sdk.Request
- Assembly
- CivitaiSharp.Sdk.dll
Immutable, thread-safe builder for querying and managing job status. Each fluent method returns a new builder instance, allowing safe reuse and caching of base configurations.
public sealed record JobQueryBuilder : IEquatable<JobQueryBuilder>
- Inheritance
-
JobQueryBuilder
- Implements
- Inherited Members
Methods
CancelAsync(Guid, bool, CancellationToken)
Cancels a specific job by its unique identifier.
public Task<Result<Unit>> CancelAsync(Guid jobId, bool force = true, CancellationToken cancellationToken = default)
Parameters
jobIdGuidThe unique job identifier.
forceboolIf true, cancels even if the job is processing. Default is true.
cancellationTokenCancellationTokenToken to cancel the asynchronous operation.
Returns
Exceptions
- ArgumentOutOfRangeException
Thrown if jobId is empty.
CancelAsync(string, bool, CancellationToken)
Cancels jobs by their batch token.
public Task<Result<Unit>> CancelAsync(string token, bool force = true, CancellationToken cancellationToken = default)
Parameters
tokenstringThe batch token from a previous job submission.
forceboolIf true, cancels even if jobs are processing. Default is true.
cancellationTokenCancellationTokenToken to cancel the asynchronous operation.
Returns
Exceptions
- ArgumentException
Thrown if token is null or whitespace.
ExecuteAsync(CancellationToken)
Executes a query for jobs matching the configured property filters.
public Task<Result<JobStatusCollection>> ExecuteAsync(CancellationToken cancellationToken = default)
Parameters
cancellationTokenCancellationTokenToken to cancel the asynchronous operation.
Returns
- Task<Result<JobStatusCollection>>
A task containing the matching jobs.
Remarks
Use WhereProperty or WhereProperties(IReadOnlyDictionary<string, JsonElement>) to add filters before calling this method.
Exceptions
- InvalidOperationException
Thrown if no property filters are configured.
GetByIdAsync(Guid, CancellationToken)
Gets the status of a specific job by its unique identifier.
public Task<Result<JobStatus>> GetByIdAsync(Guid jobId, CancellationToken cancellationToken = default)
Parameters
jobIdGuidThe unique job identifier.
cancellationTokenCancellationTokenToken to cancel the asynchronous operation.
Returns
Exceptions
- ArgumentOutOfRangeException
Thrown if jobId is empty.
GetByTokenAsync(string, CancellationToken)
Gets the status of jobs by their batch token from a previous submission.
public Task<Result<JobStatusCollection>> GetByTokenAsync(string token, CancellationToken cancellationToken = default)
Parameters
tokenstringThe batch token from a previous job submission.
cancellationTokenCancellationTokenToken to cancel the asynchronous operation.
Returns
- Task<Result<JobStatusCollection>>
A task containing the job status collection.
Exceptions
- ArgumentException
Thrown if token is null or whitespace.
TaintAsync(Guid, CancellationToken)
Marks a specific job as tainted by its unique identifier.
public Task<Result<Unit>> TaintAsync(Guid jobId, CancellationToken cancellationToken = default)
Parameters
jobIdGuidThe unique job identifier.
cancellationTokenCancellationTokenToken to cancel the asynchronous operation.
Returns
Exceptions
- ArgumentOutOfRangeException
Thrown if jobId is empty.
TaintAsync(string, CancellationToken)
Marks jobs as tainted by their batch token.
public Task<Result<Unit>> TaintAsync(string token, CancellationToken cancellationToken = default)
Parameters
tokenstringThe batch token from a previous job submission.
cancellationTokenCancellationTokenToken to cancel the asynchronous operation.
Returns
Exceptions
- ArgumentException
Thrown if token is null or whitespace.
WhereProperties(IReadOnlyDictionary<string, JsonElement>)
Adds multiple custom property filters to the query.
public JobQueryBuilder WhereProperties(IReadOnlyDictionary<string, JsonElement> properties)
Parameters
propertiesIReadOnlyDictionary<string, JsonElement>Dictionary of property key-value pairs to filter by.
Returns
- JobQueryBuilder
A new builder instance with the added property filters.
Remarks
Multiple property filters are combined with AND logic - all must match.
WhereProperty(string, bool)
Adds a custom boolean property filter to the query.
public JobQueryBuilder WhereProperty(string key, bool value)
Parameters
Returns
- JobQueryBuilder
A new builder instance with the added property filter.
WhereProperty(string, DateTime)
Adds a custom DateTime property filter to the query.
public JobQueryBuilder WhereProperty(string key, DateTime value)
Parameters
Returns
- JobQueryBuilder
A new builder instance with the added property filter.
WhereProperty(string, decimal)
Adds a custom decimal property filter to the query.
public JobQueryBuilder WhereProperty(string key, decimal value)
Parameters
Returns
- JobQueryBuilder
A new builder instance with the added property filter.
WhereProperty(string, Guid)
Adds a custom GUID property filter to the query.
public JobQueryBuilder WhereProperty(string key, Guid value)
Parameters
Returns
- JobQueryBuilder
A new builder instance with the added property filter.
WhereProperty(string, int)
Adds a custom integer property filter to the query.
public JobQueryBuilder WhereProperty(string key, int value)
Parameters
Returns
- JobQueryBuilder
A new builder instance with the added property filter.
WhereProperty(string, long)
Adds a custom long property filter to the query.
public JobQueryBuilder WhereProperty(string key, long value)
Parameters
Returns
- JobQueryBuilder
A new builder instance with the added property filter.
WhereProperty(string, string)
Adds a custom string property filter to the query.
public JobQueryBuilder WhereProperty(string key, string value)
Parameters
Returns
- JobQueryBuilder
A new builder instance with the added property filter.
WithDetailed()
Configures the query to include detailed job specifications in responses.
public JobQueryBuilder WithDetailed()
Returns
- JobQueryBuilder
A new builder instance with detailed mode enabled.
WithWait()
Configures the query to wait for job completion (blocks up to ~10 minutes).
public JobQueryBuilder WithWait()
Returns
- JobQueryBuilder
A new builder instance with wait mode enabled.
Remarks
When enabled, the API will block until jobs complete or timeout (~10 minutes). This is useful when you need immediate results without manual polling.