Jobs client

The Web SDK provides a Jobs client to perform CRUD operations on entities with the following methods.

Note

To help you update code from the Entities client to Jobs client, we provide several examples.

GetTargetsAsync

This method retrieves the targets for a job and supports the JobTargetQuery request parameter, This parameter is the job target query request and represents a request for job targets with various filtering options. It allows you to specify criteria to narrow down the job targets you are interested in.

The properties supported by this method are listed in the following table.

Property

Type

Description

JobId

long

The unique ID of the job.

State

string?

The state of the job target. This can be used to filter targets based on their current state.

Condition

string?

The condition of the job target. This can be used to filter targets based on specific conditions.

Type

string?

The type of the job target. This can be used to filter targets based on their type.

Location

string?

The location of the job target. This can be used to filter targets based on their geographical location.

Skip

int

The number of records to skip. This is useful for pagination.

Take

int

The number of records to take. This is useful for pagination. The default value is 25.

Cultures

CultureInfo[]?

The cultures information to load the entity. If no cultures are provided, multi-language properties won't be included. The default value is an array containing CultureInfo.InvariantCulture.

In the following example, the JobTargetQuery is used to request job targets for a specific job (JobId = 123) with various filters applied, such as state, condition, type, and location. The query will skip 0 records and take 50 records, and it will include multi-language properties for English (US) and French (FR) cultures.

RequestResponse
var jobTargetQuery = new JobTargetQuery(123)
{
    State = "Waiting",
    Condition = "Pending",
    Type = "System",
    Location = "67890",
    Skip = 0,
    Take = 50,
    Cultures = new[] { new CultureInfo("en-US"), new CultureInfo("fr-FR") }
};

This example calls the client method:

RequestResponse
var jobTargetQuery = new JobTargetQuery(123);
IEntityCollectionResult targets = await _client.Jobs.GetTargetsAsync(jobTargetQuery);

The method returns the collection of job targets Task<IEntityCollectionResult>. The following exceptions can occur:

  • ArgumentNullException - if the request is null.

  • ArgumentOutOfRangeException - if the request.Take or the request.Skip values are negative numbers, or the request.JobId is not a valid ID.

  • ArgumentException - if any request.cultures are null or the job entity is not found.

GetTargetAsync

This method retrieve a specific target for a job.

The properties supported by this method are listed in the following table.

Property

Type

Description

JobId

long

The unique ID of the job.

TargetId

long

The target ID.

Cultures

CultureInfo[]?

The cultures information to load the entity. If no cultures are provided, multi-language properties won't be included. The default value is an array containing CultureInfo.InvariantCulture.

In the following example,

RequestResponse
IEntity description = await _client.Jobs.GetTargetAsync(jobId, targetId);

The method returns the specific target entity Task<IEntity>. The following exceptions can occur:

  • ArgumentException - if the JobId or TargetId are not valid.

  • WebApiException - if the HTTP request fails.

SaveTargetAsync

This method creates or updates a target for a job. It supports the following parameters.

Parameter

Type

Description

jobId

long

The job ID.

target

IEntity

The target entity.

The method returns the ID of the saved target Task<long>. The following exceptions can occur:

  • ArgumentNullException - if the target is null.

  • ArgumentException - if the job ID is invalid.

  • WebApiException - if the location header is null or the entity ID cannot be extracted.

  • InternalException - if the entity ID cannot be extracted from the location header.

Use the following syntax with this method.

RequestResponse
long targetId = await _client.Jobs.SaveTargetAsync(jobId, target);

DeleteTargetAsync

This method deletes a target for a job. It supports the following parameters:

Parameter

Type

Description

jobId

long

The job ID.

targetId

long

The target ID.

The method returns a task that represents the asynchronous operation. The following exceptions can occur:

  • ArgumentException - if the job ID or target ID are invalid,

  • WebApiException - if the the HTTP request fails,

Use the following syntax with this method.

RequestResponse
await _client.Jobs.DeleteTargetAsync(jobId, targetId);

GetDescriptionAsync

This method retrieves the description of a job. It supports the following parameters:

Parameter

Type

Description

jobId

long

The job ID.

cultures

CultureInfo[]?

Optional cultures for the description.

This method returns the job description entity Task<IEntity>. The following exceptions can occur:

  • ArgumentException - if the job ID is invalid.

  • WebApiException - if the HTTP request fails.

Use the following syntax with this method.

RequestResponse
IEntity description = await _client.Jobs.GetDescriptionAsync(jobId);

SaveDescriptionAsync

This method creates or updates the description of a job. It supports the following parameters:

Parameter

Type

Description

jobId

long

The job ID.

jobDescription

IEntity

The job description entity.

This method returns the ID of the saved job description Task<long>. The following exceptions can occur:

  • ArgumentNullException - if the job description is null.

  • ArgumentException - if the job ID or job description ID is invalid.

  • WebApiException - if the location header is null or the entity ID cannot be extracted.

  • InternalException - if the entity ID cannot be extracted from the location header.

Use the following syntax with this method.

RequestResponse
long descriptionId = await _client.Jobs.SaveDescriptionAsync(jobId, jobDescription);

DeleteDescriptionAsync

This method deletes the description of a job. It supports the following parameter: jobId (long) - the job ID. This method returns a task representing the asynchronous operation. The following exceptions can occur:

  • ArgumentException - if the job ID is invalid.

  • WebApiException - if the HTTP request fails.

Use the following syntax with this method.

RequestResponse
await _client.Jobs.DeleteDescriptionAsync(jobId);

Do you have some feedback for us?

If you have suggestions for improving this article,