Skip to content

Commit f893ed6

Browse files
authored
Merge pull request #304 from neuroglia-io/schedules-feat
Added application and user interfaces to manage Schedules
2 parents ddda1c7 + 76d26b4 commit f893ed6

File tree

94 files changed

+5310
-652
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+5310
-652
lines changed

src/apis/management/Synapse.Apis.Management.Core/Services/ISynapseManagementApi.cs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Synapse.Integration.Commands.Correlations;
2020
using Synapse.Integration.Commands.EventDefinitionCollections;
2121
using Synapse.Integration.Commands.FunctionDefinitionCollections;
22+
using Synapse.Integration.Commands.Schedules;
2223
using Synapse.Integration.Commands.WorkflowInstances;
2324
using Synapse.Integration.Commands.Workflows;
2425
using Synapse.Integration.Models;
@@ -401,6 +402,100 @@ public interface ISynapseManagementApi
401402

402403
#endregion
403404

405+
#region Schedules
406+
407+
/// <summary>
408+
/// Creates a new <see cref="V1Schedule"/>
409+
/// </summary>
410+
/// <param name="command">The object that describes the command to execute</param>
411+
/// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
412+
/// <returns>The newly created <see cref="V1Schedule"/></returns>
413+
[OperationContract]
414+
Task<V1Schedule> CreateScheduleAsync(V1CreateScheduleCommand command, CancellationToken cancellationToken = default);
415+
416+
/// <summary>
417+
/// Gets the <see cref="V1Schedule"/> with the specified id
418+
/// </summary>
419+
/// <param name="id">The id of the <see cref="V1Schedule"/> to get</param>
420+
/// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
421+
/// <returns>The <see cref="V1Schedule"/> with the specified id</returns>
422+
423+
[OperationContract]
424+
Task<V1Schedule> GetScheduleByIdAsync(string id, CancellationToken cancellationToken = default);
425+
426+
/// <summary>
427+
/// Lists existing <see cref="V1Schedule"/>s
428+
/// </summary>
429+
/// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
430+
/// <returns>A new <see cref="List{T}"/> containing all existing <see cref="V1Schedule"/>s</returns>
431+
[OperationContract]
432+
Task<List<V1Schedule>> GetSchedulesAsync(CancellationToken cancellationToken = default);
433+
434+
/// <summary>
435+
/// Lists existing <see cref="V1Schedule"/>s
436+
/// </summary>
437+
/// <param name="query">The OData query string</param>
438+
/// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
439+
/// <returns>A new <see cref="List{T}"/> containing all existing <see cref="V1Schedule"/>s</returns>
440+
[OperationContract]
441+
Task<List<V1Schedule>> GetSchedulesAsync(string query, CancellationToken cancellationToken = default);
442+
443+
/// <summary>
444+
/// Triggers the specified <see cref="V1Schedule"/>
445+
/// </summary>
446+
/// <param name="id">The id of the <see cref="V1Schedule"/> to trigger</param>
447+
/// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
448+
/// <returns>A new awaitable <see cref="Task"/></returns>
449+
[OperationContract]
450+
Task TriggerScheduleAsync(string id, CancellationToken cancellationToken = default);
451+
452+
/// <summary>
453+
/// Suspends the specified <see cref="V1Schedule"/>
454+
/// </summary>
455+
/// <param name="id">The id of the <see cref="V1Schedule"/> to suspend</param>
456+
/// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
457+
/// <returns>A new awaitable <see cref="Task"/></returns>
458+
[OperationContract]
459+
Task SuspendScheduleAsync(string id, CancellationToken cancellationToken = default);
460+
461+
/// <summary>
462+
/// Resumes the specified <see cref="V1Schedule"/>
463+
/// </summary>
464+
/// <param name="id">The id of the <see cref="V1Schedule"/> to resume</param>
465+
/// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
466+
/// <returns>A new awaitable <see cref="Task"/></returns>
467+
[OperationContract]
468+
Task ResumeScheduleAsync(string id, CancellationToken cancellationToken = default);
469+
470+
/// <summary>
471+
/// Retires the specified <see cref="V1Schedule"/>
472+
/// </summary>
473+
/// <param name="id">The id of the <see cref="V1Schedule"/> to retire</param>
474+
/// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
475+
/// <returns>A new awaitable <see cref="Task"/></returns>
476+
[OperationContract]
477+
Task RetireScheduleAsync(string id, CancellationToken cancellationToken = default);
478+
479+
/// <summary>
480+
/// Makes the specified <see cref="V1Schedule"/> obsolete
481+
/// </summary>
482+
/// <param name="id">The id of the <see cref="V1Schedule"/> to make obsolete</param>
483+
/// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
484+
/// <returns>A new awaitable <see cref="Task"/></returns>
485+
[OperationContract]
486+
Task MakeScheduleObsoleteAsync(string id, CancellationToken cancellationToken = default);
487+
488+
/// <summary>
489+
/// Deletes the <see cref="V1Schedule"/> with the specified id
490+
/// </summary>
491+
/// <param name="id">The id of the <see cref="V1Schedule"/> to delete</param>
492+
/// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
493+
/// <returns>A new awaitable <see cref="Task"/></returns>
494+
[OperationContract]
495+
Task DeleteScheduleAsync(string id, CancellationToken cancellationToken = default);
496+
497+
#endregion
498+
404499
}
405500

