Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Prioritize action to the Task repository #798

Merged
merged 2 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7976,6 +7976,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 @@ -8799,6 +8800,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 @@ -8001,6 +8001,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 @@ -8824,6 +8825,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
Loading