diff --git a/source/ProcessManager.Client/IProcessManagerClient.cs b/source/ProcessManager.Client/IProcessManagerClient.cs index 6bdb17eacc..4a66c8343b 100644 --- a/source/ProcessManager.Client/IProcessManagerClient.cs +++ b/source/ProcessManager.Client/IProcessManagerClient.cs @@ -26,7 +26,7 @@ public interface IProcessManagerClient /// Cancel a scheduled orchestration instance. /// public Task CancelScheduledOrchestrationInstanceAsync( - CancelScheduledOrchestrationInstanceCommand requestDto, + CancelScheduledOrchestrationInstanceCommand command, CancellationToken cancellationToken); /// diff --git a/source/ProcessManager.Client/ProcessManager.Client.csproj b/source/ProcessManager.Client/ProcessManager.Client.csproj index 6fd2002e11..fb935df1e6 100644 --- a/source/ProcessManager.Client/ProcessManager.Client.csproj +++ b/source/ProcessManager.Client/ProcessManager.Client.csproj @@ -53,6 +53,8 @@ + + @@ -64,6 +66,7 @@ + diff --git a/source/ProcessManager.Client/ProcessManagerClient.cs b/source/ProcessManager.Client/ProcessManagerClient.cs index b3c4badbbf..993ebef19c 100644 --- a/source/ProcessManager.Client/ProcessManagerClient.cs +++ b/source/ProcessManager.Client/ProcessManagerClient.cs @@ -34,14 +34,14 @@ public ProcessManagerClient(IHttpClientFactory httpClientFactory) /// 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"); diff --git a/source/ProcessManager.Client/Processes/BRS_023_027/V1/INotifyAggregatedMeasureDataClientV1.cs b/source/ProcessManager.Client/Processes/BRS_023_027/V1/INotifyAggregatedMeasureDataClientV1.cs index 89ba31e6b9..47ed70d085 100644 --- a/source/ProcessManager.Client/Processes/BRS_023_027/V1/INotifyAggregatedMeasureDataClientV1.cs +++ b/source/ProcessManager.Client/Processes/BRS_023_027/V1/INotifyAggregatedMeasureDataClientV1.cs @@ -27,7 +27,7 @@ public interface INotifyAggregatedMeasureDataClientV1 /// Schedule a BRS-023 or BRS-027 calculation and return its id. /// public Task ScheduleNewCalculationAsync( - ScheduleOrchestrationInstanceCommand requestDto, + ScheduleOrchestrationInstanceCommand command, CancellationToken cancellationToken); /// diff --git a/source/ProcessManager.Client/Processes/BRS_023_027/V1/NotifyAggregatedMeasureDataClientV1.cs b/source/ProcessManager.Client/Processes/BRS_023_027/V1/NotifyAggregatedMeasureDataClientV1.cs index 2d0119fe8e..122d68ea9f 100644 --- a/source/ProcessManager.Client/Processes/BRS_023_027/V1/NotifyAggregatedMeasureDataClientV1.cs +++ b/source/ProcessManager.Client/Processes/BRS_023_027/V1/NotifyAggregatedMeasureDataClientV1.cs @@ -37,7 +37,7 @@ public NotifyAggregatedMeasureDataClientV1(IHttpClientFactory httpClientFactory) /// public async Task ScheduleNewCalculationAsync( - ScheduleOrchestrationInstanceCommand requestDto, + ScheduleOrchestrationInstanceCommand command, CancellationToken cancellationToken) { // TODO: @@ -47,7 +47,7 @@ public async Task ScheduleNewCalculationAsync( HttpMethod.Post, "/api/processmanager/orchestrationinstance/brs_023_027/1"); request.Content = new StringContent( - JsonSerializer.Serialize(requestDto), + JsonSerializer.Serialize(command), Encoding.UTF8, "application/json"); diff --git a/source/ProcessManager.Client/Processes/BRS_026_028/V1/IRequestCalculatedDataClientV1.cs b/source/ProcessManager.Client/Processes/BRS_026_028/V1/IRequestCalculatedDataClientV1.cs index 2f3b484128..bfe08ded01 100644 --- a/source/ProcessManager.Client/Processes/BRS_026_028/V1/IRequestCalculatedDataClientV1.cs +++ b/source/ProcessManager.Client/Processes/BRS_026_028/V1/IRequestCalculatedDataClientV1.cs @@ -25,10 +25,14 @@ public interface IRequestCalculatedDataClientV1 /// /// Start a request for energy results /// - public Task RequestCalculatedEnergyTimeSeriesAsync(RequestCalculatedDataInputV1 input, CancellationToken cancellationToken); + public Task RequestCalculatedEnergyTimeSeriesAsync( + RequestCalculatedDataInputV1 input, + CancellationToken cancellationToken); /// /// Start a request for wholesale results /// - public Task RequestCalculatedWholesaleServicesAsync(RequestCalculatedDataInputV1 input, CancellationToken cancellationToken); + public Task RequestCalculatedWholesaleServicesAsync( + RequestCalculatedDataInputV1 input, + CancellationToken cancellationToken); } diff --git a/source/ProcessManager.Client/Processes/BRS_026_028/V1/RequestCalculatedDataClientV1.cs b/source/ProcessManager.Client/Processes/BRS_026_028/V1/RequestCalculatedDataClientV1.cs index 1168476f96..613926214f 100644 --- a/source/ProcessManager.Client/Processes/BRS_026_028/V1/RequestCalculatedDataClientV1.cs +++ b/source/ProcessManager.Client/Processes/BRS_026_028/V1/RequestCalculatedDataClientV1.cs @@ -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; @@ -32,6 +33,17 @@ public class RequestCalculatedDataClientV1( public async Task RequestCalculatedEnergyTimeSeriesAsync(RequestCalculatedDataInputV1 input, CancellationToken cancellationToken) { + var x1 = new StartOrchestrationInstanceCommand(new ActorIdentityDto(Guid.NewGuid()), input.Input); + var y1 = ((ActorIdentityDto)x1.OperatingIdentity).ActorId; + + var x2 = new ScheduleOrchestrationInstanceCommand( + new UserIdentityDto(Guid.NewGuid(), Guid.NewGuid()), + DateTimeOffset.MinValue, + input.Input); + var y2 = ((ActorIdentityDto)x2.OperatingIdentity).ActorId; + + + var serviceBusMessage = CreateServiceBusMessage( "BRS_026", 1, diff --git a/source/ProcessManager.Orchestrations/ProcessManager.Orchestrations.csproj b/source/ProcessManager.Orchestrations/ProcessManager.Orchestrations.csproj index d66b82b9dd..b82cd52dc3 100644 --- a/source/ProcessManager.Orchestrations/ProcessManager.Orchestrations.csproj +++ b/source/ProcessManager.Orchestrations/ProcessManager.Orchestrations.csproj @@ -39,10 +39,13 @@ + + + diff --git a/source/ProcessManager/ProcessManager.csproj b/source/ProcessManager/ProcessManager.csproj index 8491fc11e8..5891230755 100644 --- a/source/ProcessManager/ProcessManager.csproj +++ b/source/ProcessManager/ProcessManager.csproj @@ -32,6 +32,8 @@ + + @@ -43,6 +45,7 @@ + \ No newline at end of file diff --git a/source/Shared/ProcessManager/Api/Model/IInputParameterDto.cs b/source/Shared/ProcessManager/Api/Model/IInputParameterDto.cs new file mode 100644 index 0000000000..07e868b448 --- /dev/null +++ b/source/Shared/ProcessManager/Api/Model/IInputParameterDto.cs @@ -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; + +/// +/// Marker interface for serializable input parameters to an orchestration instance. +/// +public interface IInputParameterDto; diff --git a/source/Shared/ProcessManager/Api/Model/OrchestrationInstanceCommand.cs b/source/Shared/ProcessManager/Api/Model/OrchestrationInstanceCommand.cs new file mode 100644 index 0000000000..3d170b025d --- /dev/null +++ b/source/Shared/ProcessManager/Api/Model/OrchestrationInstanceCommand.cs @@ -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; + +/// +/// A orchestration instance command executed by an identity. +/// +/// The identity executing the command. +public abstract record OrchestrationInstanceCommand(IOperatingIdentityDto OperatingIdentity); diff --git a/source/Shared/ProcessManager/Api/Model/ScheduleOrchestrationInstanceCommand.cs b/source/Shared/ProcessManager/Api/Model/ScheduleOrchestrationInstanceCommand.cs index d8eacbbf4c..b94183c913 100644 --- a/source/Shared/ProcessManager/Api/Model/ScheduleOrchestrationInstanceCommand.cs +++ b/source/Shared/ProcessManager/Api/Model/ScheduleOrchestrationInstanceCommand.cs @@ -28,4 +28,4 @@ public record ScheduleOrchestrationInstanceCommand( DateTimeOffset RunAt, TInputParameterDto InputParameter) : UserCommand(UserIdentity) - where TInputParameterDto : class; + where TInputParameterDto : IInputParameterDto; diff --git a/source/Shared/ProcessManager/Api/Model/StartOrchestrationInstanceCommand.cs b/source/Shared/ProcessManager/Api/Model/StartOrchestrationInstanceCommand.cs new file mode 100644 index 0000000000..517e298663 --- /dev/null +++ b/source/Shared/ProcessManager/Api/Model/StartOrchestrationInstanceCommand.cs @@ -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; + +/// +/// Command for starting an orchestration instance. +/// +/// Must be a JSON serializable type. +/// Identity executing the command. +/// Contains the Durable Functions orchestration input parameter value. +public record StartOrchestrationInstanceCommand( + IOperatingIdentityDto OperatingIdentity, + TInputParameterDto InputParameter) + : OrchestrationInstanceCommand(OperatingIdentity) + where TInputParameterDto : IInputParameterDto; diff --git a/source/Shared/ProcessManager/Api/Model/UserCommand.cs b/source/Shared/ProcessManager/Api/Model/UserCommand.cs index 3a0ec53bf0..0bf90bdfec 100644 --- a/source/Shared/ProcessManager/Api/Model/UserCommand.cs +++ b/source/Shared/ProcessManager/Api/Model/UserCommand.cs @@ -20,4 +20,5 @@ namespace Energinet.DataHub.ProcessManager.Api.Model; /// A command executed by a user. /// /// Identity of the user executing the command. -public abstract record UserCommand(UserIdentityDto UserIdentity); +public abstract record UserCommand(UserIdentityDto UserIdentity) + : OrchestrationInstanceCommand(UserIdentity); diff --git a/source/Shared/ProcessManager/Orchestrations/Processes/BRS_023_027/V1/Model/NotifyAggregatedMeasureDataInputV1.cs b/source/Shared/ProcessManager/Orchestrations/Processes/BRS_023_027/V1/Model/NotifyAggregatedMeasureDataInputV1.cs index f5013045ce..39feb6cb2c 100644 --- a/source/Shared/ProcessManager/Orchestrations/Processes/BRS_023_027/V1/Model/NotifyAggregatedMeasureDataInputV1.cs +++ b/source/Shared/ProcessManager/Orchestrations/Processes/BRS_023_027/V1/Model/NotifyAggregatedMeasureDataInputV1.cs @@ -17,7 +17,7 @@ namespace Energinet.DataHub.ProcessManager.Orchestrations.Processes.BRS_023_027. /// /// An immutable input to start the orchestration instance for "BRS_023_027" V1. /// -public sealed record NotifyAggregatedMeasureDataInputV1( +public record NotifyAggregatedMeasureDataInputV1( CalculationTypes CalculationType, IReadOnlyCollection GridAreaCodes, DateTimeOffset PeriodStartDate,