406501
}

src/apis/management/Synapse.Apis.Management.Grpc.Client/Services/ISynapseGrpcManagementApi.cs

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
using Synapse.Integration.Commands.Correlations;
2121
using Synapse.Integration.Commands.EventDefinitionCollections;
2222
using Synapse.Integration.Commands.FunctionDefinitionCollections;
23+
using Synapse.Integration.Commands.Schedules;
2324
using Synapse.Integration.Commands.WorkflowInstances;
2425
using Synapse.Integration.Commands.Workflows;
2526

@@ -376,6 +377,92 @@ public interface ISynapseGrpcManagementApi
376377

377378
#endregion
378379

380+
#region Schedules
381+
382+
/// <summary>
383+
/// Creates a new <see cref="V1Schedule"/>
384+
/// </summary>
385+
/// <param name="command">The object that describes the command to execute</param>
386+
/// <param name="context">The current <see cref="CallContext" /></param>
387+
/// <returns>The newly created <see cref="V1Schedule"/></returns>
388+
[OperationContract]
389+
Task<GrpcApiResult<V1Schedule>> CreateScheduleAsync(V1CreateScheduleCommand command, CallContext context = default);
390+
391+
/// <summary>
392+
/// Gets the <see cref="V1Schedule"/> with the specified id
393+
/// </summary>
394+
/// <param name="id">The id of the <see cref="V1Schedule"/> to get</param>
395+
/// <param name="context">The current <see cref="CallContext" /></param>
396+
/// <returns>The <see cref="V1Schedule"/> with the specified id</returns>
397+
398+
[OperationContract]
399+
Task<GrpcApiResult<V1Schedule>> GetScheduleByIdAsync(string id, CallContext context = default);
400+
401+
/// <summary>
402+
/// Lists existing <see cref="V1Schedule"/>s
403+
/// </summary>
404+
/// <param name="query">The OData query string</param>
405+
/// <param name="context">The current <see cref="CallContext" /></param>
406+
/// <returns>A new <see cref="List{T}"/> containing all existing <see cref="V1Schedule"/>s</returns>
407+
[OperationContract]
408+
Task<GrpcApiResult<List<V1Schedule>>> GetSchedulesAsync(string? query = null, CallContext context = default);
409+
410+
/// <summary>
411+
/// Triggers the specified <see cref="V1Schedule"/>
412+
/// </summary>
413+
/// <param name="id">The id of the <see cref="V1Schedule"/> to trigger</param>
414+
/// <param name="context">The current <see cref="CallContext" /></param>
415+
/// <returns>A new awaitable <see cref="Task"/></returns>
416+
[OperationContract]
417+
Task<GrpcApiResult> TriggerScheduleAsync(string id, CallContext context = default);
418+
419+
/// <summary>
420+
/// Suspends the specified <see cref="V1Schedule"/>
421+
/// </summary>
422+
/// <param name="id">The id of the <see cref="V1Schedule"/> to suspend</param>
423+
/// <param name="context">The current <see cref="CallContext" /></param>
424+
/// <returns>A new awaitable <see cref="Task"/></returns>
425+
[OperationContract]
426+
Task<GrpcApiResult> SuspendScheduleAsync(string id, CallContext context = default);
427+
428+
/// <summary>
429+
/// Resumes the specified <see cref="V1Schedule"/>
430+
/// </summary>
431+
/// <param name="id">The id of the <see cref="V1Schedule"/> to resume</param>
432+
/// <param name="context">The current <see cref="CallContext" /></param>
433+
/// <returns>A new awaitable <see cref="Task"/></returns>
434+
[OperationContract]
435+
Task<GrpcApiResult> ResumeScheduleAsync(string id, CallContext context = default);
436+
437+
/// <summary>
438+
/// Retires the specified <see cref="V1Schedule"/>
439+
/// </summary>
440+
/// <param name="id">The id of the <see cref="V1Schedule"/> to retire</param>
441+
/// <param name="context">The current <see cref="CallContext" /></param>
442+
/// <returns>A new awaitable <see cref="Task"/></returns>
443+
[OperationContract]
444+
Task<GrpcApiResult> RetireScheduleAsync(string id, CallContext context = default);
445+
446+
/// <summary>
447+
/// Makes the specified <see cref="V1Schedule"/> obsolete
448+
/// </summary>
449+
/// <param name="id">The id of the <see cref="V1Schedule"/> to make obsolete</param>
450+
/// <param name="context">The current <see cref="CallContext" /></param>
451+
/// <returns>A new awaitable <see cref="Task"/></returns>
452+
[OperationContract]
453+
Task<GrpcApiResult> MakeScheduleObsoleteAsync(string id, CallContext context = default);
454+
455+
/// <summary>
456+
/// Deletes the <see cref="V1Schedule"/> with the specified id
457+
/// </summary>
458+
/// <param name="id">The id of the <see cref="V1Schedule"/> to delete</param>
459+
/// <param name="context">The current <see cref="CallContext" /></param>
460+
/// <returns>A new awaitable <see cref="Task"/></returns>
461+
[OperationContract]
462+
Task<GrpcApiResult> DeleteScheduleAsync(string id, CallContext context = default);
463+
464+
#endregion
465+
379466
}
380467

381468
}

src/apis/management/Synapse.Apis.Management.Grpc.Client/Services/SynapseGrpcManagementApiClient.cs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Synapse.Integration.Commands.Correlations;
2020
using Synapse.Integration.Commands.EventDefinitionCollections;
2121
using Synapse.Integration.Commands.FunctionDefinitionCollections;
22+
using Synapse.Integration.Commands.Schedules;
2223
using Synapse.Integration.Commands.WorkflowInstances;
2324
using Synapse.Integration.Commands.Workflows;
2425

@@ -417,6 +418,79 @@ public virtual async Task<V1OperationalReport> GetOperationalReportAsync(DateTim
417418

418419
#endregion
419420

421+
#region Schedules
422+
423+
/// <inheritdoc/>
424+
public virtual async Task<V1Schedule> CreateScheduleAsync(V1CreateScheduleCommand command, CancellationToken cancellationToken = default)
425+
{
426+
var result = await this.Adapter.CreateScheduleAsync(command, cancellationToken);
427+
if (!result.Succeeded) throw new SynapseApiException(result);
428+
return result.Data!;
429+
}
430+
431+
/// <inheritdoc/>
432+
public virtual async Task<V1Schedule> GetScheduleByIdAsync(string id, CancellationToken cancellationToken = default)
433+
{
434+
var result = await this.Adapter.GetScheduleByIdAsync(id, cancellationToken);
435+
if (!result.Succeeded) throw new SynapseApiException(result);
436+
return result.Data!;
437+
}
438+
439+
/// <inheritdoc/>
440+
public virtual async Task<List<V1Schedule>> GetSchedulesAsync(CancellationToken cancellationToken = default) => await this.GetSchedulesAsync(null!, cancellationToken);
441+
442+
/// <inheritdoc/>
443+
public virtual async Task<List<V1Schedule>> GetSchedulesAsync(string query, CancellationToken cancellationToken = default)
444+
{
445+
var result = await this.Adapter.GetSchedulesAsync(query, cancellationToken);
446+
if (!result.Succeeded) throw new SynapseApiException(result);
447+
return result.Data!;
448+
}
449+
450+
/// <inheritdoc/>
451+
public virtual async Task TriggerScheduleAsync(string id, CancellationToken cancellationToken = default)
452+
{
453+
var result = await this.Adapter.TriggerScheduleAsync(id, cancellationToken);
454+
if (!result.Succeeded) throw new SynapseApiException(result);
455+
}
456+
457+
/// <inheritdoc/>
458+
public virtual async Task SuspendScheduleAsync(string id, CancellationToken cancellationToken = default)
459+
{
460+
var result = await this.Adapter.SuspendScheduleAsync(id, cancellationToken);
461+
if (!result.Succeeded) throw new SynapseApiException(result);
462+
}
463+
464+
/// <inheritdoc/>
465+
public virtual async Task ResumeScheduleAsync(string id, CancellationToken cancellationToken = default)
466+
{
467+
var result = await this.Adapter.ResumeScheduleAsync(id, cancellationToken);
468+
if (!result.Succeeded) throw new SynapseApiException(result);
469+
}
470+
471+
/// <inheritdoc/>
472+
public virtual async Task RetireScheduleAsync(string id, CancellationToken cancellationToken = default)
473+
{
474+
var result = await this.Adapter.RetireScheduleAsync(id, cancellationToken);
475+
if (!result.Succeeded) throw new SynapseApiException(result);
476+
}
477+
478+
/// <inheritdoc/>
479+
public virtual async Task MakeScheduleObsoleteAsync(string id, CancellationToken cancellationToken = default)
480+
{
481+
var result = await this.Adapter.MakeScheduleObsoleteAsync(id, cancellationToken);
482+
if (!result.Succeeded) throw new SynapseApiException(result);
483+
}
484+
485+
/// <inheritdoc/>
486+
public virtual async Task DeleteScheduleAsync(string id, CancellationToken cancellationToken = default)
487+
{
488+
var result = await this.Adapter.DeleteScheduleAsync(id, cancellationToken);
489+
if (!result.Succeeded) throw new SynapseApiException(result);
490+
}
491+
492+
#endregion
493+
420494
}
421495

422496
}

src/apis/management/Synapse.Apis.Management.Grpc/Services/SynapseGrpcManagementApi.cs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
using Synapse.Integration.Commands.Correlations;
3030
using Synapse.Integration.Commands.EventDefinitionCollections;
3131
using Synapse.Integration.Commands.FunctionDefinitionCollections;
32+
using Synapse.Integration.Commands.Schedules;
3233
using Synapse.Integration.Commands.Workflows;
3334
using Synapse.Integration.Models;
3435

@@ -326,6 +327,70 @@ public virtual async Task<GrpcApiResult<V1OperationalReport>> GetOperationalRepo
326327

327328
#endregion
328329

330+
#region Schedules
331+
332+
/// <inheritdoc/>
333+
public virtual async Task<GrpcApiResult<V1Schedule>> CreateScheduleAsync(V1CreateScheduleCommand command, CallContext context = default)
334+
{
335+
return GrpcApiResult.CreateFor(await this.Mediator.ExecuteAsync(this.Mapper.Map<Application.Commands.Schedules.V1CreateScheduleCommand>(command), context.CancellationToken));
336+
}
337+
338+
/// <inheritdoc/>
339+
public virtual async Task<GrpcApiResult<V1Schedule>> GetScheduleByIdAsync(string id, CallContext context = default)
340+
{
341+
return GrpcApiResult.CreateFor(await this.Mediator.ExecuteAsync(new V1FindByIdQuery<V1Schedule, string>(id), context.CancellationToken));
342+
}
343+
344+
/// <inheritdoc/>
345+
public virtual async Task<GrpcApiResult<List<V1Schedule>>> GetSchedulesAsync(string? query = null, CallContext context = default)
346+
{
347+
return GrpcApiResult.CreateFor(await this.Mediator.ExecuteAsync(new V1FilterQuery<V1Schedule>(this.QueryOptionsParser.Parse<V1Schedule>(query)), context.CancellationToken));
348+
}
349+
350+
/// <inheritdoc/>
351+
public virtual async Task<GrpcApiResult> TriggerScheduleAsync(string id, CallContext context = default)
352+
{
353+
if (string.IsNullOrWhiteSpace(id)) throw new ArgumentNullException(nameof(id));
354+
return GrpcApiResult.CreateFor(await this.Mediator.ExecuteAsync(this.Mapper.Map<Application.Commands.Schedules.V1TriggerScheduleCommand>(id), context.CancellationToken));
355+
}
356+
357+
/// <inheritdoc/>
358+
public virtual async Task<GrpcApiResult> SuspendScheduleAsync(string id, CallContext context = default)
359+
{
360+
if (string.IsNullOrWhiteSpace(id)) throw new ArgumentNullException(nameof(id));
361+
return GrpcApiResult.CreateFor(await this.Mediator.ExecuteAsync(this.Mapper.Map<Application.Commands.Schedules.V1SuspendScheduleCommand>(id), context.CancellationToken));
362+
}
363+
364+
/// <inheritdoc/>
365+
public virtual async Task<GrpcApiResult> ResumeScheduleAsync(string id, CallContext context = default)
366+
{
367+
if (string.IsNullOrWhiteSpace(id)) throw new ArgumentNullException(nameof(id));
368+
return GrpcApiResult.CreateFor(await this.Mediator.ExecuteAsync(this.Mapper.Map<Application.Commands.Schedules.V1ResumeScheduleCommand>(id), context.CancellationToken));
369+
}
370+
371+
/// <inheritdoc/>
372+
public virtual async Task<GrpcApiResult> RetireScheduleAsync(string id, CallContext context = default)
373+
{
374+
if (string.IsNullOrWhiteSpace(id)) throw new ArgumentNullException(nameof(id));
375+
return GrpcApiResult.CreateFor(await this.Mediator.ExecuteAsync(this.Mapper.Map<Application.Commands.Schedules.V1RetireScheduleCommand>(id), context.CancellationToken));
376+
}
377+
378+
/// <inheritdoc/>
379+
public virtual async Task<GrpcApiResult> MakeScheduleObsoleteAsync(string id, CallContext context = default)
380+
{
381+
if (string.IsNullOrWhiteSpace(id)) throw new ArgumentNullException(nameof(id));
382+
return GrpcApiResult.CreateFor(await this.Mediator.ExecuteAsync(this.Mapper.Map<Application.Commands.Schedules.V1MakeScheduleObsoleteCommand>(id), context.CancellationToken));
383+
}
384+
385+
/// <inheritdoc/>
386+
public virtual async Task<GrpcApiResult> DeleteScheduleAsync(string id, CallContext context = default)
387+
{
388+
if (string.IsNullOrWhiteSpace(id)) throw new ArgumentNullException(nameof(id));
389+
return GrpcApiResult.CreateFor(await this.Mediator.ExecuteAsync(new V1DeleteCommand<Domain.Models.V1Schedule, string>(id), context.CancellationToken));
390+
}
391+
392+
#endregion
393+
329394
}
330395

331396
}

0 commit comments

Comments
 (0)