-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #56 from jlucansky/AddMissingServiceEndpoints
Add CaseInstance and Migration services
- Loading branch information
Showing
28 changed files
with
584 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
Camunda.Api.Client/CaseInstance/CaseInstanceDeleteVariable.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#region Usings | ||
|
||
using Newtonsoft.Json; | ||
|
||
#endregion | ||
|
||
namespace Camunda.Api.Client.CaseInstance | ||
{ | ||
public class CaseInstanceDeleteVariable | ||
{ | ||
[JsonProperty("name")] | ||
public string Name; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<string> TenantIdIn; | ||
|
||
[JsonProperty("withoutTenantId")] | ||
public bool? WithoutTenantId; | ||
|
||
[JsonProperty("variables")] | ||
public List<CaseInstanceQueryVariable> Variables; | ||
|
||
[JsonProperty("variableNamesIgnoreCase")] | ||
public bool VariableNamesIgnoreCase; | ||
|
||
[JsonProperty("variableValuesIgnoreCase")] | ||
public bool VariableValuesIgnoreCase; | ||
|
||
[JsonProperty("sorting")] | ||
public List<CaseInstanceSorting> Sorting; | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
Camunda.Api.Client/CaseInstance/CaseInstanceQueryVariable.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
|
||
/// <summary> | ||
/// Retrieves a case instance by id, according to the CaseInstance interface in the engine. | ||
/// </summary> | ||
/// <returns>corresponding case instance basis info</returns> | ||
public Task<CaseInstanceInfo> Get() => _api.Get(_caseInstanceId); | ||
|
||
/// <summary> | ||
/// 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). | ||
/// </summary> | ||
/// <param name="completeCaseInstanceState">contains variables to delete or update</param> | ||
/// <returns></returns> | ||
public Task Complete(ChangeCaseInstanceState completeCaseInstanceState) => | ||
_api.Complete(_caseInstanceId, completeCaseInstanceState); | ||
|
||
/// <summary> | ||
/// 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). | ||
/// </summary> | ||
/// <param name="closeCaseInstanceState">contains variables to delete or update</param> | ||
/// <returns></returns> | ||
public Task Close(ChangeCaseInstanceState closeCaseInstanceState) => | ||
_api.Close(_caseInstanceId, closeCaseInstanceState); | ||
|
||
/// <summary> | ||
/// 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). | ||
/// </summary> | ||
/// <param name="terminateCaseInstanceState">contains variables to delete or update</param> | ||
/// <returns></returns> | ||
public Task Terminate(ChangeCaseInstanceState terminateCaseInstanceState) => | ||
_api.Terminate(_caseInstanceId, terminateCaseInstanceState); | ||
|
||
|
||
public VariableResource Variables => new VariableResource(_api, _caseInstanceId); | ||
|
||
public override string ToString() => _caseInstanceId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace Camunda.Api.Client.CaseInstance | ||
{ | ||
public class CaseInstanceService | ||
{ | ||
private ICaseInstanceRestService _api; | ||
|
||
internal CaseInstanceService(ICaseInstanceRestService api) | ||
{ | ||
_api = api; | ||
} | ||
|
||
public QueryResource<CaseInstanceQuery, CaseInstanceInfo> Query(CaseInstanceQuery query = null) => | ||
new QueryResource<CaseInstanceQuery, CaseInstanceInfo>( | ||
query, | ||
(q, f, m) => _api.GetList(q, f, m), | ||
q => _api.GetListCount(q)); | ||
|
||
/// <param name="caseInstanceId">Id of specific case instance</param> | ||
public CaseInstanceResource this[string caseInstanceId] => new CaseInstanceResource(_api, caseInstanceId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace Camunda.Api.Client.CaseInstance | ||
{ | ||
public enum CaseInstanceSorting | ||
{ | ||
CaseInstanceId, | ||
CaseDefinitionKey, | ||
CaseDefinitionId, | ||
TenantId | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
Camunda.Api.Client/CaseInstance/CaseInstanceVariableValue.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#region Usings | ||
|
||
using Newtonsoft.Json; | ||
|
||
#endregion | ||
|
||
namespace Camunda.Api.Client.CaseInstance | ||
{ | ||
public class CaseInstanceVariableValue : VariableValue | ||
{ | ||
[JsonProperty("local")] | ||
public bool Local; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Camunda.Api.Client/CaseInstance/ChangeCaseInstanceState.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<string, CaseInstanceVariableValue> Variables; | ||
|
||
[JsonProperty("deletions")] | ||
public List<CaseInstanceDeleteVariable> Deletions; | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
Camunda.Api.Client/CaseInstance/ICaseInstanceRestService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Dictionary<string, VariableValue>> GetVariables(string id, bool? deserializeValues); | ||
|
||
[Get("/case-instance/{id}/variables/{varName}")] | ||
Task<VariableValue> 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<HttpResponseMessage> 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<CaseInstanceInfo> Get(string id); | ||
|
||
[Post("/case-instance")] | ||
Task<List<CaseInstanceInfo>> GetList([Body] CaseInstanceQuery query, int? firstResult, int? maxResults); | ||
|
||
[Post("/case-instance/count")] | ||
Task<CountResult> 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); | ||
} | ||
} |
Oops, something went wrong.