This commit is contained in:
Pilzinsel64
2025-10-31 09:29:28 +01:00
parent e2a337a7aa
commit 6ae5cd51b0
8 changed files with 90 additions and 3 deletions

View File

@@ -0,0 +1,10 @@
using Pilz.Net.Api.Entities;
namespace Pilz.Net.Api.Client;
public interface IJobsHandler
{
Task<JobInfo> Execute(string name);
Task<JobInfo> Get(string name);
Task<IEnumerable<JobInfo>> GetAll();
}

View File

@@ -0,0 +1,22 @@
using Pilz.Net.Api.Entities;
using Pilz.Net.Api.Messages;
namespace Pilz.Net.Api.Client;
public class JobsHandler(IApiClient client) : IJobsHandler
{
public async Task<IEnumerable<JobInfo>> GetAll()
{
return (await client.SendRequest<ItemMessages<JobInfo>.Items>("/jobs", HttpMethod.Get)).EnsureOk().Items;
}
public async Task<JobInfo> Get(string name)
{
return (await client.SendRequest<ItemMessages<JobInfo>.Item>($"/jobs/{name}", HttpMethod.Get)).EnsureOk().Item;
}
public async Task<JobInfo> Execute(string name)
{
return (await client.SendRequest<ItemMessages<JobInfo>.Item>($"/jobs/{name}", HttpMethod.Post)).EnsureOk().Item;
}
}