Skip to content

Commit

Permalink
Designing
Browse files Browse the repository at this point in the history
  • Loading branch information
dstenroejl committed Nov 20, 2024
1 parent 22336f5 commit 2b395a2
Show file tree
Hide file tree
Showing 15 changed files with 110 additions and 12 deletions.
2 changes: 1 addition & 1 deletion source/ProcessManager.Client/IProcessManagerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public interface IProcessManagerClient
/// Cancel a scheduled orchestration instance.
/// </summary>
public Task CancelScheduledOrchestrationInstanceAsync(
CancelScheduledOrchestrationInstanceCommand requestDto,
CancelScheduledOrchestrationInstanceCommand command,
CancellationToken cancellationToken);

/// <summary>
Expand Down
3 changes: 3 additions & 0 deletions source/ProcessManager.Client/ProcessManager.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="..\Shared\ProcessManager\Api\Model\CancelScheduledOrchestrationInstanceCommand.cs" Link="Model\CancelScheduledOrchestrationInstanceCommand.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\IInputParameterDto.cs" Link="Model\IInputParameterDto.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\OrchestrationInstanceCommand.cs" Link="Model\OrchestrationInstanceCommand.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\OrchestrationInstanceTypedDto.cs" Link="Model\OrchestrationInstanceTypedDto.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\OrchestrationInstance\ActorIdentityDto.cs" Link="Model\OrchestrationInstance\ActorIdentityDto.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\OrchestrationInstance\OperatingIdentityDto.cs" Link="Model\OrchestrationInstance\OperatingIdentityDto.cs" />
Expand All @@ -64,6 +66,7 @@
<Compile Include="..\Shared\ProcessManager\Api\Model\OrchestrationInstance\StepInstanceLifecycleStates.cs" Link="Model\OrchestrationInstance\StepInstanceLifecycleStates.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\OrchestrationInstance\UserIdentityDto.cs" Link="Model\OrchestrationInstance\UserIdentityDto.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\ScheduleOrchestrationInstanceCommand.cs" Link="Model\ScheduleOrchestrationInstanceCommand.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\StartOrchestrationInstanceCommand.cs" Link="Model\StartOrchestrationInstanceCommand.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\UserCommand.cs" Link="Model\UserCommand.cs" />
<Compile Include="..\Shared\ProcessManager\Orchestrations\Processes\BRS_023_027\V1\Model\CalculationTypes.cs" Link="Processes\BRS_023_027\V1\Model\CalculationTypes.cs" />
<Compile Include="..\Shared\ProcessManager\Orchestrations\Processes\BRS_023_027\V1\Model\NotifyAggregatedMeasureDataInputV1.cs" Link="Processes\BRS_023_027\V1\Model\NotifyAggregatedMeasureDataInputV1.cs" />
Expand Down
4 changes: 2 additions & 2 deletions source/ProcessManager.Client/ProcessManagerClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ public ProcessManagerClient(IHttpClientFactory httpClientFactory)

/// <inheritdoc/>
public async Task CancelScheduledOrchestrationInstanceAsync(
CancelScheduledOrchestrationInstanceCommand requestDto,
CancelScheduledOrchestrationInstanceCommand command,
CancellationToken cancellationToken)
{
using var request = new HttpRequestMessage(
HttpMethod.Post,
"/api/processmanager/orchestrationinstance/cancel");
request.Content = new StringContent(
JsonSerializer.Serialize(requestDto),
JsonSerializer.Serialize(command),
Encoding.UTF8,
"application/json");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public interface INotifyAggregatedMeasureDataClientV1
/// Schedule a BRS-023 or BRS-027 calculation and return its id.
/// </summary>
public Task<Guid> ScheduleNewCalculationAsync(
ScheduleOrchestrationInstanceCommand<NotifyAggregatedMeasureDataInputV1> requestDto,
ScheduleOrchestrationInstanceCommand<NotifyAggregatedMeasureDataInputV1> command,
CancellationToken cancellationToken);

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public NotifyAggregatedMeasureDataClientV1(IHttpClientFactory httpClientFactory)

/// <inheritdoc/>
public async Task<Guid> ScheduleNewCalculationAsync(
ScheduleOrchestrationInstanceCommand<NotifyAggregatedMeasureDataInputV1> requestDto,
ScheduleOrchestrationInstanceCommand<NotifyAggregatedMeasureDataInputV1> command,
CancellationToken cancellationToken)
{
// TODO:
Expand All @@ -47,7 +47,7 @@ public async Task<Guid> ScheduleNewCalculationAsync(
HttpMethod.Post,
"/api/processmanager/orchestrationinstance/brs_023_027/1");
request.Content = new StringContent(
JsonSerializer.Serialize(requestDto),
JsonSerializer.Serialize(command),
Encoding.UTF8,
"application/json");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ public interface IRequestCalculatedDataClientV1
/// <summary>
/// Start a request for energy results
/// </summary>
public Task RequestCalculatedEnergyTimeSeriesAsync(RequestCalculatedDataInputV1<RequestCalculatedEnergyTimeSeriesInputV1> input, CancellationToken cancellationToken);
public Task RequestCalculatedEnergyTimeSeriesAsync(
RequestCalculatedDataInputV1<RequestCalculatedEnergyTimeSeriesInputV1> input,
CancellationToken cancellationToken);

/// <summary>
/// Start a request for wholesale results
/// </summary>
public Task RequestCalculatedWholesaleServicesAsync(RequestCalculatedDataInputV1<object> input, CancellationToken cancellationToken);
public Task RequestCalculatedWholesaleServicesAsync(
RequestCalculatedDataInputV1<object> input,
CancellationToken cancellationToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Dynamic;
using System.Text.Json;
using Azure.Messaging.ServiceBus;
using Energinet.DataHub.ProcessManager.Api.Model;
using Energinet.DataHub.ProcessManager.Api.Model.OrchestrationInstance;
using Energinet.DataHub.ProcessManager.Client.Extensions.Options;
using Energinet.DataHub.ProcessManager.Client.Processes.BRS_026_028.V1.Model;
using Energinet.DataHub.ProcessManager.Orchestrations.Contracts;
Expand All @@ -32,6 +33,17 @@ public class RequestCalculatedDataClientV1(

public async Task RequestCalculatedEnergyTimeSeriesAsync(RequestCalculatedDataInputV1<RequestCalculatedEnergyTimeSeriesInputV1> input, CancellationToken cancellationToken)
{
var x1 = new StartOrchestrationInstanceCommand<RequestCalculatedEnergyTimeSeriesInputV1>(new ActorIdentityDto(Guid.NewGuid()), input.Input);
var y1 = ((ActorIdentityDto)x1.OperatingIdentity).ActorId;

var x2 = new ScheduleOrchestrationInstanceCommand<RequestCalculatedEnergyTimeSeriesInputV1>(
new UserIdentityDto(Guid.NewGuid(), Guid.NewGuid()),
DateTimeOffset.MinValue,
input.Input);
var y2 = ((ActorIdentityDto)x2.OperatingIdentity).ActorId;



var serviceBusMessage = CreateServiceBusMessage(
"BRS_026",
1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,13 @@
<Folder Include="Processes\BRS_026\V1\Activities\" />
</ItemGroup>
<ItemGroup>
<Compile Include="..\Shared\ProcessManager\Api\Model\IInputParameterDto.cs" Link="Api\Model\IInputParameterDto.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\OrchestrationInstanceCommand.cs" Link="Api\Model\OrchestrationInstanceCommand.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\OrchestrationInstance\ActorIdentityDto.cs" Link="Api\Model\OrchestrationInstance\ActorIdentityDto.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\OrchestrationInstance\OperatingIdentityDto.cs" Link="Api\Model\OrchestrationInstance\OperatingIdentityDto.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\OrchestrationInstance\UserIdentityDto.cs" Link="Api\Model\OrchestrationInstance\UserIdentityDto.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\ScheduleOrchestrationInstanceCommand.cs" Link="Api\Model\ScheduleOrchestrationInstanceCommand.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\StartOrchestrationInstanceCommand.cs" Link="Api\Model\StartOrchestrationInstanceCommand.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\UserCommand.cs" Link="Api\Model\UserCommand.cs" />
<Compile Include="..\Shared\ProcessManager\Orchestrations\Processes\BRS_023_027\V1\Model\CalculationTypes.cs" Link="Processes\BRS_023_027\V1\Model\CalculationTypes.cs" />
<Compile Include="..\Shared\ProcessManager\Orchestrations\Processes\BRS_023_027\V1\Model\NotifyAggregatedMeasureDataInputV1.cs" Link="Processes\BRS_023_027\V1\Model\NotifyAggregatedMeasureDataInputV1.cs" />
Expand Down
3 changes: 3 additions & 0 deletions source/ProcessManager/ProcessManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
</ItemGroup>
<ItemGroup>
<Compile Include="..\Shared\ProcessManager\Api\Model\CancelScheduledOrchestrationInstanceCommand.cs" Link="Api\Model\CancelScheduledOrchestrationInstanceCommand.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\IInputParameterDto.cs" Link="Api\Model\IInputParameterDto.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\OrchestrationInstanceCommand.cs" Link="Api\Model\OrchestrationInstanceCommand.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\OrchestrationInstanceTypedDto.cs" Link="Api\Model\OrchestrationInstanceTypedDto.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\OrchestrationInstance\ActorIdentityDto.cs" Link="Api\Model\OrchestrationInstance\ActorIdentityDto.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\OrchestrationInstance\OperatingIdentityDto.cs" Link="Api\Model\OrchestrationInstance\OperatingIdentityDto.cs" />
Expand All @@ -43,6 +45,7 @@
<Compile Include="..\Shared\ProcessManager\Api\Model\OrchestrationInstance\StepInstanceLifecycleStates.cs" Link="Api\Model\OrchestrationInstance\StepInstanceLifecycleStates.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\OrchestrationInstance\UserIdentityDto.cs" Link="Api\Model\OrchestrationInstance\UserIdentityDto.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\ScheduleOrchestrationInstanceCommand.cs" Link="Api\Model\ScheduleOrchestrationInstanceCommand.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\StartOrchestrationInstanceCommand.cs" Link="Api\Model\StartOrchestrationInstanceCommand.cs" />
<Compile Include="..\Shared\ProcessManager\Api\Model\UserCommand.cs" Link="Api\Model\UserCommand.cs" />
</ItemGroup>
</Project>
20 changes: 20 additions & 0 deletions source/Shared/ProcessManager/Api/Model/IInputParameterDto.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2020 Energinet DataHub A/S
//
// Licensed under the Apache License, Version 2.0 (the "License2");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace Energinet.DataHub.ProcessManager.Api.Model;

/// <summary>
/// Marker interface for serializable input parameters to an orchestration instance.
/// </summary>
public interface IInputParameterDto;
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright 2020 Energinet DataHub A/S
//
// Licensed under the Apache License, Version 2.0 (the "License2");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Energinet.DataHub.ProcessManager.Api.Model.OrchestrationInstance;

namespace Energinet.DataHub.ProcessManager.Api.Model;

/// <summary>
/// A orchestration instance command executed by an identity.
/// </summary>
/// <param name="OperatingIdentity">The identity executing the command.</param>
public abstract record OrchestrationInstanceCommand(IOperatingIdentityDto OperatingIdentity);
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ public record ScheduleOrchestrationInstanceCommand<TInputParameterDto>(
DateTimeOffset RunAt,
TInputParameterDto InputParameter)
: UserCommand(UserIdentity)
where TInputParameterDto : class;
where TInputParameterDto : IInputParameterDto;
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2020 Energinet DataHub A/S
//
// Licensed under the Apache License, Version 2.0 (the "License2");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Energinet.DataHub.ProcessManager.Api.Model.OrchestrationInstance;

namespace Energinet.DataHub.ProcessManager.Api.Model;

/// <summary>
/// Command for starting an orchestration instance.
/// </summary>
/// <typeparam name="TInputParameterDto">Must be a JSON serializable type.</typeparam>
/// <param name="OperatingIdentity">Identity executing the command.</param>
/// <param name="InputParameter">Contains the Durable Functions orchestration input parameter value.</param>
public record StartOrchestrationInstanceCommand<TInputParameterDto>(
IOperatingIdentityDto OperatingIdentity,
TInputParameterDto InputParameter)
: OrchestrationInstanceCommand(OperatingIdentity)
where TInputParameterDto : IInputParameterDto;
3 changes: 2 additions & 1 deletion source/Shared/ProcessManager/Api/Model/UserCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ namespace Energinet.DataHub.ProcessManager.Api.Model;
/// A command executed by a user.
/// </summary>
/// <param name="UserIdentity">Identity of the user executing the command.</param>
public abstract record UserCommand(UserIdentityDto UserIdentity);
public abstract record UserCommand(UserIdentityDto UserIdentity)
: OrchestrationInstanceCommand(UserIdentity);
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace Energinet.DataHub.ProcessManager.Orchestrations.Processes.BRS_023_027.
/// <summary>
/// An immutable input to start the orchestration instance for "BRS_023_027" V1.
/// </summary>
public sealed record NotifyAggregatedMeasureDataInputV1(
public record NotifyAggregatedMeasureDataInputV1(
CalculationTypes CalculationType,
IReadOnlyCollection<string> GridAreaCodes,
DateTimeOffset PeriodStartDate,
Expand Down

0 comments on commit 2b395a2

Please sign in to comment.