From ed7c4fbfbb06a51023bc4bfccb6d6ea88710fd11 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Fri, 30 Aug 2024 11:27:10 +0200 Subject: [PATCH 01/38] Created test version including version bump to 1.5.0 --- misc/BreCalApi.cs | 1936 ++++++++++++++--- misc/BreCalApi.yaml | 4 +- src/BreCalClient/App.config | 4 +- src/BreCalClient/BreCalClient.csproj | 12 +- .../ClickOnceTestProfile.pubxml | 2 +- .../Properties/Settings.Designer.cs | 4 +- src/BreCalClient/Properties/Settings.settings | 4 +- src/BreCalClient/ShipcallControl.xaml | 2 +- src/BreCalClient/ShipcallControl.xaml.cs | 12 +- src/RoleEditor/App.config | 2 +- src/server/BreCal/__init__.py | 2 +- src/server/BreCal/local_db.py | 4 +- src/server/flaskapp.wsgi | 2 +- src/server/setup.py | 2 +- 14 files changed, 1699 insertions(+), 293 deletions(-) diff --git a/misc/BreCalApi.cs b/misc/BreCalApi.cs index f5147d3..aab99e4 100644 --- a/misc/BreCalApi.cs +++ b/misc/BreCalApi.cs @@ -1,15 +1,14 @@ //---------------------- // -// Generated REST API Client Code Generator v1.10.9.0 on 29.08.2024 08:26:31 -// Using the tool OpenAPI Generator v7.8.0 +// Generated REST API Client Code Generator v1.9.8.0 on 30.08.2024 11:13:19 +// Using the tool OpenAPI Generator v7.4.0 // //---------------------- using BreCalClient.misc.Client; using BreCalClient.misc.Model; -using FileIO = System.IO.File; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; @@ -40,13 +39,14 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; +using System.Web; /* * Bremen calling API * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -164,7 +164,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - System.Threading.Tasks.Task ShipDeleteAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task ShipDeleteAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Delete a ship (logically). /// @@ -176,7 +176,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - System.Threading.Tasks.Task> ShipDeleteWithHttpInfoAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task> ShipDeleteWithHttpInfoAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Update a ship entry /// @@ -188,7 +188,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - System.Threading.Tasks.Task ShipUpdateAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task ShipUpdateAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Update a ship entry /// @@ -200,7 +200,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - System.Threading.Tasks.Task> ShipUpdateWithHttpInfoAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task> ShipUpdateWithHttpInfoAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// create a new ship entry /// @@ -212,7 +212,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - System.Threading.Tasks.Task ShipsCreateAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task ShipsCreateAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// create a new ship entry /// @@ -224,7 +224,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - System.Threading.Tasks.Task> ShipsCreateWithHttpInfoAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task> ShipsCreateWithHttpInfoAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// gets a list of ships /// @@ -235,7 +235,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Ship> - System.Threading.Tasks.Task> ShipsGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task> ShipsGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// gets a list of ships /// @@ -246,7 +246,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Ship>) - System.Threading.Tasks.Task>> ShipsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task>> ShipsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); #endregion Asynchronous Operations } /// @@ -418,7 +418,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - public async System.Threading.Tasks.Task ShipDeleteAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task ShipDeleteAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await ShipDeleteWithHttpInfoAsync(id, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -431,7 +431,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - public async System.Threading.Tasks.Task> ShipDeleteWithHttpInfoAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> ShipDeleteWithHttpInfoAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -542,7 +542,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - public async System.Threading.Tasks.Task ShipUpdateAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task ShipUpdateAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await ShipUpdateWithHttpInfoAsync(ship, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -555,7 +555,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - public async System.Threading.Tasks.Task> ShipUpdateWithHttpInfoAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> ShipUpdateWithHttpInfoAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { // verify the required parameter 'ship' is set if (ship == null) @@ -672,7 +672,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - public async System.Threading.Tasks.Task ShipsCreateAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task ShipsCreateAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await ShipsCreateWithHttpInfoAsync(ship, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -685,7 +685,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - public async System.Threading.Tasks.Task> ShipsCreateWithHttpInfoAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> ShipsCreateWithHttpInfoAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { // verify the required parameter 'ship' is set if (ship == null) @@ -792,7 +792,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Ship> - public async System.Threading.Tasks.Task> ShipsGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> ShipsGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse> localVarResponse = await ShipsGetWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -804,7 +804,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Ship>) - public async System.Threading.Tasks.Task>> ShipsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task>> ShipsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -850,7 +850,7 @@ namespace BreCalClient.misc.Api * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -947,7 +947,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - System.Threading.Tasks.Task ShipcallCreateAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task ShipcallCreateAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Create a new ship call /// @@ -959,7 +959,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - System.Threading.Tasks.Task> ShipcallCreateWithHttpInfoAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task> ShipcallCreateWithHttpInfoAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Updates a ship call /// @@ -971,7 +971,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - System.Threading.Tasks.Task ShipcallUpdateAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task ShipcallUpdateAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Updates a ship call /// @@ -983,7 +983,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - System.Threading.Tasks.Task> ShipcallUpdateWithHttpInfoAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task> ShipcallUpdateWithHttpInfoAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Gets a list of ship calls /// @@ -995,7 +995,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Shipcall> - System.Threading.Tasks.Task> ShipcallsGetAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task> ShipcallsGetAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Gets a list of ship calls /// @@ -1007,7 +1007,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Shipcall>) - System.Threading.Tasks.Task>> ShipcallsGetWithHttpInfoAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task>> ShipcallsGetWithHttpInfoAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); #endregion Asynchronous Operations } /// @@ -1185,7 +1185,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - public async System.Threading.Tasks.Task ShipcallCreateAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task ShipcallCreateAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await ShipcallCreateWithHttpInfoAsync(shipcall, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -1198,7 +1198,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - public async System.Threading.Tasks.Task> ShipcallCreateWithHttpInfoAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> ShipcallCreateWithHttpInfoAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { // verify the required parameter 'shipcall' is set if (shipcall == null) @@ -1315,7 +1315,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - public async System.Threading.Tasks.Task ShipcallUpdateAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task ShipcallUpdateAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await ShipcallUpdateWithHttpInfoAsync(shipcall, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -1328,7 +1328,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - public async System.Threading.Tasks.Task> ShipcallUpdateWithHttpInfoAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> ShipcallUpdateWithHttpInfoAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { // verify the required parameter 'shipcall' is set if (shipcall == null) @@ -1442,7 +1442,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Shipcall> - public async System.Threading.Tasks.Task> ShipcallsGetAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> ShipcallsGetAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse> localVarResponse = await ShipcallsGetWithHttpInfoAsync(pastDays, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -1455,7 +1455,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Shipcall>) - public async System.Threading.Tasks.Task>> ShipcallsGetWithHttpInfoAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task>> ShipcallsGetWithHttpInfoAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -1505,7 +1505,7 @@ namespace BreCalClient.misc.Api * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -1621,7 +1621,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Berth> - System.Threading.Tasks.Task> BerthsGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task> BerthsGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Gets a list of all berths registered /// @@ -1632,7 +1632,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Berth>) - System.Threading.Tasks.Task>> BerthsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task>> BerthsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// History data /// @@ -1644,7 +1644,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<History> - System.Threading.Tasks.Task> HistoryGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task> HistoryGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// History data /// @@ -1656,7 +1656,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<History>) - System.Threading.Tasks.Task>> HistoryGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task>> HistoryGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Gets a list of notifications pursuant to a specified participant and ship call /// @@ -1668,7 +1668,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Notification - System.Threading.Tasks.Task NotificationsGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task NotificationsGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Gets a list of notifications pursuant to a specified participant and ship call /// @@ -1680,7 +1680,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Notification) - System.Threading.Tasks.Task> NotificationsGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task> NotificationsGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// gets one or all participants /// @@ -1692,7 +1692,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Participant> - System.Threading.Tasks.Task> ParticipantsGetAsync(int? userId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task> ParticipantsGetAsync(int? userId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// gets one or all participants /// @@ -1704,7 +1704,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Participant>) - System.Threading.Tasks.Task>> ParticipantsGetWithHttpInfoAsync(int? userId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task>> ParticipantsGetWithHttpInfoAsync(int? userId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); #endregion Asynchronous Operations } /// @@ -1872,7 +1872,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Berth> - public async System.Threading.Tasks.Task> BerthsGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> BerthsGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse> localVarResponse = await BerthsGetWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -1884,7 +1884,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Berth>) - public async System.Threading.Tasks.Task>> BerthsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task>> BerthsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -1988,7 +1988,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<History> - public async System.Threading.Tasks.Task> HistoryGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> HistoryGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse> localVarResponse = await HistoryGetWithHttpInfoAsync(shipcallId, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -2001,7 +2001,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<History>) - public async System.Threading.Tasks.Task>> HistoryGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task>> HistoryGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -2106,7 +2106,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Notification - public async System.Threading.Tasks.Task NotificationsGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task NotificationsGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await NotificationsGetWithHttpInfoAsync(shipcallId, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -2119,7 +2119,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Notification) - public async System.Threading.Tasks.Task> NotificationsGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> NotificationsGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -2227,7 +2227,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Participant> - public async System.Threading.Tasks.Task> ParticipantsGetAsync(int? userId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> ParticipantsGetAsync(int? userId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse> localVarResponse = await ParticipantsGetWithHttpInfoAsync(userId, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -2240,7 +2240,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Participant>) - public async System.Threading.Tasks.Task>> ParticipantsGetWithHttpInfoAsync(int? userId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task>> ParticipantsGetWithHttpInfoAsync(int? userId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -2290,7 +2290,7 @@ namespace BreCalClient.misc.Api * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -2409,7 +2409,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - System.Threading.Tasks.Task TimesCreateAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task TimesCreateAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Create a new times entry for a ship call /// @@ -2421,7 +2421,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - System.Threading.Tasks.Task> TimesCreateWithHttpInfoAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task> TimesCreateWithHttpInfoAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Delete a times entry for a ship call. /// @@ -2433,7 +2433,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - System.Threading.Tasks.Task TimesDeleteAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task TimesDeleteAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Delete a times entry for a ship call. /// @@ -2445,7 +2445,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - System.Threading.Tasks.Task> TimesDeleteWithHttpInfoAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task> TimesDeleteWithHttpInfoAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Gets list of times /// @@ -2457,7 +2457,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Times> - System.Threading.Tasks.Task> TimesGetAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task> TimesGetAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Gets list of times /// @@ -2469,7 +2469,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Times>) - System.Threading.Tasks.Task>> TimesGetWithHttpInfoAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task>> TimesGetWithHttpInfoAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Update a times entry for a ship call /// @@ -2481,7 +2481,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - System.Threading.Tasks.Task TimesUpdateAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task TimesUpdateAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Update a times entry for a ship call /// @@ -2493,7 +2493,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - System.Threading.Tasks.Task> TimesUpdateWithHttpInfoAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task> TimesUpdateWithHttpInfoAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); #endregion Asynchronous Operations } /// @@ -2671,7 +2671,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - public async System.Threading.Tasks.Task TimesCreateAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task TimesCreateAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await TimesCreateWithHttpInfoAsync(times, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -2684,7 +2684,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - public async System.Threading.Tasks.Task> TimesCreateWithHttpInfoAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> TimesCreateWithHttpInfoAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { // verify the required parameter 'times' is set if (times == null) @@ -2795,7 +2795,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - public async System.Threading.Tasks.Task TimesDeleteAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task TimesDeleteAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await TimesDeleteWithHttpInfoAsync(id, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -2808,7 +2808,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - public async System.Threading.Tasks.Task> TimesDeleteWithHttpInfoAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> TimesDeleteWithHttpInfoAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -2916,7 +2916,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Times> - public async System.Threading.Tasks.Task> TimesGetAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> TimesGetAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse> localVarResponse = await TimesGetWithHttpInfoAsync(shipcallId, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -2929,7 +2929,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Times>) - public async System.Threading.Tasks.Task>> TimesGetWithHttpInfoAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task>> TimesGetWithHttpInfoAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -3043,7 +3043,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - public async System.Threading.Tasks.Task TimesUpdateAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task TimesUpdateAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await TimesUpdateWithHttpInfoAsync(times, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -3056,7 +3056,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - public async System.Threading.Tasks.Task> TimesUpdateWithHttpInfoAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> TimesUpdateWithHttpInfoAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { // verify the required parameter 'times' is set if (times == null) @@ -3109,7 +3109,7 @@ namespace BreCalClient.misc.Api * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -3184,7 +3184,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of LoginResult - System.Threading.Tasks.Task LoginAsync(Credentials credentials, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task LoginAsync(Credentials credentials, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Returns a JWT session token and user data if successful /// @@ -3196,7 +3196,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (LoginResult) - System.Threading.Tasks.Task> LoginWithHttpInfoAsync(Credentials credentials, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task> LoginWithHttpInfoAsync(Credentials credentials, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Update user details (first/last name, phone, password) /// @@ -3208,7 +3208,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - System.Threading.Tasks.Task UserUpdateAsync(UserDetails userDetails, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task UserUpdateAsync(UserDetails userDetails, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Update user details (first/last name, phone, password) /// @@ -3220,7 +3220,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - System.Threading.Tasks.Task> UserUpdateWithHttpInfoAsync(UserDetails userDetails, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task> UserUpdateWithHttpInfoAsync(UserDetails userDetails, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); #endregion Asynchronous Operations } /// @@ -3398,7 +3398,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of LoginResult - public async System.Threading.Tasks.Task LoginAsync(Credentials credentials, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task LoginAsync(Credentials credentials, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await LoginWithHttpInfoAsync(credentials, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -3411,7 +3411,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (LoginResult) - public async System.Threading.Tasks.Task> LoginWithHttpInfoAsync(Credentials credentials, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> LoginWithHttpInfoAsync(Credentials credentials, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { // verify the required parameter 'credentials' is set if (credentials == null) @@ -3528,7 +3528,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - public async System.Threading.Tasks.Task UserUpdateAsync(UserDetails userDetails, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task UserUpdateAsync(UserDetails userDetails, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await UserUpdateWithHttpInfoAsync(userDetails, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -3541,7 +3541,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - public async System.Threading.Tasks.Task> UserUpdateWithHttpInfoAsync(UserDetails userDetails, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> UserUpdateWithHttpInfoAsync(UserDetails userDetails, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { // verify the required parameter 'userDetails' is set if (userDetails == null) @@ -3594,7 +3594,7 @@ namespace BreCalClient.misc.Api * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -3634,10 +3634,10 @@ namespace BreCalClient.misc.Client /// A JSON string. public string Serialize(object obj) { - if (obj != null && obj is AbstractOpenAPISchema) + if (obj != null && obj is BreCalClient.misc.Model.AbstractOpenAPISchema) { // the object to be serialized is an oneOf/anyOf schema - return ((AbstractOpenAPISchema)obj).ToJson(); + return ((BreCalClient.misc.Model.AbstractOpenAPISchema)obj).ToJson(); } else { @@ -3678,7 +3678,7 @@ namespace BreCalClient.misc.Client if (match.Success) { string fileName = filePath + ClientUtils.SanitizeFilename(match.Groups[1].Value.Replace("\"", "").Replace("'", "")); - FileIO.WriteAllBytes(fileName, bytes); + File.WriteAllBytes(fileName, bytes); return new FileStream(fileName, FileMode.Open); } } @@ -3688,7 +3688,7 @@ namespace BreCalClient.misc.Client } if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object { - return DateTime.Parse(response.Content, null, DateTimeStyles.RoundtripKind); + return DateTime.Parse(response.Content, null, System.Globalization.DateTimeStyles.RoundtripKind); } if (type == typeof(string) || type.Name.StartsWith("System.Nullable")) // return primitive type { @@ -3706,11 +3706,11 @@ namespace BreCalClient.misc.Client } public ISerializer Serializer => this; public IDeserializer Deserializer => this; - public string[] AcceptedContentTypes => ContentType.JsonAccept; + public string[] AcceptedContentTypes => RestSharp.ContentType.JsonAccept; public SupportsContentType SupportsContentType => contentType => contentType.Value.EndsWith("json", StringComparison.InvariantCultureIgnoreCase) || contentType.Value.EndsWith("javascript", StringComparison.InvariantCultureIgnoreCase); - public ContentType ContentType { get; set; } = ContentType.Json; + public ContentType ContentType { get; set; } = RestSharp.ContentType.Json; public DataFormat DataFormat => DataFormat.Json; } /// @@ -3752,7 +3752,7 @@ namespace BreCalClient.misc.Client /// public ApiClient() { - _baseUrl = GlobalConfiguration.Instance.BasePath; + _baseUrl = BreCalClient.misc.Client.GlobalConfiguration.Instance.BasePath; } /// /// Initializes a new instance of the @@ -3804,14 +3804,14 @@ namespace BreCalClient.misc.Client } /// /// Provides all logic for constructing a new RestSharp . - /// At this point, all information for querying the service is known. - /// Here, it is simply mapped into the RestSharp request. + /// At this point, all information for querying the service is known. Here, it is simply + /// mapped into the RestSharp request. /// /// The http verb. /// The target path (or resource). /// The additional request options. - /// A per-request configuration object. - /// It is assumed that any merge with GlobalConfiguration has been done before calling this method. + /// A per-request configuration object. It is assumed that any merge with + /// GlobalConfiguration has been done before calling this method. /// [private] A new RestRequest instance. /// private RestRequest NewRequest( @@ -3909,7 +3909,7 @@ namespace BreCalClient.misc.Client var bytes = ClientUtils.ReadAsBytes(file); var fileStream = file as FileStream; if (fileStream != null) - request.AddFile(fileParam.Key, bytes, Path.GetFileName(fileStream.Name)); + request.AddFile(fileParam.Key, bytes, System.IO.Path.GetFileName(fileStream.Name)); else request.AddFile(fileParam.Key, bytes, "no_file_name_provided"); } @@ -3917,13 +3917,6 @@ namespace BreCalClient.misc.Client } return request; } - /// - /// Transforms a RestResponse instance into a new ApiResponse instance. - /// At this point, we have a concrete http response from the service. - /// Here, it is simply mapped into the [public] ApiResponse object. - /// - /// The RestSharp response object - /// A new ApiResponse instance. private ApiResponse ToApiResponse(RestResponse response) { T result = response.Data; @@ -3962,41 +3955,51 @@ namespace BreCalClient.misc.Client } return transformed; } - /// - /// Executes the HTTP request for the current service. - /// Based on functions received it can be async or sync. - /// - /// Local function that executes http request and returns http response. - /// Local function to specify options for the service. - /// The RestSharp request object - /// The RestSharp options object - /// A per-request configuration object. - /// It is assumed that any merge with GlobalConfiguration has been done before calling this method. - /// A new ApiResponse instance. - private async Task> ExecClientAsync(Func>> getResponse, Action setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration) + private ApiResponse Exec(RestRequest request, RequestOptions options, IReadableConfiguration configuration) { var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl; + var cookies = new CookieContainer(); + if (options.Cookies != null && options.Cookies.Count > 0) + { + foreach (var cookie in options.Cookies) + { + cookies.Add(new Cookie(cookie.Name, cookie.Value)); + } + } var clientOptions = new RestClientOptions(baseUrl) { ClientCertificates = configuration.ClientCertificates, + CookieContainer = cookies, MaxTimeout = configuration.Timeout, Proxy = configuration.Proxy, UserAgent = configuration.UserAgent, UseDefaultCredentials = configuration.UseDefaultCredentials, RemoteCertificateValidationCallback = configuration.RemoteCertificateValidationCallback }; - setOptions(clientOptions); using (RestClient client = new RestClient(clientOptions, configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(SerializerSettings, configuration)))) { InterceptRequest(request); - RestResponse response = await getResponse(client); + RestResponse response; + if (RetryConfiguration.RetryPolicy != null) + { + var policy = RetryConfiguration.RetryPolicy; + var policyResult = policy.ExecuteAndCapture(() => client.Execute(request)); + response = (policyResult.Outcome == OutcomeType.Successful) ? client.Deserialize(policyResult.Result) : new RestResponse(request) + { + ErrorException = policyResult.FinalException + }; + } + else + { + response = client.Execute(request); + } // if the response type is oneOf/anyOf, call FromJSON to deserialize the data - if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T))) + if (typeof(BreCalClient.misc.Model.AbstractOpenAPISchema).IsAssignableFrom(typeof(T))) { try { - response.Data = (T)typeof(T).GetMethod("FromJson").Invoke(null, new object[] { response.Content }); + response.Data = (T) typeof(T).GetMethod("FromJson").Invoke(null, new object[] { response.Content }); } catch (Exception ex) { @@ -4049,69 +4052,82 @@ namespace BreCalClient.misc.Client return result; } } - private RestResponse DeserializeRestResponseFromPolicy(RestClient client, RestRequest request, PolicyResult policyResult) + private async Task> ExecAsync(RestRequest request, RequestOptions options, IReadableConfiguration configuration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { - if (policyResult.Outcome == OutcomeType.Successful) + var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl; + var clientOptions = new RestClientOptions(baseUrl) { - return client.Deserialize(policyResult.Result); - } - else - { - return new RestResponse(request) - { - ErrorException = policyResult.FinalException - }; - } - } - private ApiResponse Exec(RestRequest request, RequestOptions options, IReadableConfiguration configuration) - { - Action setOptions = (clientOptions) => - { - var cookies = new CookieContainer(); - if (options.Cookies != null && options.Cookies.Count > 0) - { - foreach (var cookie in options.Cookies) - { - cookies.Add(new Cookie(cookie.Name, cookie.Value)); - } - } - clientOptions.CookieContainer = cookies; + ClientCertificates = configuration.ClientCertificates, + MaxTimeout = configuration.Timeout, + Proxy = configuration.Proxy, + UserAgent = configuration.UserAgent, + UseDefaultCredentials = configuration.UseDefaultCredentials, + RemoteCertificateValidationCallback = configuration.RemoteCertificateValidationCallback }; - Func>> getResponse = (client) => - { - if (RetryConfiguration.RetryPolicy != null) - { - var policy = RetryConfiguration.RetryPolicy; - var policyResult = policy.ExecuteAndCapture(() => client.Execute(request)); - return Task.FromResult(DeserializeRestResponseFromPolicy(client, request, policyResult)); - } - else - { - return Task.FromResult(client.Execute(request)); - } - }; - return ExecClientAsync(getResponse, setOptions, request, options, configuration).GetAwaiter().GetResult(); - } - private Task> ExecAsync(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken)) - { - Action setOptions = (clientOptions) => - { - //no extra options - }; - Func>> getResponse = async (client) => + using (RestClient client = new RestClient(clientOptions, + configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(SerializerSettings, configuration)))) { + InterceptRequest(request); + RestResponse response; if (RetryConfiguration.AsyncRetryPolicy != null) { var policy = RetryConfiguration.AsyncRetryPolicy; var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false); - return DeserializeRestResponseFromPolicy(client, request, policyResult); + response = (policyResult.Outcome == OutcomeType.Successful) ? client.Deserialize(policyResult.Result) : new RestResponse(request) + { + ErrorException = policyResult.FinalException + }; } else { - return await client.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); + response = await client.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); } - }; - return ExecClientAsync(getResponse, setOptions, request, options, configuration); + // if the response type is oneOf/anyOf, call FromJSON to deserialize the data + if (typeof(BreCalClient.misc.Model.AbstractOpenAPISchema).IsAssignableFrom(typeof(T))) + { + response.Data = (T) typeof(T).GetMethod("FromJson").Invoke(null, new object[] { response.Content }); + } + else if (typeof(T).Name == "Stream") // for binary response + { + response.Data = (T)(object)new MemoryStream(response.RawBytes); + } + else if (typeof(T).Name == "Byte[]") // for byte response + { + response.Data = (T)(object)response.RawBytes; + } + InterceptResponse(request, response); + var result = ToApiResponse(response); + if (response.ErrorMessage != null) + { + result.ErrorText = response.ErrorMessage; + } + if (response.Cookies != null && response.Cookies.Count > 0) + { + if (result.Cookies == null) result.Cookies = new List(); + foreach (var restResponseCookie in response.Cookies.Cast()) + { + var cookie = new Cookie( + restResponseCookie.Name, + restResponseCookie.Value, + restResponseCookie.Path, + restResponseCookie.Domain + ) + { + Comment = restResponseCookie.Comment, + CommentUri = restResponseCookie.CommentUri, + Discard = restResponseCookie.Discard, + Expired = restResponseCookie.Expired, + Expires = restResponseCookie.Expires, + HttpOnly = restResponseCookie.HttpOnly, + Port = restResponseCookie.Port, + Secure = restResponseCookie.Secure, + Version = restResponseCookie.Version + }; + result.Cookies.Add(cookie); + } + } + return result; + } } #region IAsynchronousClient /// @@ -4123,7 +4139,7 @@ namespace BreCalClient.misc.Client /// GlobalConfiguration has been done before calling this method. /// Token that enables callers to cancel the request. /// A Task containing ApiResponse - public Task> GetAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default) + public Task> GetAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { var config = configuration ?? GlobalConfiguration.Instance; return ExecAsync(NewRequest(HttpMethod.Get, path, options, config), options, config, cancellationToken); @@ -4137,7 +4153,7 @@ namespace BreCalClient.misc.Client /// GlobalConfiguration has been done before calling this method. /// Token that enables callers to cancel the request. /// A Task containing ApiResponse - public Task> PostAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default) + public Task> PostAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { var config = configuration ?? GlobalConfiguration.Instance; return ExecAsync(NewRequest(HttpMethod.Post, path, options, config), options, config, cancellationToken); @@ -4151,7 +4167,7 @@ namespace BreCalClient.misc.Client /// GlobalConfiguration has been done before calling this method. /// Token that enables callers to cancel the request. /// A Task containing ApiResponse - public Task> PutAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default) + public Task> PutAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { var config = configuration ?? GlobalConfiguration.Instance; return ExecAsync(NewRequest(HttpMethod.Put, path, options, config), options, config, cancellationToken); @@ -4165,7 +4181,7 @@ namespace BreCalClient.misc.Client /// GlobalConfiguration has been done before calling this method. /// Token that enables callers to cancel the request. /// A Task containing ApiResponse - public Task> DeleteAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default) + public Task> DeleteAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { var config = configuration ?? GlobalConfiguration.Instance; return ExecAsync(NewRequest(HttpMethod.Delete, path, options, config), options, config, cancellationToken); @@ -4179,7 +4195,7 @@ namespace BreCalClient.misc.Client /// GlobalConfiguration has been done before calling this method. /// Token that enables callers to cancel the request. /// A Task containing ApiResponse - public Task> HeadAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default) + public Task> HeadAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { var config = configuration ?? GlobalConfiguration.Instance; return ExecAsync(NewRequest(HttpMethod.Head, path, options, config), options, config, cancellationToken); @@ -4193,7 +4209,7 @@ namespace BreCalClient.misc.Client /// GlobalConfiguration has been done before calling this method. /// Token that enables callers to cancel the request. /// A Task containing ApiResponse - public Task> OptionsAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default) + public Task> OptionsAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { var config = configuration ?? GlobalConfiguration.Instance; return ExecAsync(NewRequest(HttpMethod.Options, path, options, config), options, config, cancellationToken); @@ -4207,7 +4223,7 @@ namespace BreCalClient.misc.Client /// GlobalConfiguration has been done before calling this method. /// Token that enables callers to cancel the request. /// A Task containing ApiResponse - public Task> PatchAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default) + public Task> PatchAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { var config = configuration ?? GlobalConfiguration.Instance; return ExecAsync(NewRequest(HttpMethod.Patch, path, options, config), options, config, cancellationToken); @@ -4314,7 +4330,7 @@ namespace BreCalClient.misc.Client * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -4374,7 +4390,7 @@ namespace BreCalClient.misc.Client * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -4514,7 +4530,7 @@ namespace BreCalClient.misc.Client * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -4624,7 +4640,7 @@ namespace BreCalClient.misc.Client /// Encoded string. public static string Base64Encode(string text) { - return Convert.ToBase64String(global::System.Text.Encoding.UTF8.GetBytes(text)); + return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text)); } /// /// Convert stream to byte array @@ -4732,7 +4748,7 @@ namespace BreCalClient.misc.Client * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -4812,12 +4828,12 @@ namespace BreCalClient.misc.Client /// /// Initializes a new instance of the class /// - [global::System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "VirtualMemberCallInConstructor")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "VirtualMemberCallInConstructor")] public Configuration() { Proxy = null; UserAgent = WebUtility.UrlEncode("OpenAPI-Generator/1.0.0/csharp"); - BasePath = "https://brecaldevel.bsmd-emswe.eu"; + BasePath = "https://brecaltest.bsmd-emswe.eu"; DefaultHeaders = new ConcurrentDictionary(); ApiKey = new ConcurrentDictionary(); ApiKeyPrefix = new ConcurrentDictionary(); @@ -4825,7 +4841,7 @@ namespace BreCalClient.misc.Client { { new Dictionary { - {"url", "https://brecaldevel.bsmd-emswe.eu"}, + {"url", "https://brecaltest.bsmd-emswe.eu"}, {"description", "Development server hosted on vcup"}, } } @@ -4839,12 +4855,12 @@ namespace BreCalClient.misc.Client /// /// Initializes a new instance of the class /// - [global::System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "VirtualMemberCallInConstructor")] + [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "VirtualMemberCallInConstructor")] public Configuration( IDictionary defaultHeaders, IDictionary apiKey, IDictionary apiKeyPrefix, - string basePath = "https://brecaldevel.bsmd-emswe.eu") : this() + string basePath = "https://brecaltest.bsmd-emswe.eu") : this() { if (string.IsNullOrWhiteSpace(basePath)) throw new ArgumentException("The provided basePath is invalid.", "basePath"); @@ -4873,7 +4889,7 @@ namespace BreCalClient.misc.Client /// /// Gets or sets the base path for API access. /// - public virtual string BasePath + public virtual string BasePath { get { return _basePath; } set { _basePath = value; } @@ -5191,7 +5207,7 @@ namespace BreCalClient.misc.Client string report = "C# SDK (BreCalClient.misc) Debug Report:\n"; report += " OS: " + System.Environment.OSVersion + "\n"; report += " .NET Framework Version: " + System.Environment.Version + "\n"; - report += " Version of the API: 1.4.0\n"; + report += " Version of the API: 1.5.0\n"; report += " SDK Package Version: 1.0.0\n"; return report; } @@ -5260,7 +5276,7 @@ namespace BreCalClient.misc.Client * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -5280,7 +5296,7 @@ namespace BreCalClient.misc.Client * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -5337,7 +5353,7 @@ namespace BreCalClient.misc.Client * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -5370,7 +5386,7 @@ namespace BreCalClient.misc.Client * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -5403,7 +5419,7 @@ namespace BreCalClient.misc.Client * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -5425,7 +5441,7 @@ namespace BreCalClient.misc.Client /// Cancellation Token to cancel the request. /// The return type. /// A task eventually representing the response data, decorated with - Task> GetAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + Task> GetAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Executes a non-blocking call to some using the POST http verb. /// @@ -5435,7 +5451,7 @@ namespace BreCalClient.misc.Client /// Cancellation Token to cancel the request. /// The return type. /// A task eventually representing the response data, decorated with - Task> PostAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + Task> PostAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Executes a non-blocking call to some using the PUT http verb. /// @@ -5445,7 +5461,7 @@ namespace BreCalClient.misc.Client /// Cancellation Token to cancel the request. /// The return type. /// A task eventually representing the response data, decorated with - Task> PutAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + Task> PutAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Executes a non-blocking call to some using the DELETE http verb. /// @@ -5455,7 +5471,7 @@ namespace BreCalClient.misc.Client /// Cancellation Token to cancel the request. /// The return type. /// A task eventually representing the response data, decorated with - Task> DeleteAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + Task> DeleteAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Executes a non-blocking call to some using the HEAD http verb. /// @@ -5465,7 +5481,7 @@ namespace BreCalClient.misc.Client /// Cancellation Token to cancel the request. /// The return type. /// A task eventually representing the response data, decorated with - Task> HeadAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + Task> HeadAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Executes a non-blocking call to some using the OPTIONS http verb. /// @@ -5475,7 +5491,7 @@ namespace BreCalClient.misc.Client /// Cancellation Token to cancel the request. /// The return type. /// A task eventually representing the response data, decorated with - Task> OptionsAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + Task> OptionsAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Executes a non-blocking call to some using the PATCH http verb. /// @@ -5485,7 +5501,7 @@ namespace BreCalClient.misc.Client /// Cancellation Token to cancel the request. /// The return type. /// A task eventually representing the response data, decorated with - Task> PatchAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + Task> PatchAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); } } @@ -5494,7 +5510,7 @@ namespace BreCalClient.misc.Client * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -5611,7 +5627,7 @@ namespace BreCalClient.misc.Client * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -5695,7 +5711,7 @@ namespace BreCalClient.misc.Client * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -5954,7 +5970,7 @@ namespace BreCalClient.misc.Client * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -5982,7 +5998,7 @@ namespace BreCalClient.misc.Client * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -6052,7 +6068,7 @@ namespace BreCalClient.misc.Client * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -6079,7 +6095,7 @@ namespace BreCalClient.misc.Client * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -6146,7 +6162,7 @@ namespace BreCalClient.misc.Model * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -6156,7 +6172,7 @@ namespace BreCalClient.misc.Model /// Ship berth used for a ship call /// [DataContract(Name = "berth")] - public partial class Berth : IValidatableObject + public partial class Berth : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. @@ -6175,7 +6191,7 @@ namespace BreCalClient.misc.Model this.Name = name; this.OwnerId = ownerId; this.AuthorityId = authorityId; - this.Lock = varLock; + this.VarLock = varLock; this.Created = created; this.Modified = modified; this.Deleted = deleted; @@ -6207,7 +6223,7 @@ namespace BreCalClient.misc.Model /// /// If true lock must be passed [DataMember(Name = "lock", EmitDefaultValue = true)] - public bool? Lock { get; set; } + public bool? VarLock { get; set; } /// /// Gets or Sets Created /// @@ -6235,7 +6251,7 @@ namespace BreCalClient.misc.Model sb.Append(" Name: ").Append(Name).Append("\n"); sb.Append(" OwnerId: ").Append(OwnerId).Append("\n"); sb.Append(" AuthorityId: ").Append(AuthorityId).Append("\n"); - sb.Append(" Lock: ").Append(Lock).Append("\n"); + sb.Append(" VarLock: ").Append(VarLock).Append("\n"); sb.Append(" Created: ").Append(Created).Append("\n"); sb.Append(" Modified: ").Append(Modified).Append("\n"); sb.Append(" Deleted: ").Append(Deleted).Append("\n"); @@ -6251,16 +6267,114 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Berth); + } + /// + /// Returns true if Berth instances are equal + /// + /// Instance of Berth to be compared + /// Boolean + public bool Equals(Berth input) + { + if (input == null) + { + return false; + } + return + ( + this.Id == input.Id || + this.Id.Equals(input.Id) + ) && + ( + this.Name == input.Name || + (this.Name != null && + this.Name.Equals(input.Name)) + ) && + ( + this.OwnerId == input.OwnerId || + (this.OwnerId != null && + this.OwnerId.Equals(input.OwnerId)) + ) && + ( + this.AuthorityId == input.AuthorityId || + (this.AuthorityId != null && + this.AuthorityId.Equals(input.AuthorityId)) + ) && + ( + this.VarLock == input.VarLock || + (this.VarLock != null && + this.VarLock.Equals(input.VarLock)) + ) && + ( + this.Created == input.Created || + (this.Created != null && + this.Created.Equals(input.Created)) + ) && + ( + this.Modified == input.Modified || + (this.Modified != null && + this.Modified.Equals(input.Modified)) + ) && + ( + this.Deleted == input.Deleted || + this.Deleted.Equals(input.Deleted) + ); + } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = (hashCode * 59) + this.Id.GetHashCode(); + if (this.Name != null) + { + hashCode = (hashCode * 59) + this.Name.GetHashCode(); + } + if (this.OwnerId != null) + { + hashCode = (hashCode * 59) + this.OwnerId.GetHashCode(); + } + if (this.AuthorityId != null) + { + hashCode = (hashCode * 59) + this.AuthorityId.GetHashCode(); + } + if (this.VarLock != null) + { + hashCode = (hashCode * 59) + this.VarLock.GetHashCode(); + } + if (this.Created != null) + { + hashCode = (hashCode * 59) + this.Created.GetHashCode(); + } + if (this.Modified != null) + { + hashCode = (hashCode * 59) + this.Modified.GetHashCode(); + } + hashCode = (hashCode * 59) + this.Deleted.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { // Name (string) maxLength if (this.Name != null && this.Name.Length > 128) { - yield return new ValidationResult("Invalid value for Name, length must be less than 128.", new [] { "Name" }); + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Name, length must be less than 128.", new [] { "Name" }); } yield break; } @@ -6272,7 +6386,7 @@ namespace BreCalClient.misc.Model * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -6282,7 +6396,7 @@ namespace BreCalClient.misc.Model /// Credentials /// [DataContract(Name = "credentials")] - public partial class Credentials : IValidatableObject + public partial class Credentials : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. @@ -6341,11 +6455,63 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Credentials); + } + /// + /// Returns true if Credentials instances are equal + /// + /// Instance of Credentials to be compared + /// Boolean + public bool Equals(Credentials input) + { + if (input == null) + { + return false; + } + return + ( + this.Username == input.Username || + (this.Username != null && + this.Username.Equals(input.Username)) + ) && + ( + this.Password == input.Password || + (this.Password != null && + this.Password.Equals(input.Password)) + ); + } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Username != null) + { + hashCode = (hashCode * 59) + this.Username.GetHashCode(); + } + if (this.Password != null) + { + hashCode = (hashCode * 59) + this.Password.GetHashCode(); + } + return hashCode; + } + } + /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { yield break; } @@ -6357,7 +6523,7 @@ namespace BreCalClient.misc.Model * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -6367,7 +6533,7 @@ namespace BreCalClient.misc.Model /// Error /// [DataContract(Name = "Error")] - public partial class Error : IValidatableObject + public partial class Error : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. @@ -6414,11 +6580,54 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Error); + } + /// + /// Returns true if Error instances are equal + /// + /// Instance of Error to be compared + /// Boolean + public bool Equals(Error input) + { + if (input == null) + { + return false; + } + return + ( + this.Message == input.Message || + (this.Message != null && + this.Message.Equals(input.Message)) + ); + } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + if (this.Message != null) + { + hashCode = (hashCode * 59) + this.Message.GetHashCode(); + } + return hashCode; + } + } + /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { yield break; } @@ -6430,7 +6639,7 @@ namespace BreCalClient.misc.Model * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -6470,7 +6679,7 @@ namespace BreCalClient.misc.Model * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -6480,7 +6689,7 @@ namespace BreCalClient.misc.Model /// Single history entry with references /// [DataContract(Name = "history")] - public partial class History : IValidatableObject + public partial class History : IEquatable, IValidatableObject { /// /// Gets or Sets Operation @@ -6564,11 +6773,88 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as History); + } + /// + /// Returns true if History instances are equal + /// + /// Instance of History to be compared + /// Boolean + public bool Equals(History input) + { + if (input == null) + { + return false; + } + return + ( + this.Id == input.Id || + this.Id.Equals(input.Id) + ) && + ( + this.ParticipantId == input.ParticipantId || + this.ParticipantId.Equals(input.ParticipantId) + ) && + ( + this.ShipcallId == input.ShipcallId || + this.ShipcallId.Equals(input.ShipcallId) + ) && + ( + this.Timestamp == input.Timestamp || + (this.Timestamp != null && + this.Timestamp.Equals(input.Timestamp)) + ) && + ( + this.Eta == input.Eta || + (this.Eta != null && + this.Eta.Equals(input.Eta)) + ) && + ( + this.Operation == input.Operation || + this.Operation.Equals(input.Operation) + ) && + ( + this.Type == input.Type || + this.Type.Equals(input.Type) + ); + } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = (hashCode * 59) + this.Id.GetHashCode(); + hashCode = (hashCode * 59) + this.ParticipantId.GetHashCode(); + hashCode = (hashCode * 59) + this.ShipcallId.GetHashCode(); + if (this.Timestamp != null) + { + hashCode = (hashCode * 59) + this.Timestamp.GetHashCode(); + } + if (this.Eta != null) + { + hashCode = (hashCode * 59) + this.Eta.GetHashCode(); + } + hashCode = (hashCode * 59) + this.Operation.GetHashCode(); + hashCode = (hashCode * 59) + this.Type.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { yield break; } @@ -6580,7 +6866,7 @@ namespace BreCalClient.misc.Model * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -6590,7 +6876,7 @@ namespace BreCalClient.misc.Model /// A unique identifier for an entity /// [DataContract(Name = "Id")] - public partial class Id : IValidatableObject + public partial class Id : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. @@ -6626,11 +6912,50 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Id); + } + /// + /// Returns true if Id instances are equal + /// + /// Instance of Id to be compared + /// Boolean + public bool Equals(Id input) + { + if (input == null) + { + return false; + } + return + ( + this.VarId == input.VarId || + this.VarId.Equals(input.VarId) + ); + } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = (hashCode * 59) + this.VarId.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { yield break; } @@ -6642,7 +6967,7 @@ namespace BreCalClient.misc.Model * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -6652,7 +6977,7 @@ namespace BreCalClient.misc.Model /// result structure of a successful login attempt /// [DataContract(Name = "login_result")] - public partial class LoginResult : IValidatableObject + public partial class LoginResult : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. @@ -6752,11 +7077,114 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as LoginResult); + } + /// + /// Returns true if LoginResult instances are equal + /// + /// Instance of LoginResult to be compared + /// Boolean + public bool Equals(LoginResult input) + { + if (input == null) + { + return false; + } + return + ( + this.Id == input.Id || + this.Id.Equals(input.Id) + ) && + ( + this.ParticipantId == input.ParticipantId || + this.ParticipantId.Equals(input.ParticipantId) + ) && + ( + this.FirstName == input.FirstName || + (this.FirstName != null && + this.FirstName.Equals(input.FirstName)) + ) && + ( + this.LastName == input.LastName || + (this.LastName != null && + this.LastName.Equals(input.LastName)) + ) && + ( + this.UserName == input.UserName || + (this.UserName != null && + this.UserName.Equals(input.UserName)) + ) && + ( + this.UserPhone == input.UserPhone || + (this.UserPhone != null && + this.UserPhone.Equals(input.UserPhone)) + ) && + ( + this.UserEmail == input.UserEmail || + (this.UserEmail != null && + this.UserEmail.Equals(input.UserEmail)) + ) && + ( + this.Exp == input.Exp || + this.Exp.Equals(input.Exp) + ) && + ( + this.Token == input.Token || + (this.Token != null && + this.Token.Equals(input.Token)) + ); + } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = (hashCode * 59) + this.Id.GetHashCode(); + hashCode = (hashCode * 59) + this.ParticipantId.GetHashCode(); + if (this.FirstName != null) + { + hashCode = (hashCode * 59) + this.FirstName.GetHashCode(); + } + if (this.LastName != null) + { + hashCode = (hashCode * 59) + this.LastName.GetHashCode(); + } + if (this.UserName != null) + { + hashCode = (hashCode * 59) + this.UserName.GetHashCode(); + } + if (this.UserPhone != null) + { + hashCode = (hashCode * 59) + this.UserPhone.GetHashCode(); + } + if (this.UserEmail != null) + { + hashCode = (hashCode * 59) + this.UserEmail.GetHashCode(); + } + hashCode = (hashCode * 59) + this.Exp.GetHashCode(); + if (this.Token != null) + { + hashCode = (hashCode * 59) + this.Token.GetHashCode(); + } + return hashCode; + } + } + /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { yield break; } @@ -6768,7 +7196,7 @@ namespace BreCalClient.misc.Model * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -6778,7 +7206,7 @@ namespace BreCalClient.misc.Model /// a notification created by the engine if a times entry violates a rule /// [DataContract(Name = "notification")] - public partial class Notification : IValidatableObject + public partial class Notification : IEquatable, IValidatableObject { /// /// Gets or Sets NotificationType @@ -6856,11 +7284,87 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Notification); + } + /// + /// Returns true if Notification instances are equal + /// + /// Instance of Notification to be compared + /// Boolean + public bool Equals(Notification input) + { + if (input == null) + { + return false; + } + return + ( + this.Id == input.Id || + this.Id.Equals(input.Id) + ) && + ( + this.ShipcallId == input.ShipcallId || + this.ShipcallId.Equals(input.ShipcallId) + ) && + ( + this.NotificationType == input.NotificationType || + this.NotificationType.Equals(input.NotificationType) + ) && + ( + this.Message == input.Message || + (this.Message != null && + this.Message.Equals(input.Message)) + ) && + ( + this.Created == input.Created || + (this.Created != null && + this.Created.Equals(input.Created)) + ) && + ( + this.Modified == input.Modified || + (this.Modified != null && + this.Modified.Equals(input.Modified)) + ); + } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = (hashCode * 59) + this.Id.GetHashCode(); + hashCode = (hashCode * 59) + this.ShipcallId.GetHashCode(); + hashCode = (hashCode * 59) + this.NotificationType.GetHashCode(); + if (this.Message != null) + { + hashCode = (hashCode * 59) + this.Message.GetHashCode(); + } + if (this.Created != null) + { + hashCode = (hashCode * 59) + this.Created.GetHashCode(); + } + if (this.Modified != null) + { + hashCode = (hashCode * 59) + this.Modified.GetHashCode(); + } + return hashCode; + } + } + /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { yield break; } @@ -6872,7 +7376,7 @@ namespace BreCalClient.misc.Model * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -6907,7 +7411,7 @@ namespace BreCalClient.misc.Model * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -6937,7 +7441,7 @@ namespace BreCalClient.misc.Model * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -6977,7 +7481,7 @@ namespace BreCalClient.misc.Model * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -6987,7 +7491,7 @@ namespace BreCalClient.misc.Model /// A organisational entity that participates in Bremen Calling /// [DataContract(Name = "participant")] - public partial class Participant : IValidatableObject + public partial class Participant : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. @@ -7098,31 +7602,143 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Participant); + } + /// + /// Returns true if Participant instances are equal + /// + /// Instance of Participant to be compared + /// Boolean + public bool Equals(Participant input) + { + if (input == null) + { + return false; + } + return + ( + this.Id == input.Id || + this.Id.Equals(input.Id) + ) && + ( + this.Name == input.Name || + (this.Name != null && + this.Name.Equals(input.Name)) + ) && + ( + this.Street == input.Street || + (this.Street != null && + this.Street.Equals(input.Street)) + ) && + ( + this.PostalCode == input.PostalCode || + (this.PostalCode != null && + this.PostalCode.Equals(input.PostalCode)) + ) && + ( + this.City == input.City || + (this.City != null && + this.City.Equals(input.City)) + ) && + ( + this.Type == input.Type || + this.Type.Equals(input.Type) + ) && + ( + this.Flags == input.Flags || + (this.Flags != null && + this.Flags.Equals(input.Flags)) + ) && + ( + this.Created == input.Created || + (this.Created != null && + this.Created.Equals(input.Created)) + ) && + ( + this.Modified == input.Modified || + (this.Modified != null && + this.Modified.Equals(input.Modified)) + ) && + ( + this.Deleted == input.Deleted || + this.Deleted.Equals(input.Deleted) + ); + } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = (hashCode * 59) + this.Id.GetHashCode(); + if (this.Name != null) + { + hashCode = (hashCode * 59) + this.Name.GetHashCode(); + } + if (this.Street != null) + { + hashCode = (hashCode * 59) + this.Street.GetHashCode(); + } + if (this.PostalCode != null) + { + hashCode = (hashCode * 59) + this.PostalCode.GetHashCode(); + } + if (this.City != null) + { + hashCode = (hashCode * 59) + this.City.GetHashCode(); + } + hashCode = (hashCode * 59) + this.Type.GetHashCode(); + if (this.Flags != null) + { + hashCode = (hashCode * 59) + this.Flags.GetHashCode(); + } + if (this.Created != null) + { + hashCode = (hashCode * 59) + this.Created.GetHashCode(); + } + if (this.Modified != null) + { + hashCode = (hashCode * 59) + this.Modified.GetHashCode(); + } + hashCode = (hashCode * 59) + this.Deleted.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { // Name (string) maxLength if (this.Name != null && this.Name.Length > 128) { - yield return new ValidationResult("Invalid value for Name, length must be less than 128.", new [] { "Name" }); + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Name, length must be less than 128.", new [] { "Name" }); } // Street (string) maxLength if (this.Street != null && this.Street.Length > 128) { - yield return new ValidationResult("Invalid value for Street, length must be less than 128.", new [] { "Street" }); + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Street, length must be less than 128.", new [] { "Street" }); } // PostalCode (string) maxLength if (this.PostalCode != null && this.PostalCode.Length > 5) { - yield return new ValidationResult("Invalid value for PostalCode, length must be less than 5.", new [] { "PostalCode" }); + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PostalCode, length must be less than 5.", new [] { "PostalCode" }); } // City (string) maxLength if (this.City != null && this.City.Length > 64) { - yield return new ValidationResult("Invalid value for City, length must be less than 64.", new [] { "City" }); + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for City, length must be less than 64.", new [] { "City" }); } yield break; } @@ -7134,7 +7750,7 @@ namespace BreCalClient.misc.Model * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -7144,7 +7760,7 @@ namespace BreCalClient.misc.Model /// Participant assigned to a shipcall with a given role (type) /// [DataContract(Name = "participant_assignment")] - public partial class ParticipantAssignment : IValidatableObject + public partial class ParticipantAssignment : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. @@ -7194,11 +7810,55 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as ParticipantAssignment); + } + /// + /// Returns true if ParticipantAssignment instances are equal + /// + /// Instance of ParticipantAssignment to be compared + /// Boolean + public bool Equals(ParticipantAssignment input) + { + if (input == null) + { + return false; + } + return + ( + this.ParticipantId == input.ParticipantId || + this.ParticipantId.Equals(input.ParticipantId) + ) && + ( + this.Type == input.Type || + this.Type.Equals(input.Type) + ); + } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = (hashCode * 59) + this.ParticipantId.GetHashCode(); + hashCode = (hashCode * 59) + this.Type.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { yield break; } @@ -7210,7 +7870,7 @@ namespace BreCalClient.misc.Model * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -7220,7 +7880,7 @@ namespace BreCalClient.misc.Model /// a ship /// [DataContract(Name = "ship")] - public partial class Ship : IValidatableObject + public partial class Ship : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. @@ -7354,21 +8014,160 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Ship); + } + /// + /// Returns true if Ship instances are equal + /// + /// Instance of Ship to be compared + /// Boolean + public bool Equals(Ship input) + { + if (input == null) + { + return false; + } + return + ( + this.Id == input.Id || + this.Id.Equals(input.Id) + ) && + ( + this.Name == input.Name || + (this.Name != null && + this.Name.Equals(input.Name)) + ) && + ( + this.Imo == input.Imo || + (this.Imo != null && + this.Imo.Equals(input.Imo)) + ) && + ( + this.Callsign == input.Callsign || + (this.Callsign != null && + this.Callsign.Equals(input.Callsign)) + ) && + ( + this.ParticipantId == input.ParticipantId || + (this.ParticipantId != null && + this.ParticipantId.Equals(input.ParticipantId)) + ) && + ( + this.Length == input.Length || + (this.Length != null && + this.Length.Equals(input.Length)) + ) && + ( + this.Width == input.Width || + (this.Width != null && + this.Width.Equals(input.Width)) + ) && + ( + this.IsTug == input.IsTug || + this.IsTug.Equals(input.IsTug) + ) && + ( + this.BollardPull == input.BollardPull || + (this.BollardPull != null && + this.BollardPull.Equals(input.BollardPull)) + ) && + ( + this.Eni == input.Eni || + (this.Eni != null && + this.Eni.Equals(input.Eni)) + ) && + ( + this.Created == input.Created || + (this.Created != null && + this.Created.Equals(input.Created)) + ) && + ( + this.Modified == input.Modified || + (this.Modified != null && + this.Modified.Equals(input.Modified)) + ) && + ( + this.Deleted == input.Deleted || + this.Deleted.Equals(input.Deleted) + ); + } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = (hashCode * 59) + this.Id.GetHashCode(); + if (this.Name != null) + { + hashCode = (hashCode * 59) + this.Name.GetHashCode(); + } + if (this.Imo != null) + { + hashCode = (hashCode * 59) + this.Imo.GetHashCode(); + } + if (this.Callsign != null) + { + hashCode = (hashCode * 59) + this.Callsign.GetHashCode(); + } + if (this.ParticipantId != null) + { + hashCode = (hashCode * 59) + this.ParticipantId.GetHashCode(); + } + if (this.Length != null) + { + hashCode = (hashCode * 59) + this.Length.GetHashCode(); + } + if (this.Width != null) + { + hashCode = (hashCode * 59) + this.Width.GetHashCode(); + } + hashCode = (hashCode * 59) + this.IsTug.GetHashCode(); + if (this.BollardPull != null) + { + hashCode = (hashCode * 59) + this.BollardPull.GetHashCode(); + } + if (this.Eni != null) + { + hashCode = (hashCode * 59) + this.Eni.GetHashCode(); + } + if (this.Created != null) + { + hashCode = (hashCode * 59) + this.Created.GetHashCode(); + } + if (this.Modified != null) + { + hashCode = (hashCode * 59) + this.Modified.GetHashCode(); + } + hashCode = (hashCode * 59) + this.Deleted.GetHashCode(); + return hashCode; + } + } + /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { // Name (string) maxLength if (this.Name != null && this.Name.Length > 64) { - yield return new ValidationResult("Invalid value for Name, length must be less than 64.", new [] { "Name" }); + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Name, length must be less than 64.", new [] { "Name" }); } // Callsign (string) maxLength if (this.Callsign != null && this.Callsign.Length > 8) { - yield return new ValidationResult("Invalid value for Callsign, length must be less than 8.", new [] { "Callsign" }); + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Callsign, length must be less than 8.", new [] { "Callsign" }); } yield break; } @@ -7380,7 +8179,7 @@ namespace BreCalClient.misc.Model * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -7390,7 +8189,7 @@ namespace BreCalClient.misc.Model /// Shipcall /// [DataContract(Name = "shipcall")] - public partial class Shipcall : IValidatableObject + public partial class Shipcall : IEquatable, IValidatableObject { /// /// Gets or Sets Type @@ -7669,21 +8468,301 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Shipcall); + } + /// + /// Returns true if Shipcall instances are equal + /// + /// Instance of Shipcall to be compared + /// Boolean + public bool Equals(Shipcall input) + { + if (input == null) + { + return false; + } + return + ( + this.Id == input.Id || + this.Id.Equals(input.Id) + ) && + ( + this.ShipId == input.ShipId || + this.ShipId.Equals(input.ShipId) + ) && + ( + this.Type == input.Type || + this.Type.Equals(input.Type) + ) && + ( + this.Eta == input.Eta || + (this.Eta != null && + this.Eta.Equals(input.Eta)) + ) && + ( + this.Voyage == input.Voyage || + (this.Voyage != null && + this.Voyage.Equals(input.Voyage)) + ) && + ( + this.Etd == input.Etd || + (this.Etd != null && + this.Etd.Equals(input.Etd)) + ) && + ( + this.ArrivalBerthId == input.ArrivalBerthId || + (this.ArrivalBerthId != null && + this.ArrivalBerthId.Equals(input.ArrivalBerthId)) + ) && + ( + this.DepartureBerthId == input.DepartureBerthId || + (this.DepartureBerthId != null && + this.DepartureBerthId.Equals(input.DepartureBerthId)) + ) && + ( + this.TugRequired == input.TugRequired || + (this.TugRequired != null && + this.TugRequired.Equals(input.TugRequired)) + ) && + ( + this.PilotRequired == input.PilotRequired || + (this.PilotRequired != null && + this.PilotRequired.Equals(input.PilotRequired)) + ) && + ( + this.Flags == input.Flags || + (this.Flags != null && + this.Flags.Equals(input.Flags)) + ) && + ( + this.PierSide == input.PierSide || + (this.PierSide != null && + this.PierSide.Equals(input.PierSide)) + ) && + ( + this.Bunkering == input.Bunkering || + (this.Bunkering != null && + this.Bunkering.Equals(input.Bunkering)) + ) && + ( + this.ReplenishingTerminal == input.ReplenishingTerminal || + (this.ReplenishingTerminal != null && + this.ReplenishingTerminal.Equals(input.ReplenishingTerminal)) + ) && + ( + this.ReplenishingLock == input.ReplenishingLock || + (this.ReplenishingLock != null && + this.ReplenishingLock.Equals(input.ReplenishingLock)) + ) && + ( + this.Draft == input.Draft || + (this.Draft != null && + this.Draft.Equals(input.Draft)) + ) && + ( + this.TidalWindowFrom == input.TidalWindowFrom || + (this.TidalWindowFrom != null && + this.TidalWindowFrom.Equals(input.TidalWindowFrom)) + ) && + ( + this.TidalWindowTo == input.TidalWindowTo || + (this.TidalWindowTo != null && + this.TidalWindowTo.Equals(input.TidalWindowTo)) + ) && + ( + this.RainSensitiveCargo == input.RainSensitiveCargo || + (this.RainSensitiveCargo != null && + this.RainSensitiveCargo.Equals(input.RainSensitiveCargo)) + ) && + ( + this.RecommendedTugs == input.RecommendedTugs || + (this.RecommendedTugs != null && + this.RecommendedTugs.Equals(input.RecommendedTugs)) + ) && + ( + this.Anchored == input.Anchored || + (this.Anchored != null && + this.Anchored.Equals(input.Anchored)) + ) && + ( + this.MooredLock == input.MooredLock || + (this.MooredLock != null && + this.MooredLock.Equals(input.MooredLock)) + ) && + ( + this.Canceled == input.Canceled || + (this.Canceled != null && + this.Canceled.Equals(input.Canceled)) + ) && + ( + this.Evaluation == input.Evaluation || + this.Evaluation.Equals(input.Evaluation) + ) && + ( + this.EvaluationMessage == input.EvaluationMessage || + (this.EvaluationMessage != null && + this.EvaluationMessage.Equals(input.EvaluationMessage)) + ) && + ( + this.TimeRefPoint == input.TimeRefPoint || + (this.TimeRefPoint != null && + this.TimeRefPoint.Equals(input.TimeRefPoint)) + ) && + ( + this.Participants == input.Participants || + this.Participants != null && + input.Participants != null && + this.Participants.SequenceEqual(input.Participants) + ) && + ( + this.Created == input.Created || + (this.Created != null && + this.Created.Equals(input.Created)) + ) && + ( + this.Modified == input.Modified || + (this.Modified != null && + this.Modified.Equals(input.Modified)) + ); + } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = (hashCode * 59) + this.Id.GetHashCode(); + hashCode = (hashCode * 59) + this.ShipId.GetHashCode(); + hashCode = (hashCode * 59) + this.Type.GetHashCode(); + if (this.Eta != null) + { + hashCode = (hashCode * 59) + this.Eta.GetHashCode(); + } + if (this.Voyage != null) + { + hashCode = (hashCode * 59) + this.Voyage.GetHashCode(); + } + if (this.Etd != null) + { + hashCode = (hashCode * 59) + this.Etd.GetHashCode(); + } + if (this.ArrivalBerthId != null) + { + hashCode = (hashCode * 59) + this.ArrivalBerthId.GetHashCode(); + } + if (this.DepartureBerthId != null) + { + hashCode = (hashCode * 59) + this.DepartureBerthId.GetHashCode(); + } + if (this.TugRequired != null) + { + hashCode = (hashCode * 59) + this.TugRequired.GetHashCode(); + } + if (this.PilotRequired != null) + { + hashCode = (hashCode * 59) + this.PilotRequired.GetHashCode(); + } + if (this.Flags != null) + { + hashCode = (hashCode * 59) + this.Flags.GetHashCode(); + } + if (this.PierSide != null) + { + hashCode = (hashCode * 59) + this.PierSide.GetHashCode(); + } + if (this.Bunkering != null) + { + hashCode = (hashCode * 59) + this.Bunkering.GetHashCode(); + } + if (this.ReplenishingTerminal != null) + { + hashCode = (hashCode * 59) + this.ReplenishingTerminal.GetHashCode(); + } + if (this.ReplenishingLock != null) + { + hashCode = (hashCode * 59) + this.ReplenishingLock.GetHashCode(); + } + if (this.Draft != null) + { + hashCode = (hashCode * 59) + this.Draft.GetHashCode(); + } + if (this.TidalWindowFrom != null) + { + hashCode = (hashCode * 59) + this.TidalWindowFrom.GetHashCode(); + } + if (this.TidalWindowTo != null) + { + hashCode = (hashCode * 59) + this.TidalWindowTo.GetHashCode(); + } + if (this.RainSensitiveCargo != null) + { + hashCode = (hashCode * 59) + this.RainSensitiveCargo.GetHashCode(); + } + if (this.RecommendedTugs != null) + { + hashCode = (hashCode * 59) + this.RecommendedTugs.GetHashCode(); + } + if (this.Anchored != null) + { + hashCode = (hashCode * 59) + this.Anchored.GetHashCode(); + } + if (this.MooredLock != null) + { + hashCode = (hashCode * 59) + this.MooredLock.GetHashCode(); + } + if (this.Canceled != null) + { + hashCode = (hashCode * 59) + this.Canceled.GetHashCode(); + } + hashCode = (hashCode * 59) + this.Evaluation.GetHashCode(); + if (this.EvaluationMessage != null) + { + hashCode = (hashCode * 59) + this.EvaluationMessage.GetHashCode(); + } + if (this.TimeRefPoint != null) + { + hashCode = (hashCode * 59) + this.TimeRefPoint.GetHashCode(); + } + if (this.Participants != null) + { + hashCode = (hashCode * 59) + this.Participants.GetHashCode(); + } + if (this.Created != null) + { + hashCode = (hashCode * 59) + this.Created.GetHashCode(); + } + if (this.Modified != null) + { + hashCode = (hashCode * 59) + this.Modified.GetHashCode(); + } + return hashCode; + } + } + /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { // Voyage (string) maxLength if (this.Voyage != null && this.Voyage.Length > 16) { - yield return new ValidationResult("Invalid value for Voyage, length must be less than 16.", new [] { "Voyage" }); + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Voyage, length must be less than 16.", new [] { "Voyage" }); } // EvaluationMessage (string) maxLength if (this.EvaluationMessage != null && this.EvaluationMessage.Length > 512) { - yield return new ValidationResult("Invalid value for EvaluationMessage, length must be less than 512.", new [] { "EvaluationMessage" }); + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for EvaluationMessage, length must be less than 512.", new [] { "EvaluationMessage" }); } yield break; } @@ -7695,7 +8774,7 @@ namespace BreCalClient.misc.Model * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -7735,7 +8814,7 @@ namespace BreCalClient.misc.Model * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -7745,7 +8824,7 @@ namespace BreCalClient.misc.Model /// the id parameter needs to be missing on POST and to be present on PUT (Update) calls, otherwise a 400 response will be generated /// [DataContract(Name = "times")] - public partial class Times : IValidatableObject + public partial class Times : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. @@ -7991,21 +9070,255 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as Times); + } + /// + /// Returns true if Times instances are equal + /// + /// Instance of Times to be compared + /// Boolean + public bool Equals(Times input) + { + if (input == null) + { + return false; + } + return + ( + this.Id == input.Id || + this.Id.Equals(input.Id) + ) && + ( + this.EtaBerth == input.EtaBerth || + (this.EtaBerth != null && + this.EtaBerth.Equals(input.EtaBerth)) + ) && + ( + this.EtaBerthFixed == input.EtaBerthFixed || + (this.EtaBerthFixed != null && + this.EtaBerthFixed.Equals(input.EtaBerthFixed)) + ) && + ( + this.EtdBerth == input.EtdBerth || + (this.EtdBerth != null && + this.EtdBerth.Equals(input.EtdBerth)) + ) && + ( + this.EtdBerthFixed == input.EtdBerthFixed || + (this.EtdBerthFixed != null && + this.EtdBerthFixed.Equals(input.EtdBerthFixed)) + ) && + ( + this.LockTime == input.LockTime || + (this.LockTime != null && + this.LockTime.Equals(input.LockTime)) + ) && + ( + this.LockTimeFixed == input.LockTimeFixed || + (this.LockTimeFixed != null && + this.LockTimeFixed.Equals(input.LockTimeFixed)) + ) && + ( + this.ZoneEntry == input.ZoneEntry || + (this.ZoneEntry != null && + this.ZoneEntry.Equals(input.ZoneEntry)) + ) && + ( + this.ZoneEntryFixed == input.ZoneEntryFixed || + (this.ZoneEntryFixed != null && + this.ZoneEntryFixed.Equals(input.ZoneEntryFixed)) + ) && + ( + this.OperationsStart == input.OperationsStart || + (this.OperationsStart != null && + this.OperationsStart.Equals(input.OperationsStart)) + ) && + ( + this.OperationsEnd == input.OperationsEnd || + (this.OperationsEnd != null && + this.OperationsEnd.Equals(input.OperationsEnd)) + ) && + ( + this.Remarks == input.Remarks || + (this.Remarks != null && + this.Remarks.Equals(input.Remarks)) + ) && + ( + this.ShipcallId == input.ShipcallId || + this.ShipcallId.Equals(input.ShipcallId) + ) && + ( + this.ParticipantId == input.ParticipantId || + this.ParticipantId.Equals(input.ParticipantId) + ) && + ( + this.BerthId == input.BerthId || + (this.BerthId != null && + this.BerthId.Equals(input.BerthId)) + ) && + ( + this.BerthInfo == input.BerthInfo || + (this.BerthInfo != null && + this.BerthInfo.Equals(input.BerthInfo)) + ) && + ( + this.PierSide == input.PierSide || + (this.PierSide != null && + this.PierSide.Equals(input.PierSide)) + ) && + ( + this.ParticipantType == input.ParticipantType || + this.ParticipantType.Equals(input.ParticipantType) + ) && + ( + this.Ata == input.Ata || + (this.Ata != null && + this.Ata.Equals(input.Ata)) + ) && + ( + this.Atd == input.Atd || + (this.Atd != null && + this.Atd.Equals(input.Atd)) + ) && + ( + this.EtaIntervalEnd == input.EtaIntervalEnd || + (this.EtaIntervalEnd != null && + this.EtaIntervalEnd.Equals(input.EtaIntervalEnd)) + ) && + ( + this.EtdIntervalEnd == input.EtdIntervalEnd || + (this.EtdIntervalEnd != null && + this.EtdIntervalEnd.Equals(input.EtdIntervalEnd)) + ) && + ( + this.Created == input.Created || + (this.Created != null && + this.Created.Equals(input.Created)) + ) && + ( + this.Modified == input.Modified || + (this.Modified != null && + this.Modified.Equals(input.Modified)) + ); + } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = (hashCode * 59) + this.Id.GetHashCode(); + if (this.EtaBerth != null) + { + hashCode = (hashCode * 59) + this.EtaBerth.GetHashCode(); + } + if (this.EtaBerthFixed != null) + { + hashCode = (hashCode * 59) + this.EtaBerthFixed.GetHashCode(); + } + if (this.EtdBerth != null) + { + hashCode = (hashCode * 59) + this.EtdBerth.GetHashCode(); + } + if (this.EtdBerthFixed != null) + { + hashCode = (hashCode * 59) + this.EtdBerthFixed.GetHashCode(); + } + if (this.LockTime != null) + { + hashCode = (hashCode * 59) + this.LockTime.GetHashCode(); + } + if (this.LockTimeFixed != null) + { + hashCode = (hashCode * 59) + this.LockTimeFixed.GetHashCode(); + } + if (this.ZoneEntry != null) + { + hashCode = (hashCode * 59) + this.ZoneEntry.GetHashCode(); + } + if (this.ZoneEntryFixed != null) + { + hashCode = (hashCode * 59) + this.ZoneEntryFixed.GetHashCode(); + } + if (this.OperationsStart != null) + { + hashCode = (hashCode * 59) + this.OperationsStart.GetHashCode(); + } + if (this.OperationsEnd != null) + { + hashCode = (hashCode * 59) + this.OperationsEnd.GetHashCode(); + } + if (this.Remarks != null) + { + hashCode = (hashCode * 59) + this.Remarks.GetHashCode(); + } + hashCode = (hashCode * 59) + this.ShipcallId.GetHashCode(); + hashCode = (hashCode * 59) + this.ParticipantId.GetHashCode(); + if (this.BerthId != null) + { + hashCode = (hashCode * 59) + this.BerthId.GetHashCode(); + } + if (this.BerthInfo != null) + { + hashCode = (hashCode * 59) + this.BerthInfo.GetHashCode(); + } + if (this.PierSide != null) + { + hashCode = (hashCode * 59) + this.PierSide.GetHashCode(); + } + hashCode = (hashCode * 59) + this.ParticipantType.GetHashCode(); + if (this.Ata != null) + { + hashCode = (hashCode * 59) + this.Ata.GetHashCode(); + } + if (this.Atd != null) + { + hashCode = (hashCode * 59) + this.Atd.GetHashCode(); + } + if (this.EtaIntervalEnd != null) + { + hashCode = (hashCode * 59) + this.EtaIntervalEnd.GetHashCode(); + } + if (this.EtdIntervalEnd != null) + { + hashCode = (hashCode * 59) + this.EtdIntervalEnd.GetHashCode(); + } + if (this.Created != null) + { + hashCode = (hashCode * 59) + this.Created.GetHashCode(); + } + if (this.Modified != null) + { + hashCode = (hashCode * 59) + this.Modified.GetHashCode(); + } + return hashCode; + } + } + /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { // Remarks (string) maxLength if (this.Remarks != null && this.Remarks.Length > 512) { - yield return new ValidationResult("Invalid value for Remarks, length must be less than 512.", new [] { "Remarks" }); + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Remarks, length must be less than 512.", new [] { "Remarks" }); } // BerthInfo (string) maxLength if (this.BerthInfo != null && this.BerthInfo.Length > 512) { - yield return new ValidationResult("Invalid value for BerthInfo, length must be less than 512.", new [] { "BerthInfo" }); + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for BerthInfo, length must be less than 512.", new [] { "BerthInfo" }); } yield break; } @@ -8017,7 +9330,7 @@ namespace BreCalClient.misc.Model * * Administer DEBRE ship calls, times and notifications * - * The version of the OpenAPI document: 1.4.0 + * The version of the OpenAPI document: 1.5.0 * Contact: info@textbausteine.net * Generated by: https://github.com/openapitools/openapi-generator.git */ @@ -8027,7 +9340,7 @@ namespace BreCalClient.misc.Model /// fields that a user may change /// [DataContract(Name = "user_details")] - public partial class UserDetails : IValidatableObject + public partial class UserDetails : IEquatable, IValidatableObject { /// /// Initializes a new instance of the class. @@ -8111,41 +9424,134 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as UserDetails); + } + /// + /// Returns true if UserDetails instances are equal + /// + /// Instance of UserDetails to be compared + /// Boolean + public bool Equals(UserDetails input) + { + if (input == null) + { + return false; + } + return + ( + this.Id == input.Id || + this.Id.Equals(input.Id) + ) && + ( + this.OldPassword == input.OldPassword || + (this.OldPassword != null && + this.OldPassword.Equals(input.OldPassword)) + ) && + ( + this.NewPassword == input.NewPassword || + (this.NewPassword != null && + this.NewPassword.Equals(input.NewPassword)) + ) && + ( + this.FirstName == input.FirstName || + (this.FirstName != null && + this.FirstName.Equals(input.FirstName)) + ) && + ( + this.LastName == input.LastName || + (this.LastName != null && + this.LastName.Equals(input.LastName)) + ) && + ( + this.UserPhone == input.UserPhone || + (this.UserPhone != null && + this.UserPhone.Equals(input.UserPhone)) + ) && + ( + this.UserEmail == input.UserEmail || + (this.UserEmail != null && + this.UserEmail.Equals(input.UserEmail)) + ); + } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = (hashCode * 59) + this.Id.GetHashCode(); + if (this.OldPassword != null) + { + hashCode = (hashCode * 59) + this.OldPassword.GetHashCode(); + } + if (this.NewPassword != null) + { + hashCode = (hashCode * 59) + this.NewPassword.GetHashCode(); + } + if (this.FirstName != null) + { + hashCode = (hashCode * 59) + this.FirstName.GetHashCode(); + } + if (this.LastName != null) + { + hashCode = (hashCode * 59) + this.LastName.GetHashCode(); + } + if (this.UserPhone != null) + { + hashCode = (hashCode * 59) + this.UserPhone.GetHashCode(); + } + if (this.UserEmail != null) + { + hashCode = (hashCode * 59) + this.UserEmail.GetHashCode(); + } + return hashCode; + } + } + /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { // OldPassword (string) maxLength if (this.OldPassword != null && this.OldPassword.Length > 128) { - yield return new ValidationResult("Invalid value for OldPassword, length must be less than 128.", new [] { "OldPassword" }); + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for OldPassword, length must be less than 128.", new [] { "OldPassword" }); } // NewPassword (string) maxLength if (this.NewPassword != null && this.NewPassword.Length > 128) { - yield return new ValidationResult("Invalid value for NewPassword, length must be less than 128.", new [] { "NewPassword" }); + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for NewPassword, length must be less than 128.", new [] { "NewPassword" }); } // FirstName (string) maxLength if (this.FirstName != null && this.FirstName.Length > 45) { - yield return new ValidationResult("Invalid value for FirstName, length must be less than 45.", new [] { "FirstName" }); + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for FirstName, length must be less than 45.", new [] { "FirstName" }); } // LastName (string) maxLength if (this.LastName != null && this.LastName.Length > 45) { - yield return new ValidationResult("Invalid value for LastName, length must be less than 45.", new [] { "LastName" }); + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for LastName, length must be less than 45.", new [] { "LastName" }); } // UserPhone (string) maxLength if (this.UserPhone != null && this.UserPhone.Length > 128) { - yield return new ValidationResult("Invalid value for UserPhone, length must be less than 128.", new [] { "UserPhone" }); + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UserPhone, length must be less than 128.", new [] { "UserPhone" }); } // UserEmail (string) maxLength if (this.UserEmail != null && this.UserEmail.Length > 128) { - yield return new ValidationResult("Invalid value for UserEmail, length must be less than 128.", new [] { "UserEmail" }); + yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UserEmail, length must be less than 128.", new [] { "UserEmail" }); } yield break; } diff --git a/misc/BreCalApi.yaml b/misc/BreCalApi.yaml index 2accd25..a732b40 100644 --- a/misc/BreCalApi.yaml +++ b/misc/BreCalApi.yaml @@ -2,7 +2,7 @@ openapi: 3.0.0 x-stoplight: id: mwv4y8vcnopwr info: - version: 1.4.1 + version: 1.5.0 title: Bremen calling API description: 'Administer DEBRE ship calls, times and notifications' termsOfService: 'https://www.bsmd.de/' @@ -14,7 +14,7 @@ info: name: Use at your own risk url: 'https://www.bsmd.de/license' servers: - - url: 'https://brecaldevel.bsmd-emswe.eu' + - url: 'https://brecaltest.bsmd-emswe.eu' description: Development server hosted on vcup tags: - name: user diff --git a/src/BreCalClient/App.config b/src/BreCalClient/App.config index 335a433..9435c06 100644 --- a/src/BreCalClient/App.config +++ b/src/BreCalClient/App.config @@ -29,7 +29,7 @@ - #1D751F + #751D1F !!Bremen calling Testversion!! @@ -38,7 +38,7 @@ https://www.textbausteine.net/ - https://brecaldevel.bsmd-emswe.eu + https://brecaltest.bsmd-emswe.eu diff --git a/src/BreCalClient/BreCalClient.csproj b/src/BreCalClient/BreCalClient.csproj index 2403c98..ffda91f 100644 --- a/src/BreCalClient/BreCalClient.csproj +++ b/src/BreCalClient/BreCalClient.csproj @@ -8,12 +8,12 @@ True BreCalClient.App ..\..\misc\brecal.snk - 1.4.1.0 - 1.4.1.0 + 1.5.0.0 + 1.5.0.0 Bremen calling client A Windows WPF client for the Bremen calling API. containership.ico - BreCalDevelClient + BreCalTestClient @@ -116,12 +116,12 @@ - + - - + + diff --git a/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml b/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml index 2c76f88..6b9c078 100644 --- a/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml +++ b/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml @@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. 0 - 1.4.1.0 + 1.5.0.0 True Debug True diff --git a/src/BreCalClient/Properties/Settings.Designer.cs b/src/BreCalClient/Properties/Settings.Designer.cs index fd85a6b..0968a59 100644 --- a/src/BreCalClient/Properties/Settings.Designer.cs +++ b/src/BreCalClient/Properties/Settings.Designer.cs @@ -25,7 +25,7 @@ namespace BreCalClient.Properties { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("#1D751F")] + [global::System.Configuration.DefaultSettingValueAttribute("#751D1F")] public string BG_COLOR { get { return ((string)(this["BG_COLOR"])); @@ -64,7 +64,7 @@ namespace BreCalClient.Properties { [global::System.Configuration.ApplicationScopedSettingAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Configuration.DefaultSettingValueAttribute("https://brecaldevel.bsmd-emswe.eu")] + [global::System.Configuration.DefaultSettingValueAttribute("https://brecaltest.bsmd-emswe.eu")] public string API_URL { get { return ((string)(this["API_URL"])); diff --git a/src/BreCalClient/Properties/Settings.settings b/src/BreCalClient/Properties/Settings.settings index b10fd5b..a86943e 100644 --- a/src/BreCalClient/Properties/Settings.settings +++ b/src/BreCalClient/Properties/Settings.settings @@ -3,7 +3,7 @@ - #1D751F + #751D1F !!Bremen calling Testversion!! @@ -15,7 +15,7 @@ - https://brecaldevel.bsmd-emswe.eu + https://brecaltest.bsmd-emswe.eu 800 diff --git a/src/BreCalClient/ShipcallControl.xaml b/src/BreCalClient/ShipcallControl.xaml index 934ae9f..92f861e 100644 --- a/src/BreCalClient/ShipcallControl.xaml +++ b/src/BreCalClient/ShipcallControl.xaml @@ -5,7 +5,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:p = "clr-namespace:BreCalClient.Resources" xmlns:sets="clr-namespace:BreCalClient.Properties" - xmlns:db="clr-namespace:BreCalClient;assembly=BreCalDevelClient" + xmlns:db="clr-namespace:BreCalClient;assembly=BreCalTestClient" mc:Ignorable="d" d:DesignHeight="135" d:DesignWidth="800"> diff --git a/src/BreCalClient/ShipcallControl.xaml.cs b/src/BreCalClient/ShipcallControl.xaml.cs index fbf6fad..6f4dd6f 100644 --- a/src/BreCalClient/ShipcallControl.xaml.cs +++ b/src/BreCalClient/ShipcallControl.xaml.cs @@ -216,13 +216,13 @@ namespace BreCalClient switch (this.ShipcallControlModel?.Shipcall?.Type) { case ShipcallType.Arrival: // incoming - this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/arrow_down_red.png")); + this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/arrow_down_red.png")); break; case ShipcallType.Departure: // outgoing - this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/arrow_up_blue.png")); + this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/arrow_up_blue.png")); break; case ShipcallType.Shifting: // shifting - this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/arrow_right_green.png")); + this.imageShipcallType.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/arrow_right_green.png")); break; default: break; @@ -231,13 +231,13 @@ namespace BreCalClient switch(this.ShipcallControlModel?.LightMode) { case EvaluationType.Green: - this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/check.png")); + this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/check.png")); break; case EvaluationType.Yellow: - this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/sign_warning.png")); + this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/sign_warning.png")); break; case EvaluationType.Red: - this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalDevelClient;component/Resources/delete2.png")); + this.imageEvaluation.Source = new BitmapImage(new Uri("pack://application:,,,/BreCalTestClient;component/Resources/delete2.png")); break; default: break; diff --git a/src/RoleEditor/App.config b/src/RoleEditor/App.config index 51c1ce1..bd2b4e4 100644 --- a/src/RoleEditor/App.config +++ b/src/RoleEditor/App.config @@ -8,7 +8,7 @@ - Server=localhost;User ID=ds;Password=HalloWach_2323XXL!!;Database=bremen_calling_devel;Port=33306 + Server=localhost;User ID=ds;Password=HalloWach_2323XXL!!;Database=bremen_calling_test;Port=33306 diff --git a/src/server/BreCal/__init__.py b/src/server/BreCal/__init__.py index 263203e..ad6b3d0 100644 --- a/src/server/BreCal/__init__.py +++ b/src/server/BreCal/__init__.py @@ -66,7 +66,7 @@ def create_app(test_config=None, instance_path=None): app.register_blueprint(user.bp) app.register_blueprint(history.bp) - logging.basicConfig(filename='brecaldevel.log', level=logging.DEBUG, format='%(asctime)s | %(name)s | %(levelname)s | %(message)s') + logging.basicConfig(filename='brecaltest.log', level=logging.DEBUG, format='%(asctime)s | %(name)s | %(levelname)s | %(message)s') local_db.initPool(os.path.dirname(app.instance_path)) logging.info('App started') diff --git a/src/server/BreCal/local_db.py b/src/server/BreCal/local_db.py index 330bc13..3d63269 100644 --- a/src/server/BreCal/local_db.py +++ b/src/server/BreCal/local_db.py @@ -7,11 +7,11 @@ import sys config_path = None -def initPool(instancePath, connection_filename="connection_data_devel.json"): +def initPool(instancePath, connection_filename="connection_data_test.json"): try: global config_path if(config_path == None): - config_path = os.path.join(instancePath,f'../../../secure/{connection_filename}') #connection_data_devel.json'); + config_path = os.path.join(instancePath,f'../../../secure/{connection_filename}') #connection_data_test.json'); print (config_path) diff --git a/src/server/flaskapp.wsgi b/src/server/flaskapp.wsgi index 4a5f543..9dec941 100644 --- a/src/server/flaskapp.wsgi +++ b/src/server/flaskapp.wsgi @@ -2,7 +2,7 @@ import os import sys import logging -sys.path.insert(0, '/var/www/brecal_devel/src/server') +sys.path.insert(0, '/var/www/brecal_test/src/server') sys.path.insert(0, '/var/www/venv/lib/python3.10/site-packages/') import schedule diff --git a/src/server/setup.py b/src/server/setup.py index 44750aa..5b0baf2 100644 --- a/src/server/setup.py +++ b/src/server/setup.py @@ -2,7 +2,7 @@ from setuptools import find_packages, setup setup( name='BreCal', - version='1.4.0', + version='1.5.0', packages=find_packages(), include_package_data=True, zip_safe=False, From 983c21ba67bffbd9f9a8d84849b0f33a3c2fbd5d Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Mon, 2 Sep 2024 08:48:40 +0200 Subject: [PATCH 02/38] don't crash on badly formatted error messages --- src/BreCalClient/MainWindow.xaml.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/BreCalClient/MainWindow.xaml.cs b/src/BreCalClient/MainWindow.xaml.cs index cf689e6..2152c96 100644 --- a/src/BreCalClient/MainWindow.xaml.cs +++ b/src/BreCalClient/MainWindow.xaml.cs @@ -1066,12 +1066,16 @@ namespace BreCalClient // type=8, created=datetime.datetime(2024, 8, 28, 15, 13, 14), modified=None) with Flags: 42\"} Match m = Regex.Match(message, "\\{(.*)\\}"); if ((m != null) && m.Success) - { - dynamic? msg = JsonConvert.DeserializeObject(m.Value); - if(msg != null) + { + try { - message = msg.message; + dynamic? msg = JsonConvert.DeserializeObject(m.Value); + if (msg != null) + { + message = msg.message; + } } + catch (Exception) { } } _log.ErrorFormat("{0} - {1}", caption, message); From 4b5ff90b345cd71e0c55766332af4d68ba3e9f57 Mon Sep 17 00:00:00 2001 From: Max Metz Date: Tue, 3 Sep 2024 11:23:28 +0200 Subject: [PATCH 03/38] properly serializing ValidationError exceptions. --- src/server/BreCal/api/shipcalls.py | 7 ++-- src/server/BreCal/api/ships.py | 16 ++++++++ src/server/BreCal/api/times.py | 38 ++++++++++++------- .../validators/input_validation_ship.py | 3 ++ .../BreCal/validators/validation_error.py | 34 +++++++++++++++++ 5 files changed, 82 insertions(+), 16 deletions(-) create mode 100644 src/server/BreCal/validators/validation_error.py diff --git a/src/server/BreCal/api/shipcalls.py b/src/server/BreCal/api/shipcalls.py index fb74627..e6ac854 100644 --- a/src/server/BreCal/api/shipcalls.py +++ b/src/server/BreCal/api/shipcalls.py @@ -7,6 +7,7 @@ from ..services.auth_guard import auth_guard, check_jwt from BreCal.validators.input_validation import validate_posted_shipcall_data, check_if_user_is_bsmd_type from BreCal.validators.input_validation_shipcall import InputValidationShipcall from BreCal.database.sql_handler import execute_sql_query_standalone +from BreCal.validators.validation_error import create_validation_error_response, create_werkzeug_error_response from . import verify_if_request_is_json import logging @@ -58,7 +59,7 @@ def PostShipcalls(): except ValidationError as ex: logging.error(ex) print(ex) - return json.dumps({"message":f"bad format. \nError Messages: {ex.messages}. \nValid Data: {ex.valid_data}"}), 400 + return create_validation_error_response(ex=ex, status_code=400) except Exception as ex: logging.error(ex) @@ -88,12 +89,12 @@ def PutShipcalls(): except ValidationError as ex: logging.error(ex) print(ex) - return json.dumps({"message":f"bad format. \nError Messages: {ex.messages}. \nValid Data: {ex.valid_data}"}), 400 + return create_validation_error_response(ex=ex, status_code=400) except werkzeug.exceptions.Forbidden as ex: logging.error(ex) print(ex) - return json.dumps({"message":ex.description}), 403 + return create_werkzeug_error_response(ex=ex, status_code=403) except Exception as ex: logging.error(ex) diff --git a/src/server/BreCal/api/ships.py b/src/server/BreCal/api/ships.py index 31b6cf6..5935402 100644 --- a/src/server/BreCal/api/ships.py +++ b/src/server/BreCal/api/ships.py @@ -6,6 +6,7 @@ from ..schemas import model import json import logging from . import verify_if_request_is_json +from BreCal.validators.validation_error import create_validation_error_response from BreCal.validators.input_validation import check_if_user_is_bsmd_type from BreCal.validators.input_validation_ship import InputValidationShip @@ -45,6 +46,11 @@ def PostShip(): # validate the request data & user permissions InputValidationShip.evaluate_post_data(user_data, loadedModel, content) + except ValidationError as ex: + logging.error(ex) + print(ex) + return create_validation_error_response(ex=ex, status_code=400) + except Exception as ex: logging.error(ex) print(ex) @@ -69,6 +75,11 @@ def PutShip(): # validate the request data & user permissions InputValidationShip.evaluate_put_data(user_data, loadedModel, content) + except ValidationError as ex: + logging.error(ex) + print(ex) + return create_validation_error_response(ex=ex, status_code=400) + except Exception as ex: logging.error(ex) print(ex) @@ -97,6 +108,11 @@ def DeleteShip(): # validate the request data & user permissions InputValidationShip.evaluate_delete_data(user_data, ship_id) + except ValidationError as ex: + logging.error(ex) + print(ex) + return create_validation_error_response(ex=ex, status_code=400) + except Exception as ex: logging.error(ex) print(ex) diff --git a/src/server/BreCal/api/times.py b/src/server/BreCal/api/times.py index 131673f..65b18ed 100644 --- a/src/server/BreCal/api/times.py +++ b/src/server/BreCal/api/times.py @@ -7,6 +7,7 @@ import logging from marshmallow import ValidationError from BreCal.validators.input_validation_times import InputValidationTimes from . import verify_if_request_is_json +from BreCal.validators.validation_error import create_validation_error_response, create_werkzeug_error_response bp = Blueprint('times', __name__) @@ -44,7 +45,7 @@ def PostTimes(): except ValidationError as ex: logging.error(ex) print(ex) - return json.dumps(f"bad format. \nError Messages: {ex.messages}. \nValid Data: {ex.valid_data}"), 400 + return create_validation_error_response(ex=ex, status_code=400) except Exception as ex: logging.error(ex) @@ -73,7 +74,7 @@ def PutTimes(): except ValidationError as ex: logging.error(ex) print(ex) - return json.dumps(f"bad format. \nError Messages: {ex.messages}. \nValid Data: {ex.valid_data}"), 400 + return create_validation_error_response(ex=ex, status_code=400) except Exception as ex: logging.error(ex) @@ -87,17 +88,28 @@ def PutTimes(): @auth_guard() # no restriction by role def DeleteTimes(): - if 'id' in request.args: - options = {} - options["id"] = request.args.get("id") + try: + if 'id' in request.args: + options = {} + options["id"] = request.args.get("id") - # read the user data from the JWT token (set when login is performed) - user_data = check_jwt() + # read the user data from the JWT token (set when login is performed) + user_data = check_jwt() - # validate the request - InputValidationTimes.evaluate_delete_data(user_data, times_id = request.args.get("id")) + # validate the request + InputValidationTimes.evaluate_delete_data(user_data, times_id = request.args.get("id")) - return impl.times.DeleteTimes(options) - else: - logging.warning("Times delete missing id argument") - return json.dumps("missing argument"), 400 + return impl.times.DeleteTimes(options) + else: + logging.warning("Times delete missing id argument") + return json.dumps("missing argument"), 400 + + except ValidationError as ex: + logging.error(ex) + print(ex) + return create_validation_error_response(ex=ex, status_code=400) + + except Exception as ex: + logging.error(ex) + print(ex) + return json.dumps("bad format"), 400 diff --git a/src/server/BreCal/validators/input_validation_ship.py b/src/server/BreCal/validators/input_validation_ship.py index da3be4d..47fa918 100644 --- a/src/server/BreCal/validators/input_validation_ship.py +++ b/src/server/BreCal/validators/input_validation_ship.py @@ -102,6 +102,9 @@ class InputValidationShip(): @staticmethod def put_content_may_not_contain_imo_number(content:dict): put_data_ship_imo = content.get("imo",None) + + # #TODO: Aktuelle IMO abfragen und nach Änderung suchen, bevor eine Fehlermeldung erstellt wird + if put_data_ship_imo is not None: raise ValidationError(f"The IMO number field may not be changed since it serves the purpose of a primary (matching) key.") return diff --git a/src/server/BreCal/validators/validation_error.py b/src/server/BreCal/validators/validation_error.py new file mode 100644 index 0000000..cdac103 --- /dev/null +++ b/src/server/BreCal/validators/validation_error.py @@ -0,0 +1,34 @@ +import logging +import typing +import json +from marshmallow import ValidationError +import werkzeug +from werkzeug.exceptions import Forbidden + + + +def create_validation_error_response(ex:ValidationError, status_code:int=400)->typing.Tuple[str,int]: + # generate an overview the errors + #example: + # {'lock_time': ['The provided value must be in the future. Current Time: 2024-09-02 08:23:32.600791, Value: 2024-09-01 08:20:41.853000']} + errors = ex.messages + + # example: + # "Valid Data": { + # "id": 2894, + # "eta_berth": "datetime.datetime(2024, 9, 2, 11, 11, 43)", + # "eta_berth_fixed": false + # } + valid_data = ex.valid_data + + + json_response = { + "message":"ValidationError", + "errors":errors, + "valid_data":valid_data + } + return (json.dumps(json_response), status_code) + +def create_werkzeug_error_response(ex:Forbidden, status_code:int=403)->typing.Tuple[str,int]: + return json.dumps({"message":ex.description}), status_code + From 1ff972883fd7b66f20c5573e4ace1aa645d688ae Mon Sep 17 00:00:00 2001 From: Max Metz Date: Tue, 3 Sep 2024 13:07:45 +0200 Subject: [PATCH 04/38] adding input validation for time intervals --- docs/ApiValidationRules.md | 1 + src/server/BreCal/schemas/model.py | 15 +++++++++++++++ .../BreCal/validators/input_validation_times.py | 11 +++++++++++ 3 files changed, 27 insertions(+) diff --git a/docs/ApiValidationRules.md b/docs/ApiValidationRules.md index c080ae0..8a38a91 100644 --- a/docs/ApiValidationRules.md +++ b/docs/ApiValidationRules.md @@ -147,6 +147,7 @@ The id field is required, missing fields will not be updated. | Field | Validation | |-------|------------| | eta_berth, etd_berth, lock_time, zone_entry, operations_start, operations_end | if set these values must be in the future| + | eta_interval_end, etd_interval_end | if set these values must be in the future. They must be larger than their ETA/ETD counterparts. | | remarks, berth_info | must be <= 512 chars | | participant_type | must not be BSMD | diff --git a/src/server/BreCal/schemas/model.py b/src/server/BreCal/schemas/model.py index a21fb20..14bceda 100644 --- a/src/server/BreCal/schemas/model.py +++ b/src/server/BreCal/schemas/model.py @@ -436,6 +436,21 @@ class TimesSchema(Schema): # when 'value' is 'None', a ValidationError is not issued. valid_time = validate_time_is_in_not_too_distant_future(raise_validation_error=True, value=value, months=12) return + + @validates("eta_interval_end") + def validate_eta_interval_end(self, value): + # violation when time is not in the future, but also does not exceed a threshold for the 'reasonable' future + # when 'value' is 'None', a ValidationError is not issued. + valid_time = validate_time_is_in_not_too_distant_future(raise_validation_error=True, value=value, months=12) + return + + @validates("etd_interval_end") + def validate_etd_interval_end(self, value): + # violation when time is not in the future, but also does not exceed a threshold for the 'reasonable' future + # when 'value' is 'None', a ValidationError is not issued. + valid_time = validate_time_is_in_not_too_distant_future(raise_validation_error=True, value=value, months=12) + return + # deserialize PUT object target diff --git a/src/server/BreCal/validators/input_validation_times.py b/src/server/BreCal/validators/input_validation_times.py index 0385220..37b70b8 100644 --- a/src/server/BreCal/validators/input_validation_times.py +++ b/src/server/BreCal/validators/input_validation_times.py @@ -167,6 +167,17 @@ class InputValidationTimes(): if ParticipantType.BSMD in loadedModel["participant_type"]: raise ValidationError(f"current user belongs to BSMD. Cannot post times datasets. Found user data: {user_data}") + + if (loadedModel["etd_interval_end"] is not None) and (loadedModel["etd_berth"] is not None): + time_end_after_time_start = loadedModel["etd_interval_end"] >= loadedModel["etd_berth"] + if not time_end_after_time_start: + raise ValidationError(f"The provided time interval for the estimated departure time is invalid. The interval end takes place before the interval start. Found interval data: {loadedModel['etd_berth']} to {loadedModel['etd_interval_end']}") + + + if (loadedModel["eta_interval_end"] is not None) and (loadedModel["eta_berth"] is not None): + time_end_after_time_start = loadedModel["eta_interval_end"] >= loadedModel["eta_berth"] + if not time_end_after_time_start: + raise ValidationError(f"The provided time interval for the estimated arrival time is invalid. The interval begin takes place after the interval end. Found interval data: {loadedModel['eta_berth']} to {loadedModel['eta_interval_end']}") return @staticmethod From 3d2405e8fbbfcb585f4bbc0e29db771cb3a79735 Mon Sep 17 00:00:00 2001 From: Max Metz Date: Wed, 4 Sep 2024 09:41:58 +0200 Subject: [PATCH 05/38] maintenance of API Input Validation (ship & times) --- src/server/BreCal/database/sql_queries.py | 5 ++ src/server/BreCal/stubs/times.py | 12 ++++ .../validators/input_validation_ship.py | 22 ++++--- .../validators/input_validation_times.py | 12 ++-- src/server/tests/database/test_sql_queries.py | 7 +++ .../validators/test_input_validation_times.py | 57 +++++++++++++++++++ 6 files changed, 101 insertions(+), 14 deletions(-) create mode 100644 src/server/BreCal/stubs/times.py diff --git a/src/server/BreCal/database/sql_queries.py b/src/server/BreCal/database/sql_queries.py index 9888ada..e0e9b7e 100644 --- a/src/server/BreCal/database/sql_queries.py +++ b/src/server/BreCal/database/sql_queries.py @@ -266,6 +266,11 @@ class SQLQuery(): query = "SELECT id, name, imo, callsign, participant_id, length, width, is_tug, bollard_pull, eni, created, modified, deleted FROM ship ORDER BY name" return query + @staticmethod + def get_ship_by_id()->str: + query = "SELECT * FROM ship where id = ?id?" + return query + @staticmethod def get_times()->str: query = "SELECT id, eta_berth, eta_berth_fixed, etd_berth, etd_berth_fixed, lock_time, lock_time_fixed, " + \ diff --git a/src/server/BreCal/stubs/times.py b/src/server/BreCal/stubs/times.py new file mode 100644 index 0000000..a26b659 --- /dev/null +++ b/src/server/BreCal/stubs/times.py @@ -0,0 +1,12 @@ +import datetime +from BreCal.schemas import model +from BreCal.schemas.model import ParticipantType + +def get_schema_model_stub_departure(): + schemaModel = {'id': 0, 'eta_berth': None, 'eta_berth_fixed': None, 'etd_berth': datetime.datetime(2024, 9, 7, 15, 12, 58), 'etd_berth_fixed': None, 'lock_time': None, 'lock_time_fixed': None, 'zone_entry': None, 'zone_entry_fixed': None, 'operations_start': None, 'operations_end': None, 'remarks': 'test', 'participant_id': 10, 'berth_id': 146, 'berth_info': '', 'pier_side': None, 'shipcall_id': 115, 'participant_type': ParticipantType.AGENCY, 'ata': None, 'atd': None, 'eta_interval_end': None, 'etd_interval_end': None, 'created': None, 'modified': None} + return schemaModel + +def get_schema_model_stub_arrival(): + schemaModel = {'id': 0, 'eta_berth': datetime.datetime(2024, 9, 7, 15, 12, 58), 'eta_berth_fixed': None, 'etd_berth': None, 'etd_berth_fixed': None, 'lock_time': None, 'lock_time_fixed': None, 'zone_entry': None, 'zone_entry_fixed': None, 'operations_start': None, 'operations_end': None, 'remarks': 'test', 'participant_id': 10, 'berth_id': 146, 'berth_info': '', 'pier_side': None, 'shipcall_id': 115, 'participant_type': ParticipantType.AGENCY, 'ata': None, 'atd': None, 'eta_interval_end': None, 'etd_interval_end': None, 'created': None, 'modified': None} + return schemaModel + diff --git a/src/server/BreCal/validators/input_validation_ship.py b/src/server/BreCal/validators/input_validation_ship.py index 47fa918..3a47b2c 100644 --- a/src/server/BreCal/validators/input_validation_ship.py +++ b/src/server/BreCal/validators/input_validation_ship.py @@ -6,6 +6,8 @@ from marshmallow import ValidationError from string import ascii_letters, digits from BreCal.schemas.model import Ship, Shipcall, Berth, User, Participant, ShipcallType +from BreCal.database.sql_handler import execute_sql_query_standalone +from BreCal.database.sql_queries import SQLQuery from BreCal.impl.participant import GetParticipant from BreCal.impl.ships import GetShips from BreCal.impl.berths import GetBerths @@ -47,14 +49,14 @@ class InputValidationShip(): # 1.) Only users of type BSMD are allowed to PUT InputValidationShip.check_user_is_bsmd_type(user_data) - # 2.) The IMO number field may not be changed + # 2.) ID field is mandatory + InputValidationShip.content_contains_ship_id(content) + + # 3.) The IMO number field may not be changed InputValidationShip.put_content_may_not_contain_imo_number(content) - # 3.) Check for reasonable Values (see BreCal.schemas.model.ShipSchema) + # 4.) Check for reasonable Values (see BreCal.schemas.model.ShipSchema) InputValidationShip.optionally_evaluate_bollard_pull_value(content) - - # 4.) ID field is mandatory - InputValidationShip.content_contains_ship_id(content) return @staticmethod @@ -101,11 +103,15 @@ class InputValidationShip(): @staticmethod def put_content_may_not_contain_imo_number(content:dict): + # IMO is a required field, so it will never be None outside of tests. If so, there is no violation put_data_ship_imo = content.get("imo",None) + if put_data_ship_imo is None: + return + + # grab the ship by its ID and compare, whether the IMO is unchanged + ship = execute_sql_query_standalone(SQLQuery.get_ship_by_id(), param={"id":content.get("id")}, command_type="single", model=Ship) - # #TODO: Aktuelle IMO abfragen und nach Änderung suchen, bevor eine Fehlermeldung erstellt wird - - if put_data_ship_imo is not None: + if put_data_ship_imo != ship.imo: raise ValidationError(f"The IMO number field may not be changed since it serves the purpose of a primary (matching) key.") return diff --git a/src/server/BreCal/validators/input_validation_times.py b/src/server/BreCal/validators/input_validation_times.py index 37b70b8..dbe4b3b 100644 --- a/src/server/BreCal/validators/input_validation_times.py +++ b/src/server/BreCal/validators/input_validation_times.py @@ -49,12 +49,12 @@ def build_post_data_type_dependent_required_fields_dict()->dict[ShipcallType,dic ShipcallType.shifting:{ ParticipantType.undefined:[], # should not be set in POST requests ParticipantType.BSMD:[], # should not be set in POST requests - ParticipantType.TERMINAL:["operations_start", "operations_end"], - ParticipantType.AGENCY:["eta_berth", "etd_berth"], - ParticipantType.MOORING:["eta_berth", "etd_berth"], - ParticipantType.PILOT:["eta_berth", "etd_berth"], - ParticipantType.PORT_ADMINISTRATION:["eta_berth", "etd_berth"], - ParticipantType.TUG:["eta_berth", "etd_berth"], + ParticipantType.TERMINAL:["operations_start"], + ParticipantType.AGENCY:["etd_berth"], + ParticipantType.MOORING:["etd_berth"], + ParticipantType.PILOT:["etd_berth"], + ParticipantType.PORT_ADMINISTRATION:["etd_berth"], + ParticipantType.TUG:["etd_berth"], }, } return post_data_type_dependent_required_fields_dict diff --git a/src/server/tests/database/test_sql_queries.py b/src/server/tests/database/test_sql_queries.py index fc4267a..9db3d75 100644 --- a/src/server/tests/database/test_sql_queries.py +++ b/src/server/tests/database/test_sql_queries.py @@ -87,6 +87,13 @@ def test_sql_get_ships(): assert all([isinstance(ship, model.Ship) for ship in ships]) return +def test_sql_get_ship_by_id(): + query = #"SELECT * FROM ship where id = ?id?" # #TODO_refactor: put into the SQLQuery object + ship = execute_sql_query_standalone(SQLQuery.get_ship_by_id(), param={"id":1}, command_type="single", model=model.Ship) + assert isinstance(ship, model.Ship) + return + + def test_sql_get_times(): options = {'shipcall_id':153} times = execute_sql_query_standalone(query=SQLQuery.get_times(), model=model.Times, param={"scid" : options["shipcall_id"]}) diff --git a/src/server/tests/validators/test_input_validation_times.py b/src/server/tests/validators/test_input_validation_times.py index 550387a..7a9b7d5 100644 --- a/src/server/tests/validators/test_input_validation_times.py +++ b/src/server/tests/validators/test_input_validation_times.py @@ -409,3 +409,60 @@ def test_input_validation_times_delete_request_fails_when_user_belongs_to_wrong_ InputValidationTimes.check_user_belongs_to_same_group_as_dataset_determines(user_data, loadedModel=None, times_id=times_id, pdata=pdata) return +def test_input_validation_times_check_dataset_values_for_time_intervals(): + import datetime + from BreCal.schemas import model + from BreCal.validators.input_validation_times import InputValidationTimes + from BreCal.stubs.times import get_schema_model_stub_arrival, get_schema_model_stub_departure + from marshmallow import ValidationError + + ### ETD (departure) + # expected to pass + schemaModel = get_schema_model_stub_departure() + schemaModel["etd_interval_end"] = schemaModel["etd_berth"] + datetime.timedelta(minutes=2) + + schemaModel["etd_berth"] = schemaModel["etd_berth"].isoformat() + schemaModel["etd_interval_end"] = schemaModel["etd_interval_end"].isoformat() + content = schemaModel + loadedModel = model.TimesSchema().load(data=schemaModel, many=False, partial=True) + + InputValidationTimes.check_dataset_values(user_data={}, loadedModel=loadedModel, content=content) + + # expected to fail: the from-to-interval is incorrectly set. + schemaModel = get_schema_model_stub_departure() + schemaModel["etd_interval_end"] = schemaModel["etd_berth"] - datetime.timedelta(minutes=2) + + schemaModel["etd_berth"] = schemaModel["etd_berth"].isoformat() + schemaModel["etd_interval_end"] = schemaModel["etd_interval_end"].isoformat() + content = schemaModel + loadedModel = model.TimesSchema().load(data=schemaModel, many=False, partial=True) + + with pytest.raises(ValidationError, match="The provided time interval for the estimated departure time is invalid"): + InputValidationTimes.check_dataset_values(user_data={}, loadedModel=loadedModel, content=content) + + + ### ETA (arrival) + # expected to pass + schemaModel = get_schema_model_stub_arrival() + schemaModel["eta_interval_end"] = schemaModel["eta_berth"] + datetime.timedelta(minutes=2) + + schemaModel["eta_berth"] = schemaModel["eta_berth"].isoformat() + schemaModel["eta_interval_end"] = schemaModel["eta_interval_end"].isoformat() + content = schemaModel + loadedModel = model.TimesSchema().load(data=schemaModel, many=False, partial=True) + + InputValidationTimes.check_dataset_values(user_data={}, loadedModel=loadedModel, content=content) + + # expected to fail: the from-to-interval is incorrectly set. + schemaModel = get_schema_model_stub_arrival() + schemaModel["eta_interval_end"] = schemaModel["eta_berth"] - datetime.timedelta(minutes=2) + + schemaModel["eta_berth"] = schemaModel["eta_berth"].isoformat() + schemaModel["eta_interval_end"] = schemaModel["eta_interval_end"].isoformat() + content = schemaModel + loadedModel = model.TimesSchema().load(data=schemaModel, many=False, partial=True) + + with pytest.raises(ValidationError, match="The provided time interval for the estimated arrival time is invalid"): + InputValidationTimes.check_dataset_values(user_data={}, loadedModel=loadedModel, content=content) + return + From 126faff281dae04fb0cf6990ea6e6e4a2a7c46a2 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Wed, 4 Sep 2024 11:13:38 +0200 Subject: [PATCH 06/38] Removed ETA as required field from shipcall PUT/POST --- docs/ApiValidationRules.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/ApiValidationRules.md b/docs/ApiValidationRules.md index c080ae0..0e6b46f 100644 --- a/docs/ApiValidationRules.md +++ b/docs/ApiValidationRules.md @@ -112,7 +112,7 @@ Usually the "Z" is missing at the end indicating local time. #### Required fields -* eta / etd (depending on value of type: 1: eta, 2: etd, 3: both) +* eta / etd (depending on value of type: 1: eta, 2: etd, 3: etd) * type * ship_id * arrival_berth_id / departure_berth_id (depending on type, see above) From 2c0a73113b16d34f2c705f87db01469977807226 Mon Sep 17 00:00:00 2001 From: Max Metz Date: Wed, 4 Sep 2024 11:17:32 +0200 Subject: [PATCH 07/38] shipcall PUTs may no longer change the shipcall type --- .../validators/input_validation_shipcall.py | 13 ++++++++ .../test_input_validation_shipcall.py | 32 +++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/server/BreCal/validators/input_validation_shipcall.py b/src/server/BreCal/validators/input_validation_shipcall.py index 729a896..59b8b35 100644 --- a/src/server/BreCal/validators/input_validation_shipcall.py +++ b/src/server/BreCal/validators/input_validation_shipcall.py @@ -123,6 +123,9 @@ class InputValidationShipcall(): # time values must use future-dates InputValidationShipcall.check_times_are_in_future(loadedModel, content) + # the type of a shipcall may not be changed. It can only be set with the initial POST-request. + InputValidationShipcall.check_shipcall_type_is_unchanged(loadedModel) + # some arguments must not be provided InputValidationShipcall.check_forbidden_arguments(content, forbidden_keys=forbidden_keys) return @@ -247,6 +250,16 @@ class InputValidationShipcall(): if not valid_participant_types: # #TODO: according to Daniel, there may eventually be multi-assignment of participants for the same role raise ValidationError(f"every participant id and type should be listed only once. Found multiple entries for one of the participants.") + @staticmethod + def check_shipcall_type_is_unchanged(loadedModel:dict): + # the type of a shipcall may only be set on POST requests. Afterwards, shipcall types may not be changed. + query = SQLQuery.get_shipcall_by_id() + shipcall = execute_sql_query_standalone(query=query, model=Shipcall, param={"id":loadedModel.get("id")}, command_type="single") + + if int(loadedModel["type"]) != int(shipcall.type): + raise ValidationError(f"The shipcall type may only be set in the initial POST-request. Afterwards, changing the shipcall type is not allowed.") # @pytest.raises + return + @staticmethod def check_forbidden_arguments(content:dict, forbidden_keys=["evaluation", "evaluation_message"]): """ diff --git a/src/server/tests/validators/test_input_validation_shipcall.py b/src/server/tests/validators/test_input_validation_shipcall.py index df41f1f..87b3b7f 100644 --- a/src/server/tests/validators/test_input_validation_shipcall.py +++ b/src/server/tests/validators/test_input_validation_shipcall.py @@ -901,3 +901,35 @@ def test_post_data_with_valid_data(get_stub_token): assert response.status_code==201 return +def test_input_validation_shipcall_put_fails_when_type_differs(): + from marshmallow import ValidationError + from BreCal.stubs.shipcall import get_stub_valid_shipcall_arrival + from BreCal.schemas import model + from BreCal.database.sql_queries import SQLQuery + from BreCal.database.sql_handler import execute_sql_query_standalone + + from BreCal.validators.input_validation_shipcall import InputValidationShipcall + + # stub data + put_data = get_stub_valid_shipcall_arrival() + put_data["id"] = 3 + loadedModel = model.ShipcallSchema().load(data=put_data, many=False, partial=True) + + # load data from DB + shipcall_id = loadedModel.get("id") + query = SQLQuery.get_shipcall_by_id() + shipcall = execute_sql_query_standalone(query=query, model=model.Shipcall, param={"id":shipcall_id}, command_type="single") + + # create failure case. Ensures that the type is not the same as in the loaded shipcall from the DB + failure_case = 1 if shipcall.type==2 else 2 + loadedModel["type"] = model.ShipcallType(failure_case) + + # should fail: different 'type' + with pytest.raises(ValidationError, match="The shipcall type may only be set in the initial POST-request. Afterwards, changing the shipcall type is not allowed"): + InputValidationShipcall.check_shipcall_type_is_unchanged(loadedModel) + + # should pass: same 'type' + loadedModel["type"] = shipcall.type + InputValidationShipcall.check_shipcall_type_is_unchanged(loadedModel) + return + From a8d0356eb739d505db45268bca86205b206fd865 Mon Sep 17 00:00:00 2001 From: Max Metz Date: Wed, 4 Sep 2024 11:19:47 +0200 Subject: [PATCH 08/38] added the shipcall PUT rule to the docs/ApiValidatioNRules.md document --- docs/ApiValidationRules.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/ApiValidationRules.md b/docs/ApiValidationRules.md index 8a38a91..1e41b4f 100644 --- a/docs/ApiValidationRules.md +++ b/docs/ApiValidationRules.md @@ -189,6 +189,7 @@ shipcall_id, participant_id, participant_type 1. A dataset may only be changed by a user belonging to the same participant as the times dataset is referring to. 2. See reference and value checking as specified in /times POST. +3. The shipcall type may not be changed. #### Required fields From 2f678267c88567ae43fabdb75aab3c2f556b9280 Mon Sep 17 00:00:00 2001 From: Max Metz Date: Wed, 4 Sep 2024 11:41:03 +0200 Subject: [PATCH 09/38] time estimations are no longer dependency on times POST requests. This refers to eta_berth, etd_berth, operations_start, operations_end. --- .../validators/input_validation_times.py | 77 ++++++++++++++----- 1 file changed, 59 insertions(+), 18 deletions(-) diff --git a/src/server/BreCal/validators/input_validation_times.py b/src/server/BreCal/validators/input_validation_times.py index dbe4b3b..688c651 100644 --- a/src/server/BreCal/validators/input_validation_times.py +++ b/src/server/BreCal/validators/input_validation_times.py @@ -29,32 +29,32 @@ def build_post_data_type_dependent_required_fields_dict()->dict[ShipcallType,dic ShipcallType.arrival:{ ParticipantType.undefined:[], # should not be set in POST requests ParticipantType.BSMD:[], # should not be set in POST requests - ParticipantType.TERMINAL:["operations_start"], - ParticipantType.AGENCY:["eta_berth"], - ParticipantType.MOORING:["eta_berth"], - ParticipantType.PILOT:["eta_berth"], - ParticipantType.PORT_ADMINISTRATION:["eta_berth"], - ParticipantType.TUG:["eta_berth"], + ParticipantType.TERMINAL:[], + ParticipantType.AGENCY:[], + ParticipantType.MOORING:[], + ParticipantType.PILOT:[], + ParticipantType.PORT_ADMINISTRATION:[], + ParticipantType.TUG:[], }, ShipcallType.departure:{ ParticipantType.undefined:[], # should not be set in POST requests ParticipantType.BSMD:[], # should not be set in POST requests - ParticipantType.TERMINAL:["operations_end"], - ParticipantType.AGENCY:["etd_berth"], - ParticipantType.MOORING:["etd_berth"], - ParticipantType.PILOT:["etd_berth"], - ParticipantType.PORT_ADMINISTRATION:["etd_berth"], - ParticipantType.TUG:["etd_berth"], + ParticipantType.TERMINAL:[], + ParticipantType.AGENCY:[], + ParticipantType.MOORING:[], + ParticipantType.PILOT:[], + ParticipantType.PORT_ADMINISTRATION:[], + ParticipantType.TUG:[], }, ShipcallType.shifting:{ ParticipantType.undefined:[], # should not be set in POST requests ParticipantType.BSMD:[], # should not be set in POST requests - ParticipantType.TERMINAL:["operations_start"], - ParticipantType.AGENCY:["etd_berth"], - ParticipantType.MOORING:["etd_berth"], - ParticipantType.PILOT:["etd_berth"], - ParticipantType.PORT_ADMINISTRATION:["etd_berth"], - ParticipantType.TUG:["etd_berth"], + ParticipantType.TERMINAL:[], + ParticipantType.AGENCY:[], + ParticipantType.MOORING:[], + ParticipantType.PILOT:[], + ParticipantType.PORT_ADMINISTRATION:[], + ParticipantType.TUG:[], }, } return post_data_type_dependent_required_fields_dict @@ -482,3 +482,44 @@ class InputValidationTimes(): has_bsmd_flag = ParticipantFlag.BSMD in [ParticipantFlag(participant.get("flags"))] return has_bsmd_flag + +def deprecated_build_post_data_type_dependent_required_fields_dict()->dict[ShipcallType,dict[ParticipantType,typing.Optional[list[str]]]]: + """ + The required fields of a POST-request depend on ShipcallType and ParticipantType. This function creates + a dictionary, which maps those types to a list of required fields. + + The participant types 'undefined' and 'bsmd' should not be used in POST-requests. They return 'None'. + """ + post_data_type_dependent_required_fields_dict = { + ShipcallType.arrival:{ + ParticipantType.undefined:[], # should not be set in POST requests + ParticipantType.BSMD:[], # should not be set in POST requests + ParticipantType.TERMINAL:[], + ParticipantType.AGENCY:["eta_berth"], + ParticipantType.MOORING:["eta_berth"], + ParticipantType.PILOT:["eta_berth"], + ParticipantType.PORT_ADMINISTRATION:["eta_berth"], + ParticipantType.TUG:["eta_berth"], + }, + ShipcallType.departure:{ + ParticipantType.undefined:[], # should not be set in POST requests + ParticipantType.BSMD:[], # should not be set in POST requests + ParticipantType.TERMINAL:[], + ParticipantType.AGENCY:["etd_berth"], + ParticipantType.MOORING:["etd_berth"], + ParticipantType.PILOT:["etd_berth"], + ParticipantType.PORT_ADMINISTRATION:["etd_berth"], + ParticipantType.TUG:["etd_berth"], + }, + ShipcallType.shifting:{ + ParticipantType.undefined:[], # should not be set in POST requests + ParticipantType.BSMD:[], # should not be set in POST requests + ParticipantType.TERMINAL:[], + ParticipantType.AGENCY:["etd_berth"], + ParticipantType.MOORING:["etd_berth"], + ParticipantType.PILOT:["etd_berth"], + ParticipantType.PORT_ADMINISTRATION:["etd_berth"], + ParticipantType.TUG:["etd_berth"], + }, + } + return post_data_type_dependent_required_fields_dict From bc73bb3c080d4ca0ba02f2cf914d97d85267f31e Mon Sep 17 00:00:00 2001 From: Max Metz Date: Wed, 4 Sep 2024 12:11:05 +0200 Subject: [PATCH 10/38] fixed serialization of marshmallow.ValidationErrors. This was caused by the 'valid_data' containing datetime objects, which were not serializable natively. --- .../BreCal/validators/validation_error.py | 11 +++++++++-- .../tests/validators/test_validation_error.py | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 src/server/tests/validators/test_validation_error.py diff --git a/src/server/BreCal/validators/validation_error.py b/src/server/BreCal/validators/validation_error.py index cdac103..65ee985 100644 --- a/src/server/BreCal/validators/validation_error.py +++ b/src/server/BreCal/validators/validation_error.py @@ -27,8 +27,15 @@ def create_validation_error_response(ex:ValidationError, status_code:int=400)->t "errors":errors, "valid_data":valid_data } - return (json.dumps(json_response), status_code) + + # json.dumps with default=str automatically converts non-serializable values to strings. Hence, datetime objects (which are not) + # natively serializable are properly serialized. + serialized_response = json.dumps(json_response, default=str) + return (serialized_response, status_code) def create_werkzeug_error_response(ex:Forbidden, status_code:int=403)->typing.Tuple[str,int]: - return json.dumps({"message":ex.description}), status_code + # json.dumps with default=str automatically converts non-serializable values to strings. Hence, datetime objects (which are not) + # natively serializable are properly serialized. + serialized_response = json.dumps({"message":ex.description}, default=str) + return serialized_response, status_code diff --git a/src/server/tests/validators/test_validation_error.py b/src/server/tests/validators/test_validation_error.py new file mode 100644 index 0000000..a103919 --- /dev/null +++ b/src/server/tests/validators/test_validation_error.py @@ -0,0 +1,19 @@ +import pytest + +def test_create_validation_error_response_is_serializable(): + from BreCal.stubs.times_full import get_valid_stub_times + from BreCal.schemas import model + from BreCal.validators.validation_error import create_validation_error_response + + content = get_valid_stub_times() + + import datetime + content["operations_end"] = (datetime.datetime.now()-datetime.timedelta(minutes=14)).isoformat() + + content["id"] = 3 + try: + loadedModel = model.TimesSchema().load(data=content, many=False, partial=True) + except Exception as ex: + my_var = ex + create_validation_error_response(ex=ex, status_code=400) # this function initially created errors, as datetime objects were not serializable. Corrected now. + return From e4d0ea23012f89046fb232e9ff06f51ca22fd899 Mon Sep 17 00:00:00 2001 From: Max Metz Date: Wed, 4 Sep 2024 12:11:05 +0200 Subject: [PATCH 11/38] fixed serialization of marshmallow.ValidationErrors. This was caused by the 'valid_data' containing datetime objects, which were not serializable natively. --- .../BreCal/validators/validation_error.py | 11 +++++++++-- .../tests/validators/test_validation_error.py | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 src/server/tests/validators/test_validation_error.py diff --git a/src/server/BreCal/validators/validation_error.py b/src/server/BreCal/validators/validation_error.py index cdac103..65ee985 100644 --- a/src/server/BreCal/validators/validation_error.py +++ b/src/server/BreCal/validators/validation_error.py @@ -27,8 +27,15 @@ def create_validation_error_response(ex:ValidationError, status_code:int=400)->t "errors":errors, "valid_data":valid_data } - return (json.dumps(json_response), status_code) + + # json.dumps with default=str automatically converts non-serializable values to strings. Hence, datetime objects (which are not) + # natively serializable are properly serialized. + serialized_response = json.dumps(json_response, default=str) + return (serialized_response, status_code) def create_werkzeug_error_response(ex:Forbidden, status_code:int=403)->typing.Tuple[str,int]: - return json.dumps({"message":ex.description}), status_code + # json.dumps with default=str automatically converts non-serializable values to strings. Hence, datetime objects (which are not) + # natively serializable are properly serialized. + serialized_response = json.dumps({"message":ex.description}, default=str) + return serialized_response, status_code diff --git a/src/server/tests/validators/test_validation_error.py b/src/server/tests/validators/test_validation_error.py new file mode 100644 index 0000000..a103919 --- /dev/null +++ b/src/server/tests/validators/test_validation_error.py @@ -0,0 +1,19 @@ +import pytest + +def test_create_validation_error_response_is_serializable(): + from BreCal.stubs.times_full import get_valid_stub_times + from BreCal.schemas import model + from BreCal.validators.validation_error import create_validation_error_response + + content = get_valid_stub_times() + + import datetime + content["operations_end"] = (datetime.datetime.now()-datetime.timedelta(minutes=14)).isoformat() + + content["id"] = 3 + try: + loadedModel = model.TimesSchema().load(data=content, many=False, partial=True) + except Exception as ex: + my_var = ex + create_validation_error_response(ex=ex, status_code=400) # this function initially created errors, as datetime objects were not serializable. Corrected now. + return From c7371a945ab6fc3d93e6bd6ad9359a9fb98f4c14 Mon Sep 17 00:00:00 2001 From: Max Metz Date: Wed, 4 Sep 2024 12:21:22 +0200 Subject: [PATCH 12/38] adapting traffic light validation 0002-C. This no longer requires ETA verification. Adapted the description when the error occurs and renamed the function. --- .../validators/validation_rule_functions.py | 22 +++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/server/BreCal/validators/validation_rule_functions.py b/src/server/BreCal/validators/validation_rule_functions.py index ae3e3bc..b035345 100644 --- a/src/server/BreCal/validators/validation_rule_functions.py +++ b/src/server/BreCal/validators/validation_rule_functions.py @@ -27,7 +27,7 @@ error_message_dict = { # 0002 A+B+C "validation_rule_fct_shipcall_incoming_participants_disagree_on_eta":"There are deviating times between agency, mooring, port authority, pilot and tug for the estimated time of arrival (ETA) {Rule #0002A}", "validation_rule_fct_shipcall_outgoing_participants_disagree_on_etd":"There are deviating times between agency, mooring, port authority, pilot and tug for the estimated time of departure (ETD) {Rule #0002B}", - "validation_rule_fct_shipcall_shifting_participants_disagree_on_eta_or_etd":"There are deviating times between agency, mooring, port authority, pilot and tug for ETA and ETD {Rule #0002C}", + "validation_rule_fct_shipcall_shifting_participants_disagree_on_etd":"There are deviating times between agency, mooring, port authority, pilot and tug for the estimated time of departure (ETD) {Rule #0002C}", # 0003 A+B "validation_rule_fct_eta_time_not_in_operation_window":"The estimated time of arrival will be AFTER the planned start of operations. {Rule #0003A}", @@ -723,21 +723,13 @@ class ValidationRuleFunctions(ValidationRuleBaseFunctions): else: return self.get_no_violation_default_output() - def validation_rule_fct_shipcall_shifting_participants_disagree_on_eta_or_etd(self, shipcall, df_times, *args, **kwargs): + def validation_rule_fct_shipcall_shifting_participants_disagree_on_etd(self, shipcall, df_times, *args, **kwargs): """ Code: #0002-C Type: Local Rule - Description: this validation checks, whether the participants expect different ETA or ETD times + Description: this validation checks, whether the participants expect different ETD times Filter: only applies to shifting shipcalls """ - violation_state_eta = self.check_participants_agree_on_estimated_time( - shipcall = shipcall, - - query="eta_berth", - df_times=df_times, - applicable_shipcall_type=ShipcallType.SHIFTING - ) - violation_state_etd = self.check_participants_agree_on_estimated_time( shipcall = shipcall, @@ -746,16 +738,14 @@ class ValidationRuleFunctions(ValidationRuleBaseFunctions): applicable_shipcall_type=ShipcallType.SHIFTING ) - # apply 'eta_berth' check # apply 'etd_berth' - # violation: if either 'eta_berth' or 'etd_berth' is violated + # violation: if either 'etd_berth' is violated # functionally, this is the same as individually comparing all times for the participants - # times_agency.eta_berth==times_mooring.eta_berth==times_portadministration.eta_berth==times_pilot.eta_berth==times_tug.eta_berth # times_agency.etd_berth==times_mooring.etd_berth==times_portadministration.etd_berth==times_pilot.etd_berth==times_tug.etd_berth - violation_state = (violation_state_eta) or (violation_state_etd) + violation_state = (violation_state_etd) if violation_state: - validation_name = "validation_rule_fct_shipcall_shifting_participants_disagree_on_eta_or_etd" + validation_name = "validation_rule_fct_shipcall_shifting_participants_disagree_on_etd" return (StatusFlags.RED, validation_name) else: return self.get_no_violation_default_output() From facafd09bafb848f06a10fbbcfc1ae3f7d26aad9 Mon Sep 17 00:00:00 2001 From: Max Metz Date: Wed, 4 Sep 2024 12:29:06 +0200 Subject: [PATCH 13/38] adapting the .md documentation for the traffic state rules. --- misc/Ampelfunktion.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/Ampelfunktion.md b/misc/Ampelfunktion.md index 1274ba7..def1e03 100644 --- a/misc/Ampelfunktion.md +++ b/misc/Ampelfunktion.md @@ -32,7 +32,7 @@ ___ | 0002 | Zeiten für einen Eintrag weichen voneinander ab | Bedingungen:
- Header der Zeile ist zugeordnet (Agentur, Festmacher usw. - außer BSMD-Spalte)
- Zeiten ungleich (leere Einträge nicht berücksichtigen => 0001) | | | 0002 - A | Agentur + Festmacher + Hafenamt + Lotsen + Schlepper / einkommend | Schnittmenge aus:
times_agency:
- ETA Berth
____und____
times_mooring:
- ETA Berth
____und____
times_portauthority:
- ETA Berth
____und____
times_pilot:
- ETA Berth
____und____
times_tug:
- ETA Berth | rot | | 0002 - B | Agentur + Festmacher + Hafenamt + Lotsen + Schlepper / ausgehend | Schnittmenge aus:
times_agency:
- ETD Berth
____und____
times_mooring:
- ETD Berth
____und____
times_portauthority:
- ETD Berth
____und____
times_pilot:
- ETD Berth
____und____
times_tug:
- ETD Berth | rot | -| 0002 - C | Agentur + Festmacher + Hafenamt + Lotsen + Schlepper / Verholung | Schnittmenge aus:
times_agency:
- ETA Berth
- ETD Berth
____und____
times_mooring:
- ETA Berth
- ETD Berth
____und____
times_portauthority:
- ETA Berth
- ETD Berth
____und____
times_pilot:
- ETA Berth
- ETD Berth
____und____
times_tug:
- ETA Berth
- ETD Berth | rot | +| 0002 - C | Agentur + Festmacher + Hafenamt + Lotsen + Schlepper / Verholung | Schnittmenge aus:
times_agency:
- ETD Berth
____und____
times_mooring:
- ETD Berth
____und____
times_portauthority:
- ETD Berth
____und____
times_pilot:
- ETD Berth
____und____
times_tug:
- ETD Berth | rot | | 0003 | Arbeitszeit überschneidet sich mit Fahrtzeit | Bedingungen:
- Header der Zeile ist zugeordnet (Terminal)
- Zeiten passt nicht zu Ankunft / Abfahrt (leere Einträge nicht berücksichtigen => 0001) | | | 0003 - A | Terminal / einkommend | times_terminal:
- Operation Start
___vor (kleiner als)____
times_agency:
- ETA Berth | rot, aktuell __deaktiviert__! | | 0003 - B | Terminal / ausgehend + Verholung | times_terminal:
- Operation Ende
___nach (größer als)____
times_agency:
- ETD Berth | rot, aktuell __deaktiviert__! | From 1243ebf9e707dbaca18f55da112375a9b1f841bb Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Thu, 5 Sep 2024 06:49:25 +0200 Subject: [PATCH 14/38] Adjusted error formatting and bumped test version to 1.5.0.1 --- src/BreCalClient/BreCalClient.csproj | 4 ++-- src/BreCalClient/MainWindow.xaml.cs | 16 +++++++++++++++- .../PublishProfiles/ClickOnceTestProfile.pubxml | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/BreCalClient/BreCalClient.csproj b/src/BreCalClient/BreCalClient.csproj index ffda91f..3d00ee0 100644 --- a/src/BreCalClient/BreCalClient.csproj +++ b/src/BreCalClient/BreCalClient.csproj @@ -8,8 +8,8 @@ True BreCalClient.App ..\..\misc\brecal.snk - 1.5.0.0 - 1.5.0.0 + 1.5.0.1 + 1.5.0.1 Bremen calling client A Windows WPF client for the Bremen calling API. containership.ico diff --git a/src/BreCalClient/MainWindow.xaml.cs b/src/BreCalClient/MainWindow.xaml.cs index 2152c96..5b21164 100644 --- a/src/BreCalClient/MainWindow.xaml.cs +++ b/src/BreCalClient/MainWindow.xaml.cs @@ -1072,7 +1072,21 @@ namespace BreCalClient dynamic? msg = JsonConvert.DeserializeObject(m.Value); if (msg != null) { - message = msg.message; + if (msg.message != null) + { + caption = $"{caption}: {msg.message}"; + } + + if((msg.errors != null) && msg.errors.Count > 0) + { + message = ""; + foreach(string error in msg.errors) + { + message += error; + message += Environment.NewLine; + } + } + } } catch (Exception) { } diff --git a/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml b/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml index 6b9c078..8d71e33 100644 --- a/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml +++ b/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml @@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. 0 - 1.5.0.0 + 1.5.0.1 True Debug True From ab7b1ed34f1d14cf0abffac6887d11769bfd4bb0 Mon Sep 17 00:00:00 2001 From: Max Metz Date: Thu, 5 Sep 2024 12:46:04 +0200 Subject: [PATCH 15/38] every ValidationError is defined to return a dictionary. In case of validation errors without such a call, a function enforces a default with an undefined key to ensure the correct format. --- src/server/BreCal/api/ships.py | 2 +- src/server/BreCal/schemas/model.py | 24 +++--- .../BreCal/validators/input_validation.py | 38 +++++----- .../validators/input_validation_ship.py | 18 ++--- .../validators/input_validation_shipcall.py | 74 +++++++++---------- .../validators/input_validation_times.py | 36 ++++----- .../validators/input_validation_utils.py | 2 +- src/server/BreCal/validators/time_logic.py | 4 +- .../BreCal/validators/validation_error.py | 16 ++++ 9 files changed, 115 insertions(+), 99 deletions(-) diff --git a/src/server/BreCal/api/ships.py b/src/server/BreCal/api/ships.py index 5935402..9f0c43e 100644 --- a/src/server/BreCal/api/ships.py +++ b/src/server/BreCal/api/ships.py @@ -38,7 +38,7 @@ def PostShip(): # as ParticipantType is an IntFlag, a user belonging to multiple groups is properly evaluated. is_bsmd = check_if_user_is_bsmd_type(user_data) if not is_bsmd: - raise ValidationError(f"current user does not belong to BSMD. Cannot post shipcalls. Found user data: {user_data}") + raise ValidationError({"participant_type":f"current user does not belong to BSMD. Cannot post shipcalls. Found user data: {user_data}"}) content = request.get_json(force=True) loadedModel = model.ShipSchema().load(data=content, many=False, partial=True) diff --git a/src/server/BreCal/schemas/model.py b/src/server/BreCal/schemas/model.py index 14bceda..c3eed38 100644 --- a/src/server/BreCal/schemas/model.py +++ b/src/server/BreCal/schemas/model.py @@ -177,7 +177,7 @@ class Participant(Schema): valid_type = 0 <= value < max_int if not valid_type: - raise ValidationError(f"the provided integer is not supported for default behaviour of the ParticipantType IntFlag. Your choice: {value}. Supported values are: 0 <= value {max_int}") + raise ValidationError({"type":f"the provided integer is not supported for default behaviour of the ParticipantType IntFlag. Your choice: {value}. Supported values are: 0 <= value {max_int}"}) @validates("flags") @@ -188,7 +188,7 @@ class Participant(Schema): valid_type = 0 <= value < max_int if not valid_type: - raise ValidationError(f"the provided integer is not supported for default behaviour of the ParticipantFlag IntFlag. Your choice: {value}. Supported values are: 0 <= value {max_int}") + raise ValidationError({"flags":f"the provided integer is not supported for default behaviour of the ParticipantFlag IntFlag. Your choice: {value}. Supported values are: 0 <= value {max_int}"}) class ParticipantList(Participant): @@ -253,7 +253,7 @@ class ShipcallSchema(Schema): valid_shipcall_type = int(value) in [item.value for item in ShipcallType] if not valid_shipcall_type: - raise ValidationError(f"the provided type is not a valid shipcall type.") + raise ValidationError({"type":f"the provided type is not a valid shipcall type."}) @dataclass @@ -393,7 +393,7 @@ class TimesSchema(Schema): value = ParticipantType(value) if ParticipantType.BSMD in value: - raise ValidationError(f"the participant_type must not be .BSMD") + raise ValidationError({"participant_type":f"the participant_type must not be .BSMD"}) @validates("eta_berth") def validate_eta_berth(self, value): @@ -471,12 +471,12 @@ class UserSchema(Schema): def validate_user_phone(self, value): valid_characters = list(map(str,range(0,10)))+["+", " "] if not all([v in valid_characters for v in value]): - raise ValidationError(f"one of the phone number values is not valid.") + raise ValidationError({"user_phone":f"one of the phone number values is not valid."}) @validates("user_email") def validate_user_email(self, value): if not "@" in value: - raise ValidationError(f"invalid email address") + raise ValidationError({"user_email":f"invalid email address"}) @dataclass @@ -565,12 +565,12 @@ class ShipSchema(Schema): def validate_name(self, value): character_length = len(str(value)) if character_length<1: - raise ValidationError(f"'name' argument should have at least one character") + raise ValidationError({"name":f"'name' argument should have at least one character"}) elif character_length>=64: - raise ValidationError(f"'name' argument should have at max. 63 characters") + raise ValidationError({"name":f"'name' argument should have at max. 63 characters"}) if check_if_string_has_special_characters(value): - raise ValidationError(f"'name' argument should not have special characters.") + raise ValidationError({"name":f"'name' argument should not have special characters."}) return @validates("imo") @@ -578,7 +578,7 @@ class ShipSchema(Schema): value = str(value).zfill(7) # 1 becomes '0000001' (7 characters). 12345678 becomes '12345678' (8 characters) imo_length = len(value) if imo_length != 7: - raise ValidationError(f"'imo' should be a 7-digit number") + raise ValidationError({"imo":f"'imo' should be a 7-digit number"}) return @validates("callsign") @@ -586,10 +586,10 @@ class ShipSchema(Schema): if value is not None: callsign_length = len(str(value)) if callsign_length>8: - raise ValidationError(f"'callsign' argument should not have more than 8 characters") + raise ValidationError({"callsign":f"'callsign' argument should not have more than 8 characters"}) if check_if_string_has_special_characters(value): - raise ValidationError(f"'callsign' argument should not have special characters.") + raise ValidationError({"callsign":f"'callsign' argument should not have special characters."}) return diff --git a/src/server/BreCal/validators/input_validation.py b/src/server/BreCal/validators/input_validation.py index 1fb9649..cc97ccb 100644 --- a/src/server/BreCal/validators/input_validation.py +++ b/src/server/BreCal/validators/input_validation.py @@ -35,24 +35,24 @@ def validate_posted_shipcall_data(user_data:dict, loadedModel:dict, content:dict # as ParticipantType is an IntFlag, a user belonging to multiple groups is properly evaluated. is_bsmd = check_if_user_is_bsmd_type(user_data) if not is_bsmd: - raise ValidationError(f"current user does not belong to BSMD. Cannot post shipcalls. Found user data: {user_data}") + raise ValidationError({"user_participant_type":f"current user does not belong to BSMD. Cannot post shipcalls. Found user data: {user_data}"}) ##### Section 2: check loadedModel ##### valid_ship_id = check_if_ship_id_is_valid(ship_id=loadedModel.get("ship_id", None)) if not valid_ship_id: - raise ValidationError(f"provided an invalid ship id, which is not found in the database: {loadedModel.get('ship_id', None)}") + raise ValidationError({"ship_id":f"provided an invalid ship id, which is not found in the database: {loadedModel.get('ship_id', None)}"}) valid_arrival_berth_id = check_if_berth_id_is_valid(berth_id=loadedModel.get("arrival_berth_id", None)) if not valid_arrival_berth_id: - raise ValidationError(f"provided an invalid arrival berth id, which is not found in the database: {loadedModel.get('arrival_berth_id', None)}") + raise ValidationError({"arrival_berth_id":f"provided an invalid arrival berth id, which is not found in the database: {loadedModel.get('arrival_berth_id', None)}"}) valid_departure_berth_id = check_if_berth_id_is_valid(berth_id=loadedModel.get("departure_berth_id", None)) if not valid_departure_berth_id: - raise ValidationError(f"provided an invalid departure berth id, which is not found in the database: {loadedModel.get('departure_berth_id', None)}") + raise ValidationError({"departure_berth_id":f"provided an invalid departure berth id, which is not found in the database: {loadedModel.get('departure_berth_id', None)}"}) valid_participant_ids = check_if_participant_ids_are_valid(participants=loadedModel.get("participants",[])) if not valid_participant_ids: - raise ValidationError(f"one of the provided participant ids is invalid. Could not find one of these in the database: {loadedModel.get('participants', None)}") + raise ValidationError({"participants":f"one of the provided participant ids is invalid. Could not find one of these in the database: {loadedModel.get('participants', None)}"}) ##### Section 3: check content ##### @@ -62,11 +62,11 @@ def validate_posted_shipcall_data(user_data:dict, loadedModel:dict, content:dict for forbidden_key in ["canceled", "evaluation", "evaluation_message"]: value = content.get(forbidden_key, None) if value is not None: - raise ValidationError(f"'{forbidden_key}' may not be set on POST. Found: {value}") + raise ValidationError({"forbidden_key":f"'{forbidden_key}' may not be set on POST. Found: {value}"}) voyage_str_is_invalid = check_if_string_has_special_characters(text=content.get("voyage","")) if voyage_str_is_invalid: - raise ValidationError(f"there are invalid characters in the 'voyage'-string. Please use only digits and ASCII letters. Allowed: {ascii_letters+digits}. Found: {content.get('voyage')}") + raise ValidationError({"voyage":f"there are invalid characters in the 'voyage'-string. Please use only digits and ASCII letters. Allowed: {ascii_letters+digits}. Found: {content.get('voyage')}"}) ##### Section 4: check loadedModel & content ##### @@ -77,43 +77,43 @@ def validate_posted_shipcall_data(user_data:dict, loadedModel:dict, content:dict time_now = datetime.datetime.now() type_ = loadedModel.get("type", int(ShipcallType.undefined)) if int(type_)==int(ShipcallType.undefined): - raise ValidationError(f"providing 'type' is mandatory. Missing key!") + raise ValidationError({"type":f"providing 'type' is mandatory. Missing key!"}) elif int(type_)==int(ShipcallType.arrival): eta = loadedModel.get("eta") if (content.get("eta", None) is None): - raise ValidationError(f"providing 'eta' is mandatory. Missing key!") + raise ValidationError({"eta":f"providing 'eta' is mandatory. Missing key!"}) if content.get("arrival_berth_id", None) is None: - raise ValidationError(f"providing 'arrival_berth_id' is mandatory. Missing key!") + raise ValidationError({"arrival_berth_id":f"providing 'arrival_berth_id' is mandatory. Missing key!"}) if not eta >= time_now: - raise ValidationError(f"'eta' must be in the future. Incorrect datetime provided.") + raise ValidationError({"eta":f"'eta' must be in the future. Incorrect datetime provided."}) elif int(type_)==int(ShipcallType.departure): etd = loadedModel.get("etd") if (content.get("etd", None) is None): - raise ValidationError(f"providing 'etd' is mandatory. Missing key!") + raise ValidationError({"etd":f"providing 'etd' is mandatory. Missing key!"}) if content.get("departure_berth_id", None) is None: - raise ValidationError(f"providing 'departure_berth_id' is mandatory. Missing key!") + raise ValidationError({"departure_berth_id":f"providing 'departure_berth_id' is mandatory. Missing key!"}) if not etd >= time_now: - raise ValidationError(f"'etd' must be in the future. Incorrect datetime provided.") + raise ValidationError({"etd":f"'etd' must be in the future. Incorrect datetime provided."}) elif int(type_)==int(ShipcallType.shifting): eta = loadedModel.get("eta") etd = loadedModel.get("etd") # * arrival_berth_id / departure_berth_id (depending on type, see above) if (content.get("eta", None) is None) or (content.get("etd", None) is None): - raise ValidationError(f"providing 'eta' and 'etd' is mandatory. Missing one of those keys!") + raise ValidationError({"eta_or_etd":f"providing 'eta' and 'etd' is mandatory. Missing one of those keys!"}) if (content.get("arrival_berth_id", None) is None) or (content.get("departure_berth_id", None) is None): - raise ValidationError(f"providing 'arrival_berth_id' & 'departure_berth_id' is mandatory. Missing key!") + raise ValidationError({"arrival_berth_id_or_departure_berth_id":f"providing 'arrival_berth_id' & 'departure_berth_id' is mandatory. Missing key!"}) if (not eta >= time_now) or (not etd >= time_now) or (not eta >= etd): - raise ValidationError(f"'eta' and 'etd' must be in the future. Incorrect datetime provided.") + raise ValidationError({"eta_or_etd":f"'eta' and 'etd' must be in the future. Incorrect datetime provided."}) tidal_window_from = loadedModel.get("tidal_window_from", None) tidal_window_to = loadedModel.get("tidal_window_to", None) if tidal_window_to is not None: if not tidal_window_to >= time_now: - raise ValidationError(f"'tidal_window_to' must be in the future. Incorrect datetime provided.") + raise ValidationError({"tidal_window_to":f"'tidal_window_to' must be in the future. Incorrect datetime provided."}) if tidal_window_from is not None: if not tidal_window_from >= time_now: - raise ValidationError(f"'tidal_window_from' must be in the future. Incorrect datetime provided.") + raise ValidationError({"tidal_window_from":f"'tidal_window_from' must be in the future. Incorrect datetime provided."}) # #TODO: assert tidal_window_from > tidal_window_to diff --git a/src/server/BreCal/validators/input_validation_ship.py b/src/server/BreCal/validators/input_validation_ship.py index 3a47b2c..4b9ad23 100644 --- a/src/server/BreCal/validators/input_validation_ship.py +++ b/src/server/BreCal/validators/input_validation_ship.py @@ -75,16 +75,16 @@ class InputValidationShip(): if bollard_pull is not None: if not is_tug: - raise ValidationError(f"'bollard_pull' is only allowed, when a ship is a tug ('is_tug').") + raise ValidationError({"bollard_pull":f"'bollard_pull' is only allowed, when a ship is a tug ('is_tug')."}) if (not (0 < bollard_pull < 500)) & (is_tug): - raise ValidationError(f"when a ship is a tug, the bollard pull must be 0 < value < 500. ") + raise ValidationError({"bollard_pull":f"when a ship is a tug, the bollard pull must be 0 < value < 500. "}) @staticmethod def check_user_is_bsmd_type(user_data:dict): is_bsmd = check_if_user_is_bsmd_type(user_data) if not is_bsmd: - raise ValidationError(f"current user does not belong to BSMD. Cannot post, put or delete ships. Found user data: {user_data}") + raise ValidationError({"participant_type":f"current user does not belong to BSMD. Cannot post, put or delete ships. Found user data: {user_data}"}) @staticmethod def check_ship_imo_already_exists(loadedModel:dict): @@ -98,7 +98,7 @@ class InputValidationShip(): # check, if the imo in the POST-request already exists in the list imo_already_exists = loadedModel.get("imo") in ship_imos if imo_already_exists: - raise ValidationError(f"the provided ship IMO {loadedModel.get('imo')} already exists. A ship may only be added, if there is no other ship with the same IMO number.") + raise ValidationError({"imo":f"the provided ship IMO {loadedModel.get('imo')} already exists. A ship may only be added, if there is no other ship with the same IMO number."}) return @staticmethod @@ -112,14 +112,14 @@ class InputValidationShip(): ship = execute_sql_query_standalone(SQLQuery.get_ship_by_id(), param={"id":content.get("id")}, command_type="single", model=Ship) if put_data_ship_imo != ship.imo: - raise ValidationError(f"The IMO number field may not be changed since it serves the purpose of a primary (matching) key.") + raise ValidationError({"imo":f"The IMO number field may not be changed since it serves the purpose of a primary (matching) key."}) return @staticmethod def content_contains_ship_id(content:dict): put_data_ship_id = content.get('id',None) if put_data_ship_id is None: - raise ValidationError(f"The id field is required.") + raise ValidationError({"id":f"The id field is required."}) return @staticmethod @@ -130,19 +130,19 @@ class InputValidationShip(): database entry may not have a deletion state already. """ if ship_id is None: - raise ValidationError(f"The ship_id must be provided.") + raise ValidationError({"id":f"The ship id must be provided."}) response, status_code, header = GetShips(token=None) ships = json.loads(response) existing_database_entries = [ship for ship in ships if ship.get("id")==ship_id] if len(existing_database_entries)==0: - raise ValidationError(f"Could not find a ship with the specified ID. Selected: {ship_id}") + raise ValidationError({"id":f"Could not find a ship with the specified ID. Selected: {ship_id}"}) existing_database_entry = existing_database_entries[0] deletion_state = existing_database_entry.get("deleted",None) if deletion_state: - raise ValidationError(f"The selected ship entry is already deleted.") + raise ValidationError({"deleted":f"The selected ship entry is already deleted."}) return diff --git a/src/server/BreCal/validators/input_validation_shipcall.py b/src/server/BreCal/validators/input_validation_shipcall.py index 59b8b35..aae7e11 100644 --- a/src/server/BreCal/validators/input_validation_shipcall.py +++ b/src/server/BreCal/validators/input_validation_shipcall.py @@ -113,12 +113,12 @@ class InputValidationShipcall(): # voyage shall not contain special characters voyage_str_is_invalid = check_if_string_has_special_characters(text=content.get("voyage","")) if voyage_str_is_invalid: - raise ValidationError(f"there are invalid characters in the 'voyage'-string. Please use only digits and ASCII letters. Allowed: {ascii_letters+digits}. Found: {content.get('voyage')}") + raise ValidationError({"voyage":f"there are invalid characters in the 'voyage'-string. Please use only digits and ASCII letters. Allowed: {ascii_letters+digits}. Found: {content.get('voyage')}"}) # the 'flags' integer must be valid flags_value = content.get("flags", 0) if check_if_int_is_valid_flag(flags_value, enum_object=ParticipantFlag): - raise ValidationError(f"incorrect value provided for 'flags'. Must be a valid combination of the flags.") + raise ValidationError({"flags":f"incorrect value provided for 'flags'. Must be a valid combination of the flags."}) # time values must use future-dates InputValidationShipcall.check_times_are_in_future(loadedModel, content) @@ -212,7 +212,7 @@ class InputValidationShipcall(): is_bsmd_or_agency = (is_bsmd) or (is_agency) if not is_bsmd_or_agency: - raise ValidationError(f"current user must be either of participant type BSMD or AGENCY. Cannot post or put shipcalls. Found user data: {user_data} and participant_type: {participant_type}") + raise ValidationError({"participant_type":f"current user must be either of participant type BSMD or AGENCY. Cannot post or put shipcalls. Found user data: {user_data} and participant_type: {participant_type}"}) return @staticmethod @@ -232,23 +232,23 @@ class InputValidationShipcall(): valid_ship_id = check_if_ship_id_is_valid(ship_id=ship_id) if not valid_ship_id: - raise ValidationError(f"provided an invalid ship id, which is not found in the database: {ship_id}") + raise ValidationError({"ship_id":f"provided an invalid ship id, which is not found in the database: {ship_id}"}) valid_arrival_berth_id = check_if_berth_id_is_valid(berth_id=arrival_berth_id) if not valid_arrival_berth_id: - raise ValidationError(f"provided an invalid arrival berth id, which is not found in the database: {arrival_berth_id}") + raise ValidationError({"arrival_berth_id":f"provided an invalid arrival berth id, which is not found in the database: {arrival_berth_id}"}) valid_departure_berth_id = check_if_berth_id_is_valid(berth_id=departure_berth_id) if not valid_departure_berth_id: - raise ValidationError(f"provided an invalid departure berth id, which is not found in the database: {departure_berth_id}") + raise ValidationError({"departure_berth_id":f"provided an invalid departure berth id, which is not found in the database: {departure_berth_id}"}) valid_participant_ids = check_if_participant_ids_are_valid(participants=participants) if not valid_participant_ids: - raise ValidationError(f"one of the provided participant ids is invalid. Could not find one of these in the database: {participants}") + raise ValidationError({"participants":f"one of the provided participant ids is invalid. Could not find one of these in the database: {participants}"}) valid_participant_types = check_if_participant_ids_and_types_are_valid(participants=participants) if not valid_participant_types: # #TODO: according to Daniel, there may eventually be multi-assignment of participants for the same role - raise ValidationError(f"every participant id and type should be listed only once. Found multiple entries for one of the participants.") + raise ValidationError({"participants":f"every participant id and type should be listed only once. Found multiple entries for one of the participants."}) @staticmethod def check_shipcall_type_is_unchanged(loadedModel:dict): @@ -257,7 +257,7 @@ class InputValidationShipcall(): shipcall = execute_sql_query_standalone(query=query, model=Shipcall, param={"id":loadedModel.get("id")}, command_type="single") if int(loadedModel["type"]) != int(shipcall.type): - raise ValidationError(f"The shipcall type may only be set in the initial POST-request. Afterwards, changing the shipcall type is not allowed.") # @pytest.raises + raise ValidationError({"type":f"The shipcall type may only be set in the initial POST-request. Afterwards, changing the shipcall type is not allowed."}) # @pytest.raises return @staticmethod @@ -271,7 +271,7 @@ class InputValidationShipcall(): for forbidden_key in forbidden_keys: value = content.get(forbidden_key, None) if value is not None: - raise ValidationError(f"'{forbidden_key}' may not be set on POST. Found: {value}") + raise ValidationError({"forbidden_key":f"'{forbidden_key}' may not be set on POST. Found: {value}"}) return @staticmethod @@ -287,36 +287,36 @@ class InputValidationShipcall(): departure_berth_id = content.get("departure_berth_id", None) if ship_id is None: - raise ValidationError(f"providing 'ship_id' is mandatory. Missing key!") + raise ValidationError({"ship_id":f"providing 'ship_id' is mandatory. Missing key!"}) if int(type_)==int(ShipcallType.undefined): - raise ValidationError(f"providing 'type' is mandatory. Missing key!") + raise ValidationError({"type":f"providing 'type' is mandatory. Missing key!"}) # arrival: arrival_berth_id & eta must exist elif int(type_)==int(ShipcallType.arrival): if eta is None: - raise ValidationError(f"providing 'eta' is mandatory. Missing key!") + raise ValidationError({"eta":f"providing 'eta' is mandatory. Missing key!"}) if arrival_berth_id is None: - raise ValidationError(f"providing 'arrival_berth_id' is mandatory. Missing key!") + raise ValidationError({"arrival_berth_id":f"providing 'arrival_berth_id' is mandatory. Missing key!"}) # departure: departive_berth_id and etd must exist elif int(type_)==int(ShipcallType.departure): if etd is None: - raise ValidationError(f"providing 'etd' is mandatory. Missing key!") + raise ValidationError({"etd":f"providing 'etd' is mandatory. Missing key!"}) if departure_berth_id is None: - raise ValidationError(f"providing 'departure_berth_id' is mandatory. Missing key!") + raise ValidationError({"departure_berth_id":f"providing 'departure_berth_id' is mandatory. Missing key!"}) # shifting: arrival_berth_id, departure_berth_id, eta and etd must exist elif int(type_)==int(ShipcallType.shifting): if (eta is None) or (etd is None): - raise ValidationError(f"providing 'eta' and 'etd' is mandatory. Missing one of those keys!") + raise ValidationError({"eta_or_etd":f"providing 'eta' and 'etd' is mandatory. Missing one of those keys!"}) if (arrival_berth_id is None) or (departure_berth_id is None): - raise ValidationError(f"providing 'arrival_berth_id' & 'departure_berth_id' is mandatory. Missing key!") + raise ValidationError({"arrival_berth_id_or_departure_berth_id":f"providing 'arrival_berth_id' & 'departure_berth_id' is mandatory. Missing key!"}) else: - raise ValidationError(f"incorrect 'type' provided!") + raise ValidationError({"type":f"incorrect 'type' provided!"}) return @staticmethod @@ -363,32 +363,32 @@ class InputValidationShipcall(): return if type_ is None: - raise ValidationError(f"when providing 'eta' or 'etd', one must provide the type of the shipcall, so the datetimes can be verified.") + raise ValidationError({"type":f"when providing 'eta' or 'etd', one must provide the type of the shipcall, so the datetimes can be verified."}) if not isinstance(type_, (int, ShipcallType)): type_ = ShipcallType[type_] # #TODO: properly handle what happens, when eta or etd (or both) are None if int(type_)==int(ShipcallType.undefined): - raise ValidationError(f"providing 'type' is mandatory. Missing key!") + raise ValidationError({"type":f"providing 'type' is mandatory. Missing key!"}) elif int(type_)==int(ShipcallType.arrival): if eta is None: # null values -> no violation return if not eta > time_now: - raise ValidationError(f"'eta' must be in the future. Incorrect datetime provided. Current Time: {time_now}. ETA: {eta}.") + raise ValidationError({"eta":f"'eta' must be in the future. Incorrect datetime provided. Current Time: {time_now}. ETA: {eta}."}) if etd is not None: - raise ValidationError(f"'etd' should not be set when the shipcall type is 'arrival'.") + raise ValidationError({"etd":f"'etd' should not be set when the shipcall type is 'arrival'."}) elif int(type_)==int(ShipcallType.departure): if etd is None: # null values -> no violation return if not etd > time_now: - raise ValidationError(f"'etd' must be in the future. Incorrect datetime provided. Current Time: {time_now}. ETD: {etd}.") + raise ValidationError({"etd":f"'etd' must be in the future. Incorrect datetime provided. Current Time: {time_now}. ETD: {etd}."}) if eta is not None: - raise ValidationError(f"'eta' should not be set when the shipcall type is 'departure'.") + raise ValidationError({"eta":f"'eta' should not be set when the shipcall type is 'departure'."}) elif int(type_)==int(ShipcallType.shifting): if (eta is None) and (etd is None): # null values -> no violation @@ -397,30 +397,30 @@ class InputValidationShipcall(): if not ((eta is not None) and (etd is not None)): # for PUT-requests, a user could try modifying only 'eta' or only 'etd'. To simplify the # rules, a user is only allowed to provide *both* values. - raise ValidationError(f"For shifting shipcalls one should always provide, both, eta and etd.") + raise ValidationError({"eta_or_etd":f"For shifting shipcalls one should always provide, both, eta and etd."}) if (not eta > time_now) or (not etd > time_now): - raise ValidationError(f"'eta' and 'etd' must be in the future. Incorrect datetime provided. Current Time: {time_now}. ETA: {eta}. ETD: {etd}") + raise ValidationError({"eta_or_etd":f"'eta' and 'etd' must be in the future. Incorrect datetime provided. Current Time: {time_now}. ETA: {eta}. ETD: {etd}"}) if (not etd < eta): - raise ValidationError(f"The estimated time of departure ('etd') must take place *before the estimated time of arrival ('eta'). The ship cannot arrive, before it has departed. Found: ETD: {etd}, ETA: {eta}") + raise ValidationError({"eta_or_etd":f"The estimated time of departure ('etd') must take place *before the estimated time of arrival ('eta'). The ship cannot arrive, before it has departed. Found: ETD: {etd}, ETA: {eta}"}) if (eta is not None and etd is None) or (eta is None and etd is not None): - raise ValidationError(f"'eta' and 'etd' must both be provided when the shipcall type is 'shifting'.") + raise ValidationError({"eta_or_etd":f"'eta' and 'etd' must both be provided when the shipcall type is 'shifting'."}) return @staticmethod def check_tidal_window_in_future(type_, time_now, tidal_window_from, tidal_window_to): if tidal_window_to is not None: if not tidal_window_to >= time_now: - raise ValidationError(f"'tidal_window_to' must be in the future. Incorrect datetime provided.") + raise ValidationError({"tidal_window_to":f"'tidal_window_to' must be in the future. Incorrect datetime provided."}) if tidal_window_from is not None: if not tidal_window_from >= time_now: - raise ValidationError(f"'tidal_window_from' must be in the future. Incorrect datetime provided.") + raise ValidationError({"tidal_window_from":f"'tidal_window_from' must be in the future. Incorrect datetime provided."}) if (tidal_window_to is not None) and (tidal_window_from is not None): if tidal_window_to < tidal_window_from: - raise ValidationError(f"'tidal_window_to' must take place after 'tidal_window_from'. Incorrect datetime provided. Found 'tidal_window_to': {tidal_window_to}, 'tidal_window_from': {tidal_window_to}.") + raise ValidationError({"tidal_window_to_or_tidal_window_from":f"'tidal_window_to' must take place after 'tidal_window_from'. Incorrect datetime provided. Found 'tidal_window_to': {tidal_window_to}, 'tidal_window_from': {tidal_window_to}."}) return @staticmethod @@ -432,7 +432,7 @@ class InputValidationShipcall(): is_agency_participant = [ParticipantType.AGENCY in ParticipantType(participant.get("type")) for participant in participants] if not any(is_agency_participant): - raise ValidationError(f"One of the assigned participants *must* be of type 'ParticipantType.AGENCY'. Found list of participants: {participants}") + raise ValidationError({"participants":f"One of the assigned participants *must* be of type 'ParticipantType.AGENCY'. Found list of participants: {participants}"}) return @staticmethod @@ -448,14 +448,14 @@ class InputValidationShipcall(): # if the *existing* shipcall in the database is canceled, it may not be changed if shipcall.get("canceled", False): - raise ValidationError(f"The shipcall with id 'shipcall_id' is canceled. A canceled shipcall may not be changed.") + raise ValidationError({"canceled":f"The shipcall with id 'shipcall_id' is canceled. A canceled shipcall may not be changed."}) return @staticmethod def check_required_fields_of_put_request(content:dict): shipcall_id = content.get("id", None) if shipcall_id is None: - raise ValidationError(f"A PUT request requires an 'id' to refer to.") + raise ValidationError({"id":f"A PUT request requires an 'id' to refer to."}) @staticmethod def check_shipcall_id_exists(loadedModel): @@ -464,7 +464,7 @@ class InputValidationShipcall(): query = 'SELECT * FROM shipcall where (id = ?shipcall_id?)' shipcalls = execute_sql_query_standalone(query=query, model=Shipcall, param={"shipcall_id" : shipcall_id}) if len(shipcalls)==0: - raise ValidationError(f"unknown shipcall_id. There are no shipcalls with the ID {shipcall_id}") + raise ValidationError({"id":f"unknown shipcall_id. There are no shipcalls with the ID {shipcall_id}"}) return @staticmethod @@ -497,7 +497,7 @@ class InputValidationShipcall(): an_agency_is_assigned = len(assigned_agency)==1 if len(assigned_agency)>1: - raise ValidationError(f"Internal error? Found more than one assigned agency for the shipcall with ID {shipcall_id}. Found: {assigned_agency}") + raise ValidationError({"internal_error":f"Internal error? Found more than one assigned agency for the shipcall with ID {shipcall_id}. Found: {assigned_agency}"}) if an_agency_is_assigned: # Agency assigned? User must belong to the assigned agency or be a BSMD user, in case the flag is set diff --git a/src/server/BreCal/validators/input_validation_times.py b/src/server/BreCal/validators/input_validation_times.py index 688c651..7e402fa 100644 --- a/src/server/BreCal/validators/input_validation_times.py +++ b/src/server/BreCal/validators/input_validation_times.py @@ -137,7 +137,7 @@ class InputValidationTimes(): pdata = execute_sql_query_standalone(query=query, param={"id":times_id}, pooledConnection=None) if len(pdata)==0: - raise ValidationError(f"The selected time entry is already deleted. ID: {times_id}") + raise ValidationError({"deleted":f"The selected time entry is already deleted. ID: {times_id}"}) return @staticmethod @@ -145,7 +145,7 @@ class InputValidationTimes(): """a new dataset may only be created by a user who is *not* belonging to participant group BSMD""" is_bsmd = check_if_user_is_bsmd_type(user_data) if is_bsmd: - raise ValidationError(f"current user belongs to BSMD. Cannot post 'times' datasets. Found user data: {user_data}") + raise ValidationError({"participant_type":f"current user belongs to BSMD. Cannot post 'times' datasets. Found user data: {user_data}"}) return @staticmethod @@ -166,18 +166,18 @@ class InputValidationTimes(): loadedModel["participant_type"] = ParticipantType(loadedModel["participant_type"]) if ParticipantType.BSMD in loadedModel["participant_type"]: - raise ValidationError(f"current user belongs to BSMD. Cannot post times datasets. Found user data: {user_data}") + raise ValidationError({"participant_type":f"current user belongs to BSMD. Cannot post times datasets. Found user data: {user_data}"}) if (loadedModel["etd_interval_end"] is not None) and (loadedModel["etd_berth"] is not None): time_end_after_time_start = loadedModel["etd_interval_end"] >= loadedModel["etd_berth"] if not time_end_after_time_start: - raise ValidationError(f"The provided time interval for the estimated departure time is invalid. The interval end takes place before the interval start. Found interval data: {loadedModel['etd_berth']} to {loadedModel['etd_interval_end']}") + raise ValidationError({"etd":f"The provided time interval for the estimated departure time is invalid. The interval end takes place before the interval start. Found interval data: {loadedModel['etd_berth']} to {loadedModel['etd_interval_end']}"}) if (loadedModel["eta_interval_end"] is not None) and (loadedModel["eta_berth"] is not None): time_end_after_time_start = loadedModel["eta_interval_end"] >= loadedModel["eta_berth"] if not time_end_after_time_start: - raise ValidationError(f"The provided time interval for the estimated arrival time is invalid. The interval begin takes place after the interval end. Found interval data: {loadedModel['eta_berth']} to {loadedModel['eta_interval_end']}") + raise ValidationError({"eta":f"The provided time interval for the estimated arrival time is invalid. The interval begin takes place after the interval end. Found interval data: {loadedModel['eta_berth']} to {loadedModel['eta_interval_end']}"}) return @staticmethod @@ -189,19 +189,19 @@ class InputValidationTimes(): Note: whenever an ID is 'None', there is no exception, because a different method is supposed to capture non-existant mandatory fields. """ # extract the IDs - berth_id, participant_id, shipcall_id = content.get("berth_id"), content.get("participant_id"), content.get("shipcall_id") + berth_id, shipcall_id, participant_id = content.get("berth_id"), content.get("shipcall_id"), content.get("participant_id") valid_berth_id_reference = check_if_berth_id_is_valid(berth_id) if not valid_berth_id_reference: - raise ValidationError(f"The referenced berth_id '{berth_id}' does not exist in the database.") + raise ValidationError({"berth_id":f"The referenced berth_id '{berth_id}' does not exist in the database."}) valid_shipcall_id_reference = check_if_shipcall_id_is_valid(shipcall_id) if not valid_shipcall_id_reference: - raise ValidationError(f"The referenced shipcall_id '{shipcall_id}' does not exist in the database.") + raise ValidationError({"shipcall_id":f"The referenced shipcall_id '{shipcall_id}' does not exist in the database."}) valid_participant_id_reference = check_if_participant_id_is_valid_standalone(participant_id, participant_type=None) if not valid_participant_id_reference: - raise ValidationError(f"The referenced participant_id '{participant_id}' does not exist in the database.") + raise ValidationError({"participant_id":f"The referenced participant_id '{participant_id}' does not exist in the database."}) return @@ -223,7 +223,7 @@ class InputValidationTimes(): shipcall_type = ShipcallType[shipcalls.get(shipcall_id,{}).get("type",ShipcallType.undefined.name)] if (participant_type is None) or (int(shipcall_type) == int(ShipcallType.undefined)): - raise ValidationError(f"At least one of the required fields is missing. Missing: 'participant_type' or 'shipcall_type'") + raise ValidationError({"required_fields":f"At least one of the required fields is missing. Missing: 'participant_type' or 'shipcall_type'"}) # build a list of required fields based on shipcall and participant type, as well as type-independent fields @@ -240,14 +240,14 @@ class InputValidationTimes(): if any(missing_required_fields): # create a tuple of (field_key, bool) to describe to a user, which one of the fields may be missing verbosity_tuple = [(field, missing) for field, missing in zip(required_fields, missing_required_fields) if missing] - raise ValidationError(f"At least one of the required fields is missing. Missing: {verbosity_tuple}") + raise ValidationError({"required_fields":f"At least one of the required fields is missing. Missing: {verbosity_tuple}"}) return @staticmethod def check_times_required_fields_put_data(content:dict): """in a PUT request, only the 'id' is a required field. All other fields are simply ignored, when they are not provided.""" if content.get("id") is None: - raise ValidationError(f"A PUT-request requires an 'id' reference, which was not found.") + raise ValidationError({"id":f"A PUT-request requires an 'id' reference, which was not found."}) return @staticmethod @@ -337,7 +337,7 @@ class InputValidationTimes(): ] if not len(matching_spm)>0: - raise ValidationError(f'The participant group with id {user_participant_id} is not assigned to the shipcall. Found ShipcallParticipantMap: {spm_shipcall_data}') # part of a pytest.raises + raise ValidationError({"participant_id":f'The participant group with id {user_participant_id} is not assigned to the shipcall. Found ShipcallParticipantMap: {spm_shipcall_data}'}) # part of a pytest.raises return @staticmethod @@ -356,7 +356,7 @@ class InputValidationTimes(): # check, if there is already a dataset for the participant type participant_type_exists_already = any([ParticipantType(time_.get("participant_type",0)) in participant_type for time_ in times]) if participant_type_exists_already: - raise ValidationError(f"A dataset for the participant type is already present. Participant Type: {participant_type}. Times Datasets: {times}") + raise ValidationError({"participant_type":f"A dataset for the participant type is already present. Participant Type: {participant_type}. Times Datasets: {times}"}) return @staticmethod @@ -399,7 +399,7 @@ class InputValidationTimes(): # extracts the participant_id from the first matching entry, if applicable if not len(pdata)>0: # this case is usually covered by the InputValidationTimes.check_if_entry_is_already_deleted method already - raise ValidationError(f"Unknown times_id. Could not find a matching entry for ID: {times_id}") + raise ValidationError({"times_id":f"Unknown times_id. Could not find a matching entry for ID: {times_id}"}) else: participant_type = pdata[0].get("participant_type") shipcall_id = pdata[0].get("shipcall_id") @@ -415,14 +415,14 @@ class InputValidationTimes(): if special_case__bsmd_may_edit_agency_dataset: return else: - raise ValidationError(f"The dataset may only be changed by a user belonging to the same participant group as the times dataset is referring to. User participant_id: {user_participant_id}; Dataset participant_id: {participant_id_of_times_dataset}") + raise ValidationError({"user_participant_type":f"The dataset may only be changed by a user belonging to the same participant group as the times dataset is referring to. User participant_id: {user_participant_id}; Dataset participant_id: {participant_id_of_times_dataset}"}) return @staticmethod def get_participant_id_from_shipcall_participant_map(shipcall_id:int, participant_type:int, spm_shipcall_data=None)->int: """use shipcall_id and participant_type to identify the matching participant_id""" if shipcall_id is None: - raise ValidationError(f"Could not find a referenced shipcall_id within the request.") + raise ValidationError({"shipcall_id":f"Could not find a referenced shipcall_id within the request."}) if spm_shipcall_data is None: spm_shipcall_data = execute_sql_query_standalone( @@ -432,7 +432,7 @@ class InputValidationTimes(): # raise an error when there are no matches if len(spm_shipcall_data)==0: - raise ValidationError(f"Could not find a matching time dataset for the provided participant_type: {participant_type} at shipcall with id {shipcall_id}.") + raise ValidationError({"participant_type":f"Could not find a matching time dataset for the provided participant_type: {participant_type} at shipcall with id {shipcall_id}."}) participant_id_of_times_dataset = spm_shipcall_data[0].get("participant_id") return participant_id_of_times_dataset diff --git a/src/server/BreCal/validators/input_validation_utils.py b/src/server/BreCal/validators/input_validation_utils.py index e68f18e..8c2c2ed 100644 --- a/src/server/BreCal/validators/input_validation_utils.py +++ b/src/server/BreCal/validators/input_validation_utils.py @@ -158,7 +158,7 @@ def check_if_participant_id_is_valid_standalone(participant_id:int, participant_ if participant_type is not None: if participant_id not in list(participants.keys()): - raise ValidationError(f"the provided participant_id {participant_id} does not exist in the database.") + raise ValidationError({"participant_id":f"the provided participant_id {participant_id} does not exist in the database."}) # IntFlag object participant_type_in_db = ParticipantType(int(participants.get(participant_id).get("type", ParticipantType.undefined))) diff --git a/src/server/BreCal/validators/time_logic.py b/src/server/BreCal/validators/time_logic.py index 8ebad56..27e80b8 100644 --- a/src/server/BreCal/validators/time_logic.py +++ b/src/server/BreCal/validators/time_logic.py @@ -36,10 +36,10 @@ def validate_time_is_in_not_too_distant_future(raise_validation_error:bool, valu if raise_validation_error: if not is_in_future: - raise ValidationError(f"The provided value must be in the future. Current Time: {datetime.datetime.now()}, Value: {value}") + raise ValidationError({"any_date":f"The provided value must be in the future. Current Time: {datetime.datetime.now()}, Value: {value}"}) if is_too_distant: - raise ValidationError(f"The provided value is in the too distant future and exceeds a threshold for 'reasonable' entries. Found: {value}") + raise ValidationError({"any_date":f"The provided value is in the too distant future and exceeds a threshold for 'reasonable' entries. Found: {value}"}) return is_in_future & (not is_too_distant) diff --git a/src/server/BreCal/validators/validation_error.py b/src/server/BreCal/validators/validation_error.py index 65ee985..9ea846a 100644 --- a/src/server/BreCal/validators/validation_error.py +++ b/src/server/BreCal/validators/validation_error.py @@ -11,8 +11,24 @@ def create_validation_error_response(ex:ValidationError, status_code:int=400)->t # generate an overview the errors #example: # {'lock_time': ['The provided value must be in the future. Current Time: 2024-09-02 08:23:32.600791, Value: 2024-09-01 08:20:41.853000']} + # when the model schema returns an error, 'messages' is by default a dictionary. + # e.g., loadedModel = model.TimesSchema().load(data=content, many=False, partial=True) + # returns: {'eta_berth': ['The provided value must be in the future} + + # when raising a custom ValidationError, it can return a string, list or dict. + # we would like to ensure, that the content of the .messages is a dictionary. This can be accomplished by calling + # raise ValidationError({"example_key_which_fails":"the respective error message"}) errors = ex.messages + # raise ValidationError("example error") + # creates a .messages object, which is an array. e.g., ex.messages = ["example error"] + # the following conversion snipped ensures a dictionary output + if isinstance(errors, (str,list)): + errors = {"undefined_schema":errors} + + # hence, errors always has the following type: dict[str, list[str]] + + # example: # "Valid Data": { # "id": 2894, From 61b00b8b228fd5155287245f8887f0e606888d67 Mon Sep 17 00:00:00 2001 From: Max Metz Date: Mon, 9 Sep 2024 11:55:05 +0200 Subject: [PATCH 16/38] auto-converting non-lists to list values. --- src/server/BreCal/validators/validation_error.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/server/BreCal/validators/validation_error.py b/src/server/BreCal/validators/validation_error.py index 9ea846a..bdc06fd 100644 --- a/src/server/BreCal/validators/validation_error.py +++ b/src/server/BreCal/validators/validation_error.py @@ -25,6 +25,7 @@ def create_validation_error_response(ex:ValidationError, status_code:int=400)->t # the following conversion snipped ensures a dictionary output if isinstance(errors, (str,list)): errors = {"undefined_schema":errors} + errors = {k:v if isinstance(v,list) else [v] for k,v in errors.items()} # hence, errors always has the following type: dict[str, list[str]] From 85973ad8483ed3db9073755354380c638889f61e Mon Sep 17 00:00:00 2001 From: Max Metz Date: Mon, 9 Sep 2024 12:21:32 +0200 Subject: [PATCH 17/38] creating a default error response format for each API route --- src/server/BreCal/api/berths.py | 3 ++- src/server/BreCal/api/history.py | 7 +++--- src/server/BreCal/api/notifications.py | 3 ++- src/server/BreCal/api/participant.py | 3 ++- src/server/BreCal/api/shipcalls.py | 8 +++---- src/server/BreCal/api/ships.py | 12 +++++----- src/server/BreCal/api/times.py | 10 ++++---- src/server/BreCal/api/user.py | 5 ++-- .../BreCal/validators/validation_error.py | 23 +++++++++++++++---- 9 files changed, 47 insertions(+), 27 deletions(-) diff --git a/src/server/BreCal/api/berths.py b/src/server/BreCal/api/berths.py index ba8f4ff..57d960e 100644 --- a/src/server/BreCal/api/berths.py +++ b/src/server/BreCal/api/berths.py @@ -3,6 +3,7 @@ from webargs.flaskparser import parser from .. import impl from ..services.auth_guard import auth_guard import json +from BreCal.validators.validation_error import create_dynamic_exception_response bp = Blueprint('berths', __name__) @@ -15,4 +16,4 @@ def GetBerths(): token = request.headers.get('Authorization') return impl.berths.GetBerths(token) else: - return json.dumps("not authenticated"), 403 + return create_dynamic_exception_response(ex=None, status_code=403, message="not authenticated") diff --git a/src/server/BreCal/api/history.py b/src/server/BreCal/api/history.py index c1fe5ad..1cf99e4 100644 --- a/src/server/BreCal/api/history.py +++ b/src/server/BreCal/api/history.py @@ -2,20 +2,21 @@ from flask import Blueprint, request from .. import impl from ..services.auth_guard import auth_guard import json +from BreCal.validators.validation_error import create_dynamic_exception_response bp = Blueprint('history', __name__) @bp.route('/history', methods=['get']) @auth_guard() # no restriction by role -def GetParticipant(): +def GetHistory(): if 'Authorization' in request.headers: token = request.headers.get('Authorization') options = {} if not 'shipcall_id' in request.args: - return json.dumps("missing parameter"), 400 + return create_dynamic_exception_response(ex=None, status_code=400, message="missing parameter: shipcall_id") options["shipcall_id"] = request.args.get("shipcall_id") return impl.history.GetHistory(options) else: - return json.dumps("not authenticated"), 403 + return create_dynamic_exception_response(ex=None, status_code=403, message="not authenticated") diff --git a/src/server/BreCal/api/notifications.py b/src/server/BreCal/api/notifications.py index 48a2a44..b68a75f 100644 --- a/src/server/BreCal/api/notifications.py +++ b/src/server/BreCal/api/notifications.py @@ -3,6 +3,7 @@ from .. import impl from ..services.auth_guard import auth_guard import logging import json +from BreCal.validators.validation_error import create_dynamic_exception_response bp = Blueprint('notifications', __name__) @@ -16,4 +17,4 @@ def GetNotifications(): return impl.notifications.GetNotifications(options) else: logging.warning("attempt to load notifications without shipcall id") - return json.dumps("missing argument"), 400 \ No newline at end of file + return create_dynamic_exception_response(ex=None, status_code=400, message="missing argument: shipcall_id") diff --git a/src/server/BreCal/api/participant.py b/src/server/BreCal/api/participant.py index 65887f9..53a369f 100644 --- a/src/server/BreCal/api/participant.py +++ b/src/server/BreCal/api/participant.py @@ -2,6 +2,7 @@ from flask import Blueprint, request from .. import impl from ..services.auth_guard import auth_guard import json +from BreCal.validators.validation_error import create_dynamic_exception_response bp = Blueprint('participants', __name__) @@ -15,5 +16,5 @@ def GetParticipant(): options["user_id"] = request.args.get("user_id") return impl.participant.GetParticipant(options) else: - return json.dumps("not authenticated"), 403 + return create_dynamic_exception_response(ex=None, status_code=403, message="not authenticated") diff --git a/src/server/BreCal/api/shipcalls.py b/src/server/BreCal/api/shipcalls.py index e6ac854..743c85b 100644 --- a/src/server/BreCal/api/shipcalls.py +++ b/src/server/BreCal/api/shipcalls.py @@ -7,7 +7,7 @@ from ..services.auth_guard import auth_guard, check_jwt from BreCal.validators.input_validation import validate_posted_shipcall_data, check_if_user_is_bsmd_type from BreCal.validators.input_validation_shipcall import InputValidationShipcall from BreCal.database.sql_handler import execute_sql_query_standalone -from BreCal.validators.validation_error import create_validation_error_response, create_werkzeug_error_response +from BreCal.validators.validation_error import create_validation_error_response, create_werkzeug_error_response, create_dynamic_exception_response from . import verify_if_request_is_json import logging @@ -37,7 +37,7 @@ def GetShipcalls(): return impl.shipcalls.GetShipcalls(options) else: - return json.dumps("not authenticated"), 403 + return create_dynamic_exception_response(ex=None, status_code=403, message="not authenticated") @bp.route('/shipcalls', methods=['post']) @@ -65,7 +65,7 @@ def PostShipcalls(): logging.error(ex) logging.error(traceback.format_exc()) print(ex) - return json.dumps("bad format"), 400 + return create_dynamic_exception_response(ex=ex, status_code=400, message="bad format") return impl.shipcalls.PostShipcalls(loadedModel) @@ -99,6 +99,6 @@ def PutShipcalls(): except Exception as ex: logging.error(ex) print(ex) - return json.dumps("bad format"), 400 + return create_dynamic_exception_response(ex=ex, status_code=400, message="bad format") return impl.shipcalls.PutShipcalls(loadedModel) diff --git a/src/server/BreCal/api/ships.py b/src/server/BreCal/api/ships.py index 9f0c43e..9237502 100644 --- a/src/server/BreCal/api/ships.py +++ b/src/server/BreCal/api/ships.py @@ -6,7 +6,7 @@ from ..schemas import model import json import logging from . import verify_if_request_is_json -from BreCal.validators.validation_error import create_validation_error_response +from BreCal.validators.validation_error import create_validation_error_response, create_dynamic_exception_response from BreCal.validators.input_validation import check_if_user_is_bsmd_type from BreCal.validators.input_validation_ship import InputValidationShip @@ -21,7 +21,7 @@ def GetShips(): token = request.headers.get('Authorization') return impl.ships.GetShips(token) else: - return json.dumps("not authenticated"), 403 + return create_dynamic_exception_response(ex=None, status_code=403, message="not authenticated") @bp.route('/ships', methods=['post']) @@ -54,7 +54,7 @@ def PostShip(): except Exception as ex: logging.error(ex) print(ex) - return json.dumps(repr(ex)), 400 + return create_dynamic_exception_response(ex=ex, status_code=400, message=None) return impl.ships.PostShip(loadedModel) @@ -83,7 +83,7 @@ def PutShip(): except Exception as ex: logging.error(ex) print(ex) - return json.dumps(repr(ex)), 400 + return create_dynamic_exception_response(ex=ex, status_code=400, message=None) return impl.ships.PutShip(loadedModel) @@ -103,7 +103,7 @@ def DeleteShip(): options = {} options["id"] = request.args.get("id") else: - return json.dumps("no id provided"), 400 + return create_dynamic_exception_response(ex=ex, status_code=400, message="no id provided") # validate the request data & user permissions InputValidationShip.evaluate_delete_data(user_data, ship_id) @@ -116,6 +116,6 @@ def DeleteShip(): except Exception as ex: logging.error(ex) print(ex) - return json.dumps(repr(ex)), 400 + return create_dynamic_exception_response(ex=ex, status_code=400, message=None) return impl.ships.DeleteShip(options) diff --git a/src/server/BreCal/api/times.py b/src/server/BreCal/api/times.py index 65b18ed..5bf3626 100644 --- a/src/server/BreCal/api/times.py +++ b/src/server/BreCal/api/times.py @@ -7,7 +7,7 @@ import logging from marshmallow import ValidationError from BreCal.validators.input_validation_times import InputValidationTimes from . import verify_if_request_is_json -from BreCal.validators.validation_error import create_validation_error_response, create_werkzeug_error_response +from BreCal.validators.validation_error import create_validation_error_response, create_werkzeug_error_response, create_dynamic_exception_response bp = Blueprint('times', __name__) @@ -50,7 +50,7 @@ def PostTimes(): except Exception as ex: logging.error(ex) print(ex) - return json.dumps("bad format"), 400 + return create_dynamic_exception_response(ex=ex, status_code=400, message="bad format") return impl.times.PostTimes(loadedModel) @@ -79,7 +79,7 @@ def PutTimes(): except Exception as ex: logging.error(ex) print(ex) - return json.dumps("bad format"), 400 + return create_dynamic_exception_response(ex=ex, status_code=400, message="bad format") return impl.times.PutTimes(loadedModel) @@ -102,7 +102,7 @@ def DeleteTimes(): return impl.times.DeleteTimes(options) else: logging.warning("Times delete missing id argument") - return json.dumps("missing argument"), 400 + return create_dynamic_exception_response(ex=None, status_code=400, message="missing argument: id") except ValidationError as ex: logging.error(ex) @@ -112,4 +112,4 @@ def DeleteTimes(): except Exception as ex: logging.error(ex) print(ex) - return json.dumps("bad format"), 400 + return create_dynamic_exception_response(ex=ex, status_code=400, message="bad format") diff --git a/src/server/BreCal/api/user.py b/src/server/BreCal/api/user.py index 6416704..86b992b 100644 --- a/src/server/BreCal/api/user.py +++ b/src/server/BreCal/api/user.py @@ -6,6 +6,7 @@ import json import logging from marshmallow import ValidationError from . import verify_if_request_is_json +from BreCal.validators.validation_error import create_dynamic_exception_response, create_validation_error_response bp = Blueprint('user', __name__) @@ -22,12 +23,12 @@ def PutUser(): except ValidationError as ex: logging.error(ex) print(ex) - return json.dumps(f"bad format. \nError Messages: {ex.messages}. \nValid Data: {ex.valid_data}"), 400 + return create_validation_error_response(ex=ex, status_code=400) except Exception as ex: logging.error(ex) print(ex) - return json.dumps("bad format"), 400 + return create_dynamic_exception_response(ex=ex, status_code=400, message="bad format") return impl.user.PutUser(loadedModel) diff --git a/src/server/BreCal/validators/validation_error.py b/src/server/BreCal/validators/validation_error.py index bdc06fd..b9b2059 100644 --- a/src/server/BreCal/validators/validation_error.py +++ b/src/server/BreCal/validators/validation_error.py @@ -6,6 +6,14 @@ import werkzeug from werkzeug.exceptions import Forbidden +def create_default_error_format(error_description): + json_response = { + "message":f"{error_description}", + "errors":[], + "valid_data":{} + } + return json_response + def create_validation_error_response(ex:ValidationError, status_code:int=400)->typing.Tuple[str,int]: # generate an overview the errors @@ -39,11 +47,11 @@ def create_validation_error_response(ex:ValidationError, status_code:int=400)->t valid_data = ex.valid_data - json_response = { - "message":"ValidationError", + json_response = create_default_error_format(error_description="ValidationError") + json_response.update({ "errors":errors, "valid_data":valid_data - } + }) # json.dumps with default=str automatically converts non-serializable values to strings. Hence, datetime objects (which are not) # natively serializable are properly serialized. @@ -53,6 +61,13 @@ def create_validation_error_response(ex:ValidationError, status_code:int=400)->t def create_werkzeug_error_response(ex:Forbidden, status_code:int=403)->typing.Tuple[str,int]: # json.dumps with default=str automatically converts non-serializable values to strings. Hence, datetime objects (which are not) # natively serializable are properly serialized. - serialized_response = json.dumps({"message":ex.description}, default=str) + json_response = create_default_error_format(error_description=ex.description) + serialized_response = json.dumps(json_response, default=str) return serialized_response, status_code +def create_dynamic_exception_response(ex, status_code:int=400, message:typing.Optional[str]=None): + message = repr(ex) if message is None else message + json_response = create_default_error_format(error_description=message) + + serialized_response = json.dumps(json_response, default=str) + return (serialized_response, status_code) From d2cd233f130ca6ebf9bc3460929855462ab91834 Mon Sep 17 00:00:00 2001 From: Max Metz Date: Mon, 9 Sep 2024 12:46:55 +0200 Subject: [PATCH 18/38] creating default handlers for every kind of Exception in the /api/ routes. Those default functions also create automatic logging with the .warning level. Relocated the .impl-calls into the Try-Exception-blocks, so they are properly logged and avoid system failures. --- src/server/BreCal/api/berths.py | 15 ++++-- src/server/BreCal/api/history.py | 22 ++++---- src/server/BreCal/api/notifications.py | 17 +++--- src/server/BreCal/api/participant.py | 18 ++++--- src/server/BreCal/api/shipcalls.py | 52 ++++++++----------- src/server/BreCal/api/ships.py | 38 +++++--------- src/server/BreCal/api/times.py | 32 ++++-------- src/server/BreCal/api/user.py | 8 +-- .../BreCal/validators/validation_error.py | 25 ++++++--- 9 files changed, 113 insertions(+), 114 deletions(-) diff --git a/src/server/BreCal/api/berths.py b/src/server/BreCal/api/berths.py index 57d960e..114f893 100644 --- a/src/server/BreCal/api/berths.py +++ b/src/server/BreCal/api/berths.py @@ -1,3 +1,4 @@ +import logging from flask import Blueprint, request from webargs.flaskparser import parser from .. import impl @@ -12,8 +13,12 @@ bp = Blueprint('berths', __name__) @auth_guard() # no restriction by role def GetBerths(): - if 'Authorization' in request.headers: - token = request.headers.get('Authorization') - return impl.berths.GetBerths(token) - else: - return create_dynamic_exception_response(ex=None, status_code=403, message="not authenticated") + try: + if 'Authorization' in request.headers: + token = request.headers.get('Authorization') + return impl.berths.GetBerths(token) + else: + return create_dynamic_exception_response(ex=None, status_code=403, message="not authenticated") + + except Exception as ex: + return create_dynamic_exception_response(ex=ex, status_code=400) diff --git a/src/server/BreCal/api/history.py b/src/server/BreCal/api/history.py index 1cf99e4..098423f 100644 --- a/src/server/BreCal/api/history.py +++ b/src/server/BreCal/api/history.py @@ -1,3 +1,4 @@ +import logging from flask import Blueprint, request from .. import impl from ..services.auth_guard import auth_guard @@ -10,13 +11,16 @@ bp = Blueprint('history', __name__) @auth_guard() # no restriction by role def GetHistory(): - if 'Authorization' in request.headers: - token = request.headers.get('Authorization') - options = {} - if not 'shipcall_id' in request.args: - return create_dynamic_exception_response(ex=None, status_code=400, message="missing parameter: shipcall_id") - options["shipcall_id"] = request.args.get("shipcall_id") - return impl.history.GetHistory(options) - else: - return create_dynamic_exception_response(ex=None, status_code=403, message="not authenticated") + try: + if 'Authorization' in request.headers: + token = request.headers.get('Authorization') + options = {} + if not 'shipcall_id' in request.args: + return create_dynamic_exception_response(ex=None, status_code=400, message="missing parameter: shipcall_id") + options["shipcall_id"] = request.args.get("shipcall_id") + return impl.history.GetHistory(options) + else: + return create_dynamic_exception_response(ex=None, status_code=403, message="not authenticated") + except Exception as ex: + return create_dynamic_exception_response(ex=ex, status_code=400) diff --git a/src/server/BreCal/api/notifications.py b/src/server/BreCal/api/notifications.py index b68a75f..4fe4a8e 100644 --- a/src/server/BreCal/api/notifications.py +++ b/src/server/BreCal/api/notifications.py @@ -11,10 +11,13 @@ bp = Blueprint('notifications', __name__) @bp.route('/notifications', methods=['get']) @auth_guard() # no restriction by role def GetNotifications(): - if 'shipcall_id' in request.args: - options = {} - options["shipcall_id"] = request.args.get("shipcall_id") - return impl.notifications.GetNotifications(options) - else: - logging.warning("attempt to load notifications without shipcall id") - return create_dynamic_exception_response(ex=None, status_code=400, message="missing argument: shipcall_id") + try: + if 'shipcall_id' in request.args: + options = {} + options["shipcall_id"] = request.args.get("shipcall_id") + return impl.notifications.GetNotifications(options) + else: + return create_dynamic_exception_response(ex=None, status_code=400, message="missing argument: shipcall_id") + + except Exception as ex: + return create_dynamic_exception_response(ex=ex, status_code=400) diff --git a/src/server/BreCal/api/participant.py b/src/server/BreCal/api/participant.py index 53a369f..814a3dd 100644 --- a/src/server/BreCal/api/participant.py +++ b/src/server/BreCal/api/participant.py @@ -1,3 +1,4 @@ +import logging from flask import Blueprint, request from .. import impl from ..services.auth_guard import auth_guard @@ -10,11 +11,14 @@ bp = Blueprint('participants', __name__) @auth_guard() # no restriction by role def GetParticipant(): - if 'Authorization' in request.headers: - token = request.headers.get('Authorization') - options = {} - options["user_id"] = request.args.get("user_id") - return impl.participant.GetParticipant(options) - else: - return create_dynamic_exception_response(ex=None, status_code=403, message="not authenticated") + try: + if 'Authorization' in request.headers: + token = request.headers.get('Authorization') + options = {} + options["user_id"] = request.args.get("user_id") + return impl.participant.GetParticipant(options) + else: + return create_dynamic_exception_response(ex=None, status_code=403, message="not authenticated") + except Exception as ex: + return create_dynamic_exception_response(ex=ex, status_code=400) diff --git a/src/server/BreCal/api/shipcalls.py b/src/server/BreCal/api/shipcalls.py index 743c85b..b21908e 100644 --- a/src/server/BreCal/api/shipcalls.py +++ b/src/server/BreCal/api/shipcalls.py @@ -20,24 +20,28 @@ bp = Blueprint('shipcalls', __name__) @bp.route('/shipcalls', methods=['get']) @auth_guard() # no restriction by role def GetShipcalls(): - if 'Authorization' in request.headers: - token = request.headers.get('Authorization') # see impl/login to see the token encoding, which is a JWT token. + try: + if 'Authorization' in request.headers: + token = request.headers.get('Authorization') # see impl/login to see the token encoding, which is a JWT token. - """ - from BreCal.services.jwt_handler import decode_jwt - jwt = token.split('Bearer ')[1] # string key - payload = decode_jwt(jwt) # dictionary, which includes 'id' (user id) and 'participant_id' + """ + from BreCal.services.jwt_handler import decode_jwt + jwt = token.split('Bearer ')[1] # string key + payload = decode_jwt(jwt) # dictionary, which includes 'id' (user id) and 'participant_id' - # oneline: - payload = decode_jwt(request.headers.get("Authorization").split("Bearer ")[-1]) - """ - options = {} - options["participant_id"] = request.args.get("participant_id") - options["past_days"] = request.args.get("past_days", default=1, type=int) + # oneline: + payload = decode_jwt(request.headers.get("Authorization").split("Bearer ")[-1]) + """ + options = {} + options["participant_id"] = request.args.get("participant_id") + options["past_days"] = request.args.get("past_days", default=1, type=int) - return impl.shipcalls.GetShipcalls(options) - else: - return create_dynamic_exception_response(ex=None, status_code=403, message="not authenticated") + return impl.shipcalls.GetShipcalls(options) + else: + return create_dynamic_exception_response(ex=None, status_code=403, message="not authenticated") + + except Exception as ex: + return create_dynamic_exception_response(ex=ex, status_code=400) @bp.route('/shipcalls', methods=['post']) @@ -55,20 +59,15 @@ def PostShipcalls(): # validate the posted shipcall data & the user's authority InputValidationShipcall.evaluate_post_data(user_data, loadedModel, content) + return impl.shipcalls.PostShipcalls(loadedModel) except ValidationError as ex: - logging.error(ex) - print(ex) return create_validation_error_response(ex=ex, status_code=400) except Exception as ex: - logging.error(ex) logging.error(traceback.format_exc()) - print(ex) return create_dynamic_exception_response(ex=ex, status_code=400, message="bad format") - return impl.shipcalls.PostShipcalls(loadedModel) - @bp.route('/shipcalls', methods=['put']) @auth_guard() # no restriction by role @@ -85,20 +84,15 @@ def PutShipcalls(): # validate the PUT shipcall data and the user's authority InputValidationShipcall.evaluate_put_data(user_data, loadedModel, content) + return impl.shipcalls.PutShipcalls(loadedModel) except ValidationError as ex: - logging.error(ex) - print(ex) return create_validation_error_response(ex=ex, status_code=400) except werkzeug.exceptions.Forbidden as ex: - logging.error(ex) - print(ex) return create_werkzeug_error_response(ex=ex, status_code=403) except Exception as ex: - logging.error(ex) - print(ex) - return create_dynamic_exception_response(ex=ex, status_code=400, message="bad format") + logging.error(traceback.format_exc()) + return create_dynamic_exception_response(ex=None, status_code=400, message="bad format") - return impl.shipcalls.PutShipcalls(loadedModel) diff --git a/src/server/BreCal/api/ships.py b/src/server/BreCal/api/ships.py index 9237502..9e92ffa 100644 --- a/src/server/BreCal/api/ships.py +++ b/src/server/BreCal/api/ships.py @@ -17,11 +17,15 @@ bp = Blueprint('ships', __name__) @auth_guard() # no restriction by role def GetShips(): - if 'Authorization' in request.headers: - token = request.headers.get('Authorization') - return impl.ships.GetShips(token) - else: - return create_dynamic_exception_response(ex=None, status_code=403, message="not authenticated") + try: + if 'Authorization' in request.headers: + token = request.headers.get('Authorization') + return impl.ships.GetShips(token) + else: + return create_dynamic_exception_response(ex=None, status_code=403, message="not authenticated") + + except Exception as ex: + return create_dynamic_exception_response(ex=ex, status_code=400) @bp.route('/ships', methods=['post']) @@ -45,19 +49,14 @@ def PostShip(): # validate the request data & user permissions InputValidationShip.evaluate_post_data(user_data, loadedModel, content) + return impl.ships.PostShip(loadedModel) except ValidationError as ex: - logging.error(ex) - print(ex) return create_validation_error_response(ex=ex, status_code=400) except Exception as ex: - logging.error(ex) - print(ex) return create_dynamic_exception_response(ex=ex, status_code=400, message=None) - return impl.ships.PostShip(loadedModel) - @bp.route('/ships', methods=['put']) @auth_guard() # no restriction by role @@ -74,18 +73,13 @@ def PutShip(): # validate the request data & user permissions InputValidationShip.evaluate_put_data(user_data, loadedModel, content) + return impl.ships.PutShip(loadedModel) except ValidationError as ex: - logging.error(ex) - print(ex) return create_validation_error_response(ex=ex, status_code=400) except Exception as ex: - logging.error(ex) - print(ex) - return create_dynamic_exception_response(ex=ex, status_code=400, message=None) - - return impl.ships.PutShip(loadedModel) + return create_dynamic_exception_response(ex=ex, status_code=400) @bp.route('/ships', methods=['delete']) @@ -107,15 +101,11 @@ def DeleteShip(): # validate the request data & user permissions InputValidationShip.evaluate_delete_data(user_data, ship_id) + return impl.ships.DeleteShip(options) except ValidationError as ex: - logging.error(ex) - print(ex) return create_validation_error_response(ex=ex, status_code=400) except Exception as ex: - logging.error(ex) - print(ex) - return create_dynamic_exception_response(ex=ex, status_code=400, message=None) + return create_dynamic_exception_response(ex=ex, status_code=400) - return impl.ships.DeleteShip(options) diff --git a/src/server/BreCal/api/times.py b/src/server/BreCal/api/times.py index 5bf3626..ff8e17e 100644 --- a/src/server/BreCal/api/times.py +++ b/src/server/BreCal/api/times.py @@ -16,10 +16,13 @@ bp = Blueprint('times', __name__) @auth_guard() # no restriction by role def GetTimes(): - options = {} - options["shipcall_id"] = request.args.get("shipcall_id") - - return impl.times.GetTimes(options) + try: + options = {} + options["shipcall_id"] = request.args.get("shipcall_id") + return impl.times.GetTimes(options) + + except Exception as ex: + return create_dynamic_exception_response(ex=ex, status_code=400) @bp.route('/times', methods=['post']) @@ -41,18 +44,14 @@ def PostTimes(): # validate the request InputValidationTimes.evaluate_post_data(user_data, loadedModel, content) - + return impl.times.PostTimes(loadedModel) + except ValidationError as ex: - logging.error(ex) - print(ex) return create_validation_error_response(ex=ex, status_code=400) except Exception as ex: - logging.error(ex) - print(ex) return create_dynamic_exception_response(ex=ex, status_code=400, message="bad format") - return impl.times.PostTimes(loadedModel) @bp.route('/times', methods=['put']) @@ -70,18 +69,14 @@ def PutTimes(): # validate the request InputValidationTimes.evaluate_put_data(user_data, loadedModel, content) + return impl.times.PutTimes(loadedModel) except ValidationError as ex: - logging.error(ex) - print(ex) return create_validation_error_response(ex=ex, status_code=400) except Exception as ex: - logging.error(ex) - print(ex) return create_dynamic_exception_response(ex=ex, status_code=400, message="bad format") - return impl.times.PutTimes(loadedModel) @bp.route('/times', methods=['delete']) @@ -101,15 +96,10 @@ def DeleteTimes(): return impl.times.DeleteTimes(options) else: - logging.warning("Times delete missing id argument") - return create_dynamic_exception_response(ex=None, status_code=400, message="missing argument: id") + return create_dynamic_exception_response(ex=None, status_code=400, message="Times delete missing argument: id") except ValidationError as ex: - logging.error(ex) - print(ex) return create_validation_error_response(ex=ex, status_code=400) except Exception as ex: - logging.error(ex) - print(ex) return create_dynamic_exception_response(ex=ex, status_code=400, message="bad format") diff --git a/src/server/BreCal/api/user.py b/src/server/BreCal/api/user.py index 86b992b..b77c12c 100644 --- a/src/server/BreCal/api/user.py +++ b/src/server/BreCal/api/user.py @@ -19,16 +19,12 @@ def PutUser(): content = request.get_json(force=True) loadedModel = model.UserSchema().load(data=content, many=False, partial=True) + return impl.user.PutUser(loadedModel) except ValidationError as ex: - logging.error(ex) - print(ex) return create_validation_error_response(ex=ex, status_code=400) except Exception as ex: - logging.error(ex) - print(ex) - return create_dynamic_exception_response(ex=ex, status_code=400, message="bad format") + return create_dynamic_exception_response(ex=None, status_code=400, message="bad format") - return impl.user.PutUser(loadedModel) diff --git a/src/server/BreCal/validators/validation_error.py b/src/server/BreCal/validators/validation_error.py index b9b2059..36f5cc8 100644 --- a/src/server/BreCal/validators/validation_error.py +++ b/src/server/BreCal/validators/validation_error.py @@ -15,7 +15,7 @@ def create_default_error_format(error_description): return json_response -def create_validation_error_response(ex:ValidationError, status_code:int=400)->typing.Tuple[str,int]: +def create_validation_error_response(ex:ValidationError, status_code:int=400, create_log:bool=True)->typing.Tuple[str,int]: # generate an overview the errors #example: # {'lock_time': ['The provided value must be in the future. Current Time: 2024-09-02 08:23:32.600791, Value: 2024-09-01 08:20:41.853000']} @@ -46,8 +46,8 @@ def create_validation_error_response(ex:ValidationError, status_code:int=400)->t # } valid_data = ex.valid_data - - json_response = create_default_error_format(error_description="ValidationError") + message = "ValidationError" + json_response = create_default_error_format(error_description=message) json_response.update({ "errors":errors, "valid_data":valid_data @@ -56,18 +56,31 @@ def create_validation_error_response(ex:ValidationError, status_code:int=400)->t # json.dumps with default=str automatically converts non-serializable values to strings. Hence, datetime objects (which are not) # natively serializable are properly serialized. serialized_response = json.dumps(json_response, default=str) + + if create_log: + logging.warning(ex) if ex is not None else logging.warning(message) + print(ex) if ex is not None else print(message) return (serialized_response, status_code) -def create_werkzeug_error_response(ex:Forbidden, status_code:int=403)->typing.Tuple[str,int]: +def create_werkzeug_error_response(ex:Forbidden, status_code:int=403, create_log:bool=True)->typing.Tuple[str,int]: # json.dumps with default=str automatically converts non-serializable values to strings. Hence, datetime objects (which are not) # natively serializable are properly serialized. - json_response = create_default_error_format(error_description=ex.description) + message = ex.description + json_response = create_default_error_format(error_description=message) serialized_response = json.dumps(json_response, default=str) + + if create_log: + logging.warning(ex) if ex is not None else logging.warning(message) + print(ex) if ex is not None else print(message) return serialized_response, status_code -def create_dynamic_exception_response(ex, status_code:int=400, message:typing.Optional[str]=None): +def create_dynamic_exception_response(ex, status_code:int=400, message:typing.Optional[str]=None, create_log:bool=True): message = repr(ex) if message is None else message json_response = create_default_error_format(error_description=message) serialized_response = json.dumps(json_response, default=str) + + if create_log: + logging.warning(ex) if ex is not None else logging.warning(message) + print(ex) if ex is not None else print(message) return (serialized_response, status_code) From 93362d3695b808fd5d06388e6b42b7791e890797 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Mon, 9 Sep 2024 13:11:56 +0200 Subject: [PATCH 19/38] Don't crash on ship delete API error --- src/BreCalClient/ShipListDialog.xaml.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/BreCalClient/ShipListDialog.xaml.cs b/src/BreCalClient/ShipListDialog.xaml.cs index a4149e2..7ad18ed 100644 --- a/src/BreCalClient/ShipListDialog.xaml.cs +++ b/src/BreCalClient/ShipListDialog.xaml.cs @@ -49,8 +49,15 @@ namespace BreCalClient { if (!shipmodel.Ship.Deleted) { - if (this.ShipApi != null) - await this.ShipApi.ShipDeleteAsync(shipmodel.Ship.Id); + try + { + if (this.ShipApi != null) + await this.ShipApi.ShipDeleteAsync(shipmodel.Ship.Id); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); + } BreCalLists.Ships.Remove(shipmodel); // remove from "selectable" ships shipmodel.Ship.Deleted = true; // set deleted marker on working instance this.dataGridShips.ItemsSource = null; From 9127cdeac8fc3c64ad857a72dbf4a9f11e22064a Mon Sep 17 00:00:00 2001 From: Max Metz Date: Mon, 9 Sep 2024 17:06:03 +0200 Subject: [PATCH 20/38] BSMD users are now allowed to POST times entry, if they are assigned to the ShipcallParticipantMap or the special BSMD-flag-clause takes place --- src/server/BreCal/validators/input_validation_times.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/server/BreCal/validators/input_validation_times.py b/src/server/BreCal/validators/input_validation_times.py index 7e402fa..e0726fc 100644 --- a/src/server/BreCal/validators/input_validation_times.py +++ b/src/server/BreCal/validators/input_validation_times.py @@ -85,13 +85,10 @@ class InputValidationTimes(): # 2.) datasets may only be created, if the respective participant type did not already create one. InputValidationTimes.check_if_entry_already_exists_for_participant_type(user_data, loadedModel, content) - # 3.) only users who are *not* of type BSMD may post times datasets. - InputValidationTimes.check_user_is_not_bsmd_type(user_data) - - # 4.) Reference checking + # 3.) Reference checking InputValidationTimes.check_dataset_references(content) - # 5.) Value checking + # 4.) Value checking InputValidationTimes.check_dataset_values(user_data, loadedModel, content) return @@ -143,6 +140,7 @@ class InputValidationTimes(): @staticmethod def check_user_is_not_bsmd_type(user_data:dict): """a new dataset may only be created by a user who is *not* belonging to participant group BSMD""" + # this method is deprecated for /times POST requests. As the function may be used elsewhere, it will, for now, not be removed is_bsmd = check_if_user_is_bsmd_type(user_data) if is_bsmd: raise ValidationError({"participant_type":f"current user belongs to BSMD. Cannot post 'times' datasets. Found user data: {user_data}"}) From 67c852482e44ec345d4d39f2b46660af0261cdf8 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Mon, 9 Sep 2024 16:24:29 +0200 Subject: [PATCH 21/38] Added some warnings if time intervals or particular values lie in the past for shipcall and agency --- src/BreCalClient/EditShipcallControl.xaml.cs | 8 ++ .../EditTimesAgencyIncomingControl.xaml.cs | 57 ++++++++++- .../EditTimesAgencyOutgoingControl.xaml.cs | 57 ++++++++++- .../EditTimesAgencyShiftingControl.xaml.cs | 74 +++++++++++++- src/BreCalClient/EditTimesControl.xaml | 2 +- src/BreCalClient/EditTimesControl.xaml.cs | 51 +++++++++- .../EditTimesTerminalControl.xaml.cs | 58 ++++++++++- .../Resources/Resources.Designer.cs | 99 +++++++++++++++++++ src/BreCalClient/Resources/Resources.de.resx | 33 +++++++ src/BreCalClient/Resources/Resources.resx | 33 +++++++ 10 files changed, 456 insertions(+), 16 deletions(-) diff --git a/src/BreCalClient/EditShipcallControl.xaml.cs b/src/BreCalClient/EditShipcallControl.xaml.cs index 322b534..65ae975 100644 --- a/src/BreCalClient/EditShipcallControl.xaml.cs +++ b/src/BreCalClient/EditShipcallControl.xaml.cs @@ -205,15 +205,23 @@ namespace BreCalClient case ShipcallType.Departure: isEnabled &= this.comboBoxDepartureBerth.SelectedItem != null; isEnabled &= this.datePickerETD.Value.HasValue; + if(this.datePickerETD.Value.HasValue) + isEnabled &= (this.datePickerETD.Value.Value > DateTime.Now); break; case ShipcallType.Arrival: isEnabled &= this.comboBoxArrivalBerth.SelectedItem != null; isEnabled &= this.datePickerETA.Value.HasValue; + if(this.datePickerETA.Value.HasValue) + isEnabled &= (this.datePickerETA.Value.Value > DateTime.Now); break; case ShipcallType.Shifting: isEnabled &= ((this.comboBoxDepartureBerth.SelectedItem != null) && (this.comboBoxArrivalBerth.SelectedItem != null)); isEnabled &= this.datePickerETD.Value.HasValue; isEnabled &= this.datePickerETA.Value.HasValue; + if (this.datePickerETD.Value.HasValue) + isEnabled &= (this.datePickerETD.Value.Value > DateTime.Now); + if (this.datePickerETA.Value.HasValue) + isEnabled &= (this.datePickerETA.Value.Value > DateTime.Now); break; } } diff --git a/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs b/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs index 8a38a07..e7c2bb7 100644 --- a/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs +++ b/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs @@ -4,6 +4,7 @@ using BreCalClient.misc.Model; using System; +using System.Runtime.Serialization; using System.Windows; using static BreCalClient.Extensions; @@ -70,9 +71,16 @@ namespace BreCalClient private void buttonOK_Click(object sender, RoutedEventArgs e) { - this.CopyToModel(); - this.DialogResult = true; - this.Close(); + if (!CheckValues(out string message)) + { + MessageBox.Show(message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); + } + else + { + this.CopyToModel(); + this.DialogResult = true; + this.Close(); + } } private void buttonCancel_Click(object sender, RoutedEventArgs e) @@ -85,6 +93,49 @@ namespace BreCalClient #region private methods + private bool CheckValues(out string message) + { + message = ""; + + if (this.datePickerETA.Value.HasValue && (this.datePickerETA.Value.Value < DateTime.Now) && (this.datePickerETA_End.Value == null)) + { + message = BreCalClient.Resources.Resources.textETAInThePast; + return false; + } + + if(this.datePickerETA_End.Value.HasValue && this.datePickerETA_End.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textETDInThePast; + return false; + } + + if(this.datePickerETA.Value.HasValue && this.datePickerETA_End.Value.HasValue && this.datePickerETA.Value > this.datePickerETA_End.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + if (this.datePickerTidalWindowFrom.Value.HasValue && (this.datePickerTidalWindowFrom.Value.Value < DateTime.Now) && (this.datePickerTidalWindowTo.Value == null)) + { + message = BreCalClient.Resources.Resources.textTideTimesInThePast; + return false; + } + + if (this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowTo.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textTideTimesInThePast; + return false; + } + + if (this.datePickerTidalWindowFrom.Value.HasValue && this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowFrom.Value > this.datePickerTidalWindowTo.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + return true; + } + private void CopyToModel() { if (this.ShipcallModel.Shipcall != null) diff --git a/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs b/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs index 0a778fd..17dc94b 100644 --- a/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs +++ b/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs @@ -80,9 +80,16 @@ namespace BreCalClient private void buttonOK_Click(object sender, RoutedEventArgs e) { - this.CopyToModel(); - this.DialogResult = true; - this.Close(); + if (!CheckValues(out string message)) + { + System.Windows.MessageBox.Show(message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); + } + else + { + this.CopyToModel(); + this.DialogResult = true; + this.Close(); + } } private void buttonCancel_Click(object sender, RoutedEventArgs e) @@ -95,6 +102,50 @@ namespace BreCalClient #region private methods + + private bool CheckValues(out string message) + { + message = ""; + + if (this.datePickerETD.Value.HasValue && (this.datePickerETD.Value.Value < DateTime.Now) && (this.datePickerETD_End.Value == null)) + { + message = BreCalClient.Resources.Resources.textETAInThePast; + return false; + } + + if (this.datePickerETD_End.Value.HasValue && this.datePickerETD_End.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textETDInThePast; + return false; + } + + if (this.datePickerETD.Value.HasValue && this.datePickerETD_End.Value.HasValue && this.datePickerETD.Value > this.datePickerETD_End.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + if (this.datePickerTidalWindowFrom.Value.HasValue && (this.datePickerTidalWindowFrom.Value.Value < DateTime.Now) && (this.datePickerTidalWindowTo.Value == null)) + { + message = BreCalClient.Resources.Resources.textTideTimesInThePast; + return false; + } + + if (this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowTo.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textTideTimesInThePast; + return false; + } + + if (this.datePickerTidalWindowFrom.Value.HasValue && this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowFrom.Value > this.datePickerTidalWindowTo.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + return true; + } + private void CopyToModel() { if (this.ShipcallModel.Shipcall != null) diff --git a/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs b/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs index 5fa79ad..f0cf0e9 100644 --- a/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs +++ b/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs @@ -71,9 +71,16 @@ namespace BreCalClient private void buttonOK_Click(object sender, RoutedEventArgs e) { - this.CopyToModel(); - this.DialogResult = true; - this.Close(); + if (!CheckValues(out string message)) + { + System.Windows.MessageBox.Show(message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); + } + else + { + this.CopyToModel(); + this.DialogResult = true; + this.Close(); + } } private void buttonCancel_Click(object sender, RoutedEventArgs e) @@ -86,6 +93,67 @@ namespace BreCalClient #region private methods + private bool CheckValues(out string message) + { + message = ""; + + if (this.datePickerETA.Value.HasValue && (this.datePickerETA.Value.Value < DateTime.Now) && (this.datePickerETA_End.Value == null)) + { + message = BreCalClient.Resources.Resources.textETAInThePast; + return false; + } + + if (this.datePickerETA_End.Value.HasValue && this.datePickerETA_End.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textETDInThePast; + return false; + } + + if (this.datePickerETA.Value.HasValue && this.datePickerETA_End.Value.HasValue && this.datePickerETA.Value > this.datePickerETA_End.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + if (this.datePickerETD.Value.HasValue && (this.datePickerETD.Value.Value < DateTime.Now) && (this.datePickerETD_End.Value == null)) + { + message = BreCalClient.Resources.Resources.textETAInThePast; + return false; + } + + if (this.datePickerETD_End.Value.HasValue && this.datePickerETD_End.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textETDInThePast; + return false; + } + + if (this.datePickerETD.Value.HasValue && this.datePickerETD_End.Value.HasValue && this.datePickerETD.Value > this.datePickerETD_End.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + if (this.datePickerTidalWindowFrom.Value.HasValue && (this.datePickerTidalWindowFrom.Value.Value < DateTime.Now) && (this.datePickerTidalWindowTo.Value == null)) + { + message = BreCalClient.Resources.Resources.textTideTimesInThePast; + return false; + } + + if (this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowTo.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textTideTimesInThePast; + return false; + } + + if (this.datePickerTidalWindowFrom.Value.HasValue && this.datePickerTidalWindowTo.Value.HasValue && this.datePickerTidalWindowFrom.Value > this.datePickerTidalWindowTo.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + return true; + } + private void CopyToModel() { if (this.ShipcallModel.Shipcall != null) diff --git a/src/BreCalClient/EditTimesControl.xaml b/src/BreCalClient/EditTimesControl.xaml index ad03ed9..03cac40 100644 --- a/src/BreCalClient/EditTimesControl.xaml +++ b/src/BreCalClient/EditTimesControl.xaml @@ -44,7 +44,7 @@ - + diff --git a/src/BreCalClient/EditTimesControl.xaml.cs b/src/BreCalClient/EditTimesControl.xaml.cs index dfd841d..74e7e0a 100644 --- a/src/BreCalClient/EditTimesControl.xaml.cs +++ b/src/BreCalClient/EditTimesControl.xaml.cs @@ -46,9 +46,16 @@ namespace BreCalClient private void buttonOK_Click(object sender, RoutedEventArgs e) { - this.CopyToModel(); - this.DialogResult = true; - this.Close(); + if (!CheckValues(out string message)) + { + System.Windows.MessageBox.Show(message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); + } + else + { + this.CopyToModel(); + this.DialogResult = true; + this.Close(); + } } private void buttonCancel_Click(object sender, RoutedEventArgs e) @@ -85,6 +92,44 @@ namespace BreCalClient #region private methods + private bool CheckValues(out string message) + { + + message = ""; + + if (this.datePickerETABerth.Value.HasValue && (this.datePickerETABerth.Value.Value < DateTime.Now) && (this.datePickerETABerth_End.Value == null)) + { + message = BreCalClient.Resources.Resources.textETAInThePast; + return false; + } + + if (this.datePickerETABerth_End.Value.HasValue && this.datePickerETABerth_End.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textETDInThePast; + return false; + } + + if (this.datePickerETABerth.Value.HasValue && this.datePickerETABerth_End.Value.HasValue && this.datePickerETABerth.Value > this.datePickerETABerth_End.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + if (this.datePickerLockTime.Value.HasValue && (this.datePickerLockTime.Value.Value < DateTime.Now)) + { + message = BreCalClient.Resources.Resources.textLockTimeInThePast; + return false; + } + + if (this.datePickerZoneEntry.Value.HasValue && this.datePickerZoneEntry.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textZoneEntryInThePast; + return false; + } + + return true; + } + private void CopyToModel() { this.Times.Remarks = this.textBoxRemarks.Text.Trim().Truncate(512); diff --git a/src/BreCalClient/EditTimesTerminalControl.xaml.cs b/src/BreCalClient/EditTimesTerminalControl.xaml.cs index 6071ba9..6e9af6a 100644 --- a/src/BreCalClient/EditTimesTerminalControl.xaml.cs +++ b/src/BreCalClient/EditTimesTerminalControl.xaml.cs @@ -3,6 +3,7 @@ // using BreCalClient.misc.Model; +using System; using System.Windows; namespace BreCalClient @@ -61,9 +62,16 @@ namespace BreCalClient private void buttonOK_Click(object sender, RoutedEventArgs e) { - this.CopyToModel(); - this.DialogResult = true; - this.Close(); + if (!CheckValues(out string message)) + { + System.Windows.MessageBox.Show(message, "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); + } + else + { + this.CopyToModel(); + this.DialogResult = true; + this.Close(); + } } private void buttonCancel_Click(object sender, RoutedEventArgs e) @@ -95,6 +103,50 @@ namespace BreCalClient #region private methods + private bool CheckValues(out string message) + { + + message = ""; + + if (this.datePickerOperationStart.Value.HasValue && (this.datePickerOperationStart.Value.Value < DateTime.Now) && (this.datePickerOperationStart_End.Value == null)) + { + message = BreCalClient.Resources.Resources.textOperationStartInThePast; + return false; + } + + if (this.datePickerOperationStart_End.Value.HasValue && this.datePickerOperationStart_End.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textOperationStartInThePast; + return false; + } + + if (this.datePickerOperationStart.Value.HasValue && this.datePickerOperationStart_End.Value.HasValue && this.datePickerOperationStart.Value > this.datePickerOperationStart_End.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + if (this.datePickerOperationEnd.Value.HasValue && (this.datePickerOperationEnd.Value.Value < DateTime.Now) && (this.datePickerOperationEnd_End.Value == null)) + { + message = BreCalClient.Resources.Resources.textOperationEndInThePast; + return false; + } + + if (this.datePickerOperationEnd_End.Value.HasValue && this.datePickerOperationEnd_End.Value < DateTime.Now) + { + message = BreCalClient.Resources.Resources.textOperationEndInThePast; + return false; + } + + if (this.datePickerOperationEnd.Value.HasValue && this.datePickerOperationEnd_End.Value.HasValue && this.datePickerOperationEnd.Value > this.datePickerOperationEnd_End.Value) + { + message = BreCalClient.Resources.Resources.textEndValueBeforeStartValue; + return false; + } + + return true; + } + private void CopyToModel() { this.Times.PierSide = this.comboBoxPierside.SelectedIndex switch diff --git a/src/BreCalClient/Resources/Resources.Designer.cs b/src/BreCalClient/Resources/Resources.Designer.cs index 492ef15..aeada56 100644 --- a/src/BreCalClient/Resources/Resources.Designer.cs +++ b/src/BreCalClient/Resources/Resources.Designer.cs @@ -389,6 +389,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Both tide times are required. + /// + public static string textBothTideTimesNecessary { + get { + return ResourceManager.GetString("textBothTideTimesNecessary", resourceCulture); + } + } + /// /// Looks up a localized string similar to BSMD right to edit granted. /// @@ -623,6 +632,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Some interval end times are before start times. + /// + public static string textEndValueBeforeStartValue { + get { + return ResourceManager.GetString("textEndValueBeforeStartValue", resourceCulture); + } + } + /// /// Looks up a localized string similar to Ship / remark. /// @@ -632,6 +650,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Error. + /// + public static string textError { + get { + return ResourceManager.GetString("textError", resourceCulture); + } + } + /// /// Looks up a localized string similar to ETA berth. /// @@ -641,6 +668,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to ETA value is in the past. + /// + public static string textETAInThePast { + get { + return ResourceManager.GetString("textETAInThePast", resourceCulture); + } + } + /// /// Looks up a localized string similar to ETD berth. /// @@ -650,6 +686,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to ETD value is in the past. + /// + public static string textETDInThePast { + get { + return ResourceManager.GetString("textETDInThePast", resourceCulture); + } + } + /// /// Looks up a localized string similar to Exit. /// @@ -740,6 +785,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Lock time is in the past. + /// + public static string textLockTimeInThePast { + get { + return ResourceManager.GetString("textLockTimeInThePast", resourceCulture); + } + } + /// /// Looks up a localized string similar to Login. /// @@ -830,6 +884,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Operation end is in the past. + /// + public static string textOperationEndInThePast { + get { + return ResourceManager.GetString("textOperationEndInThePast", resourceCulture); + } + } + /// /// Looks up a localized string similar to Operations end. /// @@ -848,6 +911,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Operation start is in the past. + /// + public static string textOperationStartInThePast { + get { + return ResourceManager.GetString("textOperationStartInThePast", resourceCulture); + } + } + /// /// Looks up a localized string similar to Outgoing. /// @@ -1145,6 +1217,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Times for the tide window are in the past. + /// + public static string textTideTimesInThePast { + get { + return ResourceManager.GetString("textTideTimesInThePast", resourceCulture); + } + } + /// /// Looks up a localized string similar to Timestamp. /// @@ -1262,6 +1343,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Warning. + /// + public static string textWarning { + get { + return ResourceManager.GetString("textWarning", resourceCulture); + } + } + /// /// Looks up a localized string similar to Width. /// @@ -1280,6 +1370,15 @@ namespace BreCalClient.Resources { } } + /// + /// Looks up a localized string similar to Zone entry time is in the past. + /// + public static string textZoneEntryInThePast { + get { + return ResourceManager.GetString("textZoneEntryInThePast", resourceCulture); + } + } + /// /// Looks up a localized string similar to Zone entry. /// diff --git a/src/BreCalClient/Resources/Resources.de.resx b/src/BreCalClient/Resources/Resources.de.resx index a681ad9..18947eb 100644 --- a/src/BreCalClient/Resources/Resources.de.resx +++ b/src/BreCalClient/Resources/Resources.de.resx @@ -508,4 +508,37 @@ Alle Eintragungen zurücksetzen? + + Beide Tidenzeiten sollten angegeben werden (von - bis) + + + Endzeit liegt vor Startzeit + + + Error + + + Zeitpunkt ETA liegt in der Vergangenheit + + + Zeitpunkt ETD liegt in der Vergangenheit + + + Schleusenzeit liegt in der Vergangenheit + + + Operation Endzeit liegt in der Vergangenheit + + + Operation Startzeit liegt in der Vergangenheit + + + Tidenzeit liegt in der Vergangenheit + + + Warnung + + + Zeit Reviereintritt liegt in der Vergangenheit + \ No newline at end of file diff --git a/src/BreCalClient/Resources/Resources.resx b/src/BreCalClient/Resources/Resources.resx index 1cf2a78..14cf0f9 100644 --- a/src/BreCalClient/Resources/Resources.resx +++ b/src/BreCalClient/Resources/Resources.resx @@ -214,6 +214,9 @@ Berths + + Both tide times are required + BSMD right to edit granted @@ -292,15 +295,27 @@ E-mail + + Some interval end times are before start times + Ship / remark + + Error + ETA berth + + ETA value is in the past + ETD berth + + ETD value is in the past + Exit @@ -331,6 +346,9 @@ Lock time + + Lock time is in the past + Login @@ -361,12 +379,18 @@ Operation + + Operation end is in the past + Operations end Operations start + + Operation start is in the past + Outgoing @@ -466,6 +490,9 @@ Tidal window + + Times for the tide window are in the past + Timestamp @@ -505,12 +532,18 @@ Voyage + + Warning + Width Wrong username or password + + Zone entry time is in the past + Zone entry From c375b9f55330990aea6acafcc7f441ccd22c97f0 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Tue, 10 Sep 2024 12:59:39 +0200 Subject: [PATCH 22/38] Adding proper result structure to error return message --- misc/BreCalApi.cs | 1870 ++++++------------------------------------- misc/BreCalApi.yaml | 13 +- 2 files changed, 252 insertions(+), 1631 deletions(-) diff --git a/misc/BreCalApi.cs b/misc/BreCalApi.cs index aab99e4..cd59c45 100644 --- a/misc/BreCalApi.cs +++ b/misc/BreCalApi.cs @@ -1,14 +1,15 @@ //---------------------- // -// Generated REST API Client Code Generator v1.9.8.0 on 30.08.2024 11:13:19 -// Using the tool OpenAPI Generator v7.4.0 +// Generated REST API Client Code Generator v1.11.0.0 on 10.09.2024 11:10:02 +// Using the tool OpenAPI Generator v7.8.0 // //---------------------- using BreCalClient.misc.Client; using BreCalClient.misc.Model; +using FileIO = System.IO.File; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; @@ -39,7 +40,6 @@ using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; -using System.Web; /* * Bremen calling API @@ -164,7 +164,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - System.Threading.Tasks.Task ShipDeleteAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task ShipDeleteAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Delete a ship (logically). /// @@ -176,7 +176,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - System.Threading.Tasks.Task> ShipDeleteWithHttpInfoAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task> ShipDeleteWithHttpInfoAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Update a ship entry /// @@ -188,7 +188,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - System.Threading.Tasks.Task ShipUpdateAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task ShipUpdateAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Update a ship entry /// @@ -200,7 +200,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - System.Threading.Tasks.Task> ShipUpdateWithHttpInfoAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task> ShipUpdateWithHttpInfoAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// create a new ship entry /// @@ -212,7 +212,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - System.Threading.Tasks.Task ShipsCreateAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task ShipsCreateAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// create a new ship entry /// @@ -224,7 +224,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - System.Threading.Tasks.Task> ShipsCreateWithHttpInfoAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task> ShipsCreateWithHttpInfoAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// gets a list of ships /// @@ -235,7 +235,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Ship> - System.Threading.Tasks.Task> ShipsGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task> ShipsGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// gets a list of ships /// @@ -246,7 +246,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Ship>) - System.Threading.Tasks.Task>> ShipsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task>> ShipsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); #endregion Asynchronous Operations } /// @@ -418,7 +418,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - public async System.Threading.Tasks.Task ShipDeleteAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task ShipDeleteAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await ShipDeleteWithHttpInfoAsync(id, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -431,7 +431,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - public async System.Threading.Tasks.Task> ShipDeleteWithHttpInfoAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> ShipDeleteWithHttpInfoAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -542,7 +542,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - public async System.Threading.Tasks.Task ShipUpdateAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task ShipUpdateAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await ShipUpdateWithHttpInfoAsync(ship, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -555,7 +555,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - public async System.Threading.Tasks.Task> ShipUpdateWithHttpInfoAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> ShipUpdateWithHttpInfoAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { // verify the required parameter 'ship' is set if (ship == null) @@ -672,7 +672,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - public async System.Threading.Tasks.Task ShipsCreateAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task ShipsCreateAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await ShipsCreateWithHttpInfoAsync(ship, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -685,7 +685,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - public async System.Threading.Tasks.Task> ShipsCreateWithHttpInfoAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> ShipsCreateWithHttpInfoAsync(Ship ship, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { // verify the required parameter 'ship' is set if (ship == null) @@ -792,7 +792,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Ship> - public async System.Threading.Tasks.Task> ShipsGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> ShipsGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse> localVarResponse = await ShipsGetWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -804,7 +804,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Ship>) - public async System.Threading.Tasks.Task>> ShipsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task>> ShipsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -947,7 +947,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - System.Threading.Tasks.Task ShipcallCreateAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task ShipcallCreateAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Create a new ship call /// @@ -959,7 +959,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - System.Threading.Tasks.Task> ShipcallCreateWithHttpInfoAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task> ShipcallCreateWithHttpInfoAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Updates a ship call /// @@ -971,7 +971,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - System.Threading.Tasks.Task ShipcallUpdateAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task ShipcallUpdateAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Updates a ship call /// @@ -983,7 +983,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - System.Threading.Tasks.Task> ShipcallUpdateWithHttpInfoAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task> ShipcallUpdateWithHttpInfoAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Gets a list of ship calls /// @@ -995,7 +995,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Shipcall> - System.Threading.Tasks.Task> ShipcallsGetAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task> ShipcallsGetAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Gets a list of ship calls /// @@ -1007,7 +1007,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Shipcall>) - System.Threading.Tasks.Task>> ShipcallsGetWithHttpInfoAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task>> ShipcallsGetWithHttpInfoAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); #endregion Asynchronous Operations } /// @@ -1185,7 +1185,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - public async System.Threading.Tasks.Task ShipcallCreateAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task ShipcallCreateAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await ShipcallCreateWithHttpInfoAsync(shipcall, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -1198,7 +1198,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - public async System.Threading.Tasks.Task> ShipcallCreateWithHttpInfoAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> ShipcallCreateWithHttpInfoAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { // verify the required parameter 'shipcall' is set if (shipcall == null) @@ -1315,7 +1315,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - public async System.Threading.Tasks.Task ShipcallUpdateAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task ShipcallUpdateAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await ShipcallUpdateWithHttpInfoAsync(shipcall, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -1328,7 +1328,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - public async System.Threading.Tasks.Task> ShipcallUpdateWithHttpInfoAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> ShipcallUpdateWithHttpInfoAsync(Shipcall shipcall, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { // verify the required parameter 'shipcall' is set if (shipcall == null) @@ -1442,7 +1442,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Shipcall> - public async System.Threading.Tasks.Task> ShipcallsGetAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> ShipcallsGetAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse> localVarResponse = await ShipcallsGetWithHttpInfoAsync(pastDays, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -1455,7 +1455,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Shipcall>) - public async System.Threading.Tasks.Task>> ShipcallsGetWithHttpInfoAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task>> ShipcallsGetWithHttpInfoAsync(int? pastDays = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -1621,7 +1621,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Berth> - System.Threading.Tasks.Task> BerthsGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task> BerthsGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Gets a list of all berths registered /// @@ -1632,7 +1632,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Berth>) - System.Threading.Tasks.Task>> BerthsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task>> BerthsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// History data /// @@ -1644,7 +1644,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<History> - System.Threading.Tasks.Task> HistoryGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task> HistoryGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// History data /// @@ -1656,7 +1656,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<History>) - System.Threading.Tasks.Task>> HistoryGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task>> HistoryGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Gets a list of notifications pursuant to a specified participant and ship call /// @@ -1668,7 +1668,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Notification - System.Threading.Tasks.Task NotificationsGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task NotificationsGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Gets a list of notifications pursuant to a specified participant and ship call /// @@ -1680,7 +1680,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Notification) - System.Threading.Tasks.Task> NotificationsGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task> NotificationsGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// gets one or all participants /// @@ -1692,7 +1692,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Participant> - System.Threading.Tasks.Task> ParticipantsGetAsync(int? userId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task> ParticipantsGetAsync(int? userId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// gets one or all participants /// @@ -1704,7 +1704,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Participant>) - System.Threading.Tasks.Task>> ParticipantsGetWithHttpInfoAsync(int? userId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task>> ParticipantsGetWithHttpInfoAsync(int? userId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); #endregion Asynchronous Operations } /// @@ -1872,7 +1872,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Berth> - public async System.Threading.Tasks.Task> BerthsGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> BerthsGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse> localVarResponse = await BerthsGetWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -1884,7 +1884,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Berth>) - public async System.Threading.Tasks.Task>> BerthsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task>> BerthsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -1988,7 +1988,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<History> - public async System.Threading.Tasks.Task> HistoryGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> HistoryGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse> localVarResponse = await HistoryGetWithHttpInfoAsync(shipcallId, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -2001,7 +2001,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<History>) - public async System.Threading.Tasks.Task>> HistoryGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task>> HistoryGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -2106,7 +2106,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Notification - public async System.Threading.Tasks.Task NotificationsGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task NotificationsGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await NotificationsGetWithHttpInfoAsync(shipcallId, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -2119,7 +2119,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Notification) - public async System.Threading.Tasks.Task> NotificationsGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> NotificationsGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -2227,7 +2227,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Participant> - public async System.Threading.Tasks.Task> ParticipantsGetAsync(int? userId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> ParticipantsGetAsync(int? userId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse> localVarResponse = await ParticipantsGetWithHttpInfoAsync(userId, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -2240,7 +2240,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Participant>) - public async System.Threading.Tasks.Task>> ParticipantsGetWithHttpInfoAsync(int? userId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task>> ParticipantsGetWithHttpInfoAsync(int? userId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -2409,7 +2409,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - System.Threading.Tasks.Task TimesCreateAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task TimesCreateAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Create a new times entry for a ship call /// @@ -2421,7 +2421,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - System.Threading.Tasks.Task> TimesCreateWithHttpInfoAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task> TimesCreateWithHttpInfoAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Delete a times entry for a ship call. /// @@ -2433,7 +2433,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - System.Threading.Tasks.Task TimesDeleteAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task TimesDeleteAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Delete a times entry for a ship call. /// @@ -2445,7 +2445,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - System.Threading.Tasks.Task> TimesDeleteWithHttpInfoAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task> TimesDeleteWithHttpInfoAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Gets list of times /// @@ -2457,7 +2457,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Times> - System.Threading.Tasks.Task> TimesGetAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task> TimesGetAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Gets list of times /// @@ -2469,7 +2469,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Times>) - System.Threading.Tasks.Task>> TimesGetWithHttpInfoAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task>> TimesGetWithHttpInfoAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Update a times entry for a ship call /// @@ -2481,7 +2481,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - System.Threading.Tasks.Task TimesUpdateAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task TimesUpdateAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Update a times entry for a ship call /// @@ -2493,7 +2493,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - System.Threading.Tasks.Task> TimesUpdateWithHttpInfoAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task> TimesUpdateWithHttpInfoAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); #endregion Asynchronous Operations } /// @@ -2671,7 +2671,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - public async System.Threading.Tasks.Task TimesCreateAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task TimesCreateAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await TimesCreateWithHttpInfoAsync(times, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -2684,7 +2684,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - public async System.Threading.Tasks.Task> TimesCreateWithHttpInfoAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> TimesCreateWithHttpInfoAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { // verify the required parameter 'times' is set if (times == null) @@ -2795,7 +2795,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - public async System.Threading.Tasks.Task TimesDeleteAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task TimesDeleteAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await TimesDeleteWithHttpInfoAsync(id, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -2808,7 +2808,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - public async System.Threading.Tasks.Task> TimesDeleteWithHttpInfoAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> TimesDeleteWithHttpInfoAsync(int id, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -2916,7 +2916,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Times> - public async System.Threading.Tasks.Task> TimesGetAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> TimesGetAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse> localVarResponse = await TimesGetWithHttpInfoAsync(shipcallId, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -2929,7 +2929,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Times>) - public async System.Threading.Tasks.Task>> TimesGetWithHttpInfoAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task>> TimesGetWithHttpInfoAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -3043,7 +3043,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - public async System.Threading.Tasks.Task TimesUpdateAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task TimesUpdateAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await TimesUpdateWithHttpInfoAsync(times, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -3056,7 +3056,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - public async System.Threading.Tasks.Task> TimesUpdateWithHttpInfoAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> TimesUpdateWithHttpInfoAsync(Times times, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { // verify the required parameter 'times' is set if (times == null) @@ -3184,7 +3184,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of LoginResult - System.Threading.Tasks.Task LoginAsync(Credentials credentials, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task LoginAsync(Credentials credentials, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Returns a JWT session token and user data if successful /// @@ -3196,7 +3196,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (LoginResult) - System.Threading.Tasks.Task> LoginWithHttpInfoAsync(Credentials credentials, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task> LoginWithHttpInfoAsync(Credentials credentials, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Update user details (first/last name, phone, password) /// @@ -3208,7 +3208,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - System.Threading.Tasks.Task UserUpdateAsync(UserDetails userDetails, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task UserUpdateAsync(UserDetails userDetails, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Update user details (first/last name, phone, password) /// @@ -3220,7 +3220,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - System.Threading.Tasks.Task> UserUpdateWithHttpInfoAsync(UserDetails userDetails, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task> UserUpdateWithHttpInfoAsync(UserDetails userDetails, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); #endregion Asynchronous Operations } /// @@ -3398,7 +3398,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of LoginResult - public async System.Threading.Tasks.Task LoginAsync(Credentials credentials, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task LoginAsync(Credentials credentials, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await LoginWithHttpInfoAsync(credentials, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -3411,7 +3411,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (LoginResult) - public async System.Threading.Tasks.Task> LoginWithHttpInfoAsync(Credentials credentials, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> LoginWithHttpInfoAsync(Credentials credentials, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { // verify the required parameter 'credentials' is set if (credentials == null) @@ -3528,7 +3528,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Id - public async System.Threading.Tasks.Task UserUpdateAsync(UserDetails userDetails, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task UserUpdateAsync(UserDetails userDetails, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse localVarResponse = await UserUpdateWithHttpInfoAsync(userDetails, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -3541,7 +3541,7 @@ namespace BreCalClient.misc.Api /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Id) - public async System.Threading.Tasks.Task> UserUpdateWithHttpInfoAsync(UserDetails userDetails, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> UserUpdateWithHttpInfoAsync(UserDetails userDetails, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { // verify the required parameter 'userDetails' is set if (userDetails == null) @@ -3634,10 +3634,10 @@ namespace BreCalClient.misc.Client /// A JSON string. public string Serialize(object obj) { - if (obj != null && obj is BreCalClient.misc.Model.AbstractOpenAPISchema) + if (obj != null && obj is AbstractOpenAPISchema) { // the object to be serialized is an oneOf/anyOf schema - return ((BreCalClient.misc.Model.AbstractOpenAPISchema)obj).ToJson(); + return ((AbstractOpenAPISchema)obj).ToJson(); } else { @@ -3678,7 +3678,7 @@ namespace BreCalClient.misc.Client if (match.Success) { string fileName = filePath + ClientUtils.SanitizeFilename(match.Groups[1].Value.Replace("\"", "").Replace("'", "")); - File.WriteAllBytes(fileName, bytes); + FileIO.WriteAllBytes(fileName, bytes); return new FileStream(fileName, FileMode.Open); } } @@ -3688,7 +3688,7 @@ namespace BreCalClient.misc.Client } if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object { - return DateTime.Parse(response.Content, null, System.Globalization.DateTimeStyles.RoundtripKind); + return DateTime.Parse(response.Content, null, DateTimeStyles.RoundtripKind); } if (type == typeof(string) || type.Name.StartsWith("System.Nullable")) // return primitive type { @@ -3706,11 +3706,11 @@ namespace BreCalClient.misc.Client } public ISerializer Serializer => this; public IDeserializer Deserializer => this; - public string[] AcceptedContentTypes => RestSharp.ContentType.JsonAccept; + public string[] AcceptedContentTypes => ContentType.JsonAccept; public SupportsContentType SupportsContentType => contentType => contentType.Value.EndsWith("json", StringComparison.InvariantCultureIgnoreCase) || contentType.Value.EndsWith("javascript", StringComparison.InvariantCultureIgnoreCase); - public ContentType ContentType { get; set; } = RestSharp.ContentType.Json; + public ContentType ContentType { get; set; } = ContentType.Json; public DataFormat DataFormat => DataFormat.Json; } /// @@ -3752,7 +3752,7 @@ namespace BreCalClient.misc.Client /// public ApiClient() { - _baseUrl = BreCalClient.misc.Client.GlobalConfiguration.Instance.BasePath; + _baseUrl = GlobalConfiguration.Instance.BasePath; } /// /// Initializes a new instance of the @@ -3804,14 +3804,14 @@ namespace BreCalClient.misc.Client } /// /// Provides all logic for constructing a new RestSharp . - /// At this point, all information for querying the service is known. Here, it is simply - /// mapped into the RestSharp request. + /// At this point, all information for querying the service is known. + /// Here, it is simply mapped into the RestSharp request. /// /// The http verb. /// The target path (or resource). /// The additional request options. - /// A per-request configuration object. It is assumed that any merge with - /// GlobalConfiguration has been done before calling this method. + /// A per-request configuration object. + /// It is assumed that any merge with GlobalConfiguration has been done before calling this method. /// [private] A new RestRequest instance. /// private RestRequest NewRequest( @@ -3909,7 +3909,7 @@ namespace BreCalClient.misc.Client var bytes = ClientUtils.ReadAsBytes(file); var fileStream = file as FileStream; if (fileStream != null) - request.AddFile(fileParam.Key, bytes, System.IO.Path.GetFileName(fileStream.Name)); + request.AddFile(fileParam.Key, bytes, Path.GetFileName(fileStream.Name)); else request.AddFile(fileParam.Key, bytes, "no_file_name_provided"); } @@ -3917,6 +3917,13 @@ namespace BreCalClient.misc.Client } return request; } + /// + /// Transforms a RestResponse instance into a new ApiResponse instance. + /// At this point, we have a concrete http response from the service. + /// Here, it is simply mapped into the [public] ApiResponse object. + /// + /// The RestSharp response object + /// A new ApiResponse instance. private ApiResponse ToApiResponse(RestResponse response) { T result = response.Data; @@ -3955,51 +3962,41 @@ namespace BreCalClient.misc.Client } return transformed; } - private ApiResponse Exec(RestRequest request, RequestOptions options, IReadableConfiguration configuration) + /// + /// Executes the HTTP request for the current service. + /// Based on functions received it can be async or sync. + /// + /// Local function that executes http request and returns http response. + /// Local function to specify options for the service. + /// The RestSharp request object + /// The RestSharp options object + /// A per-request configuration object. + /// It is assumed that any merge with GlobalConfiguration has been done before calling this method. + /// A new ApiResponse instance. + private async Task> ExecClientAsync(Func>> getResponse, Action setOptions, RestRequest request, RequestOptions options, IReadableConfiguration configuration) { var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl; - var cookies = new CookieContainer(); - if (options.Cookies != null && options.Cookies.Count > 0) - { - foreach (var cookie in options.Cookies) - { - cookies.Add(new Cookie(cookie.Name, cookie.Value)); - } - } var clientOptions = new RestClientOptions(baseUrl) { ClientCertificates = configuration.ClientCertificates, - CookieContainer = cookies, MaxTimeout = configuration.Timeout, Proxy = configuration.Proxy, UserAgent = configuration.UserAgent, UseDefaultCredentials = configuration.UseDefaultCredentials, RemoteCertificateValidationCallback = configuration.RemoteCertificateValidationCallback }; + setOptions(clientOptions); using (RestClient client = new RestClient(clientOptions, configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(SerializerSettings, configuration)))) { InterceptRequest(request); - RestResponse response; - if (RetryConfiguration.RetryPolicy != null) - { - var policy = RetryConfiguration.RetryPolicy; - var policyResult = policy.ExecuteAndCapture(() => client.Execute(request)); - response = (policyResult.Outcome == OutcomeType.Successful) ? client.Deserialize(policyResult.Result) : new RestResponse(request) - { - ErrorException = policyResult.FinalException - }; - } - else - { - response = client.Execute(request); - } + RestResponse response = await getResponse(client); // if the response type is oneOf/anyOf, call FromJSON to deserialize the data - if (typeof(BreCalClient.misc.Model.AbstractOpenAPISchema).IsAssignableFrom(typeof(T))) + if (typeof(AbstractOpenAPISchema).IsAssignableFrom(typeof(T))) { try { - response.Data = (T) typeof(T).GetMethod("FromJson").Invoke(null, new object[] { response.Content }); + response.Data = (T)typeof(T).GetMethod("FromJson").Invoke(null, new object[] { response.Content }); } catch (Exception ex) { @@ -4052,82 +4049,69 @@ namespace BreCalClient.misc.Client return result; } } - private async Task> ExecAsync(RestRequest request, RequestOptions options, IReadableConfiguration configuration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + private RestResponse DeserializeRestResponseFromPolicy(RestClient client, RestRequest request, PolicyResult policyResult) { - var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl; - var clientOptions = new RestClientOptions(baseUrl) + if (policyResult.Outcome == OutcomeType.Successful) { - ClientCertificates = configuration.ClientCertificates, - MaxTimeout = configuration.Timeout, - Proxy = configuration.Proxy, - UserAgent = configuration.UserAgent, - UseDefaultCredentials = configuration.UseDefaultCredentials, - RemoteCertificateValidationCallback = configuration.RemoteCertificateValidationCallback + return client.Deserialize(policyResult.Result); + } + else + { + return new RestResponse(request) + { + ErrorException = policyResult.FinalException + }; + } + } + private ApiResponse Exec(RestRequest request, RequestOptions options, IReadableConfiguration configuration) + { + Action setOptions = (clientOptions) => + { + var cookies = new CookieContainer(); + if (options.Cookies != null && options.Cookies.Count > 0) + { + foreach (var cookie in options.Cookies) + { + cookies.Add(new Cookie(cookie.Name, cookie.Value)); + } + } + clientOptions.CookieContainer = cookies; }; - using (RestClient client = new RestClient(clientOptions, - configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(SerializerSettings, configuration)))) + Func>> getResponse = (client) => + { + if (RetryConfiguration.RetryPolicy != null) + { + var policy = RetryConfiguration.RetryPolicy; + var policyResult = policy.ExecuteAndCapture(() => client.Execute(request)); + return Task.FromResult(DeserializeRestResponseFromPolicy(client, request, policyResult)); + } + else + { + return Task.FromResult(client.Execute(request)); + } + }; + return ExecClientAsync(getResponse, setOptions, request, options, configuration).GetAwaiter().GetResult(); + } + private Task> ExecAsync(RestRequest request, RequestOptions options, IReadableConfiguration configuration, CancellationToken cancellationToken = default(CancellationToken)) + { + Action setOptions = (clientOptions) => + { + //no extra options + }; + Func>> getResponse = async (client) => { - InterceptRequest(request); - RestResponse response; if (RetryConfiguration.AsyncRetryPolicy != null) { var policy = RetryConfiguration.AsyncRetryPolicy; var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false); - response = (policyResult.Outcome == OutcomeType.Successful) ? client.Deserialize(policyResult.Result) : new RestResponse(request) - { - ErrorException = policyResult.FinalException - }; + return DeserializeRestResponseFromPolicy(client, request, policyResult); } else { - response = await client.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); + return await client.ExecuteAsync(request, cancellationToken).ConfigureAwait(false); } - // if the response type is oneOf/anyOf, call FromJSON to deserialize the data - if (typeof(BreCalClient.misc.Model.AbstractOpenAPISchema).IsAssignableFrom(typeof(T))) - { - response.Data = (T) typeof(T).GetMethod("FromJson").Invoke(null, new object[] { response.Content }); - } - else if (typeof(T).Name == "Stream") // for binary response - { - response.Data = (T)(object)new MemoryStream(response.RawBytes); - } - else if (typeof(T).Name == "Byte[]") // for byte response - { - response.Data = (T)(object)response.RawBytes; - } - InterceptResponse(request, response); - var result = ToApiResponse(response); - if (response.ErrorMessage != null) - { - result.ErrorText = response.ErrorMessage; - } - if (response.Cookies != null && response.Cookies.Count > 0) - { - if (result.Cookies == null) result.Cookies = new List(); - foreach (var restResponseCookie in response.Cookies.Cast()) - { - var cookie = new Cookie( - restResponseCookie.Name, - restResponseCookie.Value, - restResponseCookie.Path, - restResponseCookie.Domain - ) - { - Comment = restResponseCookie.Comment, - CommentUri = restResponseCookie.CommentUri, - Discard = restResponseCookie.Discard, - Expired = restResponseCookie.Expired, - Expires = restResponseCookie.Expires, - HttpOnly = restResponseCookie.HttpOnly, - Port = restResponseCookie.Port, - Secure = restResponseCookie.Secure, - Version = restResponseCookie.Version - }; - result.Cookies.Add(cookie); - } - } - return result; - } + }; + return ExecClientAsync(getResponse, setOptions, request, options, configuration); } #region IAsynchronousClient /// @@ -4139,7 +4123,7 @@ namespace BreCalClient.misc.Client /// GlobalConfiguration has been done before calling this method. /// Token that enables callers to cancel the request. /// A Task containing ApiResponse - public Task> GetAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public Task> GetAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default) { var config = configuration ?? GlobalConfiguration.Instance; return ExecAsync(NewRequest(HttpMethod.Get, path, options, config), options, config, cancellationToken); @@ -4153,7 +4137,7 @@ namespace BreCalClient.misc.Client /// GlobalConfiguration has been done before calling this method. /// Token that enables callers to cancel the request. /// A Task containing ApiResponse - public Task> PostAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public Task> PostAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default) { var config = configuration ?? GlobalConfiguration.Instance; return ExecAsync(NewRequest(HttpMethod.Post, path, options, config), options, config, cancellationToken); @@ -4167,7 +4151,7 @@ namespace BreCalClient.misc.Client /// GlobalConfiguration has been done before calling this method. /// Token that enables callers to cancel the request. /// A Task containing ApiResponse - public Task> PutAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public Task> PutAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default) { var config = configuration ?? GlobalConfiguration.Instance; return ExecAsync(NewRequest(HttpMethod.Put, path, options, config), options, config, cancellationToken); @@ -4181,7 +4165,7 @@ namespace BreCalClient.misc.Client /// GlobalConfiguration has been done before calling this method. /// Token that enables callers to cancel the request. /// A Task containing ApiResponse - public Task> DeleteAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public Task> DeleteAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default) { var config = configuration ?? GlobalConfiguration.Instance; return ExecAsync(NewRequest(HttpMethod.Delete, path, options, config), options, config, cancellationToken); @@ -4195,7 +4179,7 @@ namespace BreCalClient.misc.Client /// GlobalConfiguration has been done before calling this method. /// Token that enables callers to cancel the request. /// A Task containing ApiResponse - public Task> HeadAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public Task> HeadAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default) { var config = configuration ?? GlobalConfiguration.Instance; return ExecAsync(NewRequest(HttpMethod.Head, path, options, config), options, config, cancellationToken); @@ -4209,7 +4193,7 @@ namespace BreCalClient.misc.Client /// GlobalConfiguration has been done before calling this method. /// Token that enables callers to cancel the request. /// A Task containing ApiResponse - public Task> OptionsAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public Task> OptionsAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default) { var config = configuration ?? GlobalConfiguration.Instance; return ExecAsync(NewRequest(HttpMethod.Options, path, options, config), options, config, cancellationToken); @@ -4223,7 +4207,7 @@ namespace BreCalClient.misc.Client /// GlobalConfiguration has been done before calling this method. /// Token that enables callers to cancel the request. /// A Task containing ApiResponse - public Task> PatchAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public Task> PatchAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, CancellationToken cancellationToken = default) { var config = configuration ?? GlobalConfiguration.Instance; return ExecAsync(NewRequest(HttpMethod.Patch, path, options, config), options, config, cancellationToken); @@ -4640,7 +4624,7 @@ namespace BreCalClient.misc.Client /// Encoded string. public static string Base64Encode(string text) { - return Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(text)); + return Convert.ToBase64String(global::System.Text.Encoding.UTF8.GetBytes(text)); } /// /// Convert stream to byte array @@ -4828,7 +4812,7 @@ namespace BreCalClient.misc.Client /// /// Initializes a new instance of the class /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "VirtualMemberCallInConstructor")] + [global::System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "VirtualMemberCallInConstructor")] public Configuration() { Proxy = null; @@ -4855,7 +4839,7 @@ namespace BreCalClient.misc.Client /// /// Initializes a new instance of the class /// - [System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "VirtualMemberCallInConstructor")] + [global::System.Diagnostics.CodeAnalysis.SuppressMessage("ReSharper", "VirtualMemberCallInConstructor")] public Configuration( IDictionary defaultHeaders, IDictionary apiKey, @@ -4889,7 +4873,7 @@ namespace BreCalClient.misc.Client /// /// Gets or sets the base path for API access. /// - public virtual string BasePath + public virtual string BasePath { get { return _basePath; } set { _basePath = value; } @@ -5441,7 +5425,7 @@ namespace BreCalClient.misc.Client /// Cancellation Token to cancel the request. /// The return type. /// A task eventually representing the response data, decorated with - Task> GetAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + Task> GetAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Executes a non-blocking call to some using the POST http verb. /// @@ -5451,7 +5435,7 @@ namespace BreCalClient.misc.Client /// Cancellation Token to cancel the request. /// The return type. /// A task eventually representing the response data, decorated with - Task> PostAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + Task> PostAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Executes a non-blocking call to some using the PUT http verb. /// @@ -5461,7 +5445,7 @@ namespace BreCalClient.misc.Client /// Cancellation Token to cancel the request. /// The return type. /// A task eventually representing the response data, decorated with - Task> PutAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + Task> PutAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Executes a non-blocking call to some using the DELETE http verb. /// @@ -5471,7 +5455,7 @@ namespace BreCalClient.misc.Client /// Cancellation Token to cancel the request. /// The return type. /// A task eventually representing the response data, decorated with - Task> DeleteAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + Task> DeleteAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Executes a non-blocking call to some using the HEAD http verb. /// @@ -5481,7 +5465,7 @@ namespace BreCalClient.misc.Client /// Cancellation Token to cancel the request. /// The return type. /// A task eventually representing the response data, decorated with - Task> HeadAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + Task> HeadAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Executes a non-blocking call to some using the OPTIONS http verb. /// @@ -5491,7 +5475,7 @@ namespace BreCalClient.misc.Client /// Cancellation Token to cancel the request. /// The return type. /// A task eventually representing the response data, decorated with - Task> OptionsAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + Task> OptionsAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Executes a non-blocking call to some using the PATCH http verb. /// @@ -5501,7 +5485,7 @@ namespace BreCalClient.misc.Client /// Cancellation Token to cancel the request. /// The return type. /// A task eventually representing the response data, decorated with - Task> PatchAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + Task> PatchAsync(string path, RequestOptions options, IReadableConfiguration configuration = null, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); } } @@ -6172,7 +6156,7 @@ namespace BreCalClient.misc.Model /// Ship berth used for a ship call /// [DataContract(Name = "berth")] - public partial class Berth : IEquatable, IValidatableObject + public partial class Berth : IValidatableObject { /// /// Initializes a new instance of the class. @@ -6191,7 +6175,7 @@ namespace BreCalClient.misc.Model this.Name = name; this.OwnerId = ownerId; this.AuthorityId = authorityId; - this.VarLock = varLock; + this.Lock = varLock; this.Created = created; this.Modified = modified; this.Deleted = deleted; @@ -6223,7 +6207,7 @@ namespace BreCalClient.misc.Model /// /// If true lock must be passed [DataMember(Name = "lock", EmitDefaultValue = true)] - public bool? VarLock { get; set; } + public bool? Lock { get; set; } /// /// Gets or Sets Created /// @@ -6251,7 +6235,7 @@ namespace BreCalClient.misc.Model sb.Append(" Name: ").Append(Name).Append("\n"); sb.Append(" OwnerId: ").Append(OwnerId).Append("\n"); sb.Append(" AuthorityId: ").Append(AuthorityId).Append("\n"); - sb.Append(" VarLock: ").Append(VarLock).Append("\n"); + sb.Append(" Lock: ").Append(Lock).Append("\n"); sb.Append(" Created: ").Append(Created).Append("\n"); sb.Append(" Modified: ").Append(Modified).Append("\n"); sb.Append(" Deleted: ").Append(Deleted).Append("\n"); @@ -6267,114 +6251,16 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as Berth); - } - /// - /// Returns true if Berth instances are equal - /// - /// Instance of Berth to be compared - /// Boolean - public bool Equals(Berth input) - { - if (input == null) - { - return false; - } - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ) && - ( - this.OwnerId == input.OwnerId || - (this.OwnerId != null && - this.OwnerId.Equals(input.OwnerId)) - ) && - ( - this.AuthorityId == input.AuthorityId || - (this.AuthorityId != null && - this.AuthorityId.Equals(input.AuthorityId)) - ) && - ( - this.VarLock == input.VarLock || - (this.VarLock != null && - this.VarLock.Equals(input.VarLock)) - ) && - ( - this.Created == input.Created || - (this.Created != null && - this.Created.Equals(input.Created)) - ) && - ( - this.Modified == input.Modified || - (this.Modified != null && - this.Modified.Equals(input.Modified)) - ) && - ( - this.Deleted == input.Deleted || - this.Deleted.Equals(input.Deleted) - ); - } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = (hashCode * 59) + this.Id.GetHashCode(); - if (this.Name != null) - { - hashCode = (hashCode * 59) + this.Name.GetHashCode(); - } - if (this.OwnerId != null) - { - hashCode = (hashCode * 59) + this.OwnerId.GetHashCode(); - } - if (this.AuthorityId != null) - { - hashCode = (hashCode * 59) + this.AuthorityId.GetHashCode(); - } - if (this.VarLock != null) - { - hashCode = (hashCode * 59) + this.VarLock.GetHashCode(); - } - if (this.Created != null) - { - hashCode = (hashCode * 59) + this.Created.GetHashCode(); - } - if (this.Modified != null) - { - hashCode = (hashCode * 59) + this.Modified.GetHashCode(); - } - hashCode = (hashCode * 59) + this.Deleted.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { // Name (string) maxLength if (this.Name != null && this.Name.Length > 128) { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Name, length must be less than 128.", new [] { "Name" }); + yield return new ValidationResult("Invalid value for Name, length must be less than 128.", new [] { "Name" }); } yield break; } @@ -6396,7 +6282,7 @@ namespace BreCalClient.misc.Model /// Credentials /// [DataContract(Name = "credentials")] - public partial class Credentials : IEquatable, IValidatableObject + public partial class Credentials : IValidatableObject { /// /// Initializes a new instance of the class. @@ -6455,63 +6341,11 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as Credentials); - } - /// - /// Returns true if Credentials instances are equal - /// - /// Instance of Credentials to be compared - /// Boolean - public bool Equals(Credentials input) - { - if (input == null) - { - return false; - } - return - ( - this.Username == input.Username || - (this.Username != null && - this.Username.Equals(input.Username)) - ) && - ( - this.Password == input.Password || - (this.Password != null && - this.Password.Equals(input.Password)) - ); - } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.Username != null) - { - hashCode = (hashCode * 59) + this.Username.GetHashCode(); - } - if (this.Password != null) - { - hashCode = (hashCode * 59) + this.Password.GetHashCode(); - } - return hashCode; - } - } - /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { yield break; } @@ -6530,10 +6364,10 @@ namespace BreCalClient.misc.Model namespace BreCalClient.misc.Model { /// - /// Error + /// Structure returned when invalid data (bad request) is created. /// [DataContract(Name = "Error")] - public partial class Error : IEquatable, IValidatableObject + public partial class Error : IValidatableObject { /// /// Initializes a new instance of the class. @@ -6544,7 +6378,9 @@ namespace BreCalClient.misc.Model /// Initializes a new instance of the class. /// /// A human readable error message (required). - public Error(string message = default(string)) + /// A list of errors. + /// A dictionary of valid data. + public Error(string message = default(string), List errors = default(List), Object validData = default(Object)) { // to ensure "message" is required (not null) if (message == null) @@ -6552,6 +6388,8 @@ namespace BreCalClient.misc.Model throw new ArgumentNullException("message is a required property for Error and cannot be null"); } this.Message = message; + this.Errors = errors; + this.ValidData = validData; } /// /// A human readable error message @@ -6560,6 +6398,18 @@ namespace BreCalClient.misc.Model [DataMember(Name = "message", IsRequired = true, EmitDefaultValue = true)] public string Message { get; set; } /// + /// A list of errors + /// + /// A list of errors + [DataMember(Name = "errors", EmitDefaultValue = true)] + public List Errors { get; set; } + /// + /// A dictionary of valid data + /// + /// A dictionary of valid data + [DataMember(Name = "valid_data", EmitDefaultValue = true)] + public Object ValidData { get; set; } + /// /// Returns the string presentation of the object /// /// String presentation of the object @@ -6568,6 +6418,8 @@ namespace BreCalClient.misc.Model StringBuilder sb = new StringBuilder(); sb.Append("class Error {\n"); sb.Append(" Message: ").Append(Message).Append("\n"); + sb.Append(" Errors: ").Append(Errors).Append("\n"); + sb.Append(" ValidData: ").Append(ValidData).Append("\n"); sb.Append("}\n"); return sb.ToString(); } @@ -6580,54 +6432,11 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as Error); - } - /// - /// Returns true if Error instances are equal - /// - /// Instance of Error to be compared - /// Boolean - public bool Equals(Error input) - { - if (input == null) - { - return false; - } - return - ( - this.Message == input.Message || - (this.Message != null && - this.Message.Equals(input.Message)) - ); - } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - if (this.Message != null) - { - hashCode = (hashCode * 59) + this.Message.GetHashCode(); - } - return hashCode; - } - } - /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { yield break; } @@ -6689,7 +6498,7 @@ namespace BreCalClient.misc.Model /// Single history entry with references /// [DataContract(Name = "history")] - public partial class History : IEquatable, IValidatableObject + public partial class History : IValidatableObject { /// /// Gets or Sets Operation @@ -6773,88 +6582,11 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as History); - } - /// - /// Returns true if History instances are equal - /// - /// Instance of History to be compared - /// Boolean - public bool Equals(History input) - { - if (input == null) - { - return false; - } - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.ParticipantId == input.ParticipantId || - this.ParticipantId.Equals(input.ParticipantId) - ) && - ( - this.ShipcallId == input.ShipcallId || - this.ShipcallId.Equals(input.ShipcallId) - ) && - ( - this.Timestamp == input.Timestamp || - (this.Timestamp != null && - this.Timestamp.Equals(input.Timestamp)) - ) && - ( - this.Eta == input.Eta || - (this.Eta != null && - this.Eta.Equals(input.Eta)) - ) && - ( - this.Operation == input.Operation || - this.Operation.Equals(input.Operation) - ) && - ( - this.Type == input.Type || - this.Type.Equals(input.Type) - ); - } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = (hashCode * 59) + this.Id.GetHashCode(); - hashCode = (hashCode * 59) + this.ParticipantId.GetHashCode(); - hashCode = (hashCode * 59) + this.ShipcallId.GetHashCode(); - if (this.Timestamp != null) - { - hashCode = (hashCode * 59) + this.Timestamp.GetHashCode(); - } - if (this.Eta != null) - { - hashCode = (hashCode * 59) + this.Eta.GetHashCode(); - } - hashCode = (hashCode * 59) + this.Operation.GetHashCode(); - hashCode = (hashCode * 59) + this.Type.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { yield break; } @@ -6876,7 +6608,7 @@ namespace BreCalClient.misc.Model /// A unique identifier for an entity /// [DataContract(Name = "Id")] - public partial class Id : IEquatable, IValidatableObject + public partial class Id : IValidatableObject { /// /// Initializes a new instance of the class. @@ -6912,50 +6644,11 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as Id); - } - /// - /// Returns true if Id instances are equal - /// - /// Instance of Id to be compared - /// Boolean - public bool Equals(Id input) - { - if (input == null) - { - return false; - } - return - ( - this.VarId == input.VarId || - this.VarId.Equals(input.VarId) - ); - } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = (hashCode * 59) + this.VarId.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { yield break; } @@ -6977,7 +6670,7 @@ namespace BreCalClient.misc.Model /// result structure of a successful login attempt /// [DataContract(Name = "login_result")] - public partial class LoginResult : IEquatable, IValidatableObject + public partial class LoginResult : IValidatableObject { /// /// Initializes a new instance of the class. @@ -7077,114 +6770,11 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as LoginResult); - } - /// - /// Returns true if LoginResult instances are equal - /// - /// Instance of LoginResult to be compared - /// Boolean - public bool Equals(LoginResult input) - { - if (input == null) - { - return false; - } - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.ParticipantId == input.ParticipantId || - this.ParticipantId.Equals(input.ParticipantId) - ) && - ( - this.FirstName == input.FirstName || - (this.FirstName != null && - this.FirstName.Equals(input.FirstName)) - ) && - ( - this.LastName == input.LastName || - (this.LastName != null && - this.LastName.Equals(input.LastName)) - ) && - ( - this.UserName == input.UserName || - (this.UserName != null && - this.UserName.Equals(input.UserName)) - ) && - ( - this.UserPhone == input.UserPhone || - (this.UserPhone != null && - this.UserPhone.Equals(input.UserPhone)) - ) && - ( - this.UserEmail == input.UserEmail || - (this.UserEmail != null && - this.UserEmail.Equals(input.UserEmail)) - ) && - ( - this.Exp == input.Exp || - this.Exp.Equals(input.Exp) - ) && - ( - this.Token == input.Token || - (this.Token != null && - this.Token.Equals(input.Token)) - ); - } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = (hashCode * 59) + this.Id.GetHashCode(); - hashCode = (hashCode * 59) + this.ParticipantId.GetHashCode(); - if (this.FirstName != null) - { - hashCode = (hashCode * 59) + this.FirstName.GetHashCode(); - } - if (this.LastName != null) - { - hashCode = (hashCode * 59) + this.LastName.GetHashCode(); - } - if (this.UserName != null) - { - hashCode = (hashCode * 59) + this.UserName.GetHashCode(); - } - if (this.UserPhone != null) - { - hashCode = (hashCode * 59) + this.UserPhone.GetHashCode(); - } - if (this.UserEmail != null) - { - hashCode = (hashCode * 59) + this.UserEmail.GetHashCode(); - } - hashCode = (hashCode * 59) + this.Exp.GetHashCode(); - if (this.Token != null) - { - hashCode = (hashCode * 59) + this.Token.GetHashCode(); - } - return hashCode; - } - } - /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { yield break; } @@ -7206,7 +6796,7 @@ namespace BreCalClient.misc.Model /// a notification created by the engine if a times entry violates a rule /// [DataContract(Name = "notification")] - public partial class Notification : IEquatable, IValidatableObject + public partial class Notification : IValidatableObject { /// /// Gets or Sets NotificationType @@ -7284,87 +6874,11 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as Notification); - } - /// - /// Returns true if Notification instances are equal - /// - /// Instance of Notification to be compared - /// Boolean - public bool Equals(Notification input) - { - if (input == null) - { - return false; - } - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.ShipcallId == input.ShipcallId || - this.ShipcallId.Equals(input.ShipcallId) - ) && - ( - this.NotificationType == input.NotificationType || - this.NotificationType.Equals(input.NotificationType) - ) && - ( - this.Message == input.Message || - (this.Message != null && - this.Message.Equals(input.Message)) - ) && - ( - this.Created == input.Created || - (this.Created != null && - this.Created.Equals(input.Created)) - ) && - ( - this.Modified == input.Modified || - (this.Modified != null && - this.Modified.Equals(input.Modified)) - ); - } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = (hashCode * 59) + this.Id.GetHashCode(); - hashCode = (hashCode * 59) + this.ShipcallId.GetHashCode(); - hashCode = (hashCode * 59) + this.NotificationType.GetHashCode(); - if (this.Message != null) - { - hashCode = (hashCode * 59) + this.Message.GetHashCode(); - } - if (this.Created != null) - { - hashCode = (hashCode * 59) + this.Created.GetHashCode(); - } - if (this.Modified != null) - { - hashCode = (hashCode * 59) + this.Modified.GetHashCode(); - } - return hashCode; - } - } - /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { yield break; } @@ -7491,7 +7005,7 @@ namespace BreCalClient.misc.Model /// A organisational entity that participates in Bremen Calling /// [DataContract(Name = "participant")] - public partial class Participant : IEquatable, IValidatableObject + public partial class Participant : IValidatableObject { /// /// Initializes a new instance of the class. @@ -7602,143 +7116,31 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as Participant); - } - /// - /// Returns true if Participant instances are equal - /// - /// Instance of Participant to be compared - /// Boolean - public bool Equals(Participant input) - { - if (input == null) - { - return false; - } - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ) && - ( - this.Street == input.Street || - (this.Street != null && - this.Street.Equals(input.Street)) - ) && - ( - this.PostalCode == input.PostalCode || - (this.PostalCode != null && - this.PostalCode.Equals(input.PostalCode)) - ) && - ( - this.City == input.City || - (this.City != null && - this.City.Equals(input.City)) - ) && - ( - this.Type == input.Type || - this.Type.Equals(input.Type) - ) && - ( - this.Flags == input.Flags || - (this.Flags != null && - this.Flags.Equals(input.Flags)) - ) && - ( - this.Created == input.Created || - (this.Created != null && - this.Created.Equals(input.Created)) - ) && - ( - this.Modified == input.Modified || - (this.Modified != null && - this.Modified.Equals(input.Modified)) - ) && - ( - this.Deleted == input.Deleted || - this.Deleted.Equals(input.Deleted) - ); - } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = (hashCode * 59) + this.Id.GetHashCode(); - if (this.Name != null) - { - hashCode = (hashCode * 59) + this.Name.GetHashCode(); - } - if (this.Street != null) - { - hashCode = (hashCode * 59) + this.Street.GetHashCode(); - } - if (this.PostalCode != null) - { - hashCode = (hashCode * 59) + this.PostalCode.GetHashCode(); - } - if (this.City != null) - { - hashCode = (hashCode * 59) + this.City.GetHashCode(); - } - hashCode = (hashCode * 59) + this.Type.GetHashCode(); - if (this.Flags != null) - { - hashCode = (hashCode * 59) + this.Flags.GetHashCode(); - } - if (this.Created != null) - { - hashCode = (hashCode * 59) + this.Created.GetHashCode(); - } - if (this.Modified != null) - { - hashCode = (hashCode * 59) + this.Modified.GetHashCode(); - } - hashCode = (hashCode * 59) + this.Deleted.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { // Name (string) maxLength if (this.Name != null && this.Name.Length > 128) { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Name, length must be less than 128.", new [] { "Name" }); + yield return new ValidationResult("Invalid value for Name, length must be less than 128.", new [] { "Name" }); } // Street (string) maxLength if (this.Street != null && this.Street.Length > 128) { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Street, length must be less than 128.", new [] { "Street" }); + yield return new ValidationResult("Invalid value for Street, length must be less than 128.", new [] { "Street" }); } // PostalCode (string) maxLength if (this.PostalCode != null && this.PostalCode.Length > 5) { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for PostalCode, length must be less than 5.", new [] { "PostalCode" }); + yield return new ValidationResult("Invalid value for PostalCode, length must be less than 5.", new [] { "PostalCode" }); } // City (string) maxLength if (this.City != null && this.City.Length > 64) { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for City, length must be less than 64.", new [] { "City" }); + yield return new ValidationResult("Invalid value for City, length must be less than 64.", new [] { "City" }); } yield break; } @@ -7760,7 +7162,7 @@ namespace BreCalClient.misc.Model /// Participant assigned to a shipcall with a given role (type) /// [DataContract(Name = "participant_assignment")] - public partial class ParticipantAssignment : IEquatable, IValidatableObject + public partial class ParticipantAssignment : IValidatableObject { /// /// Initializes a new instance of the class. @@ -7810,55 +7212,11 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as ParticipantAssignment); - } - /// - /// Returns true if ParticipantAssignment instances are equal - /// - /// Instance of ParticipantAssignment to be compared - /// Boolean - public bool Equals(ParticipantAssignment input) - { - if (input == null) - { - return false; - } - return - ( - this.ParticipantId == input.ParticipantId || - this.ParticipantId.Equals(input.ParticipantId) - ) && - ( - this.Type == input.Type || - this.Type.Equals(input.Type) - ); - } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = (hashCode * 59) + this.ParticipantId.GetHashCode(); - hashCode = (hashCode * 59) + this.Type.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { yield break; } @@ -7880,7 +7238,7 @@ namespace BreCalClient.misc.Model /// a ship /// [DataContract(Name = "ship")] - public partial class Ship : IEquatable, IValidatableObject + public partial class Ship : IValidatableObject { /// /// Initializes a new instance of the class. @@ -8014,160 +7372,21 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as Ship); - } - /// - /// Returns true if Ship instances are equal - /// - /// Instance of Ship to be compared - /// Boolean - public bool Equals(Ship input) - { - if (input == null) - { - return false; - } - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.Name == input.Name || - (this.Name != null && - this.Name.Equals(input.Name)) - ) && - ( - this.Imo == input.Imo || - (this.Imo != null && - this.Imo.Equals(input.Imo)) - ) && - ( - this.Callsign == input.Callsign || - (this.Callsign != null && - this.Callsign.Equals(input.Callsign)) - ) && - ( - this.ParticipantId == input.ParticipantId || - (this.ParticipantId != null && - this.ParticipantId.Equals(input.ParticipantId)) - ) && - ( - this.Length == input.Length || - (this.Length != null && - this.Length.Equals(input.Length)) - ) && - ( - this.Width == input.Width || - (this.Width != null && - this.Width.Equals(input.Width)) - ) && - ( - this.IsTug == input.IsTug || - this.IsTug.Equals(input.IsTug) - ) && - ( - this.BollardPull == input.BollardPull || - (this.BollardPull != null && - this.BollardPull.Equals(input.BollardPull)) - ) && - ( - this.Eni == input.Eni || - (this.Eni != null && - this.Eni.Equals(input.Eni)) - ) && - ( - this.Created == input.Created || - (this.Created != null && - this.Created.Equals(input.Created)) - ) && - ( - this.Modified == input.Modified || - (this.Modified != null && - this.Modified.Equals(input.Modified)) - ) && - ( - this.Deleted == input.Deleted || - this.Deleted.Equals(input.Deleted) - ); - } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = (hashCode * 59) + this.Id.GetHashCode(); - if (this.Name != null) - { - hashCode = (hashCode * 59) + this.Name.GetHashCode(); - } - if (this.Imo != null) - { - hashCode = (hashCode * 59) + this.Imo.GetHashCode(); - } - if (this.Callsign != null) - { - hashCode = (hashCode * 59) + this.Callsign.GetHashCode(); - } - if (this.ParticipantId != null) - { - hashCode = (hashCode * 59) + this.ParticipantId.GetHashCode(); - } - if (this.Length != null) - { - hashCode = (hashCode * 59) + this.Length.GetHashCode(); - } - if (this.Width != null) - { - hashCode = (hashCode * 59) + this.Width.GetHashCode(); - } - hashCode = (hashCode * 59) + this.IsTug.GetHashCode(); - if (this.BollardPull != null) - { - hashCode = (hashCode * 59) + this.BollardPull.GetHashCode(); - } - if (this.Eni != null) - { - hashCode = (hashCode * 59) + this.Eni.GetHashCode(); - } - if (this.Created != null) - { - hashCode = (hashCode * 59) + this.Created.GetHashCode(); - } - if (this.Modified != null) - { - hashCode = (hashCode * 59) + this.Modified.GetHashCode(); - } - hashCode = (hashCode * 59) + this.Deleted.GetHashCode(); - return hashCode; - } - } - /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { // Name (string) maxLength if (this.Name != null && this.Name.Length > 64) { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Name, length must be less than 64.", new [] { "Name" }); + yield return new ValidationResult("Invalid value for Name, length must be less than 64.", new [] { "Name" }); } // Callsign (string) maxLength if (this.Callsign != null && this.Callsign.Length > 8) { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Callsign, length must be less than 8.", new [] { "Callsign" }); + yield return new ValidationResult("Invalid value for Callsign, length must be less than 8.", new [] { "Callsign" }); } yield break; } @@ -8189,7 +7408,7 @@ namespace BreCalClient.misc.Model /// Shipcall /// [DataContract(Name = "shipcall")] - public partial class Shipcall : IEquatable, IValidatableObject + public partial class Shipcall : IValidatableObject { /// /// Gets or Sets Type @@ -8468,301 +7687,21 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as Shipcall); - } - /// - /// Returns true if Shipcall instances are equal - /// - /// Instance of Shipcall to be compared - /// Boolean - public bool Equals(Shipcall input) - { - if (input == null) - { - return false; - } - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.ShipId == input.ShipId || - this.ShipId.Equals(input.ShipId) - ) && - ( - this.Type == input.Type || - this.Type.Equals(input.Type) - ) && - ( - this.Eta == input.Eta || - (this.Eta != null && - this.Eta.Equals(input.Eta)) - ) && - ( - this.Voyage == input.Voyage || - (this.Voyage != null && - this.Voyage.Equals(input.Voyage)) - ) && - ( - this.Etd == input.Etd || - (this.Etd != null && - this.Etd.Equals(input.Etd)) - ) && - ( - this.ArrivalBerthId == input.ArrivalBerthId || - (this.ArrivalBerthId != null && - this.ArrivalBerthId.Equals(input.ArrivalBerthId)) - ) && - ( - this.DepartureBerthId == input.DepartureBerthId || - (this.DepartureBerthId != null && - this.DepartureBerthId.Equals(input.DepartureBerthId)) - ) && - ( - this.TugRequired == input.TugRequired || - (this.TugRequired != null && - this.TugRequired.Equals(input.TugRequired)) - ) && - ( - this.PilotRequired == input.PilotRequired || - (this.PilotRequired != null && - this.PilotRequired.Equals(input.PilotRequired)) - ) && - ( - this.Flags == input.Flags || - (this.Flags != null && - this.Flags.Equals(input.Flags)) - ) && - ( - this.PierSide == input.PierSide || - (this.PierSide != null && - this.PierSide.Equals(input.PierSide)) - ) && - ( - this.Bunkering == input.Bunkering || - (this.Bunkering != null && - this.Bunkering.Equals(input.Bunkering)) - ) && - ( - this.ReplenishingTerminal == input.ReplenishingTerminal || - (this.ReplenishingTerminal != null && - this.ReplenishingTerminal.Equals(input.ReplenishingTerminal)) - ) && - ( - this.ReplenishingLock == input.ReplenishingLock || - (this.ReplenishingLock != null && - this.ReplenishingLock.Equals(input.ReplenishingLock)) - ) && - ( - this.Draft == input.Draft || - (this.Draft != null && - this.Draft.Equals(input.Draft)) - ) && - ( - this.TidalWindowFrom == input.TidalWindowFrom || - (this.TidalWindowFrom != null && - this.TidalWindowFrom.Equals(input.TidalWindowFrom)) - ) && - ( - this.TidalWindowTo == input.TidalWindowTo || - (this.TidalWindowTo != null && - this.TidalWindowTo.Equals(input.TidalWindowTo)) - ) && - ( - this.RainSensitiveCargo == input.RainSensitiveCargo || - (this.RainSensitiveCargo != null && - this.RainSensitiveCargo.Equals(input.RainSensitiveCargo)) - ) && - ( - this.RecommendedTugs == input.RecommendedTugs || - (this.RecommendedTugs != null && - this.RecommendedTugs.Equals(input.RecommendedTugs)) - ) && - ( - this.Anchored == input.Anchored || - (this.Anchored != null && - this.Anchored.Equals(input.Anchored)) - ) && - ( - this.MooredLock == input.MooredLock || - (this.MooredLock != null && - this.MooredLock.Equals(input.MooredLock)) - ) && - ( - this.Canceled == input.Canceled || - (this.Canceled != null && - this.Canceled.Equals(input.Canceled)) - ) && - ( - this.Evaluation == input.Evaluation || - this.Evaluation.Equals(input.Evaluation) - ) && - ( - this.EvaluationMessage == input.EvaluationMessage || - (this.EvaluationMessage != null && - this.EvaluationMessage.Equals(input.EvaluationMessage)) - ) && - ( - this.TimeRefPoint == input.TimeRefPoint || - (this.TimeRefPoint != null && - this.TimeRefPoint.Equals(input.TimeRefPoint)) - ) && - ( - this.Participants == input.Participants || - this.Participants != null && - input.Participants != null && - this.Participants.SequenceEqual(input.Participants) - ) && - ( - this.Created == input.Created || - (this.Created != null && - this.Created.Equals(input.Created)) - ) && - ( - this.Modified == input.Modified || - (this.Modified != null && - this.Modified.Equals(input.Modified)) - ); - } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = (hashCode * 59) + this.Id.GetHashCode(); - hashCode = (hashCode * 59) + this.ShipId.GetHashCode(); - hashCode = (hashCode * 59) + this.Type.GetHashCode(); - if (this.Eta != null) - { - hashCode = (hashCode * 59) + this.Eta.GetHashCode(); - } - if (this.Voyage != null) - { - hashCode = (hashCode * 59) + this.Voyage.GetHashCode(); - } - if (this.Etd != null) - { - hashCode = (hashCode * 59) + this.Etd.GetHashCode(); - } - if (this.ArrivalBerthId != null) - { - hashCode = (hashCode * 59) + this.ArrivalBerthId.GetHashCode(); - } - if (this.DepartureBerthId != null) - { - hashCode = (hashCode * 59) + this.DepartureBerthId.GetHashCode(); - } - if (this.TugRequired != null) - { - hashCode = (hashCode * 59) + this.TugRequired.GetHashCode(); - } - if (this.PilotRequired != null) - { - hashCode = (hashCode * 59) + this.PilotRequired.GetHashCode(); - } - if (this.Flags != null) - { - hashCode = (hashCode * 59) + this.Flags.GetHashCode(); - } - if (this.PierSide != null) - { - hashCode = (hashCode * 59) + this.PierSide.GetHashCode(); - } - if (this.Bunkering != null) - { - hashCode = (hashCode * 59) + this.Bunkering.GetHashCode(); - } - if (this.ReplenishingTerminal != null) - { - hashCode = (hashCode * 59) + this.ReplenishingTerminal.GetHashCode(); - } - if (this.ReplenishingLock != null) - { - hashCode = (hashCode * 59) + this.ReplenishingLock.GetHashCode(); - } - if (this.Draft != null) - { - hashCode = (hashCode * 59) + this.Draft.GetHashCode(); - } - if (this.TidalWindowFrom != null) - { - hashCode = (hashCode * 59) + this.TidalWindowFrom.GetHashCode(); - } - if (this.TidalWindowTo != null) - { - hashCode = (hashCode * 59) + this.TidalWindowTo.GetHashCode(); - } - if (this.RainSensitiveCargo != null) - { - hashCode = (hashCode * 59) + this.RainSensitiveCargo.GetHashCode(); - } - if (this.RecommendedTugs != null) - { - hashCode = (hashCode * 59) + this.RecommendedTugs.GetHashCode(); - } - if (this.Anchored != null) - { - hashCode = (hashCode * 59) + this.Anchored.GetHashCode(); - } - if (this.MooredLock != null) - { - hashCode = (hashCode * 59) + this.MooredLock.GetHashCode(); - } - if (this.Canceled != null) - { - hashCode = (hashCode * 59) + this.Canceled.GetHashCode(); - } - hashCode = (hashCode * 59) + this.Evaluation.GetHashCode(); - if (this.EvaluationMessage != null) - { - hashCode = (hashCode * 59) + this.EvaluationMessage.GetHashCode(); - } - if (this.TimeRefPoint != null) - { - hashCode = (hashCode * 59) + this.TimeRefPoint.GetHashCode(); - } - if (this.Participants != null) - { - hashCode = (hashCode * 59) + this.Participants.GetHashCode(); - } - if (this.Created != null) - { - hashCode = (hashCode * 59) + this.Created.GetHashCode(); - } - if (this.Modified != null) - { - hashCode = (hashCode * 59) + this.Modified.GetHashCode(); - } - return hashCode; - } - } - /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { // Voyage (string) maxLength if (this.Voyage != null && this.Voyage.Length > 16) { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Voyage, length must be less than 16.", new [] { "Voyage" }); + yield return new ValidationResult("Invalid value for Voyage, length must be less than 16.", new [] { "Voyage" }); } // EvaluationMessage (string) maxLength if (this.EvaluationMessage != null && this.EvaluationMessage.Length > 512) { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for EvaluationMessage, length must be less than 512.", new [] { "EvaluationMessage" }); + yield return new ValidationResult("Invalid value for EvaluationMessage, length must be less than 512.", new [] { "EvaluationMessage" }); } yield break; } @@ -8824,7 +7763,7 @@ namespace BreCalClient.misc.Model /// the id parameter needs to be missing on POST and to be present on PUT (Update) calls, otherwise a 400 response will be generated /// [DataContract(Name = "times")] - public partial class Times : IEquatable, IValidatableObject + public partial class Times : IValidatableObject { /// /// Initializes a new instance of the class. @@ -9070,255 +8009,21 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as Times); - } - /// - /// Returns true if Times instances are equal - /// - /// Instance of Times to be compared - /// Boolean - public bool Equals(Times input) - { - if (input == null) - { - return false; - } - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.EtaBerth == input.EtaBerth || - (this.EtaBerth != null && - this.EtaBerth.Equals(input.EtaBerth)) - ) && - ( - this.EtaBerthFixed == input.EtaBerthFixed || - (this.EtaBerthFixed != null && - this.EtaBerthFixed.Equals(input.EtaBerthFixed)) - ) && - ( - this.EtdBerth == input.EtdBerth || - (this.EtdBerth != null && - this.EtdBerth.Equals(input.EtdBerth)) - ) && - ( - this.EtdBerthFixed == input.EtdBerthFixed || - (this.EtdBerthFixed != null && - this.EtdBerthFixed.Equals(input.EtdBerthFixed)) - ) && - ( - this.LockTime == input.LockTime || - (this.LockTime != null && - this.LockTime.Equals(input.LockTime)) - ) && - ( - this.LockTimeFixed == input.LockTimeFixed || - (this.LockTimeFixed != null && - this.LockTimeFixed.Equals(input.LockTimeFixed)) - ) && - ( - this.ZoneEntry == input.ZoneEntry || - (this.ZoneEntry != null && - this.ZoneEntry.Equals(input.ZoneEntry)) - ) && - ( - this.ZoneEntryFixed == input.ZoneEntryFixed || - (this.ZoneEntryFixed != null && - this.ZoneEntryFixed.Equals(input.ZoneEntryFixed)) - ) && - ( - this.OperationsStart == input.OperationsStart || - (this.OperationsStart != null && - this.OperationsStart.Equals(input.OperationsStart)) - ) && - ( - this.OperationsEnd == input.OperationsEnd || - (this.OperationsEnd != null && - this.OperationsEnd.Equals(input.OperationsEnd)) - ) && - ( - this.Remarks == input.Remarks || - (this.Remarks != null && - this.Remarks.Equals(input.Remarks)) - ) && - ( - this.ShipcallId == input.ShipcallId || - this.ShipcallId.Equals(input.ShipcallId) - ) && - ( - this.ParticipantId == input.ParticipantId || - this.ParticipantId.Equals(input.ParticipantId) - ) && - ( - this.BerthId == input.BerthId || - (this.BerthId != null && - this.BerthId.Equals(input.BerthId)) - ) && - ( - this.BerthInfo == input.BerthInfo || - (this.BerthInfo != null && - this.BerthInfo.Equals(input.BerthInfo)) - ) && - ( - this.PierSide == input.PierSide || - (this.PierSide != null && - this.PierSide.Equals(input.PierSide)) - ) && - ( - this.ParticipantType == input.ParticipantType || - this.ParticipantType.Equals(input.ParticipantType) - ) && - ( - this.Ata == input.Ata || - (this.Ata != null && - this.Ata.Equals(input.Ata)) - ) && - ( - this.Atd == input.Atd || - (this.Atd != null && - this.Atd.Equals(input.Atd)) - ) && - ( - this.EtaIntervalEnd == input.EtaIntervalEnd || - (this.EtaIntervalEnd != null && - this.EtaIntervalEnd.Equals(input.EtaIntervalEnd)) - ) && - ( - this.EtdIntervalEnd == input.EtdIntervalEnd || - (this.EtdIntervalEnd != null && - this.EtdIntervalEnd.Equals(input.EtdIntervalEnd)) - ) && - ( - this.Created == input.Created || - (this.Created != null && - this.Created.Equals(input.Created)) - ) && - ( - this.Modified == input.Modified || - (this.Modified != null && - this.Modified.Equals(input.Modified)) - ); - } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = (hashCode * 59) + this.Id.GetHashCode(); - if (this.EtaBerth != null) - { - hashCode = (hashCode * 59) + this.EtaBerth.GetHashCode(); - } - if (this.EtaBerthFixed != null) - { - hashCode = (hashCode * 59) + this.EtaBerthFixed.GetHashCode(); - } - if (this.EtdBerth != null) - { - hashCode = (hashCode * 59) + this.EtdBerth.GetHashCode(); - } - if (this.EtdBerthFixed != null) - { - hashCode = (hashCode * 59) + this.EtdBerthFixed.GetHashCode(); - } - if (this.LockTime != null) - { - hashCode = (hashCode * 59) + this.LockTime.GetHashCode(); - } - if (this.LockTimeFixed != null) - { - hashCode = (hashCode * 59) + this.LockTimeFixed.GetHashCode(); - } - if (this.ZoneEntry != null) - { - hashCode = (hashCode * 59) + this.ZoneEntry.GetHashCode(); - } - if (this.ZoneEntryFixed != null) - { - hashCode = (hashCode * 59) + this.ZoneEntryFixed.GetHashCode(); - } - if (this.OperationsStart != null) - { - hashCode = (hashCode * 59) + this.OperationsStart.GetHashCode(); - } - if (this.OperationsEnd != null) - { - hashCode = (hashCode * 59) + this.OperationsEnd.GetHashCode(); - } - if (this.Remarks != null) - { - hashCode = (hashCode * 59) + this.Remarks.GetHashCode(); - } - hashCode = (hashCode * 59) + this.ShipcallId.GetHashCode(); - hashCode = (hashCode * 59) + this.ParticipantId.GetHashCode(); - if (this.BerthId != null) - { - hashCode = (hashCode * 59) + this.BerthId.GetHashCode(); - } - if (this.BerthInfo != null) - { - hashCode = (hashCode * 59) + this.BerthInfo.GetHashCode(); - } - if (this.PierSide != null) - { - hashCode = (hashCode * 59) + this.PierSide.GetHashCode(); - } - hashCode = (hashCode * 59) + this.ParticipantType.GetHashCode(); - if (this.Ata != null) - { - hashCode = (hashCode * 59) + this.Ata.GetHashCode(); - } - if (this.Atd != null) - { - hashCode = (hashCode * 59) + this.Atd.GetHashCode(); - } - if (this.EtaIntervalEnd != null) - { - hashCode = (hashCode * 59) + this.EtaIntervalEnd.GetHashCode(); - } - if (this.EtdIntervalEnd != null) - { - hashCode = (hashCode * 59) + this.EtdIntervalEnd.GetHashCode(); - } - if (this.Created != null) - { - hashCode = (hashCode * 59) + this.Created.GetHashCode(); - } - if (this.Modified != null) - { - hashCode = (hashCode * 59) + this.Modified.GetHashCode(); - } - return hashCode; - } - } - /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { // Remarks (string) maxLength if (this.Remarks != null && this.Remarks.Length > 512) { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for Remarks, length must be less than 512.", new [] { "Remarks" }); + yield return new ValidationResult("Invalid value for Remarks, length must be less than 512.", new [] { "Remarks" }); } // BerthInfo (string) maxLength if (this.BerthInfo != null && this.BerthInfo.Length > 512) { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for BerthInfo, length must be less than 512.", new [] { "BerthInfo" }); + yield return new ValidationResult("Invalid value for BerthInfo, length must be less than 512.", new [] { "BerthInfo" }); } yield break; } @@ -9340,7 +8045,7 @@ namespace BreCalClient.misc.Model /// fields that a user may change /// [DataContract(Name = "user_details")] - public partial class UserDetails : IEquatable, IValidatableObject + public partial class UserDetails : IValidatableObject { /// /// Initializes a new instance of the class. @@ -9424,134 +8129,41 @@ namespace BreCalClient.misc.Model return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); } /// - /// Returns true if objects are equal - /// - /// Object to be compared - /// Boolean - public override bool Equals(object input) - { - return this.Equals(input as UserDetails); - } - /// - /// Returns true if UserDetails instances are equal - /// - /// Instance of UserDetails to be compared - /// Boolean - public bool Equals(UserDetails input) - { - if (input == null) - { - return false; - } - return - ( - this.Id == input.Id || - this.Id.Equals(input.Id) - ) && - ( - this.OldPassword == input.OldPassword || - (this.OldPassword != null && - this.OldPassword.Equals(input.OldPassword)) - ) && - ( - this.NewPassword == input.NewPassword || - (this.NewPassword != null && - this.NewPassword.Equals(input.NewPassword)) - ) && - ( - this.FirstName == input.FirstName || - (this.FirstName != null && - this.FirstName.Equals(input.FirstName)) - ) && - ( - this.LastName == input.LastName || - (this.LastName != null && - this.LastName.Equals(input.LastName)) - ) && - ( - this.UserPhone == input.UserPhone || - (this.UserPhone != null && - this.UserPhone.Equals(input.UserPhone)) - ) && - ( - this.UserEmail == input.UserEmail || - (this.UserEmail != null && - this.UserEmail.Equals(input.UserEmail)) - ); - } - /// - /// Gets the hash code - /// - /// Hash code - public override int GetHashCode() - { - unchecked // Overflow is fine, just wrap - { - int hashCode = 41; - hashCode = (hashCode * 59) + this.Id.GetHashCode(); - if (this.OldPassword != null) - { - hashCode = (hashCode * 59) + this.OldPassword.GetHashCode(); - } - if (this.NewPassword != null) - { - hashCode = (hashCode * 59) + this.NewPassword.GetHashCode(); - } - if (this.FirstName != null) - { - hashCode = (hashCode * 59) + this.FirstName.GetHashCode(); - } - if (this.LastName != null) - { - hashCode = (hashCode * 59) + this.LastName.GetHashCode(); - } - if (this.UserPhone != null) - { - hashCode = (hashCode * 59) + this.UserPhone.GetHashCode(); - } - if (this.UserEmail != null) - { - hashCode = (hashCode * 59) + this.UserEmail.GetHashCode(); - } - return hashCode; - } - } - /// /// To validate all properties of the instance /// /// Validation context /// Validation Result - IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) { // OldPassword (string) maxLength if (this.OldPassword != null && this.OldPassword.Length > 128) { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for OldPassword, length must be less than 128.", new [] { "OldPassword" }); + yield return new ValidationResult("Invalid value for OldPassword, length must be less than 128.", new [] { "OldPassword" }); } // NewPassword (string) maxLength if (this.NewPassword != null && this.NewPassword.Length > 128) { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for NewPassword, length must be less than 128.", new [] { "NewPassword" }); + yield return new ValidationResult("Invalid value for NewPassword, length must be less than 128.", new [] { "NewPassword" }); } // FirstName (string) maxLength if (this.FirstName != null && this.FirstName.Length > 45) { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for FirstName, length must be less than 45.", new [] { "FirstName" }); + yield return new ValidationResult("Invalid value for FirstName, length must be less than 45.", new [] { "FirstName" }); } // LastName (string) maxLength if (this.LastName != null && this.LastName.Length > 45) { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for LastName, length must be less than 45.", new [] { "LastName" }); + yield return new ValidationResult("Invalid value for LastName, length must be less than 45.", new [] { "LastName" }); } // UserPhone (string) maxLength if (this.UserPhone != null && this.UserPhone.Length > 128) { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UserPhone, length must be less than 128.", new [] { "UserPhone" }); + yield return new ValidationResult("Invalid value for UserPhone, length must be less than 128.", new [] { "UserPhone" }); } // UserEmail (string) maxLength if (this.UserEmail != null && this.UserEmail.Length > 128) { - yield return new System.ComponentModel.DataAnnotations.ValidationResult("Invalid value for UserEmail, length must be less than 128.", new [] { "UserEmail" }); + yield return new ValidationResult("Invalid value for UserEmail, length must be less than 128.", new [] { "UserEmail" }); } yield break; } diff --git a/misc/BreCalApi.yaml b/misc/BreCalApi.yaml index a732b40..a55aa05 100644 --- a/misc/BreCalApi.yaml +++ b/misc/BreCalApi.yaml @@ -943,12 +943,21 @@ components: type: integer Error: type: object - required: - - message + description: Structure returned when invalid data (bad request) is created. properties: message: description: A human readable error message type: string + errors: + description: A list of errors + type: array + items: + type: string + valid_data: + description: A dictionary of valid data + type: object + required: + - message ShipcallType: type: string enum: From 7a97cd7d95b3bee826b6d60cef4fdea1f4880fc8 Mon Sep 17 00:00:00 2001 From: Max Metz Date: Tue, 10 Sep 2024 13:50:13 +0200 Subject: [PATCH 23/38] format of exceptions now always follows baseline format. 'errors'-key is always a list of dictionaries. --- src/server/BreCal/validators/validation_error.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/server/BreCal/validators/validation_error.py b/src/server/BreCal/validators/validation_error.py index 36f5cc8..e108222 100644 --- a/src/server/BreCal/validators/validation_error.py +++ b/src/server/BreCal/validators/validation_error.py @@ -35,7 +35,8 @@ def create_validation_error_response(ex:ValidationError, status_code:int=400, cr errors = {"undefined_schema":errors} errors = {k:v if isinstance(v,list) else [v] for k,v in errors.items()} - # hence, errors always has the following type: dict[str, list[str]] + # hence, errors always has the following type: list[dict[str, list[str]]] + errors = [errors] # example: From c90b002806e9d9de16501b96db8b36640073f988 Mon Sep 17 00:00:00 2001 From: Max Metz Date: Tue, 10 Sep 2024 14:17:03 +0200 Subject: [PATCH 24/38] Times POST no longer raises a ValidationError when the provided time is in the past. --- .../BreCal/validators/input_validation_times.py | 9 +++++---- src/server/BreCal/validators/time_logic.py | 14 +++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/server/BreCal/validators/input_validation_times.py b/src/server/BreCal/validators/input_validation_times.py index e0726fc..aee8679 100644 --- a/src/server/BreCal/validators/input_validation_times.py +++ b/src/server/BreCal/validators/input_validation_times.py @@ -85,10 +85,13 @@ class InputValidationTimes(): # 2.) datasets may only be created, if the respective participant type did not already create one. InputValidationTimes.check_if_entry_already_exists_for_participant_type(user_data, loadedModel, content) - # 3.) Reference checking + # 3.) only users who are *not* of type BSMD may post times datasets. + InputValidationTimes.check_user_is_not_bsmd_type(user_data) + + # 4.) Reference checking InputValidationTimes.check_dataset_references(content) - # 4.) Value checking + # 5.) Value checking InputValidationTimes.check_dataset_values(user_data, loadedModel, content) return @@ -140,7 +143,6 @@ class InputValidationTimes(): @staticmethod def check_user_is_not_bsmd_type(user_data:dict): """a new dataset may only be created by a user who is *not* belonging to participant group BSMD""" - # this method is deprecated for /times POST requests. As the function may be used elsewhere, it will, for now, not be removed is_bsmd = check_if_user_is_bsmd_type(user_data) if is_bsmd: raise ValidationError({"participant_type":f"current user belongs to BSMD. Cannot post 'times' datasets. Found user data: {user_data}"}) @@ -171,7 +173,6 @@ class InputValidationTimes(): if not time_end_after_time_start: raise ValidationError({"etd":f"The provided time interval for the estimated departure time is invalid. The interval end takes place before the interval start. Found interval data: {loadedModel['etd_berth']} to {loadedModel['etd_interval_end']}"}) - if (loadedModel["eta_interval_end"] is not None) and (loadedModel["eta_berth"] is not None): time_end_after_time_start = loadedModel["eta_interval_end"] >= loadedModel["eta_berth"] if not time_end_after_time_start: diff --git a/src/server/BreCal/validators/time_logic.py b/src/server/BreCal/validators/time_logic.py index 27e80b8..4f8535b 100644 --- a/src/server/BreCal/validators/time_logic.py +++ b/src/server/BreCal/validators/time_logic.py @@ -19,9 +19,9 @@ def validate_time_is_in_future(value:datetime.datetime): def validate_time_is_in_not_too_distant_future(raise_validation_error:bool, value:datetime.datetime, seconds:int=60, minutes:int=60, hours:int=24, days:int=30, months:int=12)->bool: """ - combines two boolean operations. Returns True when both conditions are met. - a) value is in the future - b) value is not too distant (e.g., at max. 1 year in the future) + A time entry is considerd valid, when it meets the following condition(s): + a) value is not too distant (e.g., at max. 1 year in the future) + Previous variants of this function also included validating that a time must be in the future. This is deprecated. When the value is 'None', the validation will be skipped. A ValidationError is never issued, but the method returns 'False'. @@ -31,17 +31,17 @@ def validate_time_is_in_not_too_distant_future(raise_validation_error:bool, valu if value is None: return False - is_in_future = validate_time_is_in_future(value) + # is_in_future = validate_time_is_in_future(value) is_too_distant = validate_time_exceeds_threshold(value, seconds, minutes, hours, days, months) if raise_validation_error: - if not is_in_future: - raise ValidationError({"any_date":f"The provided value must be in the future. Current Time: {datetime.datetime.now()}, Value: {value}"}) + #if not is_in_future: + #raise ValidationError({"any_date":f"The provided value must be in the future. Current Time: {datetime.datetime.now()}, Value: {value}"}) if is_too_distant: raise ValidationError({"any_date":f"The provided value is in the too distant future and exceeds a threshold for 'reasonable' entries. Found: {value}"}) - return is_in_future & (not is_too_distant) + return (not is_too_distant) # & is_in_future class TimeLogic(): def __init__(self): From 590df30fef028914c90fe841004d15d2ba97d2d0 Mon Sep 17 00:00:00 2001 From: Max Metz Date: Tue, 10 Sep 2024 14:48:20 +0200 Subject: [PATCH 25/38] A ship's IMO-validation was used in POST and PUT requests. This caused an issue for POST requests. --- .../validators/input_validation_shipcall.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/server/BreCal/validators/input_validation_shipcall.py b/src/server/BreCal/validators/input_validation_shipcall.py index aae7e11..5e498ff 100644 --- a/src/server/BreCal/validators/input_validation_shipcall.py +++ b/src/server/BreCal/validators/input_validation_shipcall.py @@ -90,7 +90,7 @@ class InputValidationShipcall(): InputValidationShipcall.check_referenced_ids(loadedModel) # check for reasonable values in the shipcall fields and checks for forbidden keys. - InputValidationShipcall.check_shipcall_values(loadedModel, content, forbidden_keys=["evaluation", "evaluation_message"]) + InputValidationShipcall.check_shipcall_values(loadedModel, content, forbidden_keys=["evaluation", "evaluation_message"], is_put_data=True) # a canceled shipcall cannot be selected # Note: 'canceled' is allowed in PUT-requests, if it is not already set (which is checked by InputValidationShipcall.check_shipcall_is_cancel) @@ -98,12 +98,15 @@ class InputValidationShipcall(): return @staticmethod - def check_shipcall_values(loadedModel:dict, content:dict, forbidden_keys:list=["evaluation", "evaluation_message"]): + def check_shipcall_values(loadedModel:dict, content:dict, forbidden_keys:list=["evaluation", "evaluation_message"], is_put_data:bool=False): """ individually checks each value provided in the loadedModel/content. This function validates, whether the values are reasonable. Also, some data may not be set in a POST-request. + + options: + is_put_data: bool. Some validation rules do not apply to POST data, but apply to PUT data. This flag separates the two. """ # Note: BreCal.schemas.model.ShipcallSchema has an internal validation, which the marshmallow library provides. This is used # to verify values individually, when the schema is loaded with data. @@ -120,11 +123,12 @@ class InputValidationShipcall(): if check_if_int_is_valid_flag(flags_value, enum_object=ParticipantFlag): raise ValidationError({"flags":f"incorrect value provided for 'flags'. Must be a valid combination of the flags."}) - # time values must use future-dates - InputValidationShipcall.check_times_are_in_future(loadedModel, content) - - # the type of a shipcall may not be changed. It can only be set with the initial POST-request. - InputValidationShipcall.check_shipcall_type_is_unchanged(loadedModel) + if is_put_data: + # the type of a shipcall may not be changed. It can only be set with the initial POST-request. + InputValidationShipcall.check_shipcall_type_is_unchanged(loadedModel) + else: + # time values must use future-dates + InputValidationShipcall.check_times_are_in_future(loadedModel, content) # some arguments must not be provided InputValidationShipcall.check_forbidden_arguments(content, forbidden_keys=forbidden_keys) From 5b68ef95cb46dbf9bf88eedeab98e26244ead4af Mon Sep 17 00:00:00 2001 From: Max Metz Date: Tue, 10 Sep 2024 17:37:08 +0200 Subject: [PATCH 26/38] adapting exception handling and error responses for 400 responses. Using a simplified format, which only uses the keys 'error_field' and 'error_description' --- src/server/BreCal/impl/shipcalls.py | 9 +- .../BreCal/validators/validation_error.py | 90 ++++++++++--------- 2 files changed, 49 insertions(+), 50 deletions(-) diff --git a/src/server/BreCal/impl/shipcalls.py b/src/server/BreCal/impl/shipcalls.py index 83385cf..65bb000 100644 --- a/src/server/BreCal/impl/shipcalls.py +++ b/src/server/BreCal/impl/shipcalls.py @@ -10,6 +10,7 @@ from ..services.auth_guard import check_jwt from BreCal.database.update_database import evaluate_shipcall_state from BreCal.database.sql_queries import create_sql_query_shipcall_get, create_sql_query_shipcall_post, create_sql_query_shipcall_put, create_sql_query_history_post, create_sql_query_history_put, SQLQuery from marshmallow import Schema, fields, ValidationError +from BreCal.validators.validation_error import create_validation_error_response def GetShipcalls(options): """ @@ -152,9 +153,7 @@ def PostShipcalls(schemaModel): return json.dumps({"id" : new_id}), 201, {'Content-Type': 'application/json; charset=utf-8'} except ValidationError as ex: - logging.error(ex) - print(ex) - return json.dumps({"message":f"bad format. \nError Messages: {ex.messages}. \nValid Data: {ex.valid_data}"}), 400 + return create_validation_error_response(ex, status_code=400, create_log=True) except Exception as ex: logging.error(traceback.format_exc()) @@ -265,9 +264,7 @@ def PutShipcalls(schemaModel): return json.dumps({"id" : schemaModel["id"]}), 200 except ValidationError as ex: - logging.error(ex) - print(ex) - return json.dumps({"message":f"bad format. \nError Messages: {ex.messages}. \nValid Data: {ex.valid_data}"}), 400 + return create_validation_error_response(ex, status_code=400, create_log=True) except Exception as ex: logging.error(traceback.format_exc()) diff --git a/src/server/BreCal/validators/validation_error.py b/src/server/BreCal/validators/validation_error.py index e108222..4ee0c7e 100644 --- a/src/server/BreCal/validators/validation_error.py +++ b/src/server/BreCal/validators/validation_error.py @@ -1,58 +1,59 @@ import logging import typing import json +import sys from marshmallow import ValidationError -import werkzeug from werkzeug.exceptions import Forbidden -def create_default_error_format(error_description): +def create_default_json_response_format(error_field:str, error_description:str): + """ + The default format of a JSON response for exceptions is: + { + "message":str, + "errors":typing.Optional[ + list[dict[str,list[str]]] + ] + } + """ json_response = { - "message":f"{error_description}", - "errors":[], - "valid_data":{} + "error_field":error_field, + "error_description":error_description } return json_response +def unbundle_(errors, unbundled=[]): + """ + unbundles a dictionary entry into separate items and appends them to the list {unbundled}. + Example: + errors = {"key1":{"keya":"keyb","keyc":{"keyc12":12}}} + Returns: + [{'error_field':'keya', 'error_description':['keyb']}, {'error_field':'keyc12', 'error_description':[12]}] + As can be seen, only the subkeys and their respective value are received. Each value is *always* a list. + """ + {k:unbundle_(v,unbundled=unbundled) if isinstance(v,dict) else unbundled.append({"error_field":k, "error_description":v[0] if isinstance(v,list) else str(v)}) for k,v in errors.items()} + return + +def unbundle_validation_error_message(message): + """ + inputs: + message: ValidationError.messages object. A str, list or dictionary + """ + unbundled = [] + unbundle_(message, unbundled=unbundled) + if len(unbundled)>0: + error_field = "ValidationError in the following field(s): " + " & ".join([unb["error_field"] for unb in unbundled]) + error_description = "Error Description(s): " + " & ".join([unb["error_description"] for unb in unbundled]) + else: + error_field = "ValidationError" + error_description = "unknown validation error" + return (error_field, error_description) def create_validation_error_response(ex:ValidationError, status_code:int=400, create_log:bool=True)->typing.Tuple[str,int]: - # generate an overview the errors - #example: - # {'lock_time': ['The provided value must be in the future. Current Time: 2024-09-02 08:23:32.600791, Value: 2024-09-01 08:20:41.853000']} - # when the model schema returns an error, 'messages' is by default a dictionary. - # e.g., loadedModel = model.TimesSchema().load(data=content, many=False, partial=True) - # returns: {'eta_berth': ['The provided value must be in the future} - - # when raising a custom ValidationError, it can return a string, list or dict. - # we would like to ensure, that the content of the .messages is a dictionary. This can be accomplished by calling - # raise ValidationError({"example_key_which_fails":"the respective error message"}) - errors = ex.messages - - # raise ValidationError("example error") - # creates a .messages object, which is an array. e.g., ex.messages = ["example error"] - # the following conversion snipped ensures a dictionary output - if isinstance(errors, (str,list)): - errors = {"undefined_schema":errors} - errors = {k:v if isinstance(v,list) else [v] for k,v in errors.items()} - - # hence, errors always has the following type: list[dict[str, list[str]]] - errors = [errors] - - - # example: - # "Valid Data": { - # "id": 2894, - # "eta_berth": "datetime.datetime(2024, 9, 2, 11, 11, 43)", - # "eta_berth_fixed": false - # } - valid_data = ex.valid_data - - message = "ValidationError" - json_response = create_default_error_format(error_description=message) - json_response.update({ - "errors":errors, - "valid_data":valid_data - }) + # unbundles ValidationError into a dictionary of {'error_field':str, 'error_description':str}-format + message = ex.messages + (error_field, error_description) = unbundle_validation_error_message(message) + json_response = create_default_json_response_format(error_field=error_field, error_description=error_description) # json.dumps with default=str automatically converts non-serializable values to strings. Hence, datetime objects (which are not) # natively serializable are properly serialized. @@ -67,7 +68,7 @@ def create_werkzeug_error_response(ex:Forbidden, status_code:int=403, create_log # json.dumps with default=str automatically converts non-serializable values to strings. Hence, datetime objects (which are not) # natively serializable are properly serialized. message = ex.description - json_response = create_default_error_format(error_description=message) + json_response = create_default_json_response_format(error_field=str(repr(ex)), error_description=message) serialized_response = json.dumps(json_response, default=str) if create_log: @@ -77,7 +78,8 @@ def create_werkzeug_error_response(ex:Forbidden, status_code:int=403, create_log def create_dynamic_exception_response(ex, status_code:int=400, message:typing.Optional[str]=None, create_log:bool=True): message = repr(ex) if message is None else message - json_response = create_default_error_format(error_description=message) + json_response = create_default_json_response_format(error_field="Exception", error_description=message) + json_response["message"] = "call failed" serialized_response = json.dumps(json_response, default=str) From 96d0de9e564e85787506e0510d0b76ee59dc2b6b Mon Sep 17 00:00:00 2001 From: puls200 Date: Tue, 10 Sep 2024 17:41:21 +0200 Subject: [PATCH 27/38] Update validation rules document (#47) * Update validation rules document * clarified error message array in 400 return value * simplified the return structure --- docs/ApiValidationRules.md | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/docs/ApiValidationRules.md b/docs/ApiValidationRules.md index 64bf33a..ec18ec9 100644 --- a/docs/ApiValidationRules.md +++ b/docs/ApiValidationRules.md @@ -61,11 +61,12 @@ PUT / DELETE calls referencing entities that are not found in the database will ### Return value -If a validation rule fails the call should return 400 (Bad request) including an error message in the format already in use: +If a validation rule fails the call should return 400 (Bad request) including an error message in the following format: ```json { - "message" : "reason why this call failed" + "error_field" : "A reference to the respective field(s) which have caused the error", + "error_description" : "Reason why this call failed" } ``` @@ -81,6 +82,10 @@ Date and date+time values are specified as text formatted in [RFC 3339](https:// Usually the "Z" is missing at the end indicating local time. +Generally, times may not be updated to a value in the past. There are exception (see SHIPCALL PUT below). + +Times should also not be set to a value more than 1 year in the future. The reasoning is to prevent shipcalls to stick to the top of the list by implausible (or for the workings of Bremen calling irrelevant) values too far in the future. + ## /shipcall POST 1. The call may only be performed by a user belonging to participant group type BSMD. @@ -123,7 +128,11 @@ Usually the "Z" is missing at the end indicating local time. 1. The call may only be performed by a user belonging to participant group type BSMD. 2. If a agency is selected via the shipcall_participant_map entry, users of this agency may also edit the shipcall. Care has to be taken: The agency must have been set _before_ a member of the group may edit the record. In other words: no setting the agency and editing the record by a member of the agency within the same call. -3. See value rules in /shipcall POST. Exception: Canceled may be set but only if not already set. +3. See value rules in /shipcall POST. + Exceptions: + a) Canceled may be set but only if not already set. + b) ETA/ETD may be in the past. This can happen if an agency has entered an ETA/ETD (times) in the future but + wants to edit fields of the shipcall record (e.g. the draft) but the shipcall was originally created with an ETA/ETD in the past 4. A cancelled shipcall may not be changed (is logical delete) #### Required fields @@ -189,7 +198,7 @@ shipcall_id, participant_id, participant_type 1. A dataset may only be changed by a user belonging to the same participant as the times dataset is referring to. 2. See reference and value checking as specified in /times POST. -3. The shipcall type may not be changed. +3. The shipcall type may not be changed. #### Required fields From 6505ad758f50cbe98f4b5debc8999c02bb09fb9c Mon Sep 17 00:00:00 2001 From: Max Metz Date: Tue, 10 Sep 2024 17:45:32 +0200 Subject: [PATCH 28/38] bsmd authorization for times PUT --- src/server/BreCal/validators/input_validation_times.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/server/BreCal/validators/input_validation_times.py b/src/server/BreCal/validators/input_validation_times.py index aee8679..28e450f 100644 --- a/src/server/BreCal/validators/input_validation_times.py +++ b/src/server/BreCal/validators/input_validation_times.py @@ -85,13 +85,10 @@ class InputValidationTimes(): # 2.) datasets may only be created, if the respective participant type did not already create one. InputValidationTimes.check_if_entry_already_exists_for_participant_type(user_data, loadedModel, content) - # 3.) only users who are *not* of type BSMD may post times datasets. - InputValidationTimes.check_user_is_not_bsmd_type(user_data) - - # 4.) Reference checking + # 3.) Reference checking InputValidationTimes.check_dataset_references(content) - # 5.) Value checking + # 4.) Value checking InputValidationTimes.check_dataset_values(user_data, loadedModel, content) return From 7c5bc626d060cfd91c75efafdd9f9e3e815615ba Mon Sep 17 00:00:00 2001 From: Max Metz Date: Tue, 10 Sep 2024 17:47:44 +0200 Subject: [PATCH 29/38] improving documentation --- src/server/BreCal/validators/validation_error.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/server/BreCal/validators/validation_error.py b/src/server/BreCal/validators/validation_error.py index 4ee0c7e..823a924 100644 --- a/src/server/BreCal/validators/validation_error.py +++ b/src/server/BreCal/validators/validation_error.py @@ -10,10 +10,8 @@ def create_default_json_response_format(error_field:str, error_description:str): """ The default format of a JSON response for exceptions is: { - "message":str, - "errors":typing.Optional[ - list[dict[str,list[str]]] - ] + "error_field":str, + "error_description":str } """ json_response = { From 38563d5b38c53a42f75522e6aa855ff08f5f7210 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Tue, 10 Sep 2024 18:06:28 +0200 Subject: [PATCH 30/38] Simplified error display dialog --- src/BreCalClient/MainWindow.xaml.cs | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/BreCalClient/MainWindow.xaml.cs b/src/BreCalClient/MainWindow.xaml.cs index 5b21164..bbcd559 100644 --- a/src/BreCalClient/MainWindow.xaml.cs +++ b/src/BreCalClient/MainWindow.xaml.cs @@ -337,7 +337,7 @@ namespace BreCalClient { this.Dispatcher.Invoke(new Action(() => { - MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error); + ShowErrorDialog(ex.Message, "Error saving user information"); })); } } @@ -1064,6 +1064,7 @@ namespace BreCalClient // Error calling ShipcallUpdate: {\"message\": \"PUT Requests for shipcalls can only be issued by an assigned AGENCY or BSMD users // (if the special-flag is enabled). Assigned Agency: ShipcallParticipantMap(id=628, shipcall_id=115, participant_id=10, // type=8, created=datetime.datetime(2024, 8, 28, 15, 13, 14), modified=None) with Flags: 42\"} + Match m = Regex.Match(message, "\\{(.*)\\}"); if ((m != null) && m.Success) { @@ -1072,21 +1073,15 @@ namespace BreCalClient dynamic? msg = JsonConvert.DeserializeObject(m.Value); if (msg != null) { - if (msg.message != null) + if (msg.error_field != null) { - caption = $"{caption}: {msg.message}"; + caption = $"{caption}: {msg.error_field}"; } - if((msg.errors != null) && msg.errors.Count > 0) + if(msg.error_description != null) { - message = ""; - foreach(string error in msg.errors) - { - message += error; - message += Environment.NewLine; - } - } - + message = msg.error_description; + } } } catch (Exception) { } From a305ee3bed81ef3f839d03eaa2e93ee83765ae53 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Tue, 10 Sep 2024 21:14:21 +0200 Subject: [PATCH 31/38] Version bump to 1.5.0.2 --- src/BreCalClient/BreCalClient.csproj | 4 ++-- .../Properties/PublishProfiles/ClickOnceTestProfile.pubxml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BreCalClient/BreCalClient.csproj b/src/BreCalClient/BreCalClient.csproj index 3d00ee0..23fc749 100644 --- a/src/BreCalClient/BreCalClient.csproj +++ b/src/BreCalClient/BreCalClient.csproj @@ -8,8 +8,8 @@ True BreCalClient.App ..\..\misc\brecal.snk - 1.5.0.1 - 1.5.0.1 + 1.5.0.2 + 1.5.0.2 Bremen calling client A Windows WPF client for the Bremen calling API. containership.ico diff --git a/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml b/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml index 8d71e33..ec66d8a 100644 --- a/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml +++ b/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml @@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. 0 - 1.5.0.1 + 1.5.0.2 True Debug True From a497f7f2a08295bfef69bca132ab4d6140513f5b Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Tue, 10 Sep 2024 21:15:52 +0200 Subject: [PATCH 32/38] fixed typo in error message --- src/BreCalClient/EditTimesControl.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BreCalClient/EditTimesControl.xaml.cs b/src/BreCalClient/EditTimesControl.xaml.cs index 74e7e0a..b6c23a0 100644 --- a/src/BreCalClient/EditTimesControl.xaml.cs +++ b/src/BreCalClient/EditTimesControl.xaml.cs @@ -105,7 +105,7 @@ namespace BreCalClient if (this.datePickerETABerth_End.Value.HasValue && this.datePickerETABerth_End.Value < DateTime.Now) { - message = BreCalClient.Resources.Resources.textETDInThePast; + message = BreCalClient.Resources.Resources.textETAInThePast; return false; } From a0d27289ae98536549aacc902cd01b07e3fcf743 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Tue, 10 Sep 2024 21:46:30 +0200 Subject: [PATCH 33/38] removed unnecessary float conversion --- src/BreCalClient/EditShipDialog.xaml.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BreCalClient/EditShipDialog.xaml.cs b/src/BreCalClient/EditShipDialog.xaml.cs index 741c1f4..5feeb9b 100644 --- a/src/BreCalClient/EditShipDialog.xaml.cs +++ b/src/BreCalClient/EditShipDialog.xaml.cs @@ -41,8 +41,8 @@ namespace BreCalClient } this.Ship.Imo = this.integerUpDownIMO.Value; this.Ship.Callsign = this.textBoxCallsign.Text.ToUpper().Trim(); - this.Ship.Length = (float?) this.doubleUpDownLength.Value; - this.Ship.Width = (float?) this.doubleUpDownWidth.Value; + this.Ship.Length = this.doubleUpDownLength.Value; + this.Ship.Width = this.doubleUpDownWidth.Value; this.DialogResult = true; this.Close(); From 282a860c42aae19db3b0ef1b9d7c20724fdea4ec Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Wed, 11 Sep 2024 07:08:14 +0200 Subject: [PATCH 34/38] Version bump to 1.5.0.2 --- src/BreCalClient/BreCalClient.csproj | 4 ++-- .../Properties/PublishProfiles/ClickOnceTestProfile.pubxml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BreCalClient/BreCalClient.csproj b/src/BreCalClient/BreCalClient.csproj index 23fc749..6487d08 100644 --- a/src/BreCalClient/BreCalClient.csproj +++ b/src/BreCalClient/BreCalClient.csproj @@ -8,8 +8,8 @@ True BreCalClient.App ..\..\misc\brecal.snk - 1.5.0.2 - 1.5.0.2 + 1.5.0.3 + 1.5.0.3 Bremen calling client A Windows WPF client for the Bremen calling API. containership.ico diff --git a/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml b/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml index ec66d8a..fe7aa68 100644 --- a/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml +++ b/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml @@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. 0 - 1.5.0.2 + 1.5.0.3 True Debug True From e7a6aa65844746e9f5bfb806f46d06977208cc13 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Wed, 11 Sep 2024 08:41:49 +0200 Subject: [PATCH 35/38] fixed some cut and paste error and a crash when changing the assignment fails by API --- .../EditTimesAgencyIncomingControl.xaml.cs | 2 +- .../EditTimesAgencyOutgoingControl.xaml.cs | 2 +- .../EditTimesAgencyShiftingControl.xaml.cs | 4 +-- src/BreCalClient/MainWindow.xaml.cs | 13 ++++++-- src/BreCalClient/ShipcallControlModel.cs | 31 ++++++++++++++++--- 5 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs b/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs index e7c2bb7..b1eba3b 100644 --- a/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs +++ b/src/BreCalClient/EditTimesAgencyIncomingControl.xaml.cs @@ -105,7 +105,7 @@ namespace BreCalClient if(this.datePickerETA_End.Value.HasValue && this.datePickerETA_End.Value < DateTime.Now) { - message = BreCalClient.Resources.Resources.textETDInThePast; + message = BreCalClient.Resources.Resources.textETAInThePast; return false; } diff --git a/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs b/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs index 17dc94b..7258006 100644 --- a/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs +++ b/src/BreCalClient/EditTimesAgencyOutgoingControl.xaml.cs @@ -109,7 +109,7 @@ namespace BreCalClient if (this.datePickerETD.Value.HasValue && (this.datePickerETD.Value.Value < DateTime.Now) && (this.datePickerETD_End.Value == null)) { - message = BreCalClient.Resources.Resources.textETAInThePast; + message = BreCalClient.Resources.Resources.textETDInThePast; return false; } diff --git a/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs b/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs index f0cf0e9..e8398ce 100644 --- a/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs +++ b/src/BreCalClient/EditTimesAgencyShiftingControl.xaml.cs @@ -105,7 +105,7 @@ namespace BreCalClient if (this.datePickerETA_End.Value.HasValue && this.datePickerETA_End.Value < DateTime.Now) { - message = BreCalClient.Resources.Resources.textETDInThePast; + message = BreCalClient.Resources.Resources.textETAInThePast; return false; } @@ -117,7 +117,7 @@ namespace BreCalClient if (this.datePickerETD.Value.HasValue && (this.datePickerETD.Value.Value < DateTime.Now) && (this.datePickerETD_End.Value == null)) { - message = BreCalClient.Resources.Resources.textETAInThePast; + message = BreCalClient.Resources.Resources.textETDInThePast; return false; } diff --git a/src/BreCalClient/MainWindow.xaml.cs b/src/BreCalClient/MainWindow.xaml.cs index bbcd559..db705dd 100644 --- a/src/BreCalClient/MainWindow.xaml.cs +++ b/src/BreCalClient/MainWindow.xaml.cs @@ -899,7 +899,10 @@ namespace BreCalClient try { obj.ShipcallControlModel.Shipcall?.Participants.Clear(); - obj.ShipcallControlModel.UpdateTimesAssignments(this._timesApi); + if(! await obj.ShipcallControlModel.UpdateTimesAssignments(this._timesApi)) + { + ShowErrorDialog(obj.ShipcallControlModel.LastErrorMessage, "Update assignments error"); + } foreach(ParticipantAssignment pa in obj.ShipcallControlModel.AssignedParticipants.Values) obj.ShipcallControlModel.Shipcall?.Participants.Add(pa); await _shipcallApi.ShipcallUpdateAsync(obj.ShipcallControlModel.Shipcall); @@ -1011,7 +1014,13 @@ namespace BreCalClient { try { - sc.ShipcallControlModel?.UpdateTimesAssignments(_timesApi); // if the agent changed the assignment of the participant to another + if (sc.ShipcallControlModel != null) + { + if (!await sc.ShipcallControlModel.UpdateTimesAssignments(_timesApi)) // if the agent changed the assignment of the participant to another + { + ShowErrorDialog(sc.ShipcallControlModel.LastErrorMessage, "Error updating times assignment"); + } + } // always try to be the agent, even if we are BSMD if (editControl.ShipcallModel.AssignedParticipants.ContainsKey(ParticipantType.AGENCY)) diff --git a/src/BreCalClient/ShipcallControlModel.cs b/src/BreCalClient/ShipcallControlModel.cs index cf112c5..7cc91d6 100644 --- a/src/BreCalClient/ShipcallControlModel.cs +++ b/src/BreCalClient/ShipcallControlModel.cs @@ -6,6 +6,7 @@ using BreCalClient.misc.Api; using BreCalClient.misc.Model; using System; using System.Collections.Generic; +using System.Threading.Tasks; namespace BreCalClient { @@ -38,6 +39,8 @@ namespace BreCalClient public string? Berth { get; set; } + public string LastErrorMessage { get; private set; } = ""; + internal Dictionary AssignedParticipants { get; } = new(); public List Times { get; set; } = new(); @@ -247,8 +250,9 @@ namespace BreCalClient /// This function updates the assignments for existing times records accordingly and saves them. /// /// API reference to PUT eidted times - internal async void UpdateTimesAssignments(TimesApi api) - { + internal async Task UpdateTimesAssignments(TimesApi api) + { + foreach (Extensions.ParticipantType participantType in this.AssignedParticipants.Keys) { Times? times = this.GetTimesForParticipantType(participantType); @@ -256,7 +260,15 @@ namespace BreCalClient if(times.ParticipantId != this.AssignedParticipants[participantType].ParticipantId) { times.ParticipantId = this.AssignedParticipants[participantType].ParticipantId; - await api.TimesUpdateAsync(times); + try + { + await api.TimesUpdateAsync(times); + } + catch (Exception ex) + { + LastErrorMessage = ex.Message; + return false; + } } } @@ -283,9 +295,18 @@ namespace BreCalClient foreach(Times times in deleteTimes) { - api.TimesDelete(times.Id); - this.Times.Remove(times); + try + { + api.TimesDelete(times.Id); + this.Times.Remove(times); + } + catch (Exception ex) + { + LastErrorMessage = ex.Message; + return false; + } } + return true; } #endregion From 4e39510be681d22e074779357c1f5d0f3783d09b Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Wed, 11 Sep 2024 09:11:46 +0200 Subject: [PATCH 36/38] Version bump to 1.5.0.4 --- src/BreCalClient/BreCalClient.csproj | 4 ++-- .../Properties/PublishProfiles/ClickOnceTestProfile.pubxml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/BreCalClient/BreCalClient.csproj b/src/BreCalClient/BreCalClient.csproj index 6487d08..8980732 100644 --- a/src/BreCalClient/BreCalClient.csproj +++ b/src/BreCalClient/BreCalClient.csproj @@ -8,8 +8,8 @@ True BreCalClient.App ..\..\misc\brecal.snk - 1.5.0.3 - 1.5.0.3 + 1.5.0.4 + 1.5.0.4 Bremen calling client A Windows WPF client for the Bremen calling API. containership.ico diff --git a/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml b/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml index fe7aa68..1cf52b4 100644 --- a/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml +++ b/src/BreCalClient/Properties/PublishProfiles/ClickOnceTestProfile.pubxml @@ -5,7 +5,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121. 0 - 1.5.0.3 + 1.5.0.4 True Debug True From 82ad56812eee68d2726be21ebb5b3559eb84cd29 Mon Sep 17 00:00:00 2001 From: Max Metz Date: Thu, 12 Sep 2024 10:18:41 +0200 Subject: [PATCH 37/38] correcting an issue in the DELETE methods for SHIPS and TIMES, where the ID may have been provided as a null value or was incorrectly converted (string instead of integer) --- src/server/BreCal/api/ships.py | 9 ++++++--- src/server/BreCal/validators/input_validation_ship.py | 4 ++-- src/server/BreCal/validators/input_validation_times.py | 6 ++++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/server/BreCal/api/ships.py b/src/server/BreCal/api/ships.py index 9e92ffa..157f223 100644 --- a/src/server/BreCal/api/ships.py +++ b/src/server/BreCal/api/ships.py @@ -91,16 +91,19 @@ def DeleteShip(): # read the user data from the JWT token (set when login is performed) user_data = check_jwt() - ship_id = request.args.get("id") if 'id' in request.args: options = {} options["id"] = request.args.get("id") else: - return create_dynamic_exception_response(ex=ex, status_code=400, message="no id provided") + return create_dynamic_exception_response(ex=None, status_code=400, message="no id provided") # validate the request data & user permissions - InputValidationShip.evaluate_delete_data(user_data, ship_id) + ship_id = request.args.get("id") + if ship_id is None: + return create_dynamic_exception_response(ex=None, status_code=400, message="no id provided") + + InputValidationShip.evaluate_delete_data(user_data, int(ship_id)) return impl.ships.DeleteShip(options) except ValidationError as ex: diff --git a/src/server/BreCal/validators/input_validation_ship.py b/src/server/BreCal/validators/input_validation_ship.py index 4b9ad23..25362c7 100644 --- a/src/server/BreCal/validators/input_validation_ship.py +++ b/src/server/BreCal/validators/input_validation_ship.py @@ -123,7 +123,7 @@ class InputValidationShip(): return @staticmethod - def check_if_entry_is_already_deleted(ship_id:int): + def check_if_entry_is_already_deleted(ship_id:typing.Optional[int]): """ When calling a delete request for ships, the dataset may not be deleted already. This method makes sure, that the request contains and ID, has a matching entry in the database, and the @@ -134,7 +134,7 @@ class InputValidationShip(): response, status_code, header = GetShips(token=None) ships = json.loads(response) - existing_database_entries = [ship for ship in ships if ship.get("id")==ship_id] + existing_database_entries = [ship for ship in ships if ship.get("id")==int(ship_id)] if len(existing_database_entries)==0: raise ValidationError({"id":f"Could not find a ship with the specified ID. Selected: {ship_id}"}) diff --git a/src/server/BreCal/validators/input_validation_times.py b/src/server/BreCal/validators/input_validation_times.py index 28e450f..6dd1234 100644 --- a/src/server/BreCal/validators/input_validation_times.py +++ b/src/server/BreCal/validators/input_validation_times.py @@ -108,8 +108,10 @@ class InputValidationTimes(): return @staticmethod - def evaluate_delete_data(user_data:dict, times_id:int): - # #TODO_determine: is times_id always an int or does the request.args call provide a string? + def evaluate_delete_data(user_data:dict, times_id:typing.Optional[int]): + # 0.) an ID reference must be provided and will be converted to int + if times_id is None: + raise ValidationError({"id":"no times id provided"}) times_id = int(times_id) if not isinstance(times_id, int) else times_id # 1.) The dataset entry may not be deleted already From aaea8441f66cde8172a8549796da51b40ccce897 Mon Sep 17 00:00:00 2001 From: Max Metz Date: Thu, 12 Sep 2024 10:22:27 +0200 Subject: [PATCH 38/38] shifting the ship-id check into the validation object --- src/server/BreCal/api/ships.py | 5 +---- src/server/BreCal/validators/input_validation_ship.py | 9 +++++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/server/BreCal/api/ships.py b/src/server/BreCal/api/ships.py index 157f223..482474b 100644 --- a/src/server/BreCal/api/ships.py +++ b/src/server/BreCal/api/ships.py @@ -100,10 +100,7 @@ def DeleteShip(): # validate the request data & user permissions ship_id = request.args.get("id") - if ship_id is None: - return create_dynamic_exception_response(ex=None, status_code=400, message="no id provided") - - InputValidationShip.evaluate_delete_data(user_data, int(ship_id)) + InputValidationShip.evaluate_delete_data(user_data, ship_id) return impl.ships.DeleteShip(options) except ValidationError as ex: diff --git a/src/server/BreCal/validators/input_validation_ship.py b/src/server/BreCal/validators/input_validation_ship.py index 25362c7..80c6261 100644 --- a/src/server/BreCal/validators/input_validation_ship.py +++ b/src/server/BreCal/validators/input_validation_ship.py @@ -60,7 +60,11 @@ class InputValidationShip(): return @staticmethod - def evaluate_delete_data(user_data:dict, ship_id:int): + def evaluate_delete_data(user_data:dict, ship_id:typing.Optional[int]): + if ship_id is None: + raise ValidationError({"id":f"The ship id must be provided."}) + ship_id = int(ship_id) + # 1.) Only users of type BSMD are allowed to PUT InputValidationShip.check_user_is_bsmd_type(user_data) @@ -129,9 +133,6 @@ class InputValidationShip(): makes sure, that the request contains and ID, has a matching entry in the database, and the database entry may not have a deletion state already. """ - if ship_id is None: - raise ValidationError({"id":f"The ship id must be provided."}) - response, status_code, header = GetShips(token=None) ships = json.loads(response) existing_database_entries = [ship for ship in ships if ship.get("id")==int(ship_id)]