diff --git a/Camunda.Api.Client.sln b/Camunda.Api.Client.sln index ed2d51c..5168b49 100644 --- a/Camunda.Api.Client.sln +++ b/Camunda.Api.Client.sln @@ -18,6 +18,7 @@ Global {647F2D5F-4B9C-4A36-AAB6-A787182B6083}.Release|Any CPU.ActiveCfg = Release|Any CPU {647F2D5F-4B9C-4A36-AAB6-A787182B6083}.Release|Any CPU.Build.0 = Release|Any CPU {9EC88258-9A0B-448B-90F1-9FACA497228D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9EC88258-9A0B-448B-90F1-9FACA497228D}.Debug|Any CPU.Build.0 = Debug|Any CPU {9EC88258-9A0B-448B-90F1-9FACA497228D}.Release|Any CPU.ActiveCfg = Release|Any CPU {9EC88258-9A0B-448B-90F1-9FACA497228D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection diff --git a/Camunda.Api.Client/Batch/BatchInfo.cs b/Camunda.Api.Client/Batch/BatchInfo.cs index 55e70da..d20fb2d 100644 --- a/Camunda.Api.Client/Batch/BatchInfo.cs +++ b/Camunda.Api.Client/Batch/BatchInfo.cs @@ -44,5 +44,9 @@ public class BatchInfo /// The tenant id of the batch. /// public string TenantId; + /// + /// The id of the user that created the batch. + /// + public string CreateUserId; } } diff --git a/Camunda.Api.Client/CamundaClient.cs b/Camunda.Api.Client/CamundaClient.cs index fa296f7..20c918a 100644 --- a/Camunda.Api.Client/CamundaClient.cs +++ b/Camunda.Api.Client/CamundaClient.cs @@ -8,6 +8,7 @@ using Camunda.Api.Client.CaseDefinition; using Camunda.Api.Client.CaseExecution; +using Camunda.Api.Client.CaseInstance; using Camunda.Api.Client.DecisionDefinition; using Camunda.Api.Client.Deployment; using Camunda.Api.Client.Execution; @@ -18,6 +19,7 @@ using Camunda.Api.Client.Job; using Camunda.Api.Client.JobDefinition; using Camunda.Api.Client.Message; +using Camunda.Api.Client.Migration; using Camunda.Api.Client.ProcessDefinition; using Camunda.Api.Client.ProcessInstance; using Camunda.Api.Client.Signal; @@ -25,6 +27,7 @@ using Camunda.Api.Client.User; using Camunda.Api.Client.UserTask; using Camunda.Api.Client.VariableInstance; + using JsonSerializer = Newtonsoft.Json.JsonSerializer; namespace Camunda.Api.Client @@ -33,6 +36,7 @@ public class CamundaClient { private Lazy _caseDefinitionRestService; private Lazy _caseExecutionRestService; + private Lazy _caseInstanceRestService; private Lazy _decisionDefinitionRestService; private Lazy _deploymentApi; private Lazy _executionApi; @@ -41,6 +45,7 @@ public class CamundaClient private Lazy _incidentApi; private Lazy _jobDefinitionApi; private Lazy _jobApi; + private Lazy _migrationRestService; private Lazy _messageApi; private Lazy _processDefinitionApi; private Lazy _processInstanceApi; @@ -190,6 +195,7 @@ private void CreateServices() { _caseDefinitionRestService = CreateService(); _caseExecutionRestService = CreateService(); + _caseInstanceRestService = CreateService(); _decisionDefinitionRestService = CreateService(); _deploymentApi = CreateService(); _executionApi = CreateService(); @@ -199,6 +205,7 @@ private void CreateServices() _jobApi = CreateService(); _jobDefinitionApi = CreateService(); _messageApi = CreateService(); + _migrationRestService = CreateService(); _processDefinitionApi = CreateService(); _processInstanceApi = CreateService(); _signalApi = CreateService(); @@ -251,6 +258,9 @@ public static CamundaClient Create(HttpClient httpClient) /// public CaseExecutionService CaseExecutions => new CaseExecutionService(_caseExecutionRestService.Value); + /// + public CaseInstanceService CaseInstances => new CaseInstanceService(_caseInstanceRestService.Value); + /// public DecisionDefinitionService DecisionDefinitions => new DecisionDefinitionService(_decisionDefinitionRestService.Value); @@ -281,6 +291,9 @@ public static CamundaClient Create(HttpClient httpClient) /// public MessageService Messages => new MessageService(_messageApi.Value); + /// + public MigrationService Migrations => new MigrationService(_migrationRestService.Value); + /// public ProcessDefinitionService ProcessDefinitions => new ProcessDefinitionService(_processDefinitionApi.Value); diff --git a/Camunda.Api.Client/CaseInstance/CaseInstanceDeleteVariable.cs b/Camunda.Api.Client/CaseInstance/CaseInstanceDeleteVariable.cs new file mode 100644 index 0000000..d26fed2 --- /dev/null +++ b/Camunda.Api.Client/CaseInstance/CaseInstanceDeleteVariable.cs @@ -0,0 +1,14 @@ +#region Usings + +using Newtonsoft.Json; + +#endregion + +namespace Camunda.Api.Client.CaseInstance +{ + public class CaseInstanceDeleteVariable + { + [JsonProperty("name")] + public string Name; + } +} diff --git a/Camunda.Api.Client/CaseInstance/CaseInstanceQuery.cs b/Camunda.Api.Client/CaseInstance/CaseInstanceQuery.cs new file mode 100644 index 0000000..b0b14ef --- /dev/null +++ b/Camunda.Api.Client/CaseInstance/CaseInstanceQuery.cs @@ -0,0 +1,63 @@ +#region Usings + +using System.Collections.Generic; +using Newtonsoft.Json; + +#endregion + +namespace Camunda.Api.Client.CaseInstance +{ + public class CaseInstanceQuery + { + [JsonProperty("caseInstanceId")] + public string CaseInstanceId; + + [JsonProperty("businessKey")] + public string BusinessKey; + + [JsonProperty("caseDefinitionId")] + public string CaseDefinitionId; + + [JsonProperty("caseDefinitionKey")] + public string CaseDefinitionKey; + + [JsonProperty("deploymentId")] + public string DeploymentId; + + [JsonProperty("superProcessInstance")] + public string SuperProcessInstance; + + [JsonProperty("subProcessInstance")] + public string SubProcessInstance; + + [JsonProperty("superCaseInstance")] + public string SuperCaseInstance; + + [JsonProperty("subCaseInstance")] + public string SubCaseInstance; + + [JsonProperty("active")] + public bool? Active; + + [JsonProperty("completed")] + public bool? Completed; + + [JsonProperty("tenantIdIn")] + public List TenantIdIn; + + [JsonProperty("withoutTenantId")] + public bool? WithoutTenantId; + + [JsonProperty("variables")] + public List Variables; + + [JsonProperty("variableNamesIgnoreCase")] + public bool VariableNamesIgnoreCase; + + [JsonProperty("variableValuesIgnoreCase")] + public bool VariableValuesIgnoreCase; + + [JsonProperty("sorting")] + public List Sorting; + } +} diff --git a/Camunda.Api.Client/CaseInstance/CaseInstanceQueryVariable.cs b/Camunda.Api.Client/CaseInstance/CaseInstanceQueryVariable.cs new file mode 100644 index 0000000..c9ec3fc --- /dev/null +++ b/Camunda.Api.Client/CaseInstance/CaseInstanceQueryVariable.cs @@ -0,0 +1,20 @@ +#region Usings + +using Newtonsoft.Json; + +#endregion + +namespace Camunda.Api.Client.CaseInstance +{ + public class CaseInstanceQueryVariable + { + [JsonProperty("name")] + public string Name; + + [JsonProperty("operator")] + public ConditionOperator Operator; + + [JsonProperty("value")] + public object Value; + } +} diff --git a/Camunda.Api.Client/CaseInstance/CaseInstanceResource.cs b/Camunda.Api.Client/CaseInstance/CaseInstanceResource.cs new file mode 100644 index 0000000..7e83012 --- /dev/null +++ b/Camunda.Api.Client/CaseInstance/CaseInstanceResource.cs @@ -0,0 +1,58 @@ +#region Usings + +using System.Collections.Generic; +using System.Net; +using System.Net.Http; +using System.Threading.Tasks; + +#endregion + +namespace Camunda.Api.Client.CaseInstance +{ + public class CaseInstanceResource + { + private string _caseInstanceId; + private ICaseInstanceRestService _api; + + internal CaseInstanceResource(ICaseInstanceRestService api, string caseInstanceId) + { + _api = api; + _caseInstanceId = caseInstanceId; + } + + /// + /// Retrieves a case instance by id, according to the CaseInstance interface in the engine. + /// + /// corresponding case instance basis info + public Task Get() => _api.Get(_caseInstanceId); + + /// + /// Performs a transition from ACTIVE state to COMPLETED state. In relation to the state transition, it is possible to update or delete case instance variables (please note: deletion precedes update). + /// + /// contains variables to delete or update + /// + public Task Complete(ChangeCaseInstanceState completeCaseInstanceState) => + _api.Complete(_caseInstanceId, completeCaseInstanceState); + + /// + /// Performs a transition from COMPLETED state to CLOSED state. In relation to the state transition, it is possible to update or delete case instance variables (please note: deletion precedes update). + /// + /// contains variables to delete or update + /// + public Task Close(ChangeCaseInstanceState closeCaseInstanceState) => + _api.Close(_caseInstanceId, closeCaseInstanceState); + + /// + /// Performs a transition from ACTIVE state to TERMINATED state. In relation to the state transition, it is possible to update or delete case instance variables (please note: deletion precedes update). + /// + /// contains variables to delete or update + /// + public Task Terminate(ChangeCaseInstanceState terminateCaseInstanceState) => + _api.Terminate(_caseInstanceId, terminateCaseInstanceState); + + + public VariableResource Variables => new VariableResource(_api, _caseInstanceId); + + public override string ToString() => _caseInstanceId; + } +} diff --git a/Camunda.Api.Client/CaseInstance/CaseInstanceService.cs b/Camunda.Api.Client/CaseInstance/CaseInstanceService.cs new file mode 100644 index 0000000..bdb5bca --- /dev/null +++ b/Camunda.Api.Client/CaseInstance/CaseInstanceService.cs @@ -0,0 +1,21 @@ +namespace Camunda.Api.Client.CaseInstance +{ + public class CaseInstanceService + { + private ICaseInstanceRestService _api; + + internal CaseInstanceService(ICaseInstanceRestService api) + { + _api = api; + } + + public QueryResource Query(CaseInstanceQuery query = null) => + new QueryResource( + query, + (q, f, m) => _api.GetList(q, f, m), + q => _api.GetListCount(q)); + + /// Id of specific case instance + public CaseInstanceResource this[string caseInstanceId] => new CaseInstanceResource(_api, caseInstanceId); + } +} diff --git a/Camunda.Api.Client/CaseInstance/CaseInstanceSorting.cs b/Camunda.Api.Client/CaseInstance/CaseInstanceSorting.cs new file mode 100644 index 0000000..442f6c1 --- /dev/null +++ b/Camunda.Api.Client/CaseInstance/CaseInstanceSorting.cs @@ -0,0 +1,10 @@ +namespace Camunda.Api.Client.CaseInstance +{ + public enum CaseInstanceSorting + { + CaseInstanceId, + CaseDefinitionKey, + CaseDefinitionId, + TenantId + } +} diff --git a/Camunda.Api.Client/CaseInstance/CaseInstanceVariableValue.cs b/Camunda.Api.Client/CaseInstance/CaseInstanceVariableValue.cs new file mode 100644 index 0000000..9c63a72 --- /dev/null +++ b/Camunda.Api.Client/CaseInstance/CaseInstanceVariableValue.cs @@ -0,0 +1,14 @@ +#region Usings + +using Newtonsoft.Json; + +#endregion + +namespace Camunda.Api.Client.CaseInstance +{ + public class CaseInstanceVariableValue : VariableValue + { + [JsonProperty("local")] + public bool Local; + } +} diff --git a/Camunda.Api.Client/CaseInstance/ChangeCaseInstanceState.cs b/Camunda.Api.Client/CaseInstance/ChangeCaseInstanceState.cs new file mode 100644 index 0000000..c2c76c0 --- /dev/null +++ b/Camunda.Api.Client/CaseInstance/ChangeCaseInstanceState.cs @@ -0,0 +1,18 @@ +#region Usings + +using System.Collections.Generic; +using Newtonsoft.Json; + +#endregion + +namespace Camunda.Api.Client.CaseInstance +{ + public class ChangeCaseInstanceState + { + [JsonProperty("variables")] + public Dictionary Variables; + + [JsonProperty("deletions")] + public List Deletions; + } +} diff --git a/Camunda.Api.Client/CaseInstance/ICaseInstanceRestService.cs b/Camunda.Api.Client/CaseInstance/ICaseInstanceRestService.cs new file mode 100644 index 0000000..5bdd5f6 --- /dev/null +++ b/Camunda.Api.Client/CaseInstance/ICaseInstanceRestService.cs @@ -0,0 +1,54 @@ +#region Usings + +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; +using Refit; + +#endregion + +namespace Camunda.Api.Client.CaseInstance +{ + internal interface ICaseInstanceRestService + { + [Get("/case-instance/{id}/variables")] + Task> GetVariables(string id, bool? deserializeValues); + + [Get("/case-instance/{id}/variables/{varName}")] + Task GetVariableValue(string id, string varName, bool? deserializeValue); + + // TODO: check if HttpWebResponse is indeed the correct return type + [Get("/case-instance/{id}/variables/{varName}/data")] + Task GetBinaryVariable(string id, string varName); + + [Post("/case-instance/{id}/variables")] + Task ModifyVariables(string id, [Body] PatchVariables patch); + + [Put("/case-instance/{id}/variables/{varName}")] + Task UpdateVariable(string id, string varName, [Body] VariableValue value); + + [Post("/case-instance/{id}/variables/{varName}/data")] + Task SetBinaryVariable(string id, string varName, BinaryDataContent data, ValueTypeContent valueType); + + [Delete("/case-instance/{id}/variables/{varName}")] + Task DeleteVariable(string id, string varName); + + [Get("/case-instance/{id}")] + Task Get(string id); + + [Post("/case-instance")] + Task> GetList([Body] CaseInstanceQuery query, int? firstResult, int? maxResults); + + [Post("/case-instance/count")] + Task GetListCount([Body] CaseInstanceQuery query); + + [Post("/case-instance/{id}/complete")] + Task Complete(string id, [Body] ChangeCaseInstanceState completeCaseInstance); + + [Post("/case-instance/{id}/close")] + Task Close(string id, [Body] ChangeCaseInstanceState closeCaseInstance); + + [Post("/case-instance/{id}/terminate")] + Task Terminate(string id, [Body] ChangeCaseInstanceState terminateCaseInstance); + } +} diff --git a/Camunda.Api.Client/CaseInstance/VariableResource.cs b/Camunda.Api.Client/CaseInstance/VariableResource.cs new file mode 100644 index 0000000..59607af --- /dev/null +++ b/Camunda.Api.Client/CaseInstance/VariableResource.cs @@ -0,0 +1,50 @@ +using System.Collections.Generic; +using System.Net.Http; +using System.Threading.Tasks; + +namespace Camunda.Api.Client.CaseInstance +{ + public class VariableResource : IVariableResource + { + private string _caseInstanceId; + private ICaseInstanceRestService _api; + + internal VariableResource(ICaseInstanceRestService api, string caseInstanceId) + { + _api = api; + _caseInstanceId = caseInstanceId; + } + + /// + /// Retrieves all variables of a given case instance. + /// + /// Determines whether serializable variable values (typically variables that store custom Java objects) should be deserialized on server side. + public Task> GetAll(bool deserializeValues = true) => _api.GetVariables(_caseInstanceId, deserializeValues); + /// + /// Retrieves a variable from the context of a given case instance. + /// + public Task Get(string variableName, bool deserializeValue = true) => _api.GetVariableValue(_caseInstanceId, variableName, deserializeValue); + /// + /// Retrieves a binary variable from the context of a given case instance. Applicable for byte array and file variables. + /// + public async Task GetBinary(string variableName) => (await _api.GetBinaryVariable(_caseInstanceId, variableName)).Content; + /// + /// Sets a variable in the context of a given case instance. + /// + public Task Set(string variableName, VariableValue variable) => _api.UpdateVariable(_caseInstanceId, variableName, variable); + /// + /// Sets the serialized value for a binary variable or the binary value for a file variable. + /// + public Task SetBinary(string variableName, BinaryDataContent data, BinaryVariableType valueType) => _api.SetBinaryVariable(_caseInstanceId, variableName, data, new ValueTypeContent(valueType.ToString())); + /// + /// Removes a variable from a case instance. + /// + public Task Delete(string variableName) => _api.DeleteVariable(_caseInstanceId, variableName); + /// + /// Updates or deletes the variables in the context of a case instance. Updates precede deletions. So, if a variable is updated AND deleted, the deletion overrides the update. + /// + public Task Modify(PatchVariables patch) => _api.ModifyVariables(_caseInstanceId, patch); + + public override string ToString() => _caseInstanceId; + } +} diff --git a/Camunda.Api.Client/JobDefinition/IJobDefinitionRestService.cs b/Camunda.Api.Client/JobDefinition/IJobDefinitionRestService.cs index dc8b067..e18e1b9 100644 --- a/Camunda.Api.Client/JobDefinition/IJobDefinitionRestService.cs +++ b/Camunda.Api.Client/JobDefinition/IJobDefinitionRestService.cs @@ -16,7 +16,7 @@ internal interface IJobDefinitionRestService Task GetListCount([Body] JobDefinitionQuery query); [Put("/job-definition/suspended")] - Task UpdateSuspensionState(JobDefinitionSuspensionState state); + Task UpdateSuspensionState([Body]JobDefinitionSuspensionState state); [Put("/job-definition/{jobDefinitionId}/suspended")] Task UpdateSuspensionStateForId(string jobDefinitionId, [Body] SuspensionState suspensionState); diff --git a/Camunda.Api.Client/Migration/IMigrationRestService.cs b/Camunda.Api.Client/Migration/IMigrationRestService.cs new file mode 100644 index 0000000..cee6b7d --- /dev/null +++ b/Camunda.Api.Client/Migration/IMigrationRestService.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Camunda.Api.Client.Batch; +using Refit; + +namespace Camunda.Api.Client.Migration +{ + internal interface IMigrationRestService + { + [Post("/migration/generate")] + Task Generate([Body] MigrationPlanGeneration request); + + [Post("/migration/validate")] + Task Validate([Body] MigrationPlan plan); + + [Post("/migration/execute")] + Task Execute([Body] MigrationExecution request); + + [Post("/migration/executeAsync")] + Task ExecuteAsync([Body] MigrationExecution request); + } +} diff --git a/Camunda.Api.Client/Migration/MigrationExecution.cs b/Camunda.Api.Client/Migration/MigrationExecution.cs new file mode 100644 index 0000000..0be0107 --- /dev/null +++ b/Camunda.Api.Client/Migration/MigrationExecution.cs @@ -0,0 +1,39 @@ +using System.Collections.Generic; +using Camunda.Api.Client.ProcessInstance; +using Newtonsoft.Json; + +namespace Camunda.Api.Client.Migration +{ + public class MigrationExecution + { + /// + /// The migration plan to execute. + /// + [JsonProperty("migrationPlan")] + public MigrationPlan MigrationPlan; + + /// + /// A list of process instance ids to migrate. + /// + [JsonProperty("processInstanceIds")] + public List ProcessInstanceIds; + + /// + /// A process instance query. + /// + [JsonProperty("processInstanceQuery")] + public ProcessInstanceQuery ProcessInstanceQuery; + + /// + /// A boolean value to control whether execution listeners should be invoked during migration. + /// + [JsonProperty("skipCustomListeners")] + public bool SkipCustomListeners; + + /// + /// A boolean value to control whether input/output mappings should be executed during migration. + /// + [JsonProperty("skipIoMappings")] + public bool SkipIoMappings; + } +} diff --git a/Camunda.Api.Client/Migration/MigrationInstruction.cs b/Camunda.Api.Client/Migration/MigrationInstruction.cs new file mode 100644 index 0000000..ddea4d7 --- /dev/null +++ b/Camunda.Api.Client/Migration/MigrationInstruction.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Camunda.Api.Client.Migration +{ + public class MigrationInstruction + { + /// + /// The activity ids from the source process definition being mapped. + /// + [JsonProperty("sourceActivityIds")] + public List SourceActivityIds; + + /// + /// The activity ids from the target process definition being mapped. + /// + [JsonProperty("targetActivityIds")] + public List TargetActivityIds; + + /// + /// Configuration flag whether event triggers defined are going to be updated during migration. + /// + [JsonProperty("updateEventTrigger")] + public bool UpdateEventTrigger; + } +} diff --git a/Camunda.Api.Client/Migration/MigrationInstructionValidationReport.cs b/Camunda.Api.Client/Migration/MigrationInstructionValidationReport.cs new file mode 100644 index 0000000..dd66ff4 --- /dev/null +++ b/Camunda.Api.Client/Migration/MigrationInstructionValidationReport.cs @@ -0,0 +1,20 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Camunda.Api.Client.Migration +{ + public class MigrationInstructionValidationReport + { + /// + /// A migration instruction object. + /// + [JsonProperty("instruction")] + public MigrationInstruction Instruction; + + /// + /// A list of instruction validation report messages. + /// + [JsonProperty("failures")] + public List Failures; + } +} diff --git a/Camunda.Api.Client/Migration/MigrationPlan.cs b/Camunda.Api.Client/Migration/MigrationPlan.cs new file mode 100644 index 0000000..710a072 --- /dev/null +++ b/Camunda.Api.Client/Migration/MigrationPlan.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using Newtonsoft.Json; + +namespace Camunda.Api.Client.Migration +{ + public class MigrationPlan + { + /// + /// The id of the source process definition for the migration. + /// + [JsonProperty("sourceProcessDefinitionId")] + public string SourceProcessDefinitionId; + + /// + /// The id of the target process definition for the migration. + /// + [JsonProperty("targetProcessDefinitionId")] + public string TargetProcessDefinitionId; + + /// + /// A list of migration instructions which map equal activities. + /// + [JsonProperty("instructions")] + public List Instructions; + } +} diff --git a/Camunda.Api.Client/Migration/MigrationPlanGeneration.cs b/Camunda.Api.Client/Migration/MigrationPlanGeneration.cs new file mode 100644 index 0000000..ee4a58e --- /dev/null +++ b/Camunda.Api.Client/Migration/MigrationPlanGeneration.cs @@ -0,0 +1,25 @@ +using Newtonsoft.Json; + +namespace Camunda.Api.Client.Migration +{ + public class MigrationPlanGeneration + { + /// + /// The id of the source process definition for the migration. + /// + [JsonProperty("sourceProcessDefinitionId")] + public string SourceProcessDefinitionId; + + /// + /// The id of the target process definition for the migration. + /// + [JsonProperty("targetProcessDefinitionId")] + public string TargetProcessDefinitionId; + + /// + /// A boolean flag indicating whether instructions between events should be configured to update the event triggers. + /// + [JsonProperty("updateEventTriggers")] + public bool UpdateEventTriggers; + } +} diff --git a/Camunda.Api.Client/Migration/MigrationPlanReport.cs b/Camunda.Api.Client/Migration/MigrationPlanReport.cs new file mode 100644 index 0000000..56fb41f --- /dev/null +++ b/Camunda.Api.Client/Migration/MigrationPlanReport.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Text; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; + +namespace Camunda.Api.Client.Migration +{ + public class MigrationPlanReport + { + /// + /// The list of instruction validation reports. If no validation errors are detected it is an empty list. + /// + [JsonProperty("instructionReports")] + public List InstructionReports; + } +} diff --git a/Camunda.Api.Client/Migration/MigrationService.cs b/Camunda.Api.Client/Migration/MigrationService.cs new file mode 100644 index 0000000..84ce9e4 --- /dev/null +++ b/Camunda.Api.Client/Migration/MigrationService.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; +using Camunda.Api.Client.Batch; + +namespace Camunda.Api.Client.Migration +{ + public class MigrationService + { + private IMigrationRestService _api; + + internal MigrationService(IMigrationRestService api) + { + _api = api; + } + + /// + /// Generates a migration plan for two process definitions. The generated migration plan contains migration instructions which map equal activities between the two process definitions. + /// + /// + /// + public Task Generate(MigrationPlanGeneration request) => _api.Generate(request); + + /// + /// Validates a migration plan statically without executing it. + /// + /// + /// + public Task Validate(MigrationPlan plan) => _api.Validate(plan); + + /// + /// Executes a migration plan synchronously for multiple process instances. + /// + /// + /// + public Task Execute(MigrationExecution request) => _api.Execute(request); + + /// + /// Executes a migration plan asynchronously (batch) for multiple process instances. + /// + /// + /// + public Task ExecuteAsync(MigrationExecution request) => _api.ExecuteAsync(request); + } +} diff --git a/Camunda.Api.Client/ProcessDefinition/IProcessDefinitionRestService.cs b/Camunda.Api.Client/ProcessDefinition/IProcessDefinitionRestService.cs index 3e34ce3..20af062 100644 --- a/Camunda.Api.Client/ProcessDefinition/IProcessDefinitionRestService.cs +++ b/Camunda.Api.Client/ProcessDefinition/IProcessDefinitionRestService.cs @@ -18,7 +18,11 @@ internal interface IProcessDefinitionRestService Task> GetProcessInstanceStatistics(bool failedJobs, bool? incidents, string incidentsForType); [Delete("/process-definition/{id}")] - Task Delete(string id, bool cascade, bool skipCustomListeners); + Task Delete(string id, bool cascade, bool skipCustomListeners, bool skipIoMappings); + [Delete("/process-definition/key/{key}/delete")] + Task DeleteByKey(string key, bool cascade, bool skipCustomListeners, bool skipIoMappings); + [Delete("/process-definition/key/{key}/tenant-id/{tenantId}/delete")] + Task DeleteByKeyAndTenantId(string key, string tenantId, bool cascade, bool skipCustomListeners, bool skipIoMappings); [Put("/process-definition/{id}/suspended")] Task UpdateSuspensionStateById(string id, [Body] ProcessDefinitionSuspensionState state); diff --git a/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionResource.cs b/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionResource.cs index 357057a..8455038 100644 --- a/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionResource.cs +++ b/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionResource.cs @@ -12,6 +12,12 @@ public abstract class ProcessDefinitionResource /// public abstract Task Get(); + /// + /// Deletes process definition(s). + /// + /// + public abstract Task Delete(bool cascade, bool skipCustomListeners, bool skipIoMappings); + /// /// Retrieves the BPMN 2.0 XML of this process definition. /// diff --git a/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionResourceById.cs b/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionResourceById.cs index 7cc3ce9..c2a1946 100644 --- a/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionResourceById.cs +++ b/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionResourceById.cs @@ -19,6 +19,8 @@ internal ProcessDefinitionResourceById(IProcessDefinitionRestService api, string public override Task Get() => _api.GetById(_processDefinitionId); + public override Task Delete(bool cascade, bool skipCustomListeners, bool skipIoMappings = true) => _api.Delete(_processDefinitionId, cascade, skipCustomListeners, skipIoMappings); + public override Task GetXml() => _api.GetXmlById(_processDefinitionId); public override async Task GetDiagram() => (await _api.GetDiagramById(_processDefinitionId)).Content; @@ -39,7 +41,7 @@ protected override Task> GetActivityStatistics(bool inclu public override Task> GetFormVariables(params string[] variableNames) => _api.GetFormVariablesById(_processDefinitionId, variableNames.Join()); public override Task> GetFormVariables(string[] variableNames, bool deserializeValues = true) => _api.GetFormVariablesById(_processDefinitionId, variableNames.Join(), deserializeValues); - + public override string ToString() => _processDefinitionId; } } diff --git a/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionResourceByKey.cs b/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionResourceByKey.cs index 433c4d9..5822a77 100644 --- a/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionResourceByKey.cs +++ b/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionResourceByKey.cs @@ -20,6 +20,9 @@ internal ProcessDefinitionResourceByKey(IProcessDefinitionRestService api, strin public override Task Get() => _api.GetByKey(_processDefinitionKey); + public override Task Delete(bool cascade, bool skipCustomListeners, bool skipIoMappings = true) => + _api.DeleteByKey(_processDefinitionKey, cascade, skipCustomListeners, skipIoMappings); + public override Task GetXml() => _api.GetXmlByKey(_processDefinitionKey); public override async Task GetDiagram() => (await _api.GetDiagramByKey(_processDefinitionKey)).Content; diff --git a/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionResourceByKeyAndTenantId.cs b/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionResourceByKeyAndTenantId.cs index 83cd0bc..6869fc2 100644 --- a/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionResourceByKeyAndTenantId.cs +++ b/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionResourceByKeyAndTenantId.cs @@ -21,6 +21,9 @@ internal ProcessDefinitionResourceByKeyAndTenantId(IProcessDefinitionRestService public override Task Get() => _api.GetByKeyAndTenantId(_processDefinitionKey, _tenantId); + public override Task Delete(bool cascade, bool skipCustomListeners, bool skipIoMappings) => + _api.DeleteByKeyAndTenantId(_processDefinitionKey, _tenantId, cascade, skipCustomListeners, skipIoMappings); + public override Task GetXml() => _api.GetXmlByKeyAndTenantId(_processDefinitionKey, _tenantId); public override async Task GetDiagram() => (await _api.GetDiagramByKeyAndTenantId(_processDefinitionKey, _tenantId)).Content; diff --git a/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionService.cs b/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionService.cs index b526a54..fcbbff9 100644 --- a/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionService.cs +++ b/Camunda.Api.Client/ProcessDefinition/ProcessDefinitionService.cs @@ -53,7 +53,8 @@ public Task> GetStatistics(bool includeF /// /// true, if all process instances, historic process instances and jobs for this process definition should be deleted. /// true, if only the built-in ExecutionListeners should be notified with the end event. + /// true, if input/output mappings should not be invoked. /// - public Task Delete(string processDefinitionId, bool cascade, bool skipCustomListeners) => _api.Delete(processDefinitionId, cascade, skipCustomListeners); + public Task Delete(string processDefinitionId, bool cascade, bool skipCustomListeners, bool skipIoMappings = true) => _api.Delete(processDefinitionId, cascade, skipCustomListeners, skipIoMappings); } }