/// <summary> /// Submits the job. /// </summary> /// <param name="jobDefinition">The job definition.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns> /// The job response. /// </returns> public async Task <CloudJob> SubmitJobAsync( CloudJob jobDefinition, CancellationToken cancellationToken = default) { Ensure.NotNull(jobDefinition, nameof(jobDefinition)); Ensure.NotNullOrWhiteSpace(jobDefinition.Details.Id, nameof(jobDefinition.Details.Id)); try { JobDetails jobDetails = await this.QuantumClient.Jobs.PutAsync( jobId : jobDefinition.Details.Id, jobDefinition : jobDefinition.Details, cancellationToken : cancellationToken); return(new CloudJob(this, jobDetails)); } catch (Exception ex) { throw CreateException(ex, "Could not submit job", jobDefinition.Details.Id); } }
/// <summary> /// Cancels the job. /// </summary> /// <param name="cancellationToken">The cancellation token.</param> public async Task CancelAsync(CancellationToken cancellationToken = default) { CloudJob job = (CloudJob)await this.Workspace.CancelJobAsync(this.Details.Id, cancellationToken); this.Details = job.Details; }
/// <summary> /// Refreshes the job. /// </summary> /// <param name="cancellationToken">The cancellation token.</param> /// <returns></returns> public virtual async Task RefreshAsync(CancellationToken cancellationToken = default) { CloudJob job = (CloudJob)await this.Workspace.GetJobAsync(this.Details?.Id, cancellationToken); this.Details = job.Details; }
/// <summary> /// Submits the job. /// </summary> /// <param name="workspace">The workspace.</param> /// <param name="jobDefinition">The job definition.</param> /// <returns>The job response.</returns> public static CloudJob SubmitJob( this IWorkspace workspace, CloudJob jobDefinition) { return(workspace.SubmitJobAsync(jobDefinition).GetAwaiter().GetResult()); }