Skip to content

Commit

Permalink
Add Prioritize action to the Task repository (#798)
Browse files Browse the repository at this point in the history
* Add Prioritize action to the Task repository
  • Loading branch information
denys-octopus authored Nov 6, 2023
1 parent 00ca082 commit 7f3f20d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7977,6 +7977,7 @@ Octopus.Client.Repositories
String GetRawOutputLog(Octopus.Client.Model.TaskResource)
Octopus.Client.Model.TaskTypeResource[] GetTaskTypes()
void ModifyState(Octopus.Client.Model.TaskResource, Octopus.Client.Model.TaskState, String)
void Prioritize(Octopus.Client.Model.TaskResource)
void Rerun(Octopus.Client.Model.TaskResource)
void WaitForCompletion(Octopus.Client.Model.TaskResource, Int32, Int32, Action<TaskResource[]>)
void WaitForCompletion(Octopus.Client.Model.TaskResource[], Int32, Int32, Action<TaskResource[]>)
Expand Down Expand Up @@ -8800,6 +8801,7 @@ Octopus.Client.Repositories.Async
Task<TaskTypeResource[]> GetTaskTypes(CancellationToken)
Task ModifyState(Octopus.Client.Model.TaskResource, Octopus.Client.Model.TaskState, String)
Task ModifyState(Octopus.Client.Model.TaskResource, Octopus.Client.Model.TaskState, String, CancellationToken)
Task Prioritize(Octopus.Client.Model.TaskResource, CancellationToken)
Task Rerun(Octopus.Client.Model.TaskResource)
Task Rerun(Octopus.Client.Model.TaskResource, CancellationToken)
Task WaitForCompletion(Octopus.Client.Model.TaskResource, Int32, Int32, Action<TaskResource[]>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8002,6 +8002,7 @@ Octopus.Client.Repositories
String GetRawOutputLog(Octopus.Client.Model.TaskResource)
Octopus.Client.Model.TaskTypeResource[] GetTaskTypes()
void ModifyState(Octopus.Client.Model.TaskResource, Octopus.Client.Model.TaskState, String)
void Prioritize(Octopus.Client.Model.TaskResource)
void Rerun(Octopus.Client.Model.TaskResource)
void WaitForCompletion(Octopus.Client.Model.TaskResource, Int32, Int32, Action<TaskResource[]>)
void WaitForCompletion(Octopus.Client.Model.TaskResource[], Int32, Int32, Action<TaskResource[]>)
Expand Down Expand Up @@ -8825,6 +8826,7 @@ Octopus.Client.Repositories.Async
Task<TaskTypeResource[]> GetTaskTypes(CancellationToken)
Task ModifyState(Octopus.Client.Model.TaskResource, Octopus.Client.Model.TaskState, String)
Task ModifyState(Octopus.Client.Model.TaskResource, Octopus.Client.Model.TaskState, String, CancellationToken)
Task Prioritize(Octopus.Client.Model.TaskResource, CancellationToken)
Task Rerun(Octopus.Client.Model.TaskResource)
Task Rerun(Octopus.Client.Model.TaskResource, CancellationToken)
Task WaitForCompletion(Octopus.Client.Model.TaskResource, Int32, Int32, Action<TaskResource[]>)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ namespace Octopus.Client.Tests.Repositories.Async
{
public class TaskRepositoryTests
{

[Test]
public void WaitForCompletionReportsProgress_ActionOverload()
{
Expand Down
11 changes: 11 additions & 0 deletions source/Octopus.Server.Client/Repositories/Async/TaskRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public interface ITaskRepository : IPaginate<TaskResource>, IGet<TaskResource>,
[Obsolete("Please use the overload with cancellation token instead.", false)]
Task<TaskTypeResource[]> GetTaskTypes();
Task<TaskTypeResource[]> GetTaskTypes(CancellationToken cancellationToken);

/// <summary>
/// Moves queued task to the top of the Task Queue
/// </summary>
Task Prioritize(TaskResource resource, CancellationToken cancellationToken);
[Obsolete("Please use the overload with cancellation token instead.", false)]
Task Rerun(TaskResource resource);
Task Rerun(TaskResource resource, CancellationToken cancellationToken);
Expand Down Expand Up @@ -343,6 +348,12 @@ public async Task<TaskTypeResource[]> GetTaskTypes(CancellationToken cancellatio
return await Client.Get<TaskTypeResource[]>((await Client.Repository.LoadRootDocument(cancellationToken)).Links["TaskTypes"], cancellationToken);
}

public async Task Prioritize(TaskResource resource, CancellationToken cancellationToken)
{
EnsureTaskCanRunInTheCurrentContext(resource);
await Client.Post(resource.Link("Prioritize"), (TaskResource)null, cancellationToken).ConfigureAwait(false);
}

[Obsolete("Please use the overload with cancellation token instead.", false)]
public async Task Rerun(TaskResource resource)
=> await Rerun(resource, CancellationToken.None);
Expand Down
12 changes: 11 additions & 1 deletion source/Octopus.Server.Client/Repositories/TaskRepository.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
using Octopus.Client.Model;
using Octopus.Client.Repositories.Async;
using Octopus.Client.Util;
using Octopus.Client.Validation;

namespace Octopus.Client.Repositories
{
Expand Down Expand Up @@ -46,6 +46,7 @@ public interface ITaskRepository : IPaginate<TaskResource>, IGet<TaskResource>,
TaskDetailsResource GetDetails(TaskResource resource, bool? includeVerboseOutput = null, int? tail = null);
string GetRawOutputLog(TaskResource resource);
TaskTypeResource[] GetTaskTypes();
void Prioritize(TaskResource resource);
void Rerun(TaskResource resource);
void Cancel(TaskResource resource);
void ModifyState(TaskResource resource, TaskState newState, string reason);
Expand Down Expand Up @@ -238,6 +239,15 @@ public TaskTypeResource[] GetTaskTypes()
return Client.Get<TaskTypeResource[]>(Client.Repository.LoadRootDocument().Links["TaskTypes"]);
}

/// <summary>
/// Moves queued task to the top of the Task Queue
/// </summary>
public void Prioritize(TaskResource resource)
{
EnsureTaskCanRunInTheCurrentContext(resource);
Client.Post(resource.Link("Prioritize"), (TaskResource) null);
}

public void Rerun(TaskResource resource)
{
EnsureTaskCanRunInTheCurrentContext(resource);
Expand Down

0 comments on commit 7f3f20d

Please sign in to comment.