diff --git a/README.md b/README.md
index c629245..808a855 100644
--- a/README.md
+++ b/README.md
@@ -243,6 +243,7 @@ Plc Version | Client Library Version
2.9.x | 1.0.x
2.9.x | 2.0.x
3.0.x | 2.1.x
+3.0.x | 2.2.x
## SIMATIC S7-1200:
Plc Version | Client Library Version
diff --git a/src/Webserver.API/Enums/ApiAlarmAcknowledgementState.cs b/src/Webserver.API/Enums/ApiAlarmAcknowledgementState.cs
new file mode 100644
index 0000000..58f92bc
--- /dev/null
+++ b/src/Webserver.API/Enums/ApiAlarmAcknowledgementState.cs
@@ -0,0 +1,21 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+
+namespace Siemens.Simatic.S7.Webserver.API.Enums
+{
+ ///
+ /// The acknowledgement state of the alarm
+ ///
+ public enum ApiAlarmAcknowledgementState
+ {
+ ///
+ /// Alarm is not acknowledged
+ ///
+ Not_Acknowledged = 0,
+ ///
+ /// Alarm is acknowledged
+ ///
+ Acknowledged = 1
+ }
+}
diff --git a/src/Webserver.API/Enums/ApiAlarmsBrowseFilterAttribute.cs b/src/Webserver.API/Enums/ApiAlarmsBrowseFilterAttribute.cs
new file mode 100644
index 0000000..0017ad8
--- /dev/null
+++ b/src/Webserver.API/Enums/ApiAlarmsBrowseFilterAttribute.cs
@@ -0,0 +1,53 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System.Runtime.Serialization;
+
+namespace Siemens.Simatic.S7.Webserver.API.Enums
+{
+ ///
+ /// Possible filters for ApiAlarmsBrowse request
+ ///
+ [JsonConverter(typeof(StringEnumConverter))]
+ public enum ApiAlarmsBrowseFilterAttribute
+ {
+ ///
+ /// Filter for the alarm text.
+ ///
+ [EnumMember(Value = "alarm_text")]
+ AlarmText = 1,
+ ///
+ /// Filter for the info text.
+ ///
+ [EnumMember(Value = "info_text")]
+ InfoText = 2,
+ ///
+ /// Filter for the alarm status. The value will contain either "incoming" or "outgoing".
+ ///
+ [EnumMember(Value = "status")]
+ Status = 3,
+ ///
+ /// Filter for the UTC timestamp on when the alarm went into incoming or outgoing state, provided as ISO 8601 string.
+ /// This attribute does not consider the timestamp of acknowledgement. The precision will be in nanoseconds.
+ ///
+ [EnumMember(Value = "timestamp")]
+ Timestamp = 4,
+ ///
+ /// Filter for the acknowledgement. The acknowledgement exist if the alarm is acknowledgeable. If the alarm was not configured as acknowledgeable alarm, then no acknowledgement will be returned regardless of this filter.
+ ///
+ [EnumMember(Value = "acknowledgement")]
+ Acknowledgement = 5,
+ ///
+ /// Filter for the the alarm number.
+ ///
+ [EnumMember(Value = "alarm_number")]
+ AlarmNumber = 6,
+ ///
+ /// Filter for the producer of the alarm.
+ ///
+ [EnumMember(Value = "producer")]
+ Producer = 7
+ }
+}
diff --git a/src/Webserver.API/Enums/ApiAuthenticationMode.cs b/src/Webserver.API/Enums/ApiAuthenticationMode.cs
new file mode 100644
index 0000000..bec689e
--- /dev/null
+++ b/src/Webserver.API/Enums/ApiAuthenticationMode.cs
@@ -0,0 +1,31 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using Newtonsoft.Json.Serialization;
+
+namespace Siemens.Simatic.S7.Webserver.API.Enums
+{
+ ///
+ /// User Authentication modes of the PLC.
+ /// Depends on the configured user management which authentication modes will be supported by the PLC
+ /// based on the authentication mode.
+ ///
+ [JsonConverter(typeof(StringEnumConverter), converterParameters: typeof(SnakeCaseNamingStrategy))]
+ public enum ApiAuthenticationMode
+ {
+ ///
+ /// Legacy User Management
+ ///
+ Static,
+ ///
+ /// Only Anonymous user is available
+ ///
+ Disabled,
+ ///
+ /// The users are stored on the PLC
+ ///
+ Local
+ }
+}
diff --git a/src/Webserver.API/Enums/ApiBrowseFilterMode.cs b/src/Webserver.API/Enums/ApiBrowseFilterMode.cs
new file mode 100644
index 0000000..331b281
--- /dev/null
+++ b/src/Webserver.API/Enums/ApiBrowseFilterMode.cs
@@ -0,0 +1,27 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System.Runtime.Serialization;
+
+namespace Siemens.Simatic.S7.Webserver.API.Enums
+{
+ ///
+ /// The mode if the attributes shall either be included or excluded.
+ ///
+ [JsonConverter(typeof(StringEnumConverter))]
+ public enum ApiBrowseFilterMode
+ {
+ ///
+ /// The response will include the listed attributes and exclude the others.
+ ///
+ [EnumMember(Value = "include")]
+ Include = 0,
+ ///
+ /// The response will exclude the listed attributes and include the others.
+ ///
+ [EnumMember(Value = "exclude")]
+ Exclude = 1,
+ }
+}
\ No newline at end of file
diff --git a/src/Webserver.API/Enums/ApiDayOfWeek.cs b/src/Webserver.API/Enums/ApiDayOfWeek.cs
new file mode 100644
index 0000000..af1331b
--- /dev/null
+++ b/src/Webserver.API/Enums/ApiDayOfWeek.cs
@@ -0,0 +1,45 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using Newtonsoft.Json.Serialization;
+
+namespace Siemens.Simatic.S7.Webserver.API.Enums
+{
+ ///
+ /// Represents the days of the week
+ ///
+ [JsonConverter(typeof(StringEnumConverter), converterParameters: typeof(SnakeCaseNamingStrategy))]
+ public enum ApiDayOfWeek
+ {
+ ///
+ /// Sunday
+ ///
+ Sun = 1,
+ ///
+ /// Monday
+ ///
+ Mon = 2,
+ ///
+ /// Tuesday
+ ///
+ Tue = 3,
+ ///
+ /// Wednesday
+ ///
+ Wed = 4,
+ ///
+ /// Thursday
+ ///
+ Thu = 5,
+ ///
+ /// Friday
+ ///
+ Fri = 6,
+ ///
+ /// Saturday
+ ///
+ Sat = 7
+ }
+}
diff --git a/src/Webserver.API/Enums/ApiDiagnosticBufferBrowseFilterAttributes.cs b/src/Webserver.API/Enums/ApiDiagnosticBufferBrowseFilterAttributes.cs
new file mode 100644
index 0000000..dfa6003
--- /dev/null
+++ b/src/Webserver.API/Enums/ApiDiagnosticBufferBrowseFilterAttributes.cs
@@ -0,0 +1,32 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using System.Runtime.Serialization;
+
+namespace Siemens.Simatic.S7.Webserver.API.Enums
+{
+ ///
+ /// Possible filters for ApiDiagnosticBufferBrowse request
+ ///
+ [JsonConverter(typeof(StringEnumConverter))]
+ public enum ApiDiagnosticBufferBrowseFilterAttributes
+ {
+ ///
+ /// Filter for the short diagnostic buffer text.
+ ///
+ [EnumMember(Value = "short_text")]
+ ShortText = 1,
+ ///
+ /// Filter for the long diagnostic buffer text.
+ ///
+ [EnumMember(Value = "long_text")]
+ LongText = 2,
+ ///
+ /// Filter for the help text message in case of an incoming event.
+ ///
+ [EnumMember(Value = "help_text")]
+ HelpText = 3,
+ }
+}
diff --git a/src/Webserver.API/Enums/ApiErrorCode.cs b/src/Webserver.API/Enums/ApiErrorCode.cs
index 58954c5..4764e60 100644
--- a/src/Webserver.API/Enums/ApiErrorCode.cs
+++ b/src/Webserver.API/Enums/ApiErrorCode.cs
@@ -1,11 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Enums
{
@@ -44,7 +39,7 @@ public enum ApiErrorCode
/// The system does not have the necessary resources to execute the Web API request.
/// Execute the request again as soon as sufficient resources are available again.
/// Some examples: you have
- /// -reached the limit for logins (depending on plc) - wait a maximum of 120 seconds and call the method (login) again.
+ /// -reached the limit for logins (depending on plc) - wait 150 seconds and call the method (login) again.
/// -reached the limit for tickets for one user session or still a ticket for e.g. a download that is not closed yet. Close all open tickets in order to free resources and call this method again.
/// -system does generally not have the resources currently => wait for other requests to be completed
/// Das System verfügt nicht über die nötigen Ressourcen, um den Web API-Request auszuführen
@@ -58,6 +53,15 @@ public enum ApiErrorCode
///
SystemIsReadOnly = 5,
///
+ /// The password change cannot be performed. This is caused for example if an older PLC project is present where password changes are not supported.
+ ///
+ PasswordChangeNotAccepted = 6,
+ ///
+ /// The data of a PLC of an R/H system is not accessible.
+ /// This may happen if the system is in state Syncup or RUN-redundant or if the service data of the partner PLC has been requested.
+ ///
+ PartnerNotAccessible = 7,
+ ///
/// The given credentials dont match any downloaded credentials to the plc.
///
LoginFailed = 100,
@@ -67,6 +71,18 @@ public enum ApiErrorCode
///
AlreadyAuthenticated = 101,
///
+ /// The password of the user account has expired. The user needs to change the password to successfully authenticate again.
+ ///
+ PasswordExpired = 102,
+ ///
+ /// The provided new password does not match the required password policy.
+ ///
+ NewPasswordDoesNotFollowPolicy = 103,
+ ///
+ /// The provided new password is identical with the current password.
+ ///
+ NewPasswordMatchesOldPassword = 104,
+ ///
/// The requested address does not exist or the webserver cannot access the requested address.
/// Die angeforderte Adresse existiert nicht oder der Webserver kann nicht auf die angeforderte Adresse zugreifen.
///
@@ -176,10 +192,42 @@ public enum ApiErrorCode
///
ResourceContentHasBeenCorrupted = 514,
///
+ /// Only one simultaneous ticket resource for service data across all users is possible at a time
+ ///
+ NoServiceDataResources = 600,
+ ///
+ /// The provided alarm ID is invalid.
+ ///
+ InvalidAlarmId = 800,
+ ///
+ /// The request is invalid. The user provided invalid parameters, e. g. alarm ID and count are present at the same time.
+ ///
+ InvalidAlarmsBrowseParameters = 801,
+ ///
+ /// The provided timestamp does not match the required timestamp format
+ ///
+ InvalidTimestamp = 900,
+ ///
+ /// The timestamp is not within the allowed range
+ ///
+ TimestampOutOfRange = 901,
+ ///
+ /// The provided rule is invalid. Check the DaylightSavingsRule object. If the Rule object is present, both DST and STD is required.
+ ///
+ InvalidTimeRule = 902,
+ ///
+ /// The provided UTC offset is invalid. Check the main utc offset, and the DaylightSavingsRule object's DST offset.
+ ///
+ InvalidUTCOffset = 903,
+ ///
/// The PLC is not in operating mode stop. The method cannot be executed while the plc is not in stop mode.
///
PLCNotInStop = 1004,
///
+ /// The requested hardware identifier is invalid
+ ///
+ InvalidHwId = 1100,
+ ///
/// The method has not been found by the plc - check the spelling and fw-version (and according methods) of plc
///
MethodNotFound = -32601,
diff --git a/src/Webserver.API/Enums/ApiFailsafeHardwareType.cs b/src/Webserver.API/Enums/ApiFailsafeHardwareType.cs
new file mode 100644
index 0000000..ad5f239
--- /dev/null
+++ b/src/Webserver.API/Enums/ApiFailsafeHardwareType.cs
@@ -0,0 +1,25 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using Newtonsoft.Json.Serialization;
+
+namespace Siemens.Simatic.S7.Webserver.API.Enums
+{
+ ///
+ /// The type defines if the requested hardware identifier represents either the safety PLC itself or another failsafe module.
+ ///
+ [JsonConverter(typeof(StringEnumConverter), converterParameters: typeof(SnakeCaseNamingStrategy))]
+ public enum ApiFailsafeHardwareType
+ {
+ ///
+ /// The hw id is a CPU
+ ///
+ F_cpu,
+ ///
+ /// The hw id is a module
+ ///
+ F_module
+ }
+}
diff --git a/src/Webserver.API/Enums/ApiFileResourceState.cs b/src/Webserver.API/Enums/ApiFileResourceState.cs
index d5b5c9c..83a4e6c 100644
--- a/src/Webserver.API/Enums/ApiFileResourceState.cs
+++ b/src/Webserver.API/Enums/ApiFileResourceState.cs
@@ -1,9 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Collections.Generic;
-using System.Text;
namespace Siemens.Simatic.S7.Webserver.API.Enums
{
diff --git a/src/Webserver.API/Enums/ApiFileResourceType.cs b/src/Webserver.API/Enums/ApiFileResourceType.cs
index d955beb..de25306 100644
--- a/src/Webserver.API/Enums/ApiFileResourceType.cs
+++ b/src/Webserver.API/Enums/ApiFileResourceType.cs
@@ -1,9 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Collections.Generic;
-using System.Text;
namespace Siemens.Simatic.S7.Webserver.API.Enums
{
diff --git a/src/Webserver.API/Enums/ApiObjectDirectoryStatus.cs b/src/Webserver.API/Enums/ApiObjectDirectoryStatus.cs
new file mode 100644
index 0000000..4e7e720
--- /dev/null
+++ b/src/Webserver.API/Enums/ApiObjectDirectoryStatus.cs
@@ -0,0 +1,21 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+
+namespace Siemens.Simatic.S7.Webserver.API.Enums
+{
+ ///
+ /// The status of the entry. Either incoming or outgoing.
+ ///
+ public enum ApiObjectDirectoryStatus
+ {
+ ///
+ /// The entry is incoming
+ ///
+ Incoming = 1,
+ ///
+ /// The entry is outgoing
+ ///
+ Outgoing = 2
+ }
+}
\ No newline at end of file
diff --git a/src/Webserver.API/Enums/ApiPlcHwId.cs b/src/Webserver.API/Enums/ApiPlcHwId.cs
new file mode 100644
index 0000000..c0d80c8
--- /dev/null
+++ b/src/Webserver.API/Enums/ApiPlcHwId.cs
@@ -0,0 +1,17 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+
+namespace Siemens.Simatic.S7.Webserver.API.Enums
+{
+ ///
+ /// Enum containing Hardware Ids for different types of plcs
+ ///
+ public enum ApiPlcHwId
+ {
+ ///
+ /// HwId for a standard, non-redundant plc
+ ///
+ StandardPLC = 49
+ }
+}
diff --git a/src/Webserver.API/Enums/ApiPlcModeSelectorState.cs b/src/Webserver.API/Enums/ApiPlcModeSelectorState.cs
new file mode 100644
index 0000000..6bf5098
--- /dev/null
+++ b/src/Webserver.API/Enums/ApiPlcModeSelectorState.cs
@@ -0,0 +1,34 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using Newtonsoft.Json.Serialization;
+
+namespace Siemens.Simatic.S7.Webserver.API.Enums
+{
+ ///
+ /// Represents the state of the mode selector switch of the PLC.
+ ///
+ [JsonConverter(typeof(StringEnumConverter), converterParameters: typeof(SnakeCaseNamingStrategy))]
+ public enum ApiPlcModeSelectorState
+ {
+ ///
+ /// No physical mode selector switch is present.
+ ///
+ NoSwitch,
+ ///
+ /// The mode selector switch is in position STOP.
+ ///
+ Stop,
+ ///
+ /// The mode selector switch is in position RUN.
+ ///
+ Run,
+ ///
+ /// The mode selector switch position could not be determined.
+ /// For example, the partner PLC of an R/H system is not reachable.
+ ///
+ Unknown
+ }
+}
diff --git a/src/Webserver.API/Enums/ApiPlcOperatingMode.cs b/src/Webserver.API/Enums/ApiPlcOperatingMode.cs
index 5e2fc8c..59b44de 100644
--- a/src/Webserver.API/Enums/ApiPlcOperatingMode.cs
+++ b/src/Webserver.API/Enums/ApiPlcOperatingMode.cs
@@ -1,11 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Enums
{
diff --git a/src/Webserver.API/Enums/ApiPlcProgramBrowseMode.cs b/src/Webserver.API/Enums/ApiPlcProgramBrowseMode.cs
index b6d03f9..e4d6e91 100644
--- a/src/Webserver.API/Enums/ApiPlcProgramBrowseMode.cs
+++ b/src/Webserver.API/Enums/ApiPlcProgramBrowseMode.cs
@@ -1,11 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Enums
{
diff --git a/src/Webserver.API/Enums/ApiPlcProgramDataType.cs b/src/Webserver.API/Enums/ApiPlcProgramDataType.cs
index 61f9ea8..9785a98 100644
--- a/src/Webserver.API/Enums/ApiPlcProgramDataType.cs
+++ b/src/Webserver.API/Enums/ApiPlcProgramDataType.cs
@@ -1,13 +1,8 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using Siemens.Simatic.S7.Webserver.API.Models;
using Siemens.Simatic.S7.Webserver.API.Models.ApiPlcProgramDataTypes;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Enums
{
@@ -80,9 +75,9 @@ public static int GetBytesOfDataType(this ApiPlcProgramDataType plcProgramDataTy
public static Type GetAccordingDataType(this ApiPlcProgramDataType plcProgramDataType)
{
int intVal = (int)plcProgramDataType;
- if(intVal >= 3 && intVal <= 4)
+ if (intVal >= 3 && intVal <= 4)
return typeof(byte);
- if(intVal >= 6 && intVal <= 7)
+ if (intVal >= 6 && intVal <= 7)
return typeof(char);
if (intVal >= 8 && intVal <= 18)
return typeof(short);
@@ -96,14 +91,14 @@ public static Type GetAccordingDataType(this ApiPlcProgramDataType plcProgramDat
return typeof(long);
if (intVal >= 62 && intVal <= 64)
return typeof(ulong);
- if(intVal >= 65 && intVal <= 66)
+ if (intVal >= 65 && intVal <= 66)
return typeof(string);
switch (plcProgramDataType)
{
case ApiPlcProgramDataType.Bool:
return typeof(bool);
case ApiPlcProgramDataType.Sint:
- return typeof(sbyte);
+ return typeof(sbyte);
case ApiPlcProgramDataType.S5time:
return typeof(ApiS5Time);
case ApiPlcProgramDataType.Date_and_time:
diff --git a/src/Webserver.API/Enums/ApiPlcProgramReadOrWriteMode.cs b/src/Webserver.API/Enums/ApiPlcProgramReadOrWriteMode.cs
index cf6e18d..c08694e 100644
--- a/src/Webserver.API/Enums/ApiPlcProgramReadOrWriteMode.cs
+++ b/src/Webserver.API/Enums/ApiPlcProgramReadOrWriteMode.cs
@@ -1,11 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Enums
{
diff --git a/src/Webserver.API/Enums/ApiPlcRedundancyId.cs b/src/Webserver.API/Enums/ApiPlcRedundancyId.cs
new file mode 100644
index 0000000..621b833
--- /dev/null
+++ b/src/Webserver.API/Enums/ApiPlcRedundancyId.cs
@@ -0,0 +1,25 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+
+namespace Siemens.Simatic.S7.Webserver.API.Enums
+{
+ ///
+ /// Represents which PLC with id 1 or 2 is used in an R/H system.
+ ///
+ public enum ApiPlcRedundancyId
+ {
+ ///
+ /// Standard PLC
+ ///
+ StandardPLC = 0,
+ ///
+ /// Redundancy ID 1
+ ///
+ RedundancyId_1 = 1,
+ ///
+ /// Redundancy ID 2
+ ///
+ RedundancyId_2 = 2
+ }
+}
diff --git a/src/Webserver.API/Enums/ApiTicketProvider.cs b/src/Webserver.API/Enums/ApiTicketProvider.cs
index 1172f42..d39b310 100644
--- a/src/Webserver.API/Enums/ApiTicketProvider.cs
+++ b/src/Webserver.API/Enums/ApiTicketProvider.cs
@@ -2,13 +2,7 @@
//
// SPDX-License-Identifier: MIT
using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-using System;
-using System.Collections.Generic;
-using System.Linq;
using System.Runtime.Serialization;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Enums
{
@@ -51,8 +45,11 @@ public enum ApiTicketProvider
[JsonProperty("Plc.CreateBackup")]
[EnumMember(Value = "Plc.CreateBackup")]
Plc_CreateBackup = 5,
+ ///
+ /// For Api: PlcProgram.DownloadProfilingData
+ ///
+ [JsonProperty("PlcProgram.DownloadProfilingData")]
+ [EnumMember(Value = "PlcProgram.DownloadProfilingData")]
+ PlcProgram_DownloadProfilingData = 6,
}
-
-
-
}
diff --git a/src/Webserver.API/Enums/ApiTicketState.cs b/src/Webserver.API/Enums/ApiTicketState.cs
index 8438aeb..321ca05 100644
--- a/src/Webserver.API/Enums/ApiTicketState.cs
+++ b/src/Webserver.API/Enums/ApiTicketState.cs
@@ -1,11 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Enums
{
diff --git a/src/Webserver.API/Enums/ApiWebAppResourceVisibility.cs b/src/Webserver.API/Enums/ApiWebAppResourceVisibility.cs
index 6f92fb4..3854c56 100644
--- a/src/Webserver.API/Enums/ApiWebAppResourceVisibility.cs
+++ b/src/Webserver.API/Enums/ApiWebAppResourceVisibility.cs
@@ -1,11 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Enums
{
diff --git a/src/Webserver.API/Enums/ApiWebAppState.cs b/src/Webserver.API/Enums/ApiWebAppState.cs
index d6eb565..c1b7907 100644
--- a/src/Webserver.API/Enums/ApiWebAppState.cs
+++ b/src/Webserver.API/Enums/ApiWebAppState.cs
@@ -1,11 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Enums
{
diff --git a/src/Webserver.API/Enums/ApiWebAppType.cs b/src/Webserver.API/Enums/ApiWebAppType.cs
index 71e8b8e..a6227ee 100644
--- a/src/Webserver.API/Enums/ApiWebAppType.cs
+++ b/src/Webserver.API/Enums/ApiWebAppType.cs
@@ -1,11 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Enums
{
diff --git a/src/Webserver.API/Exceptions/ApiAddressDoesNotExistException.cs b/src/Webserver.API/Exceptions/ApiAddressDoesNotExistException.cs
index dc53322..7cf83a2 100644
--- a/src/Webserver.API/Exceptions/ApiAddressDoesNotExistException.cs
+++ b/src/Webserver.API/Exceptions/ApiAddressDoesNotExistException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiAlreadyAuthenticatedException.cs b/src/Webserver.API/Exceptions/ApiAlreadyAuthenticatedException.cs
index 17654ed..ff3446a 100644
--- a/src/Webserver.API/Exceptions/ApiAlreadyAuthenticatedException.cs
+++ b/src/Webserver.API/Exceptions/ApiAlreadyAuthenticatedException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiApplicationAlreadyExistsException.cs b/src/Webserver.API/Exceptions/ApiApplicationAlreadyExistsException.cs
index 64814af..77fe9a3 100644
--- a/src/Webserver.API/Exceptions/ApiApplicationAlreadyExistsException.cs
+++ b/src/Webserver.API/Exceptions/ApiApplicationAlreadyExistsException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiApplicationDoesNotExistException.cs b/src/Webserver.API/Exceptions/ApiApplicationDoesNotExistException.cs
index 1deddc6..a001e13 100644
--- a/src/Webserver.API/Exceptions/ApiApplicationDoesNotExistException.cs
+++ b/src/Webserver.API/Exceptions/ApiApplicationDoesNotExistException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiApplicationLimitReachedException.cs b/src/Webserver.API/Exceptions/ApiApplicationLimitReachedException.cs
index 36dd035..a9d0b26 100644
--- a/src/Webserver.API/Exceptions/ApiApplicationLimitReachedException.cs
+++ b/src/Webserver.API/Exceptions/ApiApplicationLimitReachedException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiBulkRequestException.cs b/src/Webserver.API/Exceptions/ApiBulkRequestException.cs
index 6fd3de9..d95cee2 100644
--- a/src/Webserver.API/Exceptions/ApiBulkRequestException.cs
+++ b/src/Webserver.API/Exceptions/ApiBulkRequestException.cs
@@ -3,10 +3,7 @@
// SPDX-License-Identifier: MIT
using Siemens.Simatic.S7.Webserver.API.Models.Responses;
using System;
-using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
@@ -27,7 +24,7 @@ private static string GetErrorMessage(ApiBulkResponse bulkResponse)
///
/// Bulk Response from PLC
///
- public ApiBulkResponse BulkResponse{ get; private set; }
+ public ApiBulkResponse BulkResponse { get; private set; }
///
/// Bulk Request Exceptions
///
diff --git a/src/Webserver.API/Exceptions/ApiDirectoryParserException.cs b/src/Webserver.API/Exceptions/ApiDirectoryParserException.cs
index 03ed82b..ecf4f1b 100644
--- a/src/Webserver.API/Exceptions/ApiDirectoryParserException.cs
+++ b/src/Webserver.API/Exceptions/ApiDirectoryParserException.cs
@@ -1,6 +1,7 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiEntityAlreadyExistsException.cs b/src/Webserver.API/Exceptions/ApiEntityAlreadyExistsException.cs
index 87c2119..b766b46 100644
--- a/src/Webserver.API/Exceptions/ApiEntityAlreadyExistsException.cs
+++ b/src/Webserver.API/Exceptions/ApiEntityAlreadyExistsException.cs
@@ -1,6 +1,7 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiEntityDoesNotExistException.cs b/src/Webserver.API/Exceptions/ApiEntityDoesNotExistException.cs
index ff0cdf8..a8fe730 100644
--- a/src/Webserver.API/Exceptions/ApiEntityDoesNotExistException.cs
+++ b/src/Webserver.API/Exceptions/ApiEntityDoesNotExistException.cs
@@ -1,6 +1,7 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiEntityInUseException.cs b/src/Webserver.API/Exceptions/ApiEntityInUseException.cs
index 2d4f789..aaccb96 100644
--- a/src/Webserver.API/Exceptions/ApiEntityInUseException.cs
+++ b/src/Webserver.API/Exceptions/ApiEntityInUseException.cs
@@ -1,6 +1,7 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiException.cs b/src/Webserver.API/Exceptions/ApiException.cs
index bc81e4b..e396090 100644
--- a/src/Webserver.API/Exceptions/ApiException.cs
+++ b/src/Webserver.API/Exceptions/ApiException.cs
@@ -5,10 +5,6 @@
using Newtonsoft.Json.Serialization;
using Siemens.Simatic.S7.Webserver.API.Models.Responses;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiHelperInvalidPlcProgramDataTypeException.cs b/src/Webserver.API/Exceptions/ApiHelperInvalidPlcProgramDataTypeException.cs
index af54f3a..4c787b2 100644
--- a/src/Webserver.API/Exceptions/ApiHelperInvalidPlcProgramDataTypeException.cs
+++ b/src/Webserver.API/Exceptions/ApiHelperInvalidPlcProgramDataTypeException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiInconsistentApiWebAppDataException.cs b/src/Webserver.API/Exceptions/ApiInconsistentApiWebAppDataException.cs
index 46bb8e3..c7a7f3b 100644
--- a/src/Webserver.API/Exceptions/ApiInconsistentApiWebAppDataException.cs
+++ b/src/Webserver.API/Exceptions/ApiInconsistentApiWebAppDataException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiInternalErrorException.cs b/src/Webserver.API/Exceptions/ApiInternalErrorException.cs
index 2ace38e..05fe1b4 100644
--- a/src/Webserver.API/Exceptions/ApiInternalErrorException.cs
+++ b/src/Webserver.API/Exceptions/ApiInternalErrorException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiInvalidAddressException.cs b/src/Webserver.API/Exceptions/ApiInvalidAddressException.cs
index cd6e116..3878d2d 100644
--- a/src/Webserver.API/Exceptions/ApiInvalidAddressException.cs
+++ b/src/Webserver.API/Exceptions/ApiInvalidAddressException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiInvalidAlarmIdException.cs b/src/Webserver.API/Exceptions/ApiInvalidAlarmIdException.cs
new file mode 100644
index 0000000..d6ead62
--- /dev/null
+++ b/src/Webserver.API/Exceptions/ApiInvalidAlarmIdException.cs
@@ -0,0 +1,37 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Exceptions
+{
+ ///
+ /// The provided alarm ID is invalid. This alarm does not exist (anymore).
+ ///
+ public class ApiInvalidAlarmIdException : Exception
+ {
+ private static string message = "The provided alarm ID is invalid. This alarm does not exist (anymore).";
+ ///
+ /// The provided alarm ID is invalid. This alarm does not exist (anymore).
+ ///
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiInvalidAlarmIdException(Exception innerException) : base(message, innerException) { }
+ ///
+ /// The provided alarm ID is invalid
+ ///
+ public ApiInvalidAlarmIdException() : base(message) { }
+ ///
+ /// The provided alarm ID is invalid. This alarm does not exist (anymore).
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ public ApiInvalidAlarmIdException(string userMessage) : base(message + Environment.NewLine + userMessage) { }
+ ///
+ /// The provided alarm ID is invalid. This alarm does not exist (anymore).
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiInvalidAlarmIdException(string userMessage, Exception innerException) : base(message + Environment.NewLine + userMessage, innerException) { }
+ }
+}
diff --git a/src/Webserver.API/Exceptions/ApiInvalidAlarmsBrowseParametersException.cs b/src/Webserver.API/Exceptions/ApiInvalidAlarmsBrowseParametersException.cs
new file mode 100644
index 0000000..1435dac
--- /dev/null
+++ b/src/Webserver.API/Exceptions/ApiInvalidAlarmsBrowseParametersException.cs
@@ -0,0 +1,37 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Exceptions
+{
+ ///
+ /// The request is invalid. The user provided invalid parameters, e. g. alarm ID and count are present at the same time.
+ ///
+ public class ApiInvalidAlarmsBrowseParametersException : Exception
+ {
+ private static string message = "The request is invalid. The user provided invalid parameters, e. g. alarm ID and count are present at the same time.";
+ ///
+ /// The request is invalid. The user provided invalid parameters, e. g. alarm ID and count are present at the same time.
+ ///
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiInvalidAlarmsBrowseParametersException(Exception innerException) : base(message, innerException) { }
+ ///
+ /// The request is invalid. The user provided invalid parameters, e. g. alarm ID and count are present at the same time.
+ ///
+ public ApiInvalidAlarmsBrowseParametersException() : base(message) { }
+ ///
+ /// The request is invalid. The user provided invalid parameters, e. g. alarm ID and count are present at the same time.
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ public ApiInvalidAlarmsBrowseParametersException(string userMessage) : base(message + Environment.NewLine + userMessage) { }
+ ///
+ /// The request is invalid. The user provided invalid parameters, e. g. alarm ID and count are present at the same time.
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiInvalidAlarmsBrowseParametersException(string userMessage, Exception innerException) : base(message + Environment.NewLine + userMessage, innerException) { }
+ }
+}
diff --git a/src/Webserver.API/Exceptions/ApiInvalidApplicationNameException.cs b/src/Webserver.API/Exceptions/ApiInvalidApplicationNameException.cs
index fb63bdf..a748ee1 100644
--- a/src/Webserver.API/Exceptions/ApiInvalidApplicationNameException.cs
+++ b/src/Webserver.API/Exceptions/ApiInvalidApplicationNameException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiInvalidArrayIndexException.cs b/src/Webserver.API/Exceptions/ApiInvalidArrayIndexException.cs
index 6e4e7f1..d7f5b27 100644
--- a/src/Webserver.API/Exceptions/ApiInvalidArrayIndexException.cs
+++ b/src/Webserver.API/Exceptions/ApiInvalidArrayIndexException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiInvalidETagException.cs b/src/Webserver.API/Exceptions/ApiInvalidETagException.cs
index a025b2e..426cb50 100644
--- a/src/Webserver.API/Exceptions/ApiInvalidETagException.cs
+++ b/src/Webserver.API/Exceptions/ApiInvalidETagException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiInvalidHWIDException.cs b/src/Webserver.API/Exceptions/ApiInvalidHWIDException.cs
new file mode 100644
index 0000000..7520330
--- /dev/null
+++ b/src/Webserver.API/Exceptions/ApiInvalidHWIDException.cs
@@ -0,0 +1,37 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Exceptions
+{
+ ///
+ /// The requested hardware identifier is invalid. The user shall verify the request and look up the correct hardware identifier.
+ ///
+ public class ApiInvalidHwIdException : Exception
+ {
+ private static string message = "The requested hardware identifier is invalid. The user shall verify the request and look up the correct hardware identifier..";
+ ///
+ /// The requested hardware identifier is invalid. The user shall verify the request and look up the correct hardware identifier.
+ ///
+ public ApiInvalidHwIdException() : base(message) { }
+ ///
+ /// The requested hardware identifier is invalid. The user shall verify the request and look up the correct hardware identifier.
+ ///
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiInvalidHwIdException(Exception innerException) : base(message, innerException) { }
+ ///
+ /// The requested hardware identifier is invalid. The user shall verify the request and look up the correct hardware identifier.
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ public ApiInvalidHwIdException(string userMessage) : base(message + Environment.NewLine + userMessage) { }
+ ///
+ /// The requested hardware identifier is invalid. The user shall verify the request and look up the correct hardware identifier.
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiInvalidHwIdException(string userMessage, Exception innerException) : base(message + Environment.NewLine + userMessage, innerException) { }
+ }
+}
diff --git a/src/Webserver.API/Exceptions/ApiInvalidMediaTypeException.cs b/src/Webserver.API/Exceptions/ApiInvalidMediaTypeException.cs
index a8db341..6c17768 100644
--- a/src/Webserver.API/Exceptions/ApiInvalidMediaTypeException.cs
+++ b/src/Webserver.API/Exceptions/ApiInvalidMediaTypeException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiInvalidModificationTimeException.cs b/src/Webserver.API/Exceptions/ApiInvalidModificationTimeException.cs
index 79a8ff4..6d8008e 100644
--- a/src/Webserver.API/Exceptions/ApiInvalidModificationTimeException.cs
+++ b/src/Webserver.API/Exceptions/ApiInvalidModificationTimeException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiInvalidParametersException.cs b/src/Webserver.API/Exceptions/ApiInvalidParametersException.cs
index b6b970a..263f10b 100644
--- a/src/Webserver.API/Exceptions/ApiInvalidParametersException.cs
+++ b/src/Webserver.API/Exceptions/ApiInvalidParametersException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiInvalidResourceNameException.cs b/src/Webserver.API/Exceptions/ApiInvalidResourceNameException.cs
index ba0d0b4..bfb524e 100644
--- a/src/Webserver.API/Exceptions/ApiInvalidResourceNameException.cs
+++ b/src/Webserver.API/Exceptions/ApiInvalidResourceNameException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiInvalidResponseException.cs b/src/Webserver.API/Exceptions/ApiInvalidResponseException.cs
index 93515e7..afb3df0 100644
--- a/src/Webserver.API/Exceptions/ApiInvalidResponseException.cs
+++ b/src/Webserver.API/Exceptions/ApiInvalidResponseException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiInvalidTicketIdValueException.cs b/src/Webserver.API/Exceptions/ApiInvalidTicketIdValueException.cs
index be85835..1705ab2 100644
--- a/src/Webserver.API/Exceptions/ApiInvalidTicketIdValueException.cs
+++ b/src/Webserver.API/Exceptions/ApiInvalidTicketIdValueException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiInvalidTimeRuleException.cs b/src/Webserver.API/Exceptions/ApiInvalidTimeRuleException.cs
new file mode 100644
index 0000000..25fcd4d
--- /dev/null
+++ b/src/Webserver.API/Exceptions/ApiInvalidTimeRuleException.cs
@@ -0,0 +1,37 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Exceptions
+{
+ ///
+ /// The provided rule is invalid. Check the DaylightSavingsRule object. If the Rule object is present, both DST and STD is required.
+ ///
+ public class ApiInvalidTimeRuleException : Exception
+ {
+ private static string message = "The provided rule is invalid. Check the DaylightSavingsRule object. If the Rule object is present, both DST and STD is required.";
+ ///
+ /// The provided rule is invalid. Check the DaylightSavingsRule object. If the Rule object is present, both DST and STD is required.
+ ///
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiInvalidTimeRuleException(Exception innerException) : base(message, innerException) { }
+ ///
+ /// The provided rule is invalid. Check the DaylightSavingsRule object. If the Rule object is present, both DST and STD is required.
+ ///
+ public ApiInvalidTimeRuleException() : base(message) { }
+ ///
+ /// The provided rule is invalid. Check the DaylightSavingsRule object. If the Rule object is present, both DST and STD is required.
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ public ApiInvalidTimeRuleException(string userMessage) : base(message + Environment.NewLine + userMessage) { }
+ ///
+ /// The provided rule is invalid. Check the DaylightSavingsRule object. If the Rule object is present, both DST and STD is required.
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiInvalidTimeRuleException(string userMessage, Exception innerException) : base(message + Environment.NewLine + userMessage, innerException) { }
+ }
+}
diff --git a/src/Webserver.API/Exceptions/ApiInvalidTimestampException.cs b/src/Webserver.API/Exceptions/ApiInvalidTimestampException.cs
new file mode 100644
index 0000000..8e8a209
--- /dev/null
+++ b/src/Webserver.API/Exceptions/ApiInvalidTimestampException.cs
@@ -0,0 +1,37 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Exceptions
+{
+ ///
+ /// The provided timestamp does not match the required timestamp format
+ ///
+ public class ApiInvalidTimestampException : Exception
+ {
+ private static string message = "The provided timestamp does not match the required timestamp format";
+ ///
+ /// The provided timestamp does not match the required timestamp format
+ ///
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiInvalidTimestampException(Exception innerException) : base(message, innerException) { }
+ ///
+ /// The provided timestamp does not match the required timestamp format
+ ///
+ public ApiInvalidTimestampException() : base(message) { }
+ ///
+ /// The provided timestamp does not match the required timestamp format
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ public ApiInvalidTimestampException(string userMessage) : base(message + Environment.NewLine + userMessage) { }
+ ///
+ /// The provided timestamp does not match the required timestamp format
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiInvalidTimestampException(string userMessage, Exception innerException) : base(message + Environment.NewLine + userMessage, innerException) { }
+ }
+}
diff --git a/src/Webserver.API/Exceptions/ApiInvalidUTCOffsetException.cs b/src/Webserver.API/Exceptions/ApiInvalidUTCOffsetException.cs
new file mode 100644
index 0000000..0972257
--- /dev/null
+++ b/src/Webserver.API/Exceptions/ApiInvalidUTCOffsetException.cs
@@ -0,0 +1,37 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Exceptions
+{
+ ///
+ /// The provided UTC offset is invalid. Check the main utc offset, and the DaylightSavingsRule object's DST offset.
+ ///
+ public class ApiInvalidUTCOffsetException : Exception
+ {
+ private static string message = "The provided UTC offset is invalid. Check the main utc offset, and the DaylightSavingsRule object's DST offset.";
+ ///
+ /// The provided UTC offset is invalid. Check the main utc offset, and the DaylightSavingsRule object's DST offset.
+ ///
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiInvalidUTCOffsetException(Exception innerException) : base(message, innerException) { }
+ ///
+ /// The provided UTC offset is invalid. Check the main utc offset, and the DaylightSavingsRule object's DST offset.
+ ///
+ public ApiInvalidUTCOffsetException() : base(message) { }
+ ///
+ /// The provided UTC offset is invalid. Check the main utc offset, and the DaylightSavingsRule object's DST offset.
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ public ApiInvalidUTCOffsetException(string userMessage) : base(message + Environment.NewLine + userMessage) { }
+ ///
+ /// The provided UTC offset is invalid. Check the main utc offset, and the DaylightSavingsRule object's DST offset.
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiInvalidUTCOffsetException(string userMessage, Exception innerException) : base(message + Environment.NewLine + userMessage, innerException) { }
+ }
+}
diff --git a/src/Webserver.API/Exceptions/ApiMethodNotFoundException.cs b/src/Webserver.API/Exceptions/ApiMethodNotFoundException.cs
index 2a05ea7..69b3194 100644
--- a/src/Webserver.API/Exceptions/ApiMethodNotFoundException.cs
+++ b/src/Webserver.API/Exceptions/ApiMethodNotFoundException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiNewPasswordDoesNotFollowPolicyException.cs b/src/Webserver.API/Exceptions/ApiNewPasswordDoesNotFollowPolicyException.cs
new file mode 100644
index 0000000..046f920
--- /dev/null
+++ b/src/Webserver.API/Exceptions/ApiNewPasswordDoesNotFollowPolicyException.cs
@@ -0,0 +1,38 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Exceptions
+{
+ ///
+ /// The provided new password does not match the required password policy.
+ ///
+ public class ApiNewPasswordDoesNotFollowPolicyException : Exception
+ {
+ private static string message = "The provided new password does not match the required password policy.";
+ ///
+ /// The provided new password does not match the required password policy.
+ ///
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiNewPasswordDoesNotFollowPolicyException(Exception innerException) : base(message, innerException) { }
+ ///
+ /// The provided new password does not match the required password policy.
+ ///
+ public ApiNewPasswordDoesNotFollowPolicyException() : base(message) { }
+ ///
+ /// The provided new password does not match the required password policy.
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ public ApiNewPasswordDoesNotFollowPolicyException(string userMessage) : base(message + Environment.NewLine + userMessage) { }
+ ///
+ /// The provided new password does not match the required password policy.
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiNewPasswordDoesNotFollowPolicyException(string userMessage, Exception innerException) : base(message + Environment.NewLine + userMessage, innerException) { }
+ }
+}
+
diff --git a/src/Webserver.API/Exceptions/ApiNewPasswordMatchesOldPasswordException.cs b/src/Webserver.API/Exceptions/ApiNewPasswordMatchesOldPasswordException.cs
new file mode 100644
index 0000000..702c8e5
--- /dev/null
+++ b/src/Webserver.API/Exceptions/ApiNewPasswordMatchesOldPasswordException.cs
@@ -0,0 +1,37 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Exceptions
+{
+ ///
+ /// The provided new password is identical with the former password.
+ ///
+ public class ApiNewPasswordMatchesOldPasswordException : Exception
+ {
+ private static string message = "The provided new password is identical with the former password.";
+ ///
+ /// The provided new password is identical with the former password.
+ ///
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiNewPasswordMatchesOldPasswordException(Exception innerException) : base(message, innerException) { }
+ ///
+ /// The provided new password is identical with the former password.
+ ///
+ public ApiNewPasswordMatchesOldPasswordException() : base(message) { }
+ ///
+ /// The provided new password is identical with the former password.
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ public ApiNewPasswordMatchesOldPasswordException(string userMessage) : base(message + Environment.NewLine + userMessage) { }
+ ///
+ /// The provided new password is identical with the former password.
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiNewPasswordMatchesOldPasswordException(string userMessage, Exception innerException) : base(message + Environment.NewLine + userMessage, innerException) { }
+ }
+}
diff --git a/src/Webserver.API/Exceptions/ApiNoResourcesException.cs b/src/Webserver.API/Exceptions/ApiNoResourcesException.cs
index 2d1ce05..562a4b9 100644
--- a/src/Webserver.API/Exceptions/ApiNoResourcesException.cs
+++ b/src/Webserver.API/Exceptions/ApiNoResourcesException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
@@ -13,7 +9,7 @@ namespace Siemens.Simatic.S7.Webserver.API.Exceptions
/// The system does not have the necessary resources to execute the Web API request.
/// Execute the request again as soon as sufficient resources are available again.
/// Some examples: you have
- /// -reached the limit for logins (depending on plc) - wait a maximum of 120 seconds and call the method (login) again.
+ /// -reached the limit for logins (depending on plc) - wait 150 seconds and call the method (login) again.
/// -reached the limit for tickets for one user session or still a ticket for e.g. a download that is not closed yet. Close all open tickets in order to free resources and call this method again.
/// -system does generally not have the resources currently => wait for other requests to be completed
///
@@ -21,7 +17,7 @@ public class ApiNoResourcesException : Exception
{
private static string message = $"The system does not have the necessary resources to execute the Web API request. " +
$"{Environment.NewLine}Execute the request again as soon as sufficient resources are available again. Some examples: you have{Environment.NewLine}" +
- $" -reached the limit for logins (depending on plc)=> wait a maximum of 120 seconds and call the method (login) again.{Environment.NewLine}" +
+ $" -reached the limit for logins (depending on plc)=> wait 150 seconds and call the method (login) again.{Environment.NewLine}" +
$" -reached the limit for tickets for one user session or still a ticket for e.g. a download that is not closed yet. " +
$"Close all open tickets in order to free resources and call this method again. {Environment.NewLine}" +
$" -system does generally not have the resources currently => wait for other requests to be completed";
@@ -29,7 +25,7 @@ public class ApiNoResourcesException : Exception
/// The system does not have the necessary resources to execute the Web API request.
/// Execute the request again as soon as sufficient resources are available again.
/// Some examples: you have
- /// -reached the limit for logins (depending on plc) - wait a maximum of 120 seconds and call the method (login) again.
+ /// -reached the limit for logins (depending on plc) - wait 150 seconds and call the method (login) again.
/// -reached the limit for tickets for one user session or still a ticket for e.g. a download that is not closed yet. Close all open tickets in order to free resources and call this method again.
/// -system does generally not have the resources currently => wait for other requests to be completed
///
@@ -40,7 +36,7 @@ public ApiNoResourcesException(Exception innerException) : base(message, innerEx
/// The system does not have the necessary resources to execute the Web API request.
/// Execute the request again as soon as sufficient resources are available again.
/// Some examples: you have
- /// -reached the limit for logins (depending on plc) - wait a maximum of 120 seconds and call the method (login) again.
+ /// -reached the limit for logins (depending on plc) - wait 150 seconds and call the method (login) again.
/// -reached the limit for tickets for one user session or still a ticket for e.g. a download that is not closed yet. Close all open tickets in order to free resources and call this method again.
/// -system does generally not have the resources currently => wait for other requests to be completed
///
@@ -50,7 +46,7 @@ public ApiNoResourcesException() : base(message) { }
/// The system does not have the necessary resources to execute the Web API request.
/// Execute the request again as soon as sufficient resources are available again.
/// Some examples: you have
- /// -reached the limit for logins (depending on plc) - wait a maximum of 120 seconds and call the method (login) again.
+ /// -reached the limit for logins (depending on plc) - wait 150 seconds and call the method (login) again.
/// -reached the limit for tickets for one user session or still a ticket for e.g. a download that is not closed yet. Close all open tickets in order to free resources and call this method again.
/// -system does generally not have the resources currently => wait for other requests to be completed
///
@@ -60,7 +56,7 @@ public ApiNoResourcesException(string userMessage) : base(message + Environment.
/// The system does not have the necessary resources to execute the Web API request.
/// Execute the request again as soon as sufficient resources are available again.
/// Some examples: you have
- /// -reached the limit for logins (depending on plc) - wait a maximum of 120 seconds and call the method (login) again.
+ /// -reached the limit for logins (depending on plc) - wait 150 seconds and call the method (login) again.
/// -reached the limit for tickets for one user session or still a ticket for e.g. a download that is not closed yet. Close all open tickets in order to free resources and call this method again.
/// -system does generally not have the resources currently => wait for other requests to be completed
///
diff --git a/src/Webserver.API/Exceptions/ApiNoServiceDataResourcesException.cs b/src/Webserver.API/Exceptions/ApiNoServiceDataResourcesException.cs
new file mode 100644
index 0000000..52cb20e
--- /dev/null
+++ b/src/Webserver.API/Exceptions/ApiNoServiceDataResourcesException.cs
@@ -0,0 +1,37 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Exceptions
+{
+ ///
+ /// Only one simultaneous ticket resource for service data across all users is possible at a time
+ ///
+ public class ApiNoServiceDataResourcesException : Exception
+ {
+ private static string message = "Only one simultaneous ticket resource for service data across all users is possible at a time.";
+ ///
+ /// Only one simultaneous ticket resource for service data across all users is possible at a time
+ ///
+ public ApiNoServiceDataResourcesException() : base(message) { }
+ ///
+ /// Only one simultaneous ticket resource for service data across all users is possible at a time
+ ///
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiNoServiceDataResourcesException(Exception innerException) : base(message, innerException) { }
+ ///
+ /// Only one simultaneous ticket resource for service data across all users is possible at a time
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ public ApiNoServiceDataResourcesException(string userMessage) : base(message + Environment.NewLine + userMessage) { }
+ ///
+ /// Only one simultaneous ticket resource for service data across all users is possible at a time
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiNoServiceDataResourcesException(string userMessage, Exception innerException) : base(message + Environment.NewLine + userMessage, innerException) { }
+ }
+}
diff --git a/src/Webserver.API/Exceptions/ApiPLCNotInStopException.cs b/src/Webserver.API/Exceptions/ApiPLCNotInStopException.cs
index c217e3a..ba79355 100644
--- a/src/Webserver.API/Exceptions/ApiPLCNotInStopException.cs
+++ b/src/Webserver.API/Exceptions/ApiPLCNotInStopException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiPartnerNotAccessibleException.cs b/src/Webserver.API/Exceptions/ApiPartnerNotAccessibleException.cs
new file mode 100644
index 0000000..30c70f9
--- /dev/null
+++ b/src/Webserver.API/Exceptions/ApiPartnerNotAccessibleException.cs
@@ -0,0 +1,38 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Exceptions
+{
+ ///
+ /// The data of a PLC of an R/H system is not accessible.
+ /// This may happen if the system is in state Syncup or RUN-redundant.
+ ///
+ public class ApiPartnerNotAccessibleException : Exception
+ {
+ private static string message = "The data of a PLC of an R/H system is not accessible. This may happen if the system is in state Syncup or RUN-redundant.";
+ ///
+ /// The data of a PLC of an R/H system is not accessible. This may happen if the system is in state Syncup or RUN-redundant or if the service data of the partner PLC has been requested.
+ ///
+ public ApiPartnerNotAccessibleException() : base(message) { }
+ ///
+ /// The data of a PLC of an R/H system is not accessible. This may happen if the system is in state Syncup or RUN-redundant or if the service data of the partner PLC has been requested.
+ ///
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiPartnerNotAccessibleException(Exception innerException) : base(message, innerException) { }
+ ///
+ /// The data of a PLC of an R/H system is not accessible. This may happen if the system is in state Syncup or RUN-redundant or if the service data of the partner PLC has been requested.
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ public ApiPartnerNotAccessibleException(string userMessage) : base(message + Environment.NewLine + userMessage) { }
+ ///
+ /// The data of a PLC of an R/H system is not accessible. This may happen if the system is in state Syncup or RUN-redundant or if the service data of the partner PLC has been requested.
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiPartnerNotAccessibleException(string userMessage, Exception innerException) : base(message + Environment.NewLine + userMessage, innerException) { }
+ }
+}
diff --git a/src/Webserver.API/Exceptions/ApiPasswordChangeNotAcceptedException.cs b/src/Webserver.API/Exceptions/ApiPasswordChangeNotAcceptedException.cs
new file mode 100644
index 0000000..8c27e4e
--- /dev/null
+++ b/src/Webserver.API/Exceptions/ApiPasswordChangeNotAcceptedException.cs
@@ -0,0 +1,37 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Exceptions
+{
+ ///
+ /// The password change cannot be performed. This is caused for example if an older PLC project is present where password changes are not supported.
+ ///
+ public class ApiPasswordChangeNotAcceptedException : Exception
+ {
+ private static string message = "The password change cannot be performed. This is caused for example if an older PLC project is present where password changes are not supported.";
+ ///
+ /// The password change cannot be performed. This is caused for example if an older PLC project is present where password changes are not supported.
+ ///
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiPasswordChangeNotAcceptedException(Exception innerException) : base(message, innerException) { }
+ ///
+ /// The password change cannot be performed. This is caused for example if an older PLC project is present where password changes are not supported.
+ ///
+ public ApiPasswordChangeNotAcceptedException() : base(message) { }
+ ///
+ /// The password change cannot be performed. This is caused for example if an older PLC project is present where password changes are not supported.
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ public ApiPasswordChangeNotAcceptedException(string userMessage) : base(message + Environment.NewLine + userMessage) { }
+ ///
+ /// The password change cannot be performed. This is caused for example if an older PLC project is present where password changes are not supported.
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiPasswordChangeNotAcceptedException(string userMessage, Exception innerException) : base(message + Environment.NewLine + userMessage, innerException) { }
+ }
+}
diff --git a/src/Webserver.API/Exceptions/ApiPasswordExpiredException.cs b/src/Webserver.API/Exceptions/ApiPasswordExpiredException.cs
new file mode 100644
index 0000000..2b334c9
--- /dev/null
+++ b/src/Webserver.API/Exceptions/ApiPasswordExpiredException.cs
@@ -0,0 +1,37 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Exceptions
+{
+ ///
+ /// The password of the user account has expired. The user needs to change the password to successfully authenticate again.
+ ///
+ public class ApiPasswordExpiredException : Exception
+ {
+ private static string message = "The password of the user account has expired. The user needs to change the password to successfully authenticate again.";
+ ///
+ /// The password of the user account has expired. The user needs to change the password to successfully authenticate again.
+ ///
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiPasswordExpiredException(Exception innerException) : base(message, innerException) { }
+ ///
+ /// The password of the user account has expired. The user needs to change the password to successfully authenticate again.
+ ///
+ public ApiPasswordExpiredException() : base(message) { }
+ ///
+ /// The password of the user account has expired. The user needs to change the password to successfully authenticate again.
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ public ApiPasswordExpiredException(string userMessage) : base(message + Environment.NewLine + userMessage) { }
+ ///
+ /// The password of the user account has expired. The user needs to change the password to successfully authenticate again.
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiPasswordExpiredException(string userMessage, Exception innerException) : base(message + Environment.NewLine + userMessage, innerException) { }
+ }
+}
\ No newline at end of file
diff --git a/src/Webserver.API/Exceptions/ApiResourceAlreadyExistsException.cs b/src/Webserver.API/Exceptions/ApiResourceAlreadyExistsException.cs
index 54da8b8..c5b2306 100644
--- a/src/Webserver.API/Exceptions/ApiResourceAlreadyExistsException.cs
+++ b/src/Webserver.API/Exceptions/ApiResourceAlreadyExistsException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiResourceContentHasBeenCorruptedException.cs b/src/Webserver.API/Exceptions/ApiResourceContentHasBeenCorruptedException.cs
index aa55c04..40ae41f 100644
--- a/src/Webserver.API/Exceptions/ApiResourceContentHasBeenCorruptedException.cs
+++ b/src/Webserver.API/Exceptions/ApiResourceContentHasBeenCorruptedException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiResourceContentIsNotReadyException.cs b/src/Webserver.API/Exceptions/ApiResourceContentIsNotReadyException.cs
index 9d826ab..ef9b5e6 100644
--- a/src/Webserver.API/Exceptions/ApiResourceContentIsNotReadyException.cs
+++ b/src/Webserver.API/Exceptions/ApiResourceContentIsNotReadyException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiResourceDeploymentFailedException.cs b/src/Webserver.API/Exceptions/ApiResourceDeploymentFailedException.cs
index 2a52d3c..e6d65f7 100644
--- a/src/Webserver.API/Exceptions/ApiResourceDeploymentFailedException.cs
+++ b/src/Webserver.API/Exceptions/ApiResourceDeploymentFailedException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiResourceDoesNotExistException.cs b/src/Webserver.API/Exceptions/ApiResourceDoesNotExistException.cs
index cffdec8..152281b 100644
--- a/src/Webserver.API/Exceptions/ApiResourceDoesNotExistException.cs
+++ b/src/Webserver.API/Exceptions/ApiResourceDoesNotExistException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiResourceLimitReachedException.cs b/src/Webserver.API/Exceptions/ApiResourceLimitReachedException.cs
index 75aa940..1e24003 100644
--- a/src/Webserver.API/Exceptions/ApiResourceLimitReachedException.cs
+++ b/src/Webserver.API/Exceptions/ApiResourceLimitReachedException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiResourceVisibilityIsNotPublicException.cs b/src/Webserver.API/Exceptions/ApiResourceVisibilityIsNotPublicException.cs
index f5a07be..541afa9 100644
--- a/src/Webserver.API/Exceptions/ApiResourceVisibilityIsNotPublicException.cs
+++ b/src/Webserver.API/Exceptions/ApiResourceVisibilityIsNotPublicException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiSystemIsBusyException.cs b/src/Webserver.API/Exceptions/ApiSystemIsBusyException.cs
index 0ad55e3..6963528 100644
--- a/src/Webserver.API/Exceptions/ApiSystemIsBusyException.cs
+++ b/src/Webserver.API/Exceptions/ApiSystemIsBusyException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
@@ -29,7 +25,7 @@ public ApiSystemIsBusyException() : base(message) { }
///
/// The exception that is the cause of the current exception, or a null reference
/// (Nothing in Visual Basic) if no inner exception is specified.
- public ApiSystemIsBusyException(Exception innerException) : base(message, innerException){ }
+ public ApiSystemIsBusyException(Exception innerException) : base(message, innerException) { }
///
/// The requested operation cannot be executet since the system is currently processing another request.
diff --git a/src/Webserver.API/Exceptions/ApiSystemIsReadOnlyException.cs b/src/Webserver.API/Exceptions/ApiSystemIsReadOnlyException.cs
index da5cff7..fd8042d 100644
--- a/src/Webserver.API/Exceptions/ApiSystemIsReadOnlyException.cs
+++ b/src/Webserver.API/Exceptions/ApiSystemIsReadOnlyException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiTicketNotFoundException.cs b/src/Webserver.API/Exceptions/ApiTicketNotFoundException.cs
index 3384d12..f7ec6a5 100644
--- a/src/Webserver.API/Exceptions/ApiTicketNotFoundException.cs
+++ b/src/Webserver.API/Exceptions/ApiTicketNotFoundException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiTicketNotInCompletedStateException.cs b/src/Webserver.API/Exceptions/ApiTicketNotInCompletedStateException.cs
index f757fe4..c2a0005 100644
--- a/src/Webserver.API/Exceptions/ApiTicketNotInCompletedStateException.cs
+++ b/src/Webserver.API/Exceptions/ApiTicketNotInCompletedStateException.cs
@@ -3,10 +3,6 @@
// SPDX-License-Identifier: MIT
using Siemens.Simatic.S7.Webserver.API.Models;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
@@ -23,8 +19,9 @@ public ApiTicketNotInCompletedStateException(ApiTicket ticket) :
base($"Ticket: {ticket.Id + Environment.NewLine} is not in completed state! " +
$"instead: {ticket.State.ToString() + Environment.NewLine} " +
$"further ticket Information:{Environment.NewLine}" +
- $"ticket Provider: { ticket.Provider.ToString() + Environment.NewLine}" +
- $"date created: { ticket.Date_created }" +
- ((ticket.Data != null && ticket.Data.ToString() != "{}") ? $"ticket data: {ticket.Data.ToString()}":"")) { }
+ $"ticket Provider: {ticket.Provider.ToString() + Environment.NewLine}" +
+ $"date created: {ticket.Date_created}" +
+ ((ticket.Data != null && ticket.Data.ToString() != "{}") ? $"ticket data: {ticket.Data.ToString()}" : ""))
+ { }
}
}
diff --git a/src/Webserver.API/Exceptions/ApiTicketingEndpointUploadException.cs b/src/Webserver.API/Exceptions/ApiTicketingEndpointUploadException.cs
index 5c2175c..518152a 100644
--- a/src/Webserver.API/Exceptions/ApiTicketingEndpointUploadException.cs
+++ b/src/Webserver.API/Exceptions/ApiTicketingEndpointUploadException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiTimestampOutOfRangeException.cs b/src/Webserver.API/Exceptions/ApiTimestampOutOfRangeException.cs
new file mode 100644
index 0000000..1876ea3
--- /dev/null
+++ b/src/Webserver.API/Exceptions/ApiTimestampOutOfRangeException.cs
@@ -0,0 +1,37 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Exceptions
+{
+ ///
+ /// The timestamp is not within the allowed range
+ ///
+ public class ApiTimestampOutOfRangeException : Exception
+ {
+ private static string message = "The timestamp is not within the allowed range";
+ ///
+ /// The timestamp is not within the allowed range
+ ///
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiTimestampOutOfRangeException(Exception innerException) : base(message, innerException) { }
+ ///
+ /// The timestamp is not within the allowed range
+ ///
+ public ApiTimestampOutOfRangeException() : base(message) { }
+ ///
+ /// The timestamp is not within the allowed range
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ public ApiTimestampOutOfRangeException(string userMessage) : base(message + Environment.NewLine + userMessage) { }
+ ///
+ /// The timestamp is not within the allowed range
+ ///
+ /// Further information about the error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception, or a null reference
+ /// (Nothing in Visual Basic) if no inner exception is specified.
+ public ApiTimestampOutOfRangeException(string userMessage, Exception innerException) : base(message + Environment.NewLine + userMessage, innerException) { }
+ }
+}
diff --git a/src/Webserver.API/Exceptions/ApiUnsupportedAddressException.cs b/src/Webserver.API/Exceptions/ApiUnsupportedAddressException.cs
index 65e434a..8d1c5bd 100644
--- a/src/Webserver.API/Exceptions/ApiUnsupportedAddressException.cs
+++ b/src/Webserver.API/Exceptions/ApiUnsupportedAddressException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiVariableIsNotAStructureException.cs b/src/Webserver.API/Exceptions/ApiVariableIsNotAStructureException.cs
index aad6d49..42fa245 100644
--- a/src/Webserver.API/Exceptions/ApiVariableIsNotAStructureException.cs
+++ b/src/Webserver.API/Exceptions/ApiVariableIsNotAStructureException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiWebAppConfigParserException.cs b/src/Webserver.API/Exceptions/ApiWebAppConfigParserException.cs
index 1824f91..71eb8f1 100644
--- a/src/Webserver.API/Exceptions/ApiWebAppConfigParserException.cs
+++ b/src/Webserver.API/Exceptions/ApiWebAppConfigParserException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/ApiWebAppConfigurationFailedException.cs b/src/Webserver.API/Exceptions/ApiWebAppConfigurationFailedException.cs
index c1862a6..d59ddfe 100644
--- a/src/Webserver.API/Exceptions/ApiWebAppConfigurationFailedException.cs
+++ b/src/Webserver.API/Exceptions/ApiWebAppConfigurationFailedException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Exceptions/InvalidHttpRequestException.cs b/src/Webserver.API/Exceptions/InvalidHttpRequestException.cs
index 95dabfb..2d1bd8d 100644
--- a/src/Webserver.API/Exceptions/InvalidHttpRequestException.cs
+++ b/src/Webserver.API/Exceptions/InvalidHttpRequestException.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Exceptions
{
diff --git a/src/Webserver.API/Models/AdditionalTicketData/ApiPlcRestoreBackupTicketData.cs b/src/Webserver.API/Models/AdditionalTicketData/ApiPlcRestoreBackupTicketData.cs
index 1d460a1..f9375ac 100644
--- a/src/Webserver.API/Models/AdditionalTicketData/ApiPlcRestoreBackupTicketData.cs
+++ b/src/Webserver.API/Models/AdditionalTicketData/ApiPlcRestoreBackupTicketData.cs
@@ -2,8 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Text;
namespace Siemens.Simatic.S7.Webserver.API.Models.AdditionalTicketData
{
diff --git a/src/Webserver.API/Models/AdditionalTicketData/ApiTicketDataBase.cs b/src/Webserver.API/Models/AdditionalTicketData/ApiTicketDataBase.cs
index b4bf963..4e2a1df 100644
--- a/src/Webserver.API/Models/AdditionalTicketData/ApiTicketDataBase.cs
+++ b/src/Webserver.API/Models/AdditionalTicketData/ApiTicketDataBase.cs
@@ -2,8 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Text;
namespace Siemens.Simatic.S7.Webserver.API.Models.AdditionalTicketData
{
diff --git a/src/Webserver.API/Models/AlarmsBrowse/ApiAlarms.cs b/src/Webserver.API/Models/AlarmsBrowse/ApiAlarms.cs
new file mode 100644
index 0000000..6a65d41
--- /dev/null
+++ b/src/Webserver.API/Models/AlarmsBrowse/ApiAlarms.cs
@@ -0,0 +1,108 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.AlarmsBrowse
+{
+ ///
+ /// The current alarms of the PLC
+ ///
+ public class ApiAlarms
+ {
+ ///
+ /// The actual language in which the text entries are returned.
+ ///If the provided language in the request was invalid, invalid must be returned by the API and all text attributes must be empty strings(if requested for the response).
+ ///
+ public string Language { get; set; }
+ ///
+ /// The timestamp of the last modification of the alarming system at the time when the Read request was performed.
+ /// Checking this, the user could find out if new changes occurred on the alarming system without polling for the data.
+ ///
+ public DateTime Last_Modified { get; set; }
+ ///
+ /// The number of active alarms.
+ /// It must be the number of total available entries, not the entries returned by a filtered request.
+ ///
+ public uint Count_Current { get; set; }
+ ///
+ /// The maximum number of possible alarms.
+ ///
+ public uint Count_Max { get; set; }
+ ///
+ /// The array of alarms where each object represents an individual alarm entry.
+ /// It must be omitted from the response if the requested count was 0.
+ /// Otherwise, it must contain either an array of alarms or an empty array in case that there are no active alarms.
+ ///
+ public List Entries { get; set; }
+
+ ///
+ /// Check wether properties match
+ ///
+ ///
+ /// Returns true if the ApiAlarmsBrowse are the same
+ public override bool Equals(object obj)
+ {
+ var structure = obj as ApiAlarms;
+ if (structure == null)
+ {
+ return false;
+ }
+ if ((structure.Entries == null) != (this.Entries == null))
+ {
+ return false;
+ }
+ if (structure.Entries != null)
+ {
+ structure.Entries.SequenceEqual(this.Entries);
+ }
+ return structure.Language == this.Language &&
+ structure.Last_Modified == this.Last_Modified &&
+ structure.Count_Current == this.Count_Current &&
+ structure.Count_Max == this.Count_Max;
+ }
+
+ ///
+ /// GetHashCode for ApiAlarmsBrowse
+ ///
+ /// Hash code of the ApiAlarms
+ public override int GetHashCode()
+ {
+ int EntriesHashCode = 0;
+ if (Entries != null)
+ {
+ foreach (var entry in Entries)
+ {
+ EntriesHashCode ^= entry.GetHashCode();
+ }
+ }
+ return (EntriesHashCode, Language, Last_Modified, Count_Current, Count_Max).GetHashCode();
+ }
+
+ ///
+ /// ToString for ApiAlarms
+ ///
+ /// ApiAlarms as a multiline string
+ public override string ToString()
+ {
+ return ToString(NullValueHandling.Ignore);
+ }
+ ///
+ /// ToString for ApiAlarms
+ ///
+ /// Defines if null values should be ignored
+ /// ApiAlarms as a multiline string
+ public string ToString(NullValueHandling nullValueHandling)
+ {
+ JsonSerializerSettings options = new JsonSerializerSettings()
+ {
+ NullValueHandling = nullValueHandling,
+ };
+ string result = JsonConvert.SerializeObject(this, Formatting.Indented, options);
+ return result;
+ }
+ }
+}
diff --git a/src/Webserver.API/Models/AlarmsBrowse/ApiAlarms_Entry.cs b/src/Webserver.API/Models/AlarmsBrowse/ApiAlarms_Entry.cs
new file mode 100644
index 0000000..a7c56fa
--- /dev/null
+++ b/src/Webserver.API/Models/AlarmsBrowse/ApiAlarms_Entry.cs
@@ -0,0 +1,135 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using Siemens.Simatic.S7.Webserver.API.Enums;
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.AlarmsBrowse
+{
+ ///
+ /// Represents an individual alarm entry
+ ///
+ public class ApiAlarms_Entry
+ {
+ ///
+ /// The ID of the alarm. It is a 64-bit value that must be encoded as a string.
+ ///
+ public string Id { get; set; }
+ ///
+ /// Contains the alarm number.
+ ///
+ public int? Alarm_Number { get; set; }
+ ///
+ /// Contains the alarm status. The value must contain either "incoming" or "outgoing".
+ ///
+ [JsonConverter(typeof(StringEnumConverter))]
+ public ApiObjectDirectoryStatus? Status { get; set; }
+ ///
+ /// The UTC timestamp on when the alarm went into incoming or outgoing state, provided as ISO 8601 string.
+ /// This attribute does not consider the timestamp of acknowledgement. The precision must be in nanoseconds.
+ ///
+ public DateTime Timestamp { get; set; }
+ ///
+ /// The producer of the alarm.
+ ///
+ public string Producer { get; set; }
+ ///
+ /// Contains the hardware identifier in case that the alarm producer is system_diagnostics.
+ /// If any other case, the attribute will not be returned.
+ ///
+ public int? Hwid { get; set; }
+ ///
+ /// This exist if the alarm is an alarm that is generally acknowledgeable.
+ /// If the alarm was not configured as acknowledgeable alarm, then this object must not be returned.
+ ///
+ public ApiAlarms_EntryAcknowledgement Acknowledgement { get; set; }
+ ///
+ /// The alarm text in the language returned by attribute language.
+ /// Must be empty if the text parsing failed due to an internal error.
+ ///
+ public string Alarm_Text { get; set; }
+ ///
+ /// The info text in the language returned by attribute language.
+ /// Must be empty if the text parsing failed due to an internal error.
+ ///
+ public string Info_Text { get; set; }
+ ///
+ /// This attribute must be present if either alarm_text or info_text is part of the response.
+ /// If any of the two texts is inconsistent, then this flag must return true.
+ ///
+ public bool? Text_Inconsistent { get; set; }
+
+ ///
+ /// Check wether properties match
+ ///
+ ///
+ /// Returns true if the ApiAlarmsBrowse are the same
+ public override bool Equals(object obj)
+ {
+ var structure = obj as ApiAlarms_Entry;
+ if (structure is null)
+ {
+ return false;
+ }
+ if ((structure.Acknowledgement == null) != (this.Acknowledgement == null))
+ {
+ return false;
+ }
+ if (structure.Acknowledgement != null)
+ {
+ if (!structure.Acknowledgement.Equals(this.Acknowledgement))
+ {
+ return false;
+ }
+ }
+ return structure != null &&
+ structure.Id == this.Id &&
+ structure.Alarm_Number == this.Alarm_Number &&
+ structure.Status == this.Status &&
+ structure.Timestamp == this.Timestamp &&
+ structure.Hwid == this.Hwid &&
+ structure.Alarm_Text == this.Alarm_Text &&
+ structure.Info_Text == this.Info_Text &&
+ structure.Text_Inconsistent == this.Text_Inconsistent;
+ }
+
+ ///
+ /// GetHashCode for ApiAlarm_Entry
+ ///
+ /// Hash code of ApiAlarm_Entry
+ public override int GetHashCode()
+ {
+ int acknowledgementHash = 0;
+ if (Acknowledgement != null)
+ {
+ acknowledgementHash ^= Acknowledgement.GetHashCode();
+ }
+ return (Id, Alarm_Number, Status, Timestamp, Hwid, acknowledgementHash, Alarm_Text, Info_Text, Text_Inconsistent).GetHashCode();
+ }
+
+ ///
+ /// ToString for ApiAlarms_Entry
+ ///
+ /// ApiAlarms as a multiline string
+ public override string ToString()
+ {
+ return ToString(NullValueHandling.Ignore);
+ }
+ ///
+ /// ToString for ApiAlarms_Entry
+ ///
+ /// Defines if null values should be ignored
+ /// ApiAlarms as a multiline string
+ public string ToString(NullValueHandling nullValueHandling)
+ {
+ JsonSerializerSettings options = new JsonSerializerSettings()
+ {
+ NullValueHandling = nullValueHandling,
+ };
+ string result = JsonConvert.SerializeObject(this, Formatting.Indented, options);
+ return result;
+ }
+ }
+}
diff --git a/src/Webserver.API/Models/AlarmsBrowse/ApiAlarms_EntryAcknowledgement.cs b/src/Webserver.API/Models/AlarmsBrowse/ApiAlarms_EntryAcknowledgement.cs
new file mode 100644
index 0000000..a9de5a6
--- /dev/null
+++ b/src/Webserver.API/Models/AlarmsBrowse/ApiAlarms_EntryAcknowledgement.cs
@@ -0,0 +1,78 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using Siemens.Simatic.S7.Webserver.API.Enums;
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.AlarmsBrowse
+{
+ ///
+ /// This exist if the alarm is an alarm that is generally acknowledgeable.
+ ///
+ public class ApiAlarms_EntryAcknowledgement
+ {
+ ///
+ /// Readable string that tells the acknowledgement state of the alarm:
+ ///
+ /// - not_acknowledged
+ /// - acknowledged
+ ///
+ ///
+ [JsonConverter(typeof(StringEnumConverter))]
+ public ApiAlarmAcknowledgementState State { get; set; }
+ ///
+ /// In case that the alarms current incoming/outgoing status has been acknowledged, the timestamp returns the corresponding acknowledgement time encoded as ISO timestamp.
+ /// The precision must be in nanoseconds.
+ /// The timestamp must not be present if the alarm has not been acknowledged yet.
+ ///
+ public DateTime Timestamp { get; set; }
+
+ ///
+ /// Check wether properties match
+ ///
+ ///
+ /// Returns true if the ApiAlarmsBrowse are the same
+ public override bool Equals(object obj)
+ {
+ var structure = obj as ApiAlarms_EntryAcknowledgement;
+ if (structure == null) { return false; }
+ return structure != null &&
+ structure.State == this.State &&
+ structure.Timestamp == this.Timestamp;
+ }
+
+ ///
+ /// GetHashCode for ApiAlarmsBrowse
+ ///
+ /// Hash code of ApiAlarm_EntryAcknowledgement
+ public override int GetHashCode()
+ {
+ return (State, Timestamp).GetHashCode();
+ }
+
+ ///
+ /// ToString for ApiAlarms_EntryAcknowledgement
+ ///
+ /// ApiAlarms as a multiline string
+ public override string ToString()
+ {
+ return ToString(NullValueHandling.Ignore);
+ }
+ ///
+ /// ToString for ApiAlarms_EntryAcknowledgement
+ ///
+ /// Defines if null values should be ignored
+ /// ApiAlarms as a multiline string
+ public string ToString(NullValueHandling nullValueHandling)
+ {
+ JsonSerializerSettings options = new JsonSerializerSettings()
+ {
+ NullValueHandling = nullValueHandling,
+ };
+ string result = JsonConvert.SerializeObject(this, Formatting.Indented, options);
+ return result;
+ }
+ }
+}
diff --git a/src/Webserver.API/Models/AlarmsBrowse/ApiAlarms_RequestFilters.cs b/src/Webserver.API/Models/AlarmsBrowse/ApiAlarms_RequestFilters.cs
new file mode 100644
index 0000000..fc8f1f7
--- /dev/null
+++ b/src/Webserver.API/Models/AlarmsBrowse/ApiAlarms_RequestFilters.cs
@@ -0,0 +1,39 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Siemens.Simatic.S7.Webserver.API.Enums;
+using System.Collections.Generic;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.AlarmsBrowse
+{
+ ///
+ /// Optional parameter for ApiAlarms.Browse request
+ ///
+ public class ApiAlarms_RequestFilters
+ {
+ ///
+ /// The mode if the attributes shall either be included or excluded. Can be either include or exclude.
+ ///
+ public ApiBrowseFilterMode Mode { get; set; }
+ ///
+ /// If present, the user has the option to include or exclude certain attributes, see mode parameter.
+ /// Possible array entries are: "alarm_text", "info_text", "status", "timestamp", "acknowledgement", "alarm_number", "producer"
+ ///
+ public List Attributes { get; set; }
+
+ ///
+ /// Base constructor for ApiAlarms_RequestFilters
+ ///
+ public ApiAlarms_RequestFilters() { }
+ ///
+ /// Constructor with parameters.
+ ///
+ /// The mode if the attributes shall be included or excluded. Can be either include or exclude.
+ /// List of possible filter attributes.
+ public ApiAlarms_RequestFilters(ApiBrowseFilterMode mode, List attributes)
+ {
+ Mode = mode;
+ Attributes = attributes;
+ }
+ }
+}
diff --git a/src/Webserver.API/Models/ApiClass.cs b/src/Webserver.API/Models/ApiClass.cs
index 04917d4..7f862c5 100644
--- a/src/Webserver.API/Models/ApiClass.cs
+++ b/src/Webserver.API/Models/ApiClass.cs
@@ -1,11 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models
{
diff --git a/src/Webserver.API/Models/ApiDiagnosticBuffer/ApiDiagnosticBuffer.cs b/src/Webserver.API/Models/ApiDiagnosticBuffer/ApiDiagnosticBuffer.cs
new file mode 100644
index 0000000..3642e53
--- /dev/null
+++ b/src/Webserver.API/Models/ApiDiagnosticBuffer/ApiDiagnosticBuffer.cs
@@ -0,0 +1,105 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.ApiDiagnosticBuffer
+{
+ ///
+ /// Containes information of the diagnosticbuffer and it's entires:
+ /// List of entries, Time of last modification, Count of current entries, Count of maximum entires, Language of the entries
+ ///
+ public class ApiDiagnosticBuffer
+ {
+ ///
+ /// The language of the response in which the texts are returned.
+ /// If the provided language in the request was invalid, invalid must be returned by the API.
+ ///
+ public string Language { get; set; }
+ ///
+ /// The timestamp of the system time of the last change to the diagnostic buffer (same as the timestamp of the last entry), expressed as ISO 8601 timestamp.
+ /// Precision must be nanoseconds.
+ ///
+ public DateTime Last_Modified { get; set; }
+ ///
+ /// The number of available diagnostic buffer entries. It must be the number of total available entries, not the entries returned by a filtered request.
+ ///
+ public int Count_Current { get; set; }
+ ///
+ /// The maximum number of possible diagnostic buffer entries.
+ ///
+ public int Count_Max { get; set; }
+ ///
+ /// The array of diagnostic buffer entries where each object represents an individual diagnostic buffer entry.
+ /// It must be omitted from the response if the requested count was 0. Otherwise, it must contain an array of entries.
+ ///
+ public List Entries { get; set; }
+
+ ///
+ /// Check wether properties match
+ ///
+ /// ApiDiagnosticBuffer
+ /// Returns true if the ApiDiagnosticBuffer are the same
+ public override bool Equals(object obj)
+ {
+ var structure = obj as ApiDiagnosticBuffer;
+ if (structure == null) { return false; }
+ if ((structure.Entries == null) != (this.Entries == null))
+ {
+ return false;
+ }
+ if (structure.Entries != null)
+ {
+ if (structure.Entries.Count != this.Entries.Count) { return false; }
+ for (int i = 0; i < structure.Entries.Count; i++)
+ {
+ if (!structure.Entries[i].Equals(this.Entries[i])) { return false; }
+ }
+ }
+ return structure.Last_Modified == this.Last_Modified &&
+ structure.Count_Current == this.Count_Current &&
+ structure.Count_Max == this.Count_Max &&
+ structure.Language == this.Language;
+ }
+ ///
+ /// GetHashCode for ApiDiagnosticBuffer etc.
+ ///
+ /// hashcode for the ApiDiagnosticBuffer
+ public override int GetHashCode()
+ {
+ int EntriesHashCode = 0;
+ if (Entries != null)
+ {
+ foreach (var entry in Entries)
+ {
+ EntriesHashCode ^= entry.GetHashCode();
+ }
+ }
+ return (EntriesHashCode, Last_Modified, Count_Current, Count_Max, Language).GetHashCode();
+ }
+ ///
+ /// ToString for ApiDiagnosticBuffer
+ ///
+ /// ApiDiagnosticBuffer as a multiline string
+ public override string ToString()
+ {
+ return ToString(NullValueHandling.Ignore);
+ }
+ ///
+ /// ToString for ApiDiagnosticBuffer
+ ///
+ /// Defines if null values should be ignored
+ /// ApiDiagnosticBuffer as a multiline string
+ public string ToString(NullValueHandling nullValueHandling)
+ {
+ JsonSerializerSettings options = new JsonSerializerSettings()
+ {
+ NullValueHandling = nullValueHandling,
+ };
+ string result = JsonConvert.SerializeObject(this, Formatting.Indented, options);
+ return result;
+ }
+ }
+}
diff --git a/src/Webserver.API/Models/ApiDiagnosticBuffer/ApiDiagnosticBuffer_Entry.cs b/src/Webserver.API/Models/ApiDiagnosticBuffer/ApiDiagnosticBuffer_Entry.cs
new file mode 100644
index 0000000..7a8c169
--- /dev/null
+++ b/src/Webserver.API/Models/ApiDiagnosticBuffer/ApiDiagnosticBuffer_Entry.cs
@@ -0,0 +1,103 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Newtonsoft.Json.Converters;
+using Siemens.Simatic.S7.Webserver.API.Enums;
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.ApiDiagnosticBuffer
+{
+ ///
+ /// Containes one entry from the Diagnosticbuffer.
+ ///
+ public class ApiDiagnosticBuffer_Entry
+ {
+ ///
+ /// This attribute is provided as UTC time. The local time of the PLC is not considered for the returned timestamp.
+ /// The timestamp of the diagnostic buffer entry in UTC Time, expressed as ISO 8601 timestamp. Precision must be nanoseconds.
+ ///
+ public DateTime Timestamp { get; set; }
+ ///
+ /// Either "incoming" or "outgoing".
+ ///
+ [JsonConverter(typeof(StringEnumConverter))]
+ public ApiObjectDirectoryStatus Status { get; set; }
+ ///
+ /// The long diagnostic buffer text.
Must be empty if the text parsing failed due to an internal error.
+ ///
+ public string Long_Text { get; set; }
+ ///
+ /// The short diagnostic buffer text.
Must be empty if the text parsing failed due to an internal error.
+ ///
+ public string Short_Text { get; set; }
+ ///
+ /// The help text message in case of an incoming event.
Must be empty if the text parsing failed due to an internal error.
+ ///
+ public string Help_Text { get; set; }
+ ///
+ /// Contains the event ID of the diagnostic buffer entry which consists of the text list ID and text ID of the event.
+ /// On a client, the event ID is usually shown in hexadecimal representation, for example "16# 02:426A".
+ ///
+ public ApiDiagnosticBuffer_EntryEvent Event { get; set; }
+
+ ///
+ /// Check whether properties match
+ ///
+ /// ApiDiagnosticBuffer_Entry
+ /// Returns true if the ApiDiagnosticBuffer_Entries are the same
+ public override bool Equals(object obj)
+ {
+ var structure = obj as ApiDiagnosticBuffer_Entry;
+ if (structure == null) { return false; }
+ if ((structure.Short_Text == null) != (this.Short_Text == null))
+ {
+ return false;
+ }
+ if ((structure.Long_Text == null) != (this.Long_Text == null))
+ {
+ return false;
+ }
+ if ((structure.Help_Text == null) != (this.Help_Text == null))
+ {
+ return false;
+ }
+ return structure.Timestamp == this.Timestamp &&
+ structure.Status == this.Status &&
+ (structure.Long_Text ?? "") == (this.Long_Text ?? "") &&
+ (structure.Short_Text ?? "") == (this.Short_Text ?? "") &&
+ (structure.Help_Text ?? "") == (this.Help_Text ?? "") &&
+ structure.Event.Equals(this.Event);
+ }
+ ///
+ /// GetHashCode for DiagnosticBufferEvent
+ ///
+ /// hashcode for the DiagnosticBufferEvent
+ public override int GetHashCode()
+ {
+ return (Timestamp, Status, Long_Text ?? "", Short_Text ?? "", Help_Text ?? "", Event.GetHashCode()).GetHashCode();
+ }
+ ///
+ /// ToString for ApiDiagnosticBuffer_Entry
+ ///
+ /// ApiDiagnosticBuffer_Entry as a multiline string
+ public override string ToString()
+ {
+ return ToString(NullValueHandling.Ignore);
+ }
+ ///
+ /// ToString for ApiDiagnosticBuffer_Entry
+ ///
+ /// Defines if null values should be ignored
+ /// ApiDiagnosticBuffer_Entry as a multiline string
+ public string ToString(NullValueHandling nullValueHandling)
+ {
+ JsonSerializerSettings options = new JsonSerializerSettings()
+ {
+ NullValueHandling = nullValueHandling,
+ };
+ string result = JsonConvert.SerializeObject(this, Formatting.Indented, options);
+ return result;
+ }
+ }
+}
diff --git a/src/Webserver.API/Models/ApiDiagnosticBuffer/ApiDiagnosticBuffer_EntryEvent.cs b/src/Webserver.API/Models/ApiDiagnosticBuffer/ApiDiagnosticBuffer_EntryEvent.cs
new file mode 100644
index 0000000..1f10334
--- /dev/null
+++ b/src/Webserver.API/Models/ApiDiagnosticBuffer/ApiDiagnosticBuffer_EntryEvent.cs
@@ -0,0 +1,64 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.ApiDiagnosticBuffer
+{
+ ///
+ /// Containes the Textlist_Id and Text_Id of a diagnosticbuffer entry event.
+ ///
+ public class ApiDiagnosticBuffer_EntryEvent
+ {
+ ///
+ /// The text list ID of the event.
+ ///
+ public int Textlist_Id { get; set; }
+ ///
+ /// The text ID of the event.
+ ///
+ public int Text_Id { get; set; }
+ ///
+ /// Check wether properties match
+ ///
+ /// ApiDiagnosticBuffer_EntryEvent
+ /// Returns true if the DiagnosticBufferEvents are the same
+ public override bool Equals(object obj)
+ {
+ var structure = obj as ApiDiagnosticBuffer_EntryEvent;
+ if (structure == null) { return false; }
+ return structure.Textlist_Id == this.Textlist_Id &&
+ structure.Text_Id == this.Text_Id;
+ }
+ ///
+ /// GetHashCode for DiagnosticBufferEvent
+ ///
+ /// hashcode for the DiagnosticBufferEvent
+ public override int GetHashCode()
+ {
+ return (Textlist_Id, Text_Id).GetHashCode();
+ }
+ ///
+ /// ToString for ApiDiagnosticBuffer_EntryEvent
+ ///
+ /// ApiDiagnosticBuffer_EntryEvent as a multiline string
+ public override string ToString()
+ {
+ return ToString(NullValueHandling.Ignore);
+ }
+ ///
+ /// ToString for ApiDiagnosticBuffer_EntryEvent
+ ///
+ /// Defines if null values should be ignored
+ /// ApiDiagnosticBuffer_EntryEvent as a multiline string
+ public string ToString(NullValueHandling nullValueHandling)
+ {
+ JsonSerializerSettings options = new JsonSerializerSettings()
+ {
+ NullValueHandling = nullValueHandling,
+ };
+ string result = JsonConvert.SerializeObject(this, Formatting.Indented, options);
+ return result;
+ }
+ }
+}
diff --git a/src/Webserver.API/Models/ApiDiagnosticBuffer/ApiDiagnosticBuffer_RequestFilters.cs b/src/Webserver.API/Models/ApiDiagnosticBuffer/ApiDiagnosticBuffer_RequestFilters.cs
new file mode 100644
index 0000000..c678e5a
--- /dev/null
+++ b/src/Webserver.API/Models/ApiDiagnosticBuffer/ApiDiagnosticBuffer_RequestFilters.cs
@@ -0,0 +1,25 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Siemens.Simatic.S7.Webserver.API.Enums;
+using System.Collections.Generic;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.ApiDiagnosticBuffer
+{
+ ///
+ /// Optional parameter for ApiDiagnostucBuffer request
+ ///
+ public class ApiDiagnosticBuffer_RequestFilters
+ {
+ ///
+ /// The mode if the attributes shall either be included or excluded. Can be either include or exclude.
+ ///
+ public ApiBrowseFilterMode Mode { get; set; }
+ ///
+ /// If the entries object is not present in the request, then all parameters must be returned in the response.
+ /// If present, the user has the option to include or exclude certain attributes, see mode parameter.
+ /// Possible array entries are: "short_text", "long_text", "help_text"
+ ///
+ public List Attributes { get; set; }
+ }
+}
diff --git a/src/Webserver.API/Models/ApiError.cs b/src/Webserver.API/Models/ApiError.cs
index dda6e37..b7ee79b 100644
--- a/src/Webserver.API/Models/ApiError.cs
+++ b/src/Webserver.API/Models/ApiError.cs
@@ -2,11 +2,7 @@
//
// SPDX-License-Identifier: MIT
using Siemens.Simatic.S7.Webserver.API.Enums;
-using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models
{
diff --git a/src/Webserver.API/Models/ApiFailsafeRuntimeGroup.cs b/src/Webserver.API/Models/ApiFailsafeRuntimeGroup.cs
new file mode 100644
index 0000000..2ce4caa
--- /dev/null
+++ b/src/Webserver.API/Models/ApiFailsafeRuntimeGroup.cs
@@ -0,0 +1,70 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Siemens.Simatic.S7.Webserver.API.Services.Converters.JsonConverters;
+using System;
+using System.Linq;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models
+{
+ ///
+ /// Represents a Failsafe Runtime Group on the PLC
+ ///
+ public class ApiFailsafeRuntimeGroup
+ {
+ ///
+ /// The name of the F-runtime group.
+ ///
+ public string Name { get; set; }
+ ///
+ /// The signature of the runtime group, encoded as array of 4 elements to represent the 32-bit signature.
+ ///
+ public string Signature { get; set; }
+ ///
+ /// The current cycle time.
+ ///
+ [JsonConverter(typeof(TimeSpanISO8601Converter))]
+ public TimeSpan Cycle_time_current { get; set; }
+ ///
+ /// The maximum cycle time.
+ ///
+ [JsonConverter(typeof(TimeSpanISO8601Converter))]
+ public TimeSpan Cycle_time_Max { get; set; }
+ ///
+ /// The current runtime.
+ ///
+ [JsonConverter(typeof(TimeSpanISO8601Converter))]
+ public TimeSpan Runtime_current { get; set; }
+ ///
+ /// The maximum runtime.
+ ///
+ [JsonConverter(typeof(TimeSpanISO8601Converter))]
+ public TimeSpan Runtime_max { get; set; }
+
+ ///
+ /// Compares object and this
+ ///
+ /// Object to compare
+ /// True if input object and this match
+ public override bool Equals(object obj)
+ {
+ return obj is ApiFailsafeRuntimeGroup group &&
+ Name == group.Name &&
+ Enumerable.SequenceEqual(Signature, group.Signature) &&
+ Cycle_time_current.Equals(group.Cycle_time_current) &&
+ Cycle_time_Max.Equals(group.Cycle_time_Max) &&
+ Runtime_current.Equals(group.Runtime_current) &&
+ Runtime_max.Equals(group.Runtime_max);
+ }
+
+ ///
+ /// GetHashCode()
+ ///
+ /// Hash code
+ public override int GetHashCode()
+ {
+ return (Name, Signature, Cycle_time_current, Cycle_time_Max, Runtime_current, Runtime_max).GetHashCode();
+ }
+ }
+}
diff --git a/src/Webserver.API/Models/ApiFileResource.cs b/src/Webserver.API/Models/ApiFileResource.cs
index dcc7961..2f8ab7b 100644
--- a/src/Webserver.API/Models/ApiFileResource.cs
+++ b/src/Webserver.API/Models/ApiFileResource.cs
@@ -7,7 +7,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
namespace Siemens.Simatic.S7.Webserver.API.Models
{
diff --git a/src/Webserver.API/Models/ApiLanguage.cs b/src/Webserver.API/Models/ApiLanguage.cs
new file mode 100644
index 0000000..b339cef
--- /dev/null
+++ b/src/Webserver.API/Models/ApiLanguage.cs
@@ -0,0 +1,18 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System.Globalization;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models
+{
+ ///
+ /// Class containing one language (culture info)
+ ///
+ public class ApiLanguage
+ {
+ ///
+ /// Language with built-in CultureInfo class
+ ///
+ public CultureInfo Language { get; set; }
+ }
+}
diff --git a/src/Webserver.API/Models/ApiPasswordExpiration.cs b/src/Webserver.API/Models/ApiPasswordExpiration.cs
new file mode 100644
index 0000000..d1844a6
--- /dev/null
+++ b/src/Webserver.API/Models/ApiPasswordExpiration.cs
@@ -0,0 +1,44 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models
+{
+ ///
+ /// Holds password expiration information.
+ ///
+ public class ApiPasswordExpiration
+ {
+ ///
+ /// The UTC timestamp, when the user password will expire.
+ ///
+ public DateTime Timestamp { get; set; }
+
+ ///
+ /// Indicates to the user if the warning threshold for the password has been reached.
+ ///
+ public bool Warning { get; set; }
+
+ ///
+ /// Compares this to input object
+ ///
+ /// Object to compare to
+ /// True if objects are the same
+ public override bool Equals(object obj)
+ {
+ return obj is ApiPasswordExpiration expiration &&
+ Timestamp == expiration.Timestamp &&
+ Warning == expiration.Warning;
+ }
+
+ ///
+ /// Get Hash Code of PasswordExpiraton object
+ ///
+ /// Hash Code
+ public override int GetHashCode()
+ {
+ return (Timestamp, Warning).GetHashCode();
+ }
+ }
+}
diff --git a/src/Webserver.API/Models/ApiPasswordPolicy.cs b/src/Webserver.API/Models/ApiPasswordPolicy.cs
new file mode 100644
index 0000000..c5b0f8e
--- /dev/null
+++ b/src/Webserver.API/Models/ApiPasswordPolicy.cs
@@ -0,0 +1,62 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+
+namespace Siemens.Simatic.S7.Webserver.API.Models
+{
+ ///
+ /// A set of criteria defined for passwords.
+ ///
+ public class ApiPasswordPolicy
+ {
+ ///
+ /// Minimum length of passwords
+ ///
+ public int Min_password_length { get; set; }
+ ///
+ /// Maximum length of passwords
+ ///
+ public int Max_password_length { get; set; }
+ ///
+ /// Minimum number of digits required in a password
+ ///
+ public int Min_digits { get; set; }
+ ///
+ /// Minimum number of special characters required in a password
+ ///
+ public int Min_special_characters { get; set; }
+ ///
+ /// If true, the password must contain uppercase letters.
+ ///
+ public bool Requires_uppercase_characters { get; set; }
+ ///
+ /// If true, the password must contain lowercase letters.
+ ///
+ public bool Requires_lowercase_characters { get; set; }
+
+ ///
+ /// Check if incoming object is the same as this
+ ///
+ /// Object to check
+ /// True if they match
+ public override bool Equals(object obj)
+ {
+ return obj is ApiPasswordPolicy policy &&
+ Min_password_length == policy.Min_password_length &&
+ Max_password_length == policy.Max_password_length &&
+ Min_digits == policy.Min_digits &&
+ Min_special_characters == policy.Min_special_characters &&
+ Requires_uppercase_characters == policy.Requires_uppercase_characters &&
+ Requires_lowercase_characters == policy.Requires_lowercase_characters;
+ }
+
+ ///
+ /// Get hashcode of object
+ ///
+ /// Hashcode
+ public override int GetHashCode()
+ {
+ return (Min_special_characters, Min_password_length, Min_digits, Max_password_length, Requires_uppercase_characters, Requires_lowercase_characters).GetHashCode();
+ }
+ }
+}
diff --git a/src/Webserver.API/Models/ApiPlcProgramBrowseCodeBlocksData.cs b/src/Webserver.API/Models/ApiPlcProgramBrowseCodeBlocksData.cs
new file mode 100644
index 0000000..caf709a
--- /dev/null
+++ b/src/Webserver.API/Models/ApiPlcProgramBrowseCodeBlocksData.cs
@@ -0,0 +1,113 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Newtonsoft.Json.Serialization;
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models
+{
+ ///
+ /// ApiPlcProgramBrowseCodeBlocksData: Data class representing a code block value in the ApiPlcProgramBrowseCodeBlocksRequest response.
+ ///
+ public class ApiPlcProgramBrowseCodeBlocksData : IEquatable
+ {
+ ///
+ /// Function to Memberwise clone an ApiPlcProgramData to another Object.
+ ///
+ ///
+ public ApiPlcProgramBrowseCodeBlocksData ShallowCopy()
+ {
+ return (ApiPlcProgramBrowseCodeBlocksData) this.MemberwiseClone();
+ }
+
+ ///
+ /// Name of the code block.
+ ///
+ [JsonProperty("name")]
+ public string Name { get; set; }
+
+ ///
+ /// Number of the code block.
+ ///
+ [JsonProperty("block_number")]
+ public ushort BlockNumber { get; set; }
+
+ ///
+ /// Type of the code block.
+ ///
+ [JsonProperty("block_type")]
+ public string BlockType { get; set; }
+
+ ///
+ /// Constructor.
+ ///
+ [JsonConstructor]
+ public ApiPlcProgramBrowseCodeBlocksData(string name, ushort blockNumber, string blockType)
+ {
+ Name = name;
+ BlockNumber = blockNumber;
+ BlockType = blockType;
+ }
+
+ ///
+ /// Returns the Name with Quotes => $"\"{Name}\""
+ ///
+ ///
+ public string GetNameWithQuotes()
+ {
+ return $"\"{Name}\"";
+ }
+
+ ///
+ /// return the Serialized Object
+ ///
+ /// Json Object String of the Data
+ public string GetObjectString()
+ {
+ return JsonConvert.SerializeObject(this, new JsonSerializerSettings()
+ {
+ ContractResolver = new CamelCasePropertyNamesContractResolver(),
+ NullValueHandling = NullValueHandling.Ignore
+ });
+ }
+
+ ///
+ /// Call GetNameWithQuotes for debugging comfort!
+ ///
+ /// Name with quotes
+ public override string ToString()
+ {
+ return GetNameWithQuotes();
+ }
+
+ ///
+ /// Check the object for equality.
+ ///
+ ///
+ ///
+ public override bool Equals(object obj)
+ {
+ return Equals(obj as ApiPlcProgramBrowseCodeBlocksData);
+ }
+
+ ///
+ /// Check the object for equality.
+ ///
+ ///
+ ///
+ public virtual bool Equals(ApiPlcProgramBrowseCodeBlocksData obj)
+ {
+ return !(obj is null) && (obj.Name == Name) && (obj.BlockNumber == BlockNumber) && (obj.BlockType == BlockType);
+ }
+
+ ///
+ /// Return the object's hash code.
+ ///
+ /// HashCode
+ public override int GetHashCode()
+ {
+ return (Name, BlockNumber, BlockType).GetHashCode();
+ }
+ }
+}
diff --git a/src/Webserver.API/Models/ApiPlcProgramData.cs b/src/Webserver.API/Models/ApiPlcProgramData.cs
index f6748b9..e022277 100644
--- a/src/Webserver.API/Models/ApiPlcProgramData.cs
+++ b/src/Webserver.API/Models/ApiPlcProgramData.cs
@@ -1,15 +1,13 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Siemens.Simatic.S7.Webserver.API.Enums;
using Siemens.Simatic.S7.Webserver.API.Exceptions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
namespace Siemens.Simatic.S7.Webserver.API.Models
{
@@ -47,12 +45,16 @@ public ApiPlcProgramData ShallowCopy()
///
/// ApiPlcProgramDataType => helper class to determine the TIA DataTypes and map them to the byte size,...
///
- public ApiPlcProgramDataType Datatype { get { return dataType; }
- set {
+ public ApiPlcProgramDataType Datatype
+ {
+ get { return dataType; }
+ set
+ {
if (value == ApiPlcProgramDataType.None)
throw new ApiInvalidResponseException("Api PlcProgramDataType:" + value.ToString() + " was invalid!");
dataType = value;
- } }
+ }
+ }
private List _arrayDimensions;
///
@@ -97,7 +99,7 @@ public List BuildChildrenFromArrayDimensions(ListJson Object String of the Data
public string GetObjectString()
{
- return JsonConvert.SerializeObject(this, new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver()
- , NullValueHandling = NullValueHandling.Ignore });
+ return JsonConvert.SerializeObject(this, new JsonSerializerSettings()
+ {
+ ContractResolver = new CamelCasePropertyNamesContractResolver()
+ ,
+ NullValueHandling = NullValueHandling.Ignore
+ });
}
///
diff --git a/src/Webserver.API/Models/ApiPlcProgramDataArrayIndexer.cs b/src/Webserver.API/Models/ApiPlcProgramDataArrayIndexer.cs
index 708336c..8383353 100644
--- a/src/Webserver.API/Models/ApiPlcProgramDataArrayIndexer.cs
+++ b/src/Webserver.API/Models/ApiPlcProgramDataArrayIndexer.cs
@@ -1,11 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models
{
@@ -46,5 +41,5 @@ public override int GetHashCode()
return (Start_index, Count).GetHashCode();
}
}
-
+
}
diff --git a/src/Webserver.API/Models/ApiPlcProgramDataTypes/ApiDateAndTime.cs b/src/Webserver.API/Models/ApiPlcProgramDataTypes/ApiDateAndTime.cs
index 46f9be4..62033ff 100644
--- a/src/Webserver.API/Models/ApiPlcProgramDataTypes/ApiDateAndTime.cs
+++ b/src/Webserver.API/Models/ApiPlcProgramDataTypes/ApiDateAndTime.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.ApiPlcProgramDataTypes
{
@@ -18,7 +14,9 @@ public class ApiDateAndTime
///
/// Year of the Date And Time Tag
///
- public int Year { get
+ public int Year
+ {
+ get
{
return _year;
}
@@ -32,7 +30,9 @@ public int Year { get
///
/// Month of the Date And Time Tag
///
- public int Month {get
+ public int Month
+ {
+ get
{
return _month;
}
@@ -46,7 +46,9 @@ public int Month {get
///
/// Day of the Date And Time Tag
///
- public int Day { get
+ public int Day
+ {
+ get
{
return _day;
}
@@ -60,7 +62,9 @@ public int Day { get
///
/// Hour of the Date And Time Tag
///
- public int Hour { get
+ public int Hour
+ {
+ get
{
return _hour;
}
@@ -74,7 +78,9 @@ public int Hour { get
///
/// Minute of the Date And Time Tag
///
- public int Minute { get
+ public int Minute
+ {
+ get
{
return _minute;
}
@@ -88,7 +94,9 @@ public int Minute { get
///
/// Second of the Date And Time Tag
///
- public double Second { get
+ public double Second
+ {
+ get
{
return _second;
}
@@ -120,8 +128,8 @@ public ApiDateAndTime()
/// hour to set
/// minute to set
/// second to set
- public ApiDateAndTime(int year, int month, int day, int hour, int minute, double second)
- : this((new DateTime(year, month, day, hour, minute, (int)second)).AddMilliseconds((second-(int)second)*1000))
+ public ApiDateAndTime(int year, int month, int day, int hour, int minute, double second)
+ : this((new DateTime(year, month, day, hour, minute, (int)second)).AddMilliseconds((second - (int)second) * 1000))
{
}
@@ -129,7 +137,7 @@ public ApiDateAndTime(int year, int month, int day, int hour, int minute, double
/// Represents the biggest possible value of ApiDateAndTime. This field is constant.
///
public static readonly ApiDateAndTime MaxValue = new ApiDateAndTime() { _year = 2089, _month = 12, _day = 31, _hour = 23, _minute = 59, _second = 59.999 };
-
+
///
/// Represents the smallest possible value of ApiDateAndTime. This field is constant.
@@ -147,7 +155,7 @@ public ApiDateAndTime(DateTime dateTime)
this._day = dateTime.Day;
this._hour = dateTime.Hour;
this._minute = dateTime.Minute;
- this._second = dateTime.Second + ((double)dateTime.Millisecond/1000);
+ this._second = dateTime.Second + ((double)dateTime.Millisecond / 1000);
CheckValidity(nameof(dateTime));
}
diff --git a/src/Webserver.API/Models/ApiPlcProgramDataTypes/ApiS5Time.cs b/src/Webserver.API/Models/ApiPlcProgramDataTypes/ApiS5Time.cs
index 935883c..3f2abba 100644
--- a/src/Webserver.API/Models/ApiPlcProgramDataTypes/ApiS5Time.cs
+++ b/src/Webserver.API/Models/ApiPlcProgramDataTypes/ApiS5Time.cs
@@ -2,10 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.ApiPlcProgramDataTypes
{
@@ -18,13 +14,15 @@ public class ApiS5Time
///
/// Base of the displayment in the response
///
- public int Basis { get
+ public int Basis
+ {
+ get
{
return _basis;
}
set
{
- if(value == 10 || value == 100||value == 1000|| value == 10000)
+ if (value == 10 || value == 100 || value == 1000 || value == 10000)
{
_basis = value;
}
@@ -39,13 +37,15 @@ public int Basis { get
///
/// Value of the requested var
///
- public int Value { get
+ public int Value
+ {
+ get
{
return _value;
}
set
{
- if(value >= 0 && value <= 999)
+ if (value >= 0 && value <= 999)
{
_value = value;
}
@@ -111,17 +111,17 @@ public ApiS5Time(TimeSpan timeSpan)
Basis = 10;
Value = (int)(timeSpan.TotalMilliseconds / (double)Basis);
}
- else if(timeSpan >= TimeSpan.FromSeconds(10) && timeSpan < TimeSpan.FromSeconds(100))
+ else if (timeSpan >= TimeSpan.FromSeconds(10) && timeSpan < TimeSpan.FromSeconds(100))
{
Basis = 100;
Value = (int)((timeSpan.TotalMilliseconds / (double)Basis));
}
- else if(timeSpan >= TimeSpan.FromSeconds(100) && timeSpan < TimeSpan.FromSeconds(1000))
+ else if (timeSpan >= TimeSpan.FromSeconds(100) && timeSpan < TimeSpan.FromSeconds(1000))
{
Basis = 1000;
Value = (int)(timeSpan.TotalMilliseconds / (double)Basis);
}
- else if(timeSpan >= TimeSpan.FromSeconds(1000) && timeSpan < TimeSpan.FromSeconds(10000))
+ else if (timeSpan >= TimeSpan.FromSeconds(1000) && timeSpan < TimeSpan.FromSeconds(10000))
{
Basis = 10000;
Value = (int)(timeSpan.TotalMilliseconds / (double)Basis);
@@ -130,7 +130,7 @@ public ApiS5Time(TimeSpan timeSpan)
{
throw new ArgumentOutOfRangeException(nameof(timeSpan));
}
- if(GetTimeSpan() != timeSpan)
+ if (GetTimeSpan() != timeSpan)
{
throw new ArgumentOutOfRangeException(nameof(timeSpan));
}
@@ -161,7 +161,7 @@ public bool Equals(ApiS5Time other)
///
public override int GetHashCode()
{
- return (Basis,Value).GetHashCode();
+ return (Basis, Value).GetHashCode();
}
}
}
diff --git a/src/Webserver.API/Models/ApiQuantityStructure.cs b/src/Webserver.API/Models/ApiQuantityStructure.cs
new file mode 100644
index 0000000..786debc
--- /dev/null
+++ b/src/Webserver.API/Models/ApiQuantityStructure.cs
@@ -0,0 +1,59 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+
+namespace Siemens.Simatic.S7.Webserver.API.Models
+{
+ ///
+ /// This method returns a variety of quantity structure information of the webserver.
+ ///
+ public class ApiQuantityStructure
+ {
+ ///
+ /// The size of the HTTP request body of a JSON-RPC request in bytes.
+ ///
+ public long Webapi_Max_Http_Request_Body_Size { get; set; }
+ ///
+ /// The number of parallel requests to the JSON-RPC endpoint.
+ ///
+ public int Webapi_Max_Parallel_Requests { get; set; }
+ ///
+ /// The number of parallel user sessions using the JSON-RPC endpoint.
+ ///
+ public int Webapi_Max_Parallel_User_Sessions { get; set; }
+
+ ///
+ /// Check whether properties match
+ ///
+ /// Object to check
+ /// Returns true if the ApiQuantityStructures are the same
+ public override bool Equals(object obj)
+ {
+ var structure = obj as ApiQuantityStructure;
+ return structure != null &&
+ structure.Webapi_Max_Parallel_User_Sessions == this.Webapi_Max_Parallel_User_Sessions &&
+ structure.Webapi_Max_Parallel_Requests == this.Webapi_Max_Parallel_Requests &&
+ structure.Webapi_Max_Http_Request_Body_Size == this.Webapi_Max_Http_Request_Body_Size;
+ }
+
+ ///
+ /// GetHashCode for SequenceEqual etc.
+ ///
+ /// hashcode for the ApiQuantityStructures
+ public override int GetHashCode()
+ {
+ return (Webapi_Max_Http_Request_Body_Size, Webapi_Max_Parallel_Requests, Webapi_Max_Parallel_User_Sessions).GetHashCode();
+ }
+
+ ///
+ /// ToString for ApiQuantityStructures
+ ///
+ /// Formatted string
+ public override string ToString()
+ {
+ return $"{nameof(Webapi_Max_Http_Request_Body_Size)}: {Webapi_Max_Http_Request_Body_Size} | " +
+ $"{nameof(Webapi_Max_Parallel_Requests)}: {Webapi_Max_Parallel_Requests} | " +
+ $"{nameof(Webapi_Max_Parallel_User_Sessions)}: {Webapi_Max_Parallel_User_Sessions}";
+ }
+ }
+}
diff --git a/src/Webserver.API/Models/ApiSyslog/ApiPlcSyslog.cs b/src/Webserver.API/Models/ApiSyslog/ApiPlcSyslog.cs
new file mode 100644
index 0000000..26f46d0
--- /dev/null
+++ b/src/Webserver.API/Models/ApiSyslog/ApiPlcSyslog.cs
@@ -0,0 +1,82 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.ApiSyslog
+{
+ ///
+ /// Content of the PLC-internal syslog ring buffer
+ ///
+ public class ApiPlcSyslog
+ {
+ ///
+ /// Holds an array of objects where each object represents a single syslog message of the PLC-internal syslog ring buffer.
+ ///
+ public List Entries { get; set; }
+ ///
+ /// This attribute contains the total number of insertions into the syslog buffer since PLC booted up.
+ ///
+ public uint Count_Total { get; set; }
+ ///
+ /// This attribute contains the number of insertions into the syslog buffer that were lost,
+ /// meaning the number of the entries which were overwritten by new entries, and which were not saved to a syslog server.
+ ///
+ public uint Count_Lost { get; set; }
+
+ ///
+ /// Check whether properties match
+ ///
+ ///
+ /// Returns true if the ApiSyslogs are the same
+ public override bool Equals(object obj)
+ {
+ return obj is ApiPlcSyslog syslog &&
+ Entries.SequenceEqual(syslog.Entries) &&
+ Count_Total == syslog.Count_Total &&
+ Count_Lost == syslog.Count_Lost;
+ }
+
+ ///
+ /// GetHashCode for ApiSyslog
+ ///
+ /// The hash code of the apiSyslog
+ public override int GetHashCode()
+ {
+ int EntriesHashCode = 0;
+ if (Entries != null)
+ {
+ foreach (var entry in Entries)
+ {
+ EntriesHashCode ^= entry.GetHashCode();
+ }
+ }
+ return (EntriesHashCode, Count_Total, Count_Lost).GetHashCode();
+ }
+
+ ///
+ /// ToString for ApiPlcSyslog
+ ///
+ /// ApiPlcSyslog as a multiline string
+ public override string ToString()
+ {
+ return ToString(NullValueHandling.Ignore);
+ }
+ ///
+ /// ToString for ApiPlcSyslog
+ ///
+ /// Defines if null values should be ignored
+ /// ApiPlcSyslog as a multiline string
+ public string ToString(NullValueHandling nullValueHandling)
+ {
+ JsonSerializerSettings options = new JsonSerializerSettings()
+ {
+ NullValueHandling = nullValueHandling,
+ };
+ string result = JsonConvert.SerializeObject(this, Formatting.Indented, options);
+ return result;
+ }
+ }
+}
diff --git a/src/Webserver.API/Models/ApiSyslog/ApiPlcSyslog_Entry.cs b/src/Webserver.API/Models/ApiSyslog/ApiPlcSyslog_Entry.cs
new file mode 100644
index 0000000..29a5895
--- /dev/null
+++ b/src/Webserver.API/Models/ApiSyslog/ApiPlcSyslog_Entry.cs
@@ -0,0 +1,49 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.ApiSyslog
+{
+ ///
+ /// A single syslog message of the PLC-internal syslog ring buffer
+ ///
+ public class ApiPlcSyslog_Entry
+ {
+ ///
+ /// A raw syslog entry as defined in the RFC.
+ ///
+ public string Raw { get; set; }
+ ///
+ /// Check whether properties match
+ ///
+ ///
+ /// Returns true if the ApiSyslog_Entries are the same
+ public override bool Equals(object obj)
+ {
+ var structure = obj as ApiPlcSyslog_Entry;
+ if (structure is null)
+ {
+ return false;
+ }
+ return structure.Raw == this.Raw;
+ }
+
+ ///
+ /// GetHashCode for ApiSyslog_Entry
+ ///
+ /// The hash code of the ApiSyslog_Entry
+ public override int GetHashCode()
+ {
+ return Raw.GetHashCode();
+ }
+
+ ///
+ /// ToString for ApiSyslog_Entry
+ ///
+ /// Raw
+ public override string ToString()
+ {
+ return Raw;
+ }
+ }
+}
diff --git a/src/Webserver.API/Models/ApiTicket.cs b/src/Webserver.API/Models/ApiTicket.cs
index efb7b31..06a1915 100644
--- a/src/Webserver.API/Models/ApiTicket.cs
+++ b/src/Webserver.API/Models/ApiTicket.cs
@@ -1,15 +1,11 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
+using Siemens.Simatic.S7.Webserver.API.Enums;
+using Siemens.Simatic.S7.Webserver.API.Exceptions;
using System;
using System.Collections.Generic;
using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Xml;
-using Siemens.Simatic.S7.Webserver.API.Enums;
-using Siemens.Simatic.S7.Webserver.API.Exceptions;
namespace Siemens.Simatic.S7.Webserver.API.Models
{
@@ -24,27 +20,32 @@ public class ApiTicket
///
/// 28 byte string!
///
- public string Id { get { return id; }
- set {
+ public string Id
+ {
+ get { return id; }
+ set
+ {
if (value.Length != 28)
throw new ApiInvalidTicketIdValueException($"- given string:{value}");
else
id = value;
- } }
+ }
+ }
private ApiTicketState state;
///
/// ApiTicketState - None is not a valid State! there are no Stateless Tickets (so far)
///
- public ApiTicketState State {
+ public ApiTicketState State
+ {
get
{
return state;
}
set
{
- if(value == ApiTicketState.None)
+ if (value == ApiTicketState.None)
{
throw new Exception($"{value.ToString()} is not an expected value for ApiTicketState!");
}
@@ -70,7 +71,7 @@ public ApiTicketProvider Provider
}
set
{
- if(value == ApiTicketProvider.None)
+ if (value == ApiTicketProvider.None)
{
//throw new ApiException(new Responses.ApiErrorModel() { Error = new ApiError() { } })
throw new Exception($"{value.ToString()} is not an expected value for ApiTicketProvider!");
diff --git a/src/Webserver.API/Models/ApiWebAppData.cs b/src/Webserver.API/Models/ApiWebAppData.cs
index d102a54..0d943a1 100644
--- a/src/Webserver.API/Models/ApiWebAppData.cs
+++ b/src/Webserver.API/Models/ApiWebAppData.cs
@@ -4,11 +4,7 @@
using Newtonsoft.Json;
using Siemens.Simatic.S7.Webserver.API.Enums;
using Siemens.Simatic.S7.Webserver.API.Exceptions;
-using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models
{
@@ -41,13 +37,15 @@ public ApiWebAppData ShallowCopy()
///
/// State of ApiWebApp => Enabled/Disabled, None is not valid!
///
- public ApiWebAppState State { get
+ public ApiWebAppState State
+ {
+ get
{
return state;
}
set
{
- if(value == ApiWebAppState.None)
+ if (value == ApiWebAppState.None)
{
throw new ApiInvalidResponseException($"Returned from api was:{value.ToString()} - which is not valid! contact Siemens");
}
diff --git a/src/Webserver.API/Models/ApiWebAppDataSaveSetting.cs b/src/Webserver.API/Models/ApiWebAppDataSaveSetting.cs
index ddc55d6..bf726af 100644
--- a/src/Webserver.API/Models/ApiWebAppDataSaveSetting.cs
+++ b/src/Webserver.API/Models/ApiWebAppDataSaveSetting.cs
@@ -3,11 +3,6 @@
// SPDX-License-Identifier: MIT
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models
{
@@ -69,7 +64,7 @@ public ApiWebAppDataSaveSetting()
/// will be used to determine wether a directory will be created
/// for saving in case it does not yet exist and is provided via DirectoryPath
/// Setting for the Serialization
- public ApiWebAppDataSaveSetting(string directoryPath, string configurationName,
+ public ApiWebAppDataSaveSetting(string directoryPath, string configurationName,
bool checkConsistency, bool createDirectoryIfNotExists, JsonSerializerSettings jsonSerializerSetting)
{
DirectoryPath = directoryPath;
diff --git a/src/Webserver.API/Models/ApiWebAppResource.cs b/src/Webserver.API/Models/ApiWebAppResource.cs
index 2b0025d..b597147 100644
--- a/src/Webserver.API/Models/ApiWebAppResource.cs
+++ b/src/Webserver.API/Models/ApiWebAppResource.cs
@@ -4,10 +4,6 @@
using Siemens.Simatic.S7.Webserver.API.Enums;
using Siemens.Simatic.S7.Webserver.API.Exceptions;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models
{
@@ -46,7 +42,8 @@ public ApiWebAppResource ShallowCopy()
///
/// Resource Visibility - (plc uses to) determine wether a user is allowed to access the Resource (has cookie with according rights)
///
- public ApiWebAppResourceVisibility Visibility {
+ public ApiWebAppResourceVisibility Visibility
+ {
get
{
return visibility;
@@ -100,9 +97,9 @@ public bool Equals(ApiWebAppResource other)
string lastModified = this.Last_modified.ToString();
string otherLastModified = other.Last_modified.ToString();
- if(IgnoreBOMDifference.HasValue && IgnoreBOMDifference == true)
+ if (IgnoreBOMDifference.HasValue && IgnoreBOMDifference == true)
{
- bool toReturn = (this.Name == other.Name && ((this.Size == (other.Size - 3)) || (this.Size == other.Size) || (this.Size == (other.Size +3))) && this.Media_type == other.Media_type
+ bool toReturn = (this.Name == other.Name && ((this.Size == (other.Size - 3)) || (this.Size == other.Size) || (this.Size == (other.Size + 3))) && this.Media_type == other.Media_type
&& this.Visibility == other.Visibility && (lastModified == otherLastModified) && this.Etag == other.Etag);
return toReturn;
}
@@ -111,7 +108,7 @@ public bool Equals(ApiWebAppResource other)
return this.Name == other.Name && (this.Size == other.Size) && this.Media_type == other.Media_type
&& this.Visibility == other.Visibility && (lastModified == otherLastModified) && this.Etag == other.Etag;
}
-
+
}
///
diff --git a/src/Webserver.API/Models/FailsafeParameters/FailsafeHardware.cs b/src/Webserver.API/Models/FailsafeParameters/FailsafeHardware.cs
new file mode 100644
index 0000000..1bc6ebe
--- /dev/null
+++ b/src/Webserver.API/Models/FailsafeParameters/FailsafeHardware.cs
@@ -0,0 +1,108 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Siemens.Simatic.S7.Webserver.API.Services.Converters.JsonConverters;
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.FailsafeParameters
+{
+ ///
+ /// Base class for Failsafe Hardware Types
+ ///
+ [JsonConverter(typeof(FailsafeHardwareConverter))]
+ public class FailsafeHardware
+ {
+ }
+
+ ///
+ /// Failsafe CPU
+ ///
+ public class FailsafeCPU : FailsafeHardware
+ {
+ ///
+ /// The timestamp of the last failsafe program modification.
+ ///
+ public DateTime Last_f_program_modification { get; set; }
+ ///
+ /// The collective signature encoded as string containing a hexadecimal representation of the 32-bit signature.
+ ///
+ public string Collective_signature { get; set; }
+
+ ///
+ /// The remaining was introduced with Safety system version V2.4. Older versions do not support the remaining time.
+ /// The version can be configured in the TIA Portal Safety Administration.
+ ///
+ [JsonConverter(typeof(TimeSpanISO8601Converter))]
+ public TimeSpan? Remaining_time { get; set; }
+
+ ///
+ /// Checks if the incoming object is the same as this
+ ///
+ /// Object to check
+ /// True if they are the same object
+ public override bool Equals(object obj)
+ {
+ return obj is FailsafeCPU cpu &&
+ Last_f_program_modification == cpu.Last_f_program_modification &&
+ Remaining_time == cpu.Remaining_time &&
+ Collective_signature == cpu.Collective_signature;
+ }
+
+ ///
+ /// Hash code
+ ///
+ /// (LastFProgramModification, CollectiveSignature).GetHashCode()
+ public override int GetHashCode()
+ {
+ return (Last_f_program_modification, Collective_signature, Remaining_time).GetHashCode();
+ }
+ }
+
+ ///
+ /// Failsafe Module
+ ///
+ public class FailsafeModule : FailsafeHardware
+ {
+ ///
+ /// F-monitoring time.
+ ///
+ [JsonConverter(typeof(TimeSpanISO8601Converter))]
+ public TimeSpan F_monitoring_time { get; set; }
+ ///
+ /// Contains the F-source address.
+ ///
+ public int F_source_address { get; set; }
+ ///
+ /// Contains the F-destination address
+ ///
+ public int F_destination_address { get; set; }
+ ///
+ /// The F-Par CRC encoded as string containing a hexadecimal representation of the 32-bit signature.
+ ///
+ public string F_par_crc { get; set; }
+
+ ///
+ /// Checks if the incoming object is the same as this
+ ///
+ /// Object to check
+ /// True if they are the same object
+ public override bool Equals(object obj)
+ {
+ return obj is FailsafeModule module &&
+ F_monitoring_time.Equals(module.F_monitoring_time) &&
+ F_source_address == module.F_source_address &&
+ F_destination_address == module.F_destination_address &&
+ F_par_crc == module.F_par_crc;
+ }
+
+ ///
+ /// Hash code
+ ///
+ /// (FMonitoringTime, FParCrc, FDestinationAddress, FSourceAddress).GetHashCode()
+ public override int GetHashCode()
+ {
+ return (F_monitoring_time, F_par_crc, F_destination_address, F_source_address).GetHashCode();
+ }
+ }
+}
diff --git a/src/Webserver.API/Models/HttpClientAndWebAppCookie.cs b/src/Webserver.API/Models/HttpClientAndWebAppCookie.cs
index ffc3403..fe7bf9e 100644
--- a/src/Webserver.API/Models/HttpClientAndWebAppCookie.cs
+++ b/src/Webserver.API/Models/HttpClientAndWebAppCookie.cs
@@ -1,12 +1,8 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
using System.Collections.Generic;
-using System.Linq;
using System.Net.Http;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models
{
diff --git a/src/Webserver.API/Models/HttpClientConnectionConfiguration.cs b/src/Webserver.API/Models/HttpClientConnectionConfiguration.cs
index a0ca0e7..acafe6a 100644
--- a/src/Webserver.API/Models/HttpClientConnectionConfiguration.cs
+++ b/src/Webserver.API/Models/HttpClientConnectionConfiguration.cs
@@ -1,15 +1,8 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using Siemens.Simatic.S7.Webserver.API.Models.Requests;
-using Siemens.Simatic.S7.Webserver.API.Services.IdGenerator;
-using Siemens.Simatic.S7.Webserver.API.Services.RequestHandling;
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Net.Http.Headers;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models
{
@@ -78,7 +71,7 @@ public HttpClientConnectionConfiguration ShallowCopy()
/// Defaults to false
/// Defaults to false
/// Defaults to true
- public HttpClientConnectionConfiguration(string baseAddress, string username, string password,
+ public HttpClientConnectionConfiguration(string baseAddress, string username, string password,
TimeSpan timeOut, bool connectionClose, bool allowAutoRedirect, bool discardPasswordAfterConnect)
{
this.BaseAddress = baseAddress;
diff --git a/src/Webserver.API/Models/IApiWebAppData.cs b/src/Webserver.API/Models/IApiWebAppData.cs
index 591ad5b..09e87ae 100644
--- a/src/Webserver.API/Models/IApiWebAppData.cs
+++ b/src/Webserver.API/Models/IApiWebAppData.cs
@@ -1,8 +1,8 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System.Collections.Generic;
using Siemens.Simatic.S7.Webserver.API.Enums;
+using System.Collections.Generic;
namespace Siemens.Simatic.S7.Webserver.API.Models
{
diff --git a/src/Webserver.API/Models/Requests/ApiRequest.cs b/src/Webserver.API/Models/Requests/ApiRequest.cs
index 8560868..e317950 100644
--- a/src/Webserver.API/Models/Requests/ApiRequest.cs
+++ b/src/Webserver.API/Models/Requests/ApiRequest.cs
@@ -2,12 +2,8 @@
//
// SPDX-License-Identifier: MIT
using Newtonsoft.Json;
-using Siemens.Simatic.S7.Webserver.API.Models;
using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Requests
{
@@ -23,7 +19,7 @@ public class ApiRequest : ApiBaseRequest, IApiRequest, IApiBaseRequestThe required JsonRpc
/// The required ID
/// Optional parameters for those Api Request where it is possible (e.g. Files.Rename)
- public ApiRequest(string method, string jsonRpc, string id, Dictionary requestParams = null)
+ public ApiRequest(string method, string jsonRpc, string id, Dictionary requestParams = null)
: base(method, jsonRpc, id, requestParams)
{
}
@@ -42,7 +38,7 @@ public class ApiRequestIntId : ApiBaseRequest, IApiRequestIntId, IApiBaseRe
/// The required JsonRpc
/// The required ID as an Integer
/// Optional parameters for those Api Request where it is possible (e.g. Files.Rename)
- public ApiRequestIntId(string method, string jsonRpc, int id, Dictionary requestParams = null)
+ public ApiRequestIntId(string method, string jsonRpc, int id, Dictionary requestParams = null)
: base(method, jsonRpc, id, requestParams)
{
}
diff --git a/src/Webserver.API/Models/Requests/IApiRequest.cs b/src/Webserver.API/Models/Requests/IApiRequest.cs
index 693f1df..c61b391 100644
--- a/src/Webserver.API/Models/Requests/IApiRequest.cs
+++ b/src/Webserver.API/Models/Requests/IApiRequest.cs
@@ -1,12 +1,7 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using Siemens.Simatic.S7.Webserver.API.Models;
-using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Requests
{
diff --git a/src/Webserver.API/Models/Responses/ApiAlarmsBrowseResponse.cs b/src/Webserver.API/Models/Responses/ApiAlarmsBrowseResponse.cs
new file mode 100644
index 0000000..b327177
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ApiAlarmsBrowseResponse.cs
@@ -0,0 +1,14 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Siemens.Simatic.S7.Webserver.API.Models.AlarmsBrowse;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
+{
+ ///
+ /// Response to an ApiAlarms.Browse request
+ ///
+ public class ApiAlarmsBrowseResponse : ApiResultResponse
+ {
+ }
+}
diff --git a/src/Webserver.API/Models/Responses/ApiArrayOfApiClassResponse.cs b/src/Webserver.API/Models/Responses/ApiArrayOfApiClassResponse.cs
index fd26f82..8502848 100644
--- a/src/Webserver.API/Models/Responses/ApiArrayOfApiClassResponse.cs
+++ b/src/Webserver.API/Models/Responses/ApiArrayOfApiClassResponse.cs
@@ -1,19 +1,14 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using Siemens.Simatic.S7.Webserver.API.Models;
-using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
///
/// ApiResponse (Jsonrpc,id) with a List of ApiClasses
///
- public class ApiArrayOfApiClassResponse : ApiResultResponse >
+ public class ApiArrayOfApiClassResponse : ApiResultResponse>
{
}
}
diff --git a/src/Webserver.API/Models/Responses/ApiBrowseFilesResponse.cs b/src/Webserver.API/Models/Responses/ApiBrowseFilesResponse.cs
index ad14c50..fb971fc 100644
--- a/src/Webserver.API/Models/Responses/ApiBrowseFilesResponse.cs
+++ b/src/Webserver.API/Models/Responses/ApiBrowseFilesResponse.cs
@@ -2,9 +2,6 @@
//
// SPDX-License-Identifier: MIT
using Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults;
-using System;
-using System.Collections.Generic;
-using System.Text;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
diff --git a/src/Webserver.API/Models/Responses/ApiBrowseTicketsResponse.cs b/src/Webserver.API/Models/Responses/ApiBrowseTicketsResponse.cs
index 7397ae7..f630e2e 100644
--- a/src/Webserver.API/Models/Responses/ApiBrowseTicketsResponse.cs
+++ b/src/Webserver.API/Models/Responses/ApiBrowseTicketsResponse.cs
@@ -1,13 +1,7 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using Siemens.Simatic.S7.Webserver.API.Models;
using Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
diff --git a/src/Webserver.API/Models/Responses/ApiBulkResponse.cs b/src/Webserver.API/Models/Responses/ApiBulkResponse.cs
index 28c436e..d85fbdf 100644
--- a/src/Webserver.API/Models/Responses/ApiBulkResponse.cs
+++ b/src/Webserver.API/Models/Responses/ApiBulkResponse.cs
@@ -1,11 +1,8 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
diff --git a/src/Webserver.API/Models/Responses/ApiDiagnosticBufferBrowseResponse.cs b/src/Webserver.API/Models/Responses/ApiDiagnosticBufferBrowseResponse.cs
new file mode 100644
index 0000000..aca3a3b
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ApiDiagnosticBufferBrowseResponse.cs
@@ -0,0 +1,13 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
+{
+ ///
+ /// Response to an ApiDiagnosticBuffer.Browse request
+ ///
+ public class ApiDiagnosticBufferBrowseResponse : ApiResultResponse
+ {
+ }
+}
diff --git a/src/Webserver.API/Models/Responses/ApiDoubleResponse.cs b/src/Webserver.API/Models/Responses/ApiDoubleResponse.cs
index 16464a7..a4eaac9 100644
--- a/src/Webserver.API/Models/Responses/ApiDoubleResponse.cs
+++ b/src/Webserver.API/Models/Responses/ApiDoubleResponse.cs
@@ -1,11 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
diff --git a/src/Webserver.API/Models/Responses/ApiErrorModel.cs b/src/Webserver.API/Models/Responses/ApiErrorModel.cs
index 97b2a10..9d0f9aa 100644
--- a/src/Webserver.API/Models/Responses/ApiErrorModel.cs
+++ b/src/Webserver.API/Models/Responses/ApiErrorModel.cs
@@ -1,9 +1,9 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
using Siemens.Simatic.S7.Webserver.API.Enums;
using Siemens.Simatic.S7.Webserver.API.Exceptions;
+using System;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
@@ -90,12 +90,38 @@ public void ThrowAccordingException(string apiRequestString, string responseStri
throw new ApiInvalidETagException(new ApiException(this, apiRequestString));
case ApiErrorCode.ResourceContentHasBeenCorrupted:
throw new ApiResourceContentHasBeenCorruptedException(new ApiException(this, apiRequestString));
+ case ApiErrorCode.InvalidAlarmId:
+ throw new ApiInvalidAlarmIdException(new ApiException(this, apiRequestString));
+ case ApiErrorCode.InvalidAlarmsBrowseParameters:
+ throw new ApiInvalidAlarmsBrowseParametersException(new ApiException(this, apiRequestString));
case ApiErrorCode.PLCNotInStop:
throw new ApiPLCNotInStopException(new ApiException(this, apiRequestString));
case ApiErrorCode.MethodNotFound:
throw new ApiMethodNotFoundException(new ApiException(this, apiRequestString));
case ApiErrorCode.InvalidParams:
throw new ApiInvalidParametersException(new ApiException(this, apiRequestString));
+ case ApiErrorCode.PasswordExpired:
+ throw new ApiPasswordExpiredException(new ApiException(this, apiRequestString));
+ case ApiErrorCode.PasswordChangeNotAccepted:
+ throw new ApiPasswordChangeNotAcceptedException(new ApiException(this, apiRequestString));
+ case ApiErrorCode.NewPasswordDoesNotFollowPolicy:
+ throw new ApiNewPasswordDoesNotFollowPolicyException(new ApiException(this, apiRequestString));
+ case ApiErrorCode.NewPasswordMatchesOldPassword:
+ throw new ApiNewPasswordMatchesOldPasswordException(new ApiException(this, apiRequestString));
+ case ApiErrorCode.PartnerNotAccessible:
+ throw new ApiPartnerNotAccessibleException(new ApiException(this, apiRequestString));
+ case ApiErrorCode.NoServiceDataResources:
+ throw new ApiNoServiceDataResourcesException(new ApiException(this, apiRequestString));
+ case ApiErrorCode.InvalidHwId:
+ throw new ApiInvalidHwIdException(new ApiException(this, apiRequestString));
+ case ApiErrorCode.InvalidTimestamp:
+ throw new ApiInvalidTimestampException(new ApiException(this, apiRequestString));
+ case ApiErrorCode.TimestampOutOfRange:
+ throw new ApiTimestampOutOfRangeException(new ApiException(this, apiRequestString));
+ case ApiErrorCode.InvalidTimeRule:
+ throw new ApiInvalidTimeRuleException(new ApiException(this, apiRequestString));
+ case ApiErrorCode.InvalidUTCOffset:
+ throw new ApiInvalidUTCOffsetException(new ApiException(this, apiRequestString));
default:
throw new ApiException(this, apiRequestString);
diff --git a/src/Webserver.API/Models/Responses/ApiFailsafeReadParametersResponse.cs b/src/Webserver.API/Models/Responses/ApiFailsafeReadParametersResponse.cs
new file mode 100644
index 0000000..4dae3bf
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ApiFailsafeReadParametersResponse.cs
@@ -0,0 +1,14 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
+{
+ ///
+ /// Response containing Failsafe ReadParameters result
+ ///
+ public class ApiFailsafeReadParametersResponse : ApiResultResponse
+ {
+ }
+}
diff --git a/src/Webserver.API/Models/Responses/ApiFailsafeReadRuntimeGroupsResponse.cs b/src/Webserver.API/Models/Responses/ApiFailsafeReadRuntimeGroupsResponse.cs
new file mode 100644
index 0000000..21844cd
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ApiFailsafeReadRuntimeGroupsResponse.cs
@@ -0,0 +1,14 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
+{
+ ///
+ /// Response containing Failsafe.ReadRuntimeGroups result
+ ///
+ public class ApiFailsafeReadRuntimeGroupsResponse : ApiResultResponse
+ {
+ }
+}
diff --git a/src/Webserver.API/Models/Responses/ApiGetAuthenticationModeResponse.cs b/src/Webserver.API/Models/Responses/ApiGetAuthenticationModeResponse.cs
new file mode 100644
index 0000000..64a6f5d
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ApiGetAuthenticationModeResponse.cs
@@ -0,0 +1,14 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
+{
+ ///
+ /// Response of Api.GetAuthenticationMode
+ ///
+ public class ApiGetAuthenticationModeResponse : ApiResultResponse
+ {
+ }
+}
diff --git a/src/Webserver.API/Models/Responses/ApiGetPasswordPolicyResponse.cs b/src/Webserver.API/Models/Responses/ApiGetPasswordPolicyResponse.cs
new file mode 100644
index 0000000..7e42b42
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ApiGetPasswordPolicyResponse.cs
@@ -0,0 +1,14 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
+{
+ ///
+ /// Response of Api.GetPasswordPolicy
+ ///
+ public class ApiGetPasswordPolicyResponse : ApiResultResponse
+ {
+ }
+}
diff --git a/src/Webserver.API/Models/Responses/ApiGetQuantityStructuresResponse.cs b/src/Webserver.API/Models/Responses/ApiGetQuantityStructuresResponse.cs
new file mode 100644
index 0000000..738bc1e
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ApiGetQuantityStructuresResponse.cs
@@ -0,0 +1,13 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
+{
+ ///
+ /// ApiResponse (Jsonrpc,id) with an Api Quantity Structure object
+ ///
+ public class ApiGetQuantityStructuresResponse : ApiResultResponse
+ {
+
+ }
+}
diff --git a/src/Webserver.API/Models/Responses/ApiLoginResponse.cs b/src/Webserver.API/Models/Responses/ApiLoginResponse.cs
index 5af39e2..1716de8 100644
--- a/src/Webserver.API/Models/Responses/ApiLoginResponse.cs
+++ b/src/Webserver.API/Models/Responses/ApiLoginResponse.cs
@@ -2,11 +2,6 @@
//
// SPDX-License-Identifier: MIT
using Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
@@ -15,6 +10,6 @@ namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
///
public class ApiLoginResponse : ApiResultResponse
{
-
+
}
}
diff --git a/src/Webserver.API/Models/Responses/ApiPlcProgramBrowseCodeBlocksResponse.cs b/src/Webserver.API/Models/Responses/ApiPlcProgramBrowseCodeBlocksResponse.cs
new file mode 100644
index 0000000..da58dbf
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ApiPlcProgramBrowseCodeBlocksResponse.cs
@@ -0,0 +1,14 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System.Collections.Generic;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
+{
+ ///
+ /// ApiPlcProgramBrowseCodeBlocksResponse (Jsonrpc,id) with a List of ApiPlcProgramBrowseCodeBlocksData
+ ///
+ public class ApiPlcProgramBrowseCodeBlocksResponse : ApiResultResponse>
+ {
+ }
+}
diff --git a/src/Webserver.API/Models/Responses/ApiPlcProgramBrowseResponse.cs b/src/Webserver.API/Models/Responses/ApiPlcProgramBrowseResponse.cs
index 87f5486..e95f304 100644
--- a/src/Webserver.API/Models/Responses/ApiPlcProgramBrowseResponse.cs
+++ b/src/Webserver.API/Models/Responses/ApiPlcProgramBrowseResponse.cs
@@ -1,12 +1,7 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using Siemens.Simatic.S7.Webserver.API.Models;
-using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
diff --git a/src/Webserver.API/Models/Responses/ApiPlcReadModeSelectorStateResponse.cs b/src/Webserver.API/Models/Responses/ApiPlcReadModeSelectorStateResponse.cs
new file mode 100644
index 0000000..2ef0fbf
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ApiPlcReadModeSelectorStateResponse.cs
@@ -0,0 +1,15 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
+{
+ ///
+ /// ApiResponse (Jsonrpc,id) with Mode Selector State
+ ///
+ public class ApiPlcReadModeSelectorStateResponse : ApiResultResponse
+ {
+
+ }
+}
diff --git a/src/Webserver.API/Models/Responses/ApiPlcReadSystemTimeResult.cs b/src/Webserver.API/Models/Responses/ApiPlcReadSystemTimeResult.cs
index c99b9f2..56d8e14 100644
--- a/src/Webserver.API/Models/Responses/ApiPlcReadSystemTimeResult.cs
+++ b/src/Webserver.API/Models/Responses/ApiPlcReadSystemTimeResult.cs
@@ -2,9 +2,6 @@
//
// SPDX-License-Identifier: MIT
using Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults;
-using System;
-using System.Collections.Generic;
-using System.Text;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
diff --git a/src/Webserver.API/Models/Responses/ApiPlcReadTimeSettingsResponse.cs b/src/Webserver.API/Models/Responses/ApiPlcReadTimeSettingsResponse.cs
index 5f72f4c..f5fc4c4 100644
--- a/src/Webserver.API/Models/Responses/ApiPlcReadTimeSettingsResponse.cs
+++ b/src/Webserver.API/Models/Responses/ApiPlcReadTimeSettingsResponse.cs
@@ -2,9 +2,6 @@
//
// SPDX-License-Identifier: MIT
using Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults;
-using System;
-using System.Collections.Generic;
-using System.Text;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
diff --git a/src/Webserver.API/Models/Responses/ApiReadLanguagesResponse.cs b/src/Webserver.API/Models/Responses/ApiReadLanguagesResponse.cs
new file mode 100644
index 0000000..94d92da
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ApiReadLanguagesResponse.cs
@@ -0,0 +1,15 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
+{
+ ///
+ /// Response of Project.ReadLanguages
+ ///
+ public class ApiReadLanguagesResponse : ApiResultResponse
+ {
+
+ }
+}
diff --git a/src/Webserver.API/Models/Responses/ApiReadOperatingModeResponse.cs b/src/Webserver.API/Models/Responses/ApiReadOperatingModeResponse.cs
index b051aa0..78b3ed9 100644
--- a/src/Webserver.API/Models/Responses/ApiReadOperatingModeResponse.cs
+++ b/src/Webserver.API/Models/Responses/ApiReadOperatingModeResponse.cs
@@ -3,11 +3,6 @@
// SPDX-License-Identifier: MIT
using Siemens.Simatic.S7.Webserver.API.Enums;
using Siemens.Simatic.S7.Webserver.API.Exceptions;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
@@ -19,9 +14,10 @@ public class ApiReadOperatingModeResponse : ApiResultResponse
/// ApiPlcOperatingMode Result => Only accept valid Plc Operating Modes!
///
- public override ApiPlcOperatingMode Result {
+ public override ApiPlcOperatingMode Result
+ {
get => base.Result;
- set
+ set
{
if (value == ApiPlcOperatingMode.None || value == ApiPlcOperatingMode.Unknown)
throw new ApiInvalidResponseException($"ApiPlcOperatingmode returned from api was:{value.ToString()} - which is not valid! contact Siemens");
diff --git a/src/Webserver.API/Models/Responses/ApiResultResponse.cs b/src/Webserver.API/Models/Responses/ApiResultResponse.cs
index 98d1247..f710e02 100644
--- a/src/Webserver.API/Models/Responses/ApiResultResponse.cs
+++ b/src/Webserver.API/Models/Responses/ApiResultResponse.cs
@@ -1,18 +1,13 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
///
/// Generally an ApiResponse contains "Id" and "JsonRpc"
///
- public class ApiResultResponse : BaseApiResponse //BaseResultObject => dann wären Properties von BaseResultObject verfügbar
+ public class ApiResultResponse : BaseApiResponse
{
///
/// The (requested) Result the Api has responded with
diff --git a/src/Webserver.API/Models/Responses/ApiSingleStringResponse.cs b/src/Webserver.API/Models/Responses/ApiSingleStringResponse.cs
index 64c292d..18b097c 100644
--- a/src/Webserver.API/Models/Responses/ApiSingleStringResponse.cs
+++ b/src/Webserver.API/Models/Responses/ApiSingleStringResponse.cs
@@ -1,12 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using Siemens.Simatic.S7.Webserver.API.Exceptions;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
diff --git a/src/Webserver.API/Models/Responses/ApiSyslogBrowseResponse.cs b/src/Webserver.API/Models/Responses/ApiSyslogBrowseResponse.cs
new file mode 100644
index 0000000..cad83d7
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ApiSyslogBrowseResponse.cs
@@ -0,0 +1,13 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
+{
+ ///
+ /// Response to ApiSyslogBrowse request
+ ///
+ public class ApiSyslogBrowseResponse : ApiResultResponse
+ {
+ }
+}
diff --git a/src/Webserver.API/Models/Responses/ApiTicketIdResponse.cs b/src/Webserver.API/Models/Responses/ApiTicketIdResponse.cs
index 0e5a32b..8cab8d3 100644
--- a/src/Webserver.API/Models/Responses/ApiTicketIdResponse.cs
+++ b/src/Webserver.API/Models/Responses/ApiTicketIdResponse.cs
@@ -1,14 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using Siemens.Simatic.S7.Webserver.API.Models.Requests;
-using Siemens.Simatic.S7.Webserver.API.Services.RequestHandling;
-using Siemens.Simatic.S7.Webserver.API.StaticHelpers;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
@@ -31,9 +23,9 @@ public ApiTicketIdResponse() : base()
///
public ApiTicketIdResponse(ApiSingleStringResponse singleStringResponse) : base()
{
- this.Id = string.Copy(singleStringResponse.Id);
- this.JsonRpc = string.Copy(singleStringResponse.JsonRpc);
- this.Result = string.Copy(singleStringResponse.Result);
+ this.Id = singleStringResponse.Id;
+ this.JsonRpc = singleStringResponse.JsonRpc;
+ this.Result = singleStringResponse.Result;
}
}
}
diff --git a/src/Webserver.API/Models/Responses/ApiTrueOnSuccessResponse.cs b/src/Webserver.API/Models/Responses/ApiTrueOnSuccessResponse.cs
index 673e3d2..919cd4f 100644
--- a/src/Webserver.API/Models/Responses/ApiTrueOnSuccessResponse.cs
+++ b/src/Webserver.API/Models/Responses/ApiTrueOnSuccessResponse.cs
@@ -2,11 +2,6 @@
//
// SPDX-License-Identifier: MIT
using Siemens.Simatic.S7.Webserver.API.Exceptions;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
@@ -18,7 +13,8 @@ public class ApiTrueOnSuccessResponse : ApiResultResponse
///
/// True on SuccessResponse: Only Accept "true"
///
- public override bool Result {
+ public override bool Result
+ {
get => base.Result; set
{
if (value)
@@ -29,7 +25,7 @@ public override bool Result {
{
throw new ApiInvalidResponseException($"Server responded with \"{value}\" for a true on success response!?");
}
-
+
}
}
}
diff --git a/src/Webserver.API/Models/Responses/ApiTrueWithResourceResponse.cs b/src/Webserver.API/Models/Responses/ApiTrueWithResourceResponse.cs
index 660fcdd..13c34a1 100644
--- a/src/Webserver.API/Models/Responses/ApiTrueWithResourceResponse.cs
+++ b/src/Webserver.API/Models/Responses/ApiTrueWithResourceResponse.cs
@@ -1,12 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Siemens.Simatic.S7.Webserver.API.Models;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
diff --git a/src/Webserver.API/Models/Responses/ApiTrueWithWebAppResponse.cs b/src/Webserver.API/Models/Responses/ApiTrueWithWebAppResponse.cs
index 25be999..53bb8a7 100644
--- a/src/Webserver.API/Models/Responses/ApiTrueWithWebAppResponse.cs
+++ b/src/Webserver.API/Models/Responses/ApiTrueWithWebAppResponse.cs
@@ -1,12 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using Siemens.Simatic.S7.Webserver.API.Models;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
diff --git a/src/Webserver.API/Models/Responses/ApiWebAppBrowseResourcesResponse.cs b/src/Webserver.API/Models/Responses/ApiWebAppBrowseResourcesResponse.cs
index fccaa3e..f96759e 100644
--- a/src/Webserver.API/Models/Responses/ApiWebAppBrowseResourcesResponse.cs
+++ b/src/Webserver.API/Models/Responses/ApiWebAppBrowseResourcesResponse.cs
@@ -2,11 +2,6 @@
//
// SPDX-License-Identifier: MIT
using Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
diff --git a/src/Webserver.API/Models/Responses/ApiWebAppBrowseResponse.cs b/src/Webserver.API/Models/Responses/ApiWebAppBrowseResponse.cs
index 0ac6ed7..97ef3b9 100644
--- a/src/Webserver.API/Models/Responses/ApiWebAppBrowseResponse.cs
+++ b/src/Webserver.API/Models/Responses/ApiWebAppBrowseResponse.cs
@@ -2,11 +2,6 @@
//
// SPDX-License-Identifier: MIT
using Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
diff --git a/src/Webserver.API/Models/Responses/ApiWebServerGetReadDefaultPageResponse.cs b/src/Webserver.API/Models/Responses/ApiWebServerGetReadDefaultPageResponse.cs
new file mode 100644
index 0000000..84c30c8
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ApiWebServerGetReadDefaultPageResponse.cs
@@ -0,0 +1,14 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
+{
+ ///
+ /// ApiWebServerGetReadDefaultPageResponse: containing the default page result
+ ///
+ public class ApiWebServerGetReadDefaultPageResponse : ApiResultResponse
+ {
+ }
+}
diff --git a/src/Webserver.API/Models/Responses/BaseApiResponse.cs b/src/Webserver.API/Models/Responses/BaseApiResponse.cs
index 44e9adf..d208de0 100644
--- a/src/Webserver.API/Models/Responses/BaseApiResponse.cs
+++ b/src/Webserver.API/Models/Responses/BaseApiResponse.cs
@@ -1,11 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses
{
diff --git a/src/Webserver.API/Models/Responses/ResponseResults/ApiFailsafeReadParametersResult.cs b/src/Webserver.API/Models/Responses/ResponseResults/ApiFailsafeReadParametersResult.cs
new file mode 100644
index 0000000..c765e4e
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ResponseResults/ApiFailsafeReadParametersResult.cs
@@ -0,0 +1,31 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Siemens.Simatic.S7.Webserver.API.Enums;
+using Siemens.Simatic.S7.Webserver.API.Models.FailsafeParameters;
+using Siemens.Simatic.S7.Webserver.API.Services.Converters.JsonConverters;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults
+{
+ ///
+ /// Result containing Failsafe.ReadParameters objects
+ ///
+ public class ApiFailsafeReadParametersResult
+ {
+ ///
+ /// The status if the safety mode is enabled or not.
+ ///
+ [JsonConverter(typeof(EnabledDisabledConverter))]
+ public bool Safety_mode { get; set; }
+ ///
+ /// The type defines if the requested hardware identifier represents either the safety PLC itself or another failsafe module.
+ ///
+ public ApiFailsafeHardwareType Type { get; set; }
+ ///
+ /// If the requested hardware identifier represents the safety PLC itself and the PLC has a safety program,this object must be present using data structure 'FailsafeCPU'
+ /// If the requested hardware identifier represents any other safety module than the Safety PLC itself, this object must be present using data structure 'FailsafeModule'
+ ///
+ public FailsafeHardware Parameters { get; set; }
+ }
+}
diff --git a/src/Webserver.API/Models/Responses/ResponseResults/ApiFailsafeReadRuntimeGroupsResult.cs b/src/Webserver.API/Models/Responses/ResponseResults/ApiFailsafeReadRuntimeGroupsResult.cs
new file mode 100644
index 0000000..d6e89bd
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ResponseResults/ApiFailsafeReadRuntimeGroupsResult.cs
@@ -0,0 +1,18 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System.Collections.Generic;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults
+{
+ ///
+ /// Result containing runtime groups
+ ///
+ public class ApiFailsafeReadRuntimeGroupsResult
+ {
+ ///
+ /// List of runtime groups. The list may be empty if no runtime groups exist.
+ ///
+ public List Groups { get; set; }
+ }
+}
diff --git a/src/Webserver.API/Models/Responses/ResponseResults/ApiGetAuthenticationModeResult.cs b/src/Webserver.API/Models/Responses/ResponseResults/ApiGetAuthenticationModeResult.cs
new file mode 100644
index 0000000..b5f0683
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ResponseResults/ApiGetAuthenticationModeResult.cs
@@ -0,0 +1,19 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Siemens.Simatic.S7.Webserver.API.Enums;
+using System.Collections.Generic;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults
+{
+ ///
+ /// A class containing a list of authentication modes
+ ///
+ public class ApiGetAuthenticationModeResult
+ {
+ ///
+ /// A list of authentication modes
+ ///
+ public List Authentication_modes { get; set; }
+ }
+}
diff --git a/src/Webserver.API/Models/Responses/ResponseResults/ApiGetPasswordPolicyResult.cs b/src/Webserver.API/Models/Responses/ResponseResults/ApiGetPasswordPolicyResult.cs
new file mode 100644
index 0000000..f531c32
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ResponseResults/ApiGetPasswordPolicyResult.cs
@@ -0,0 +1,17 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults
+{
+ ///
+ /// Result of Api.GetPasswordPolicy
+ ///
+ public class ApiGetPasswordPolicyResult
+ {
+ ///
+ /// Currently configured password policy
+ ///
+ public ApiPasswordPolicy Password_policy { get; set; }
+ }
+}
diff --git a/src/Webserver.API/Models/Responses/ResponseResults/ApiPlcReadModeSelectorStateResult.cs b/src/Webserver.API/Models/Responses/ResponseResults/ApiPlcReadModeSelectorStateResult.cs
new file mode 100644
index 0000000..dfe1b02
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ResponseResults/ApiPlcReadModeSelectorStateResult.cs
@@ -0,0 +1,18 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Siemens.Simatic.S7.Webserver.API.Enums;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults
+{
+ ///
+ /// Plc.ReadModeSelectorState result containing the mode selector enum
+ ///
+ public class ApiPlcReadModeSelectorStateResult
+ {
+ ///
+ /// The state of the mode selector switch of the PLC
+ ///
+ public ApiPlcModeSelectorState Mode_Selector { get; set; }
+ }
+}
diff --git a/src/Webserver.API/Models/Responses/ResponseResults/ApiPlcReadSystemTimeResult.cs b/src/Webserver.API/Models/Responses/ResponseResults/ApiPlcReadSystemTimeResult.cs
index 0a15cec..844a47d 100644
--- a/src/Webserver.API/Models/Responses/ResponseResults/ApiPlcReadSystemTimeResult.cs
+++ b/src/Webserver.API/Models/Responses/ResponseResults/ApiPlcReadSystemTimeResult.cs
@@ -2,8 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Text;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults
{
diff --git a/src/Webserver.API/Models/Responses/ResponseResults/ApiPlcReadTimeSettingsResult.cs b/src/Webserver.API/Models/Responses/ResponseResults/ApiPlcReadTimeSettingsResult.cs
index c743d7b..ec6d3f7 100644
--- a/src/Webserver.API/Models/Responses/ResponseResults/ApiPlcReadTimeSettingsResult.cs
+++ b/src/Webserver.API/Models/Responses/ResponseResults/ApiPlcReadTimeSettingsResult.cs
@@ -1,224 +1,53 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Siemens.Simatic.S7.Webserver.API.Models.TimeSettings;
+using Siemens.Simatic.S7.Webserver.API.Services.Converters.JsonConverters;
using System;
-using System.Collections.Generic;
-using System.Text;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults
{
///
- /// Plc.ApiPlcReadTimeSettingsResult result
+ /// Result of Plc.ReadTimeSettings
///
public class ApiPlcReadTimeSettingsResult
{
///
/// Offset to the current time => Utc_offset + daylight savings time offset if currently applied
///
- public int Current_offset { get; set; }
-
-
- ///
- /// ISO formatted Offset to the current time => Utc_offset + daylight savings time offset if currently applied
- ///
- public string ISO_Current_offset
- {
- get
- {
- return IsoFormatter.SetISOFormat(Current_offset);
- }
- }
+ [JsonConverter(typeof(TimeSpanISO8601Converter))]
+ public TimeSpan Current_offset { get; set; }
///
/// fixed offset to utc
///
- public int Utc_offset { get; set; }
-
-
- ///
- /// ISO formatted offset to utc
- ///
- public string ISO_Utc_offset
- {
- get
- {
- return IsoFormatter.SetISOFormat(Utc_offset);
- }
- }
+ [JsonConverter(typeof(TimeSpanISO8601Converter))]
+ public TimeSpan Utc_offset { get; set; }
///
- /// Current Daylight savings rule
+ /// (Optional) Current Daylight savings rule
///
- public DaylightSavingsRule Rule { get; set; } //optional
+ public DaylightSavingsRule Rule { get; set; }
///
- /// Can be used to comfortly get the current time for a given timestampf of a Plc.ReadSystemTime result
+ /// Can be used to comfortly get the current time for a given timestamp of a Plc.ReadSystemTime result
///
/// Timestamp of result of Plc.ReadSystemTime (UTC)
- ///
+ /// Return current time based on an input plc time, plus the current offset from this time setting.
public DateTime GetCurrentTime(DateTime plcReadSystemTimeResult)
{
- return (plcReadSystemTimeResult + TimeSpan.FromMinutes(Current_offset));
+ return (plcReadSystemTimeResult + Current_offset);
}
///
/// Can be used to comfortly get the current time for a given Plc.ReadSystemTime result
///
/// Result of Plc.ReadSystemTime (UTC)
- ///
+ /// Return current time based on a read system time result, plus the current offset from this time setting.
public DateTime GetCurrentTime(ApiPlcReadSystemTimeResult plcReadSystemTimeResult)
{
- return (plcReadSystemTimeResult.Timestamp + TimeSpan.FromMinutes(Current_offset));
- }
- }
-
- ///
- /// Daylight savings rule
- ///
- public class DaylightSavingsRule
- {
- ///
- /// Start of Standard time
- ///
- public StandardTimeConfiguration Std { get; set; }
-
- ///
- /// Start of Daylight saving time
- ///
- public DaylightSavingsTimeConfiguration Dst { get; set; }
-
- ///
- /// (Name, Has_children, Db_number, Datatype, Array_dimensions, Max_length, Address, Area, Read_only) Equal!;
- ///
- ///
- ///
- public override bool Equals(object obj) => Equals(obj as DaylightSavingsRule);
-
- ///
- /// Equals => (Name,Has_children,Db_number, Datatype, Array_dimensions, Max_length, Address, Area, Read_only, Value, Children)
- ///
- ///
- ///
- public bool Equals(DaylightSavingsRule obj)
- {
- if (obj is null)
- return false;
- var toReturn = this.Std.Equals(obj.Std);
- toReturn &= this.Dst.Equals(obj.Dst);
- return toReturn;
- }
-
- ///
- /// (Name, Has_children, Db_number, Datatype, Array_dimensions, Max_length, Address, Area, Read_only).GetHashCode();
- ///
- ///
- public override int GetHashCode()
- {
- return (Std, Dst).GetHashCode();
- }
- }
-
- ///
- /// Standard time configuration containing the start date of the standard time
- ///
- public class StandardTimeConfiguration
- {
- ///
- /// PlcDate of the StartTime of the standard time or daylight savings time
- ///
- public PlcDate Start { get; set; }
-
- ///
- /// PlcDate to determine the start of the standard or daylight savings time configuration
- ///
- public class PlcDate
- {
- ///
- /// Minute
- ///
- public int Minute { get; set; }
- ///
- /// Hour
- ///
- public int Hour { get; set; }
- ///
- /// Week in month;
- /// Speciality: Week 5 always stands for the last Week in the according month.
- ///
- public int Week { get; set; }
- ///
- /// Month
- ///
- public int Month { get; set; }
- ///
- /// first three letters of the according day of week (lowercase)
- ///
- public string Day_of_week { get; set; }
- }
- }
-
- ///
- /// Daylight savings time configuration containing the start date of the daylight savings time and the offset during the daylight savings time
- ///
- public class DaylightSavingsTimeConfiguration : StandardTimeConfiguration
- {
- ///
- /// Offset during the daylight savings time
- ///
- public int Offset { get; set; }
-
- ///
- /// ISO formatted Offset during the daylight savings time
- ///
- public string ISO_Offset
- {
- get
- {
- return IsoFormatter.SetISOFormat(Offset);
- }
- }
- }
-
- ///
- /// Helper class for get the ISO formatted offsets.
- ///
- public static class IsoFormatter
- {
- ///
- /// Get the ISO formatted offset
- ///
- ///
- ///
- /// ISO formatted offset if minutes and/or hours bigger than 0 - otherwise ""
- public static string SetISOFormat(int minute = 0, int hour = 0)
- {
- string iso = "";
- if (hour > 0 || minute > 0)
- {
- iso = "PT";
- if (minute >= 60)
- {
- hour += (minute / 60);
- if (minute % 60 == 0)
- {
- minute = 0;
- }
- else
- {
- minute = (minute % 60);
- }
- }
- if (hour > 0)
- {
- iso += hour + "H";
- }
-
- if (minute > 0)
- {
- iso += minute + "M";
- }
- }
- return iso;
+ return (plcReadSystemTimeResult.Timestamp + Current_offset);
}
}
}
\ No newline at end of file
diff --git a/src/Webserver.API/Models/Responses/ResponseResults/ApiReadLanguagesResult.cs b/src/Webserver.API/Models/Responses/ResponseResults/ApiReadLanguagesResult.cs
new file mode 100644
index 0000000..9de4053
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ResponseResults/ApiReadLanguagesResult.cs
@@ -0,0 +1,18 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using System.Collections.Generic;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults
+{
+ ///
+ /// Read Langzages result containing a List of ApiLanguageResults
+ ///
+ public class ApiReadLanguagesResult
+ {
+ ///
+ /// List containing languages (CultureInfo) wrapped in an ApiLanguageResult
+ ///
+ public List Languages { get; set; }
+ }
+}
diff --git a/src/Webserver.API/Models/Responses/ResponseResults/ApiTokenResult.cs b/src/Webserver.API/Models/Responses/ResponseResults/ApiTokenResult.cs
index bacc157..0b867df 100644
--- a/src/Webserver.API/Models/Responses/ResponseResults/ApiTokenResult.cs
+++ b/src/Webserver.API/Models/Responses/ResponseResults/ApiTokenResult.cs
@@ -1,27 +1,38 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Siemens.Simatic.S7.Webserver.API.Services.Converters.JsonConverters;
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults
{
///
- /// ApiTokenResult: Containing a Token and optional a Web_application_cookie.
+ /// ApiTokenResult: Containing a Token and an optional Web_application_cookie.
+ /// May also contain password_expiration information if the authentication mode is "local" and is enabled on the PLC.
///
public class ApiTokenResult
{
///
/// Token given from the Api (used to authenticate in headers as "X-Auth-Token"
///
- public string Token;
+ public string Token { get; set; }
///
/// Not c# conform wording to match Api Response behaviour
///
- public string Web_application_cookie;
+ public string Web_application_cookie { get; set; }
+
+ ///
+ /// Holds password expiration information if local authentication mode is used,
+ /// and password expiration is enabled on the PLC.
+ ///
+ public ApiPasswordExpiration Password_expiration { get; set; }
+
+ ///
+ /// The inactivity duration after which a log out (using the API method Api.Logout) will be automatically performed.
+ ///
+ [JsonConverter(typeof(TimeSpanISO8601Converter))]
+ public TimeSpan Runtime_timeout { get; set; }
}
}
diff --git a/src/Webserver.API/Models/Responses/ResponseResults/ApiWebAppBrowseResourcesResult.cs b/src/Webserver.API/Models/Responses/ResponseResults/ApiWebAppBrowseResourcesResult.cs
index 967dc24..b4f6e3c 100644
--- a/src/Webserver.API/Models/Responses/ResponseResults/ApiWebAppBrowseResourcesResult.cs
+++ b/src/Webserver.API/Models/Responses/ResponseResults/ApiWebAppBrowseResourcesResult.cs
@@ -1,13 +1,7 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using Siemens.Simatic.S7.Webserver.API.Models;
-using Siemens.Simatic.S7.Webserver.API.Models.Responses;
-using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults
{
diff --git a/src/Webserver.API/Models/Responses/ResponseResults/ApiWebAppBrowseResult.cs b/src/Webserver.API/Models/Responses/ResponseResults/ApiWebAppBrowseResult.cs
index 51e938b..e5bc505 100644
--- a/src/Webserver.API/Models/Responses/ResponseResults/ApiWebAppBrowseResult.cs
+++ b/src/Webserver.API/Models/Responses/ResponseResults/ApiWebAppBrowseResult.cs
@@ -1,12 +1,7 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using Siemens.Simatic.S7.Webserver.API.Models;
-using System;
using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults
{
diff --git a/src/Webserver.API/Models/Responses/ResponseResults/WebServerDefaultPageResult.cs b/src/Webserver.API/Models/Responses/ResponseResults/WebServerDefaultPageResult.cs
new file mode 100644
index 0000000..d936446
--- /dev/null
+++ b/src/Webserver.API/Models/Responses/ResponseResults/WebServerDefaultPageResult.cs
@@ -0,0 +1,17 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.Responses.ResponseResults
+{
+ ///
+ /// Result of a WebServer.ReadDefaultPage request
+ ///
+ public class WebServerDefaultPageResult
+ {
+ ///
+ /// Default page's name given from the Api
+ ///
+ public string Default_page;
+ }
+}
diff --git a/src/Webserver.API/Models/TimeSettings/DaylightSavingsRule.cs b/src/Webserver.API/Models/TimeSettings/DaylightSavingsRule.cs
new file mode 100644
index 0000000..4c94026
--- /dev/null
+++ b/src/Webserver.API/Models/TimeSettings/DaylightSavingsRule.cs
@@ -0,0 +1,91 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.TimeSettings
+{
+ ///
+ /// Daylight savings rule
+ ///
+ public class DaylightSavingsRule
+ {
+ ///
+ /// Start of Standard time
+ ///
+ public StandardTimeConfiguration Std { get; set; }
+ ///
+ /// Start of Daylight saving time
+ ///
+ public DaylightSavingsTimeConfiguration Dst { get; set; }
+
+ ///
+ /// Constructor to create a daylight-savings rule using STD and DST objects
+ ///
+ /// Represents the standard time configuration
+ /// Represents the daylight-savings time configuration
+ [JsonConstructor]
+ public DaylightSavingsRule(StandardTimeConfiguration std, DaylightSavingsTimeConfiguration dst)
+ {
+ this.Std = std;
+ this.Dst = dst;
+ }
+
+ ///
+ /// Constructor to create a daylight-savings rule -- this will also create the STD and DST objects
+ ///
+ /// The starting time of the standard time
+ /// The starting time of the daylight-savings time
+ /// The offset of daylight savings time from the standard time
+ public DaylightSavingsRule(PlcDate stdStart, PlcDate dstStart, TimeSpan dstTimeOffset)
+ {
+ this.Std = new StandardTimeConfiguration(stdStart);
+ this.Dst = new DaylightSavingsTimeConfiguration(dstStart, dstTimeOffset);
+ }
+
+ ///
+ /// Mixed constructor to create a daylight-savings rule: needs an STD object, but creates the DST object on it's own.
+ ///
+ /// The standard time configuration
+ /// The starting time of the daylight-savings time
+ /// The offset of daylight savings time from the standard time
+ public DaylightSavingsRule(StandardTimeConfiguration std, PlcDate dstStart, TimeSpan dstTimeOffset)
+ {
+ this.Std = std;
+ this.Dst = new DaylightSavingsTimeConfiguration(dstStart, dstTimeOffset);
+ }
+
+ ///
+ /// Mixed constructor to create a daylight-savings rule: creates the STD object on it's own, but expects a DST object.
+ ///
+ /// The starting time of the standard time
+ /// The daylight-savings time configuration
+ public DaylightSavingsRule(PlcDate stdStart, DaylightSavingsTimeConfiguration dst)
+ {
+ this.Std = new StandardTimeConfiguration(stdStart);
+ this.Dst = dst;
+ }
+
+ ///
+ /// Get HashCode of DaylightSavingsRule
+ ///
+ /// Hashcode
+ public override int GetHashCode()
+ {
+ return (Std, Dst).GetHashCode();
+ }
+
+ ///
+ /// Checks if the input object is the same as this DaylightSavingsRule
+ ///
+ /// Object to check
+ /// True if this and obj is the same
+ public override bool Equals(object obj)
+ {
+ return obj is DaylightSavingsRule rule &&
+ Std.Equals(rule.Std) &&
+ Dst.Equals(rule.Dst);
+ }
+ }
+}
diff --git a/src/Webserver.API/Models/TimeSettings/DaylightSavingsTimeConfiguration.cs b/src/Webserver.API/Models/TimeSettings/DaylightSavingsTimeConfiguration.cs
new file mode 100644
index 0000000..cba4a25
--- /dev/null
+++ b/src/Webserver.API/Models/TimeSettings/DaylightSavingsTimeConfiguration.cs
@@ -0,0 +1,71 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Siemens.Simatic.S7.Webserver.API.Services.Converters.JsonConverters;
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.TimeSettings
+{
+ ///
+ /// Daylight savings time configuration containing the start date of the daylight savings time and the offset during the daylight savings time
+ ///
+ public class DaylightSavingsTimeConfiguration : StandardTimeConfiguration
+ {
+ private TimeSpan _offset;
+ ///
+ /// Offset during the daylight savings time
+ ///
+ [JsonConverter(typeof(TimeSpanISO8601Converter))]
+ public TimeSpan Offset
+ {
+ get
+ {
+ return _offset;
+ }
+ set
+ {
+ if (value.TotalMinutes >= -180 && value.TotalMinutes <= 180)
+ {
+ _offset = value;
+ }
+ else
+ {
+ throw new ArgumentOutOfRangeException($"Valid values of {nameof(Offset)} are between -180 and 180 minutes. Input value was {value}");
+ }
+ }
+ }
+
+ ///
+ /// Constructor to create a DST object
+ ///
+ /// The starting time of the daylight-savings time
+ /// The offset of daylight savings time from the standard time
+ public DaylightSavingsTimeConfiguration(PlcDate start, TimeSpan timeOffset) : base(start)
+ {
+ this.Offset = timeOffset;
+ }
+
+ ///
+ /// Checks whether incoming object is same as this DST
+ ///
+ /// Object to check
+ /// True if they're the same
+ public override bool Equals(object obj)
+ {
+ return obj is DaylightSavingsTimeConfiguration configuration &&
+ base.Equals(obj) &&
+ Start.Equals(configuration.Start) &&
+ Offset.Equals(configuration.Offset);
+ }
+
+ ///
+ /// (Offset, Start).GetHashCode()
+ ///
+ /// Hashcode
+ public override int GetHashCode()
+ {
+ return (Offset, Start).GetHashCode();
+ }
+ }
+}
diff --git a/src/Webserver.API/Models/TimeSettings/PlcDate.cs b/src/Webserver.API/Models/TimeSettings/PlcDate.cs
new file mode 100644
index 0000000..bb10a2c
--- /dev/null
+++ b/src/Webserver.API/Models/TimeSettings/PlcDate.cs
@@ -0,0 +1,146 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Siemens.Simatic.S7.Webserver.API.Enums;
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.TimeSettings
+{
+ ///
+ /// PlcDate to determine the start of the standard or daylight savings time configuration
+ ///
+ public class PlcDate
+ {
+ private int _minute;
+ ///
+ /// Minute
+ ///
+ public int Minute
+ {
+ get
+ {
+ return _minute;
+ }
+ set
+ {
+ if (value >= 0 && value <= 59)
+ {
+ _minute = value;
+ }
+ else
+ {
+ throw new ArgumentOutOfRangeException($"Valid values of {nameof(Minute)} are 0 through 59. Input value was {value}");
+ }
+ }
+ }
+ private int _hour;
+ ///
+ /// Hour
+ ///
+ public int Hour
+ {
+ get
+ {
+ return _hour;
+ }
+ set
+ {
+ if (value >= 0 && value <= 23)
+ {
+ _hour = value;
+ }
+ else
+ {
+ throw new ArgumentOutOfRangeException($"Valid values of {nameof(Hour)} are 0 through 23. Input value was {value}");
+ }
+ }
+ }
+ private int _week;
+ ///
+ /// Week in month;
+ /// Speciality: Week 5 always stands for the last Week in the according month.
+ ///
+ public int Week
+ {
+ get
+ {
+ return _week;
+ }
+ set
+ {
+ if (value >= 1 && value <= 5)
+ {
+ _week = value;
+ }
+ else
+ {
+ throw new ArgumentOutOfRangeException($"Valid values of {nameof(Week)} are 1 through 5. Input value was {value}");
+ }
+ }
+ }
+ private int _month;
+ ///
+ /// Month
+ ///
+ public int Month
+ {
+ get
+ {
+ return _month;
+ }
+ set
+ {
+ if (value >= 1 && value <= 12)
+ {
+ _month = value;
+ }
+ else
+ {
+ throw new ArgumentOutOfRangeException($"Valid values of {nameof(Month)} are 1 through 12. Input value was {value}");
+ }
+ }
+ }
+ ///
+ /// First three letters of the according day of week
+ ///
+ public ApiDayOfWeek Day_of_week { get; set; }
+ ///
+ /// Constructor to create PlcDate object
+ ///
+ /// Month, from 1 to 12
+ /// Week, from 1 to 5
+ /// Weekday, 1 to 7
+ /// Hour, 0 to 24
+ /// Minute, 0 to 60
+ public PlcDate(int month, int week, ApiDayOfWeek day_of_week, int hour, int minute)
+ {
+ Minute = minute;
+ Hour = hour;
+ Week = week;
+ Month = month;
+ Day_of_week = day_of_week;
+ }
+ ///
+ /// Checks whether incoming object is same as this PlcDate
+ ///
+ /// Object to check
+ /// True if they're the same
+ public override bool Equals(object obj)
+ {
+ return obj is PlcDate date &&
+ Minute == date.Minute &&
+ Hour == date.Hour &&
+ Week == date.Week &&
+ Month == date.Month &&
+ Day_of_week == date.Day_of_week;
+ }
+ ///
+ /// Get HashCode of PlcDate
+ ///
+ /// Hashcode
+ public override int GetHashCode()
+ {
+ return (Minute, Hour, Week, Month, Day_of_week).GetHashCode();
+ }
+ }
+}
diff --git a/src/Webserver.API/Models/TimeSettings/StandardTimeConfiguration.cs b/src/Webserver.API/Models/TimeSettings/StandardTimeConfiguration.cs
new file mode 100644
index 0000000..e85d3bf
--- /dev/null
+++ b/src/Webserver.API/Models/TimeSettings/StandardTimeConfiguration.cs
@@ -0,0 +1,45 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+
+namespace Siemens.Simatic.S7.Webserver.API.Models.TimeSettings
+{
+ ///
+ /// Standard time configuration containing the start date of the standard time
+ ///
+ public class StandardTimeConfiguration
+ {
+ ///
+ /// PlcDate of the StartTime of the standard time or daylight savings time
+ ///
+ public PlcDate Start { get; set; }
+ ///
+ /// Constructor to create an STD object
+ ///
+ /// The starting time of the standard time
+ public StandardTimeConfiguration(PlcDate start)
+ {
+ Start = start;
+ }
+
+ ///
+ /// Checks whether incoming object is same as this STD
+ ///
+ /// Object to check
+ /// True if they're the same
+ public override bool Equals(object obj)
+ {
+ return obj is StandardTimeConfiguration configuration &&
+ Start.Equals(configuration.Start);
+ }
+
+ ///
+ /// Get HashCode of StandardTime
+ ///
+ /// Hashcode
+ public override int GetHashCode()
+ {
+ return Start.GetHashCode();
+ }
+ }
+}
diff --git a/src/Webserver.API/Services/ApiStandardServiceFactory.cs b/src/Webserver.API/Services/ApiStandardServiceFactory.cs
index 34302a3..3cdc444 100644
--- a/src/Webserver.API/Services/ApiStandardServiceFactory.cs
+++ b/src/Webserver.API/Services/ApiStandardServiceFactory.cs
@@ -13,10 +13,10 @@
using Siemens.Simatic.S7.Webserver.API.Services.Ticketing;
using Siemens.Simatic.S7.Webserver.API.Services.WebApp;
using System;
-using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Services
@@ -63,18 +63,17 @@ public ApiStandardServiceFactory(IIdGenerator idGenerator, IApiRequestParameterC
_apiWebAppResourceBuilder = apiWebAppResourceBuilder ?? throw new ArgumentNullException(nameof(apiWebAppResourceBuilder));
}
-
-
///
/// Get an httpclient using standard values for
///
/// ip address or dns name of your plc
/// username to login with
/// password to login with
+ /// Cancellation token to cancel pending requests.
/// an authorized httpclient (client with header value x-auth-token set)
- public async Task GetHttpClientAsync(string baseAddress, string username, string password)
+ public async Task GetHttpClientAsync(string baseAddress, string username, string password, CancellationToken cancellationToken = default(CancellationToken))
{
- return await GetHttpClientAsync(GetConnectionConfiguration(baseAddress, username, password));
+ return await GetHttpClientAsync(GetConnectionConfiguration(baseAddress, username, password), cancellationToken);
}
///
@@ -108,10 +107,11 @@ public HttpClientConnectionConfiguration GetConnectionConfiguration(string baseA
/// username to login with
/// password to login with
/// bool used to determine if the response should include a valid application cookie value for protected pages access
+ /// Cancellation token to cancel pending requests.
/// an authorized httpclient (client with header value x-auth-token set) and the according webappcookie
- public async Task GetHttpClientAsync(string baseAddress, string username, string password, bool include_web_application_cookie)
+ public async Task GetHttpClientAsync(string baseAddress, string username, string password, bool include_web_application_cookie, CancellationToken cancellationToken = default(CancellationToken))
{
- return await GetHttpClientAsync(GetConnectionConfiguration(baseAddress, username, password), include_web_application_cookie);
+ return await GetHttpClientAsync(GetConnectionConfiguration(baseAddress, username, password), include_web_application_cookie, cancellationToken);
}
///
@@ -130,8 +130,9 @@ public HttpClientAndWebAppCookie GetHttpClient(string baseAddress, string userna
///
/// Connection Configuration which should contains the base address, username, passwort etc.
/// bool used to determine if the response should include a valid application cookie value for protected pages access
+ /// Cancellation token to cancel pending requests.
/// an authorized httpclient (client with header value x-auth-token set) and the according webappcookie
- public async Task GetHttpClientAsync(HttpClientConnectionConfiguration connectionConfiguration, bool include_web_application_cookie)
+ public async Task GetHttpClientAsync(HttpClientConnectionConfiguration connectionConfiguration, bool include_web_application_cookie, CancellationToken cancellationToken = default(CancellationToken))
{
HttpClientHandler httpClientHandler = new HttpClientHandler()
{
@@ -166,7 +167,7 @@ public async Task GetHttpClientAsync(HttpClientConnec
request_body.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
// send the request and check for errors
- var response = await httpClient.PostAsync("api/jsonrpc", request_body);
+ var response = await httpClient.PostAsync("api/jsonrpc", request_body, cancellationToken);
_apiResponseChecker.CheckHttpResponseForErrors(response, apiLoginRequestString);
var respString = await response.Content.ReadAsStringAsync();
_apiResponseChecker.CheckResponseStringForErros(respString, apiLoginRequestString);
@@ -204,9 +205,10 @@ public HttpClientAndWebAppCookie GetHttpClient(HttpClientConnectionConfiguration
/// Get an httpclient using the given
///
/// Connection Configuration which should contains the base address, username, passwort etc.
+ /// Token used to cancel requests without waiting for the response
/// an authorized httpclient (client with header value x-auth-token set)
///
- public async Task GetHttpClientAsync(HttpClientConnectionConfiguration connectionConfiguration)
+ public async Task GetHttpClientAsync(HttpClientConnectionConfiguration connectionConfiguration, CancellationToken cancellationToken = default(CancellationToken))
{
HttpClientHandler httpClientHandler = new HttpClientHandler()
{
@@ -240,7 +242,7 @@ public async Task GetHttpClientAsync(HttpClientConnectionConfigurati
ByteArrayContent request_body = new ByteArrayContent(byteArr);
request_body.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
// send the request
- var response = await httpClient.PostAsync("api/jsonrpc", request_body);
+ var response = await httpClient.PostAsync("api/jsonrpc", request_body, cancellationToken);
_apiResponseChecker.CheckHttpResponseForErrors(response, apiLoginRequestString);
var respString = await response.Content.ReadAsStringAsync();
_apiResponseChecker.CheckResponseStringForErros(respString, apiLoginRequestString);
@@ -278,9 +280,9 @@ public HttpClient GetHttpClient(HttpClientConnectionConfiguration connectionConf
/// username to login with
/// password to login with
/// A usable and authenticated
- public async Task GetApiHttpClientRequestHandlerAsync(string baseAddress, string username, string password)
+ public async Task GetApiHttpClientRequestHandlerAsync(string baseAddress, string username, string password, CancellationToken cancellationToken = default(CancellationToken))
{
- var httpClient = await GetHttpClientAsync(baseAddress, username, password);
+ var httpClient = await GetHttpClientAsync(baseAddress, username, password, cancellationToken);
return new ApiHttpClientRequestHandler(httpClient, _apiRequestFactory, _apiResponseChecker);
}
@@ -305,6 +307,18 @@ public async Task GetApiHttpClientRequestHandlerAsync(HttpCl
return new ApiHttpClientRequestHandler(httpClient, _apiRequestFactory, _apiResponseChecker);
}
+ ///
+ /// Get an using the given
+ ///
+ /// Connection configuration to use
+ /// Cancellation token to cancel pending requests.
+ /// A usable and authenticated
+ public async Task GetApiHttpClientRequestHandlerAsync(HttpClientConnectionConfiguration connectionConfiguration, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var httpClient = await GetHttpClientAsync(connectionConfiguration, cancellationToken);
+ return new ApiHttpClientRequestHandler(httpClient, _apiRequestFactory, _apiResponseChecker);
+ }
+
///
/// Get an using the given
///
diff --git a/src/Webserver.API/Services/Backup/ApiBackupHandler.cs b/src/Webserver.API/Services/Backup/ApiBackupHandler.cs
index a044150..ebbcd55 100644
--- a/src/Webserver.API/Services/Backup/ApiBackupHandler.cs
+++ b/src/Webserver.API/Services/Backup/ApiBackupHandler.cs
@@ -2,14 +2,14 @@
//
// SPDX-License-Identifier: MIT
using Siemens.Simatic.S7.Webserver.API.Exceptions;
-using Siemens.Simatic.S7.Webserver.API.Services.RequestHandling;
using Siemens.Simatic.S7.Webserver.API.Services.HelperHandlers;
+using Siemens.Simatic.S7.Webserver.API.Services.RequestHandling;
+using Siemens.Simatic.S7.Webserver.API.Services.Ticketing;
using System;
using System.IO;
-using System.Linq;
using System.Net.Http;
+using System.Threading;
using System.Threading.Tasks;
-using Siemens.Simatic.S7.Webserver.API.Services.Ticketing;
namespace Siemens.Simatic.S7.Webserver.API.Services.Backup
{
@@ -40,14 +40,14 @@ public ApiBackupHandler(IApiRequestHandler apiRequestHandler, IApiTicketHandler
/// choose wether you want to replace an existing file or add another file with that name to you download directory in case one already exists
/// FileInfo
///
- public async Task DownloadBackupAsync(string pathToDownloadDirectory = null, string backupName = null, bool overwriteExistingFile = false)
+ public async Task DownloadBackupAsync(string pathToDownloadDirectory = null, string backupName = null, bool overwriteExistingFile = false, CancellationToken cancellationToken = default(CancellationToken))
{
if (pathToDownloadDirectory != null && !Directory.Exists(pathToDownloadDirectory))
{
throw new DirectoryNotFoundException($"the given directory at {Environment.NewLine}{pathToDownloadDirectory}{Environment.NewLine} has not been found!");
}
- var ticket = (await ApiRequestHandler.PlcCreateBackupAsync()).Result;
- return (await ApiTicketHandler.HandleDownloadAsync(ticket, pathToDownloadDirectory, backupName, null, overwriteExistingFile)).File_Downloaded;
+ var ticket = (await ApiRequestHandler.PlcCreateBackupAsync(cancellationToken)).Result;
+ return (await ApiTicketHandler.HandleDownloadAsync(ticket, pathToDownloadDirectory, backupName, null, overwriteExistingFile, cancellationToken)).File_Downloaded;
}
///
@@ -70,21 +70,21 @@ public FileInfo DownloadBackup(string pathToDownloadDirectory = null, string bac
/// timeout for the waithandler => plc to be up again after reboot, etc. - defaults to 3 minutes
/// Task
/// File at restorefilepath has not been found
- public async Task RestoreBackupAsync(string restoreFilePath, string userName, string password, TimeSpan? timeOut = null)
+ public async Task RestoreBackupAsync(string restoreFilePath, string userName, string password, TimeSpan? timeOut = null, CancellationToken cancellationToken = default(CancellationToken))
{
var timeToWait = timeOut ?? TimeSpan.FromMinutes(3);
- if(restoreFilePath == null)
+ if (restoreFilePath == null)
{
throw new ArgumentNullException(nameof(restoreFilePath));
}
- if(!File.Exists(restoreFilePath))
+ if (!File.Exists(restoreFilePath))
{
throw new FileNotFoundException($"the given file at {Environment.NewLine}{restoreFilePath}{Environment.NewLine} has not been found!");
}
- string ticketResponse = (await ApiRequestHandler.PlcRestoreBackupAsync(password)).Result;
+ string ticketResponse = (await ApiRequestHandler.PlcRestoreBackupAsync(password, cancellationToken)).Result;
try
{
- await ApiTicketHandler.HandleUploadAsync(ticketResponse, restoreFilePath);
+ await ApiTicketHandler.HandleUploadAsync(ticketResponse, restoreFilePath, cancellationToken);
}
// HttpRequestException is okay since during the upload the plc will power cycle and not "successfully answer" the request
catch (ApiTicketingEndpointUploadException e)
@@ -92,15 +92,13 @@ public async Task RestoreBackupAsync(string restoreFilePath, string userName, st
if (e.InnerException != null || !(e.InnerException is HttpRequestException))
throw;
}
- //var ticket = await ApiRequestHandler.ApiBrowseTicketsAsync();
-
var waitHandler = new WaitHandler(timeToWait);
WaitForPlcReboot(waitHandler);
- await ApiRequestHandler.ReLoginAsync(userName, password);
- ticketResponse = (await ApiRequestHandler.PlcRestoreBackupAsync(password)).Result;
- await ApiTicketHandler.HandleUploadAsync(ticketResponse, restoreFilePath);
+ await ApiRequestHandler.ReLoginAsync(userName, password, cancellationToken: cancellationToken);
+ ticketResponse = (await ApiRequestHandler.PlcRestoreBackupAsync(password, cancellationToken)).Result;
+ await ApiTicketHandler.HandleUploadAsync(ticketResponse, restoreFilePath, cancellationToken);
WaitForPlcReboot(waitHandler);
- await ApiRequestHandler.ReLoginAsync(userName, password);
+ await ApiRequestHandler.ReLoginAsync(userName, password, cancellationToken: cancellationToken);
}
///
diff --git a/src/Webserver.API/Services/Backup/IApiBackupHandler.cs b/src/Webserver.API/Services/Backup/IApiBackupHandler.cs
index a11e851..5354109 100644
--- a/src/Webserver.API/Services/Backup/IApiBackupHandler.cs
+++ b/src/Webserver.API/Services/Backup/IApiBackupHandler.cs
@@ -3,6 +3,7 @@
// SPDX-License-Identifier: MIT
using System;
using System.IO;
+using System.Threading;
using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Services.Backup
@@ -27,7 +28,7 @@ public interface IApiBackupHandler
/// will default to the backup name suggested by the plc
/// choose wether you want to replace an existing file or add another file with that name to you download directory in case one already exists
/// FileInfo
- Task DownloadBackupAsync(string pathToDownloadDirectory = null, string backupName = null, bool overwriteExistingFile = false);
+ Task DownloadBackupAsync(string pathToDownloadDirectory = null, string backupName = null, bool overwriteExistingFile = false, CancellationToken cancellationToken = default(CancellationToken));
///
/// Will send a Downloadresource, Downloadticket and Closeticket request to the API
///
@@ -45,6 +46,6 @@ public interface IApiBackupHandler
/// path to the file to be restored
/// timeout for the waithandler => plc to be up again after reboot, etc.
/// Task/void
- Task RestoreBackupAsync(string restoreFilePath, string userName, string password, TimeSpan? timeOut = null);
+ Task RestoreBackupAsync(string restoreFilePath, string userName, string password, TimeSpan? timeOut = null, CancellationToken cancellationToken = default(CancellationToken));
}
}
\ No newline at end of file
diff --git a/src/Webserver.API/Services/Converters/JsonConverters/EnabledDisabledConverter.cs b/src/Webserver.API/Services/Converters/JsonConverters/EnabledDisabledConverter.cs
new file mode 100644
index 0000000..0e6d106
--- /dev/null
+++ b/src/Webserver.API/Services/Converters/JsonConverters/EnabledDisabledConverter.cs
@@ -0,0 +1,48 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Services.Converters.JsonConverters
+{
+ ///
+ /// Converts string "enabled" (true) or "disabled" (false) into a bool, or vice versa
+ ///
+ public class EnabledDisabledConverter : JsonConverter
+ {
+ ///
+ /// Deserializes string "enabled" (true) or "disabled" (false) into a bool
+ ///
+ /// Deserialized bool value
+ public override bool? ReadJson(JsonReader reader, Type objectType, bool? existingValue, bool hasExistingValue, JsonSerializer serializer)
+ {
+ if (reader.TokenType == JsonToken.String)
+ {
+ string value = reader.Value.ToString().ToLower();
+ if (value == "enabled")
+ {
+ return true;
+ }
+ else if (value == "disabled")
+ {
+ return false;
+ }
+ }
+ return null;
+ }
+
+ ///
+ /// Serializes bool into "enabled" (true) or "disabled" (false)
+ ///
+ public override void WriteJson(JsonWriter writer, bool? value, JsonSerializer serializer)
+ {
+ if (value.HasValue)
+ {
+ string boolAsString = value.Value ? "enabled" : "disabled";
+ writer.WriteValue(boolAsString);
+ }
+ else writer.WriteNull();
+ }
+ }
+}
diff --git a/src/Webserver.API/Services/Converters/JsonConverters/FailsafeHardwareConverter.cs b/src/Webserver.API/Services/Converters/JsonConverters/FailsafeHardwareConverter.cs
new file mode 100644
index 0000000..311439e
--- /dev/null
+++ b/src/Webserver.API/Services/Converters/JsonConverters/FailsafeHardwareConverter.cs
@@ -0,0 +1,57 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+using Siemens.Simatic.S7.Webserver.API.Models.FailsafeParameters;
+using System;
+
+namespace Siemens.Simatic.S7.Webserver.API.Services.Converters.JsonConverters
+{
+ ///
+ /// Decides which derived class to use when deserializing/serializing parameters of Failsafe.ReadParameters
+ ///
+ public class FailsafeHardwareConverter : JsonConverter
+ {
+ ///
+ /// Read FailsafeHardware from json
+ ///
+ /// A FailsafeHardware object: either a CPU or a Module if the parameters are correct
+ public override FailsafeHardware ReadJson(JsonReader reader, Type objectType, FailsafeHardware existingValue, bool hasExistingValue, JsonSerializer serializer)
+ {
+ var jObject = JObject.Load(reader);
+ if (jObject["collective_signature"] != null)
+ {
+ var fCPU = new FailsafeCPU();
+ serializer.Populate(jObject.CreateReader(), fCPU);
+ return fCPU;
+ }
+ else if (jObject["f_par_crc"] != null)
+ {
+ var fModule = new FailsafeModule();
+ serializer.Populate(jObject.CreateReader(), fModule);
+ return fModule;
+ }
+
+ var baseHW = new FailsafeHardware();
+ serializer.Populate(jObject.CreateReader(), baseHW);
+ return baseHW;
+ }
+ ///
+ /// Writes to json
+ ///
+ public override void WriteJson(JsonWriter writer, FailsafeHardware value, JsonSerializer serializer)
+ {
+ JObject jObject = JObject.FromObject(value);
+ if (value is FailsafeCPU CPU)
+ {
+ jObject = JObject.FromObject(CPU);
+ }
+ else if (value is FailsafeModule module)
+ {
+ jObject = JObject.FromObject(module);
+ }
+ jObject.WriteTo(writer);
+ }
+ }
+}
diff --git a/src/Webserver.API/Services/Converters/JsonConverters/TimeSpanISO8601Converter.cs b/src/Webserver.API/Services/Converters/JsonConverters/TimeSpanISO8601Converter.cs
new file mode 100644
index 0000000..dbcca76
--- /dev/null
+++ b/src/Webserver.API/Services/Converters/JsonConverters/TimeSpanISO8601Converter.cs
@@ -0,0 +1,68 @@
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using System;
+using System.Xml;
+
+namespace Siemens.Simatic.S7.Webserver.API.Services.Converters.JsonConverters
+{
+ ///
+ /// A JsonConverter that converts a TimeSpan into an ISO8601 duration
+ ///
+ public class TimeSpanISO8601Converter : JsonConverter
+ {
+ ///
+ /// Writes to Json
+ ///
+ public override void WriteJson(JsonWriter writer, TimeSpan value, JsonSerializer serializer)
+ {
+ writer.WriteValue(value.ToISO8601Duration());
+ }
+ ///
+ /// Reads from json
+ ///
+ public override TimeSpan ReadJson(JsonReader reader, Type objectType, TimeSpan existingValue, bool hasExistingValue, JsonSerializer serializer)
+ {
+ if (reader.TokenType == JsonToken.String)
+ {
+ var durationString = reader.Value.ToString();
+ return TimeSpanExtensions.ISO8601DurationToTimeSpan(durationString);
+ }
+
+ throw new JsonSerializationException("Expected string value for TimeSpan.");
+ }
+ ///
+ /// Can it read from json
+ ///
+ public override bool CanRead => true;
+ ///
+ /// Can it write to json
+ ///
+ public override bool CanWrite => true;
+ }
+ ///
+ /// Extensions for TimeSpan object
+ ///
+ public static class TimeSpanExtensions
+ {
+ ///
+ /// Converts TimeSpan into ISO8601 duration string
+ ///
+ /// TimeSpan to convert
+ /// Duration as ISO8601 string
+ public static string ToISO8601Duration(this TimeSpan ts)
+ {
+ return XmlConvert.ToString(ts);
+ }
+ ///
+ /// Converts an ISO8601 duration string into a TimeSpan object
+ ///
+ /// A string that is an ISO8601 duration, eg.: PT3H
+ /// New TimeSpan object with the input duration
+ public static TimeSpan ISO8601DurationToTimeSpan(string iso8601Duration)
+ {
+ return XmlConvert.ToTimeSpan(iso8601Duration);
+ }
+ }
+}
diff --git a/src/Webserver.API/Services/FileHandling/ApiDirectoryBuilder.cs b/src/Webserver.API/Services/FileHandling/ApiDirectoryBuilder.cs
index c8a872c..98479e7 100644
--- a/src/Webserver.API/Services/FileHandling/ApiDirectoryBuilder.cs
+++ b/src/Webserver.API/Services/FileHandling/ApiDirectoryBuilder.cs
@@ -4,12 +4,10 @@
using Newtonsoft.Json;
using Siemens.Simatic.S7.Webserver.API.Exceptions;
using Siemens.Simatic.S7.Webserver.API.Models;
-using Siemens.Simatic.S7.Webserver.API.Services.FileParser;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Text;
namespace Siemens.Simatic.S7.Webserver.API.Services.FileHandling
{
@@ -54,7 +52,7 @@ public ApiDirectoryBuilder(string pathToLocalDirectory, IApiFileResourceBuilder
///
public ApiFileResource Build(string configFilePath)
{
- if(!File.Exists(configFilePath))
+ if (!File.Exists(configFilePath))
{
throw new FileNotFoundException(configFilePath);
}
@@ -73,7 +71,7 @@ public ApiFileResource Build(string configFilePath)
///
public ApiFileResource Build(ApiDirectoryBuilderConfiguration parseConfiguration)
{
- if(!Directory.Exists(PathToLocalDirectory))
+ if (!Directory.Exists(PathToLocalDirectory))
{
throw new DirectoryNotFoundException(PathToLocalDirectory);
}
@@ -97,11 +95,11 @@ public ApiFileResource Build(ApiDirectoryBuilderConfiguration parseConfiguration
{
PathToLocalDirectory = PathToLocalDirectory,
State = Enums.ApiFileResourceState.Active,
- Type = Enums.ApiFileResourceType.Dir,
+ Type = Enums.ApiFileResourceType.Dir,
Last_Modified = dirInf.LastWriteTime,
Name = dirInf.Name,
};
-
+
resource.Parents = new List();
// get resources in Directory
@@ -119,7 +117,7 @@ public ApiFileResource Build(ApiDirectoryBuilderConfiguration parseConfiguration
{
throw new ApiDirectoryParserException("Missing parameter 'Type' or Type was invalid => 'None' or 0 ", serializationException);
}
- throw serializationException;
+ throw;
}
}
diff --git a/src/Webserver.API/Services/FileHandling/ApiDirectoryBuilderConfiguration.cs b/src/Webserver.API/Services/FileHandling/ApiDirectoryBuilderConfiguration.cs
index d9eab08..8f501f4 100644
--- a/src/Webserver.API/Services/FileHandling/ApiDirectoryBuilderConfiguration.cs
+++ b/src/Webserver.API/Services/FileHandling/ApiDirectoryBuilderConfiguration.cs
@@ -1,9 +1,7 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
using System.Collections.Generic;
-using System.Text;
namespace Siemens.Simatic.S7.Webserver.API.Services.FileHandling
{
diff --git a/src/Webserver.API/Services/FileHandling/ApiDirectoryHandler.cs b/src/Webserver.API/Services/FileHandling/ApiDirectoryHandler.cs
index eb5ff6c..9d68d21 100644
--- a/src/Webserver.API/Services/FileHandling/ApiDirectoryHandler.cs
+++ b/src/Webserver.API/Services/FileHandling/ApiDirectoryHandler.cs
@@ -1,16 +1,16 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using Newtonsoft.Json.Serialization;
using Newtonsoft.Json;
+using Siemens.Simatic.S7.Webserver.API.Exceptions;
+using Siemens.Simatic.S7.Webserver.API.Models;
using Siemens.Simatic.S7.Webserver.API.Services.RequestHandling;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
+using System.Threading;
using System.Threading.Tasks;
-using Siemens.Simatic.S7.Webserver.API.Models;
-using Siemens.Simatic.S7.Webserver.API.Exceptions;
namespace Siemens.Simatic.S7.Webserver.API.Services.FileHandling
{
@@ -41,16 +41,16 @@ public ApiDirectoryHandler(IApiRequestHandler apiRequestHandler, IApiFileHandler
/// the function will only upload the resource and its direct sub-resources
///
/// - e.g. from parsed directory
- public async Task DeployAsync(ApiFileResource resource)
+ public async Task DeployAsync(ApiFileResource resource, CancellationToken cancellationToken = default(CancellationToken))
{
if (resource.Type == Enums.ApiFileResourceType.File)
{
- await ApiFileHandler.DeployFileAsync(resource);
+ await ApiFileHandler.DeployFileAsync(resource, cancellationToken);
}
else
{
var dirName = resource.GetVarNameForMethods();
- await ApiRequestHandler.FilesCreateDirectoryAsync(dirName);
+ await ApiRequestHandler.FilesCreateDirectoryAsync(dirName, cancellationToken);
foreach (var subres in resource.Resources)
{
await DeployAsync(subres);
@@ -72,24 +72,24 @@ public async Task DeployAsync(ApiFileResource resource)
///
/// the resource to delete
/// Task for deletion
- public async Task DeleteAsync(ApiFileResource resource)
+ public async Task DeleteAsync(ApiFileResource resource, CancellationToken cancellationToken = default(CancellationToken))
{
if (resource.Type == Enums.ApiFileResourceType.File)
{
var resName = resource.GetVarNameForMethods();
try
{
- await ApiRequestHandler.FilesDeleteAsync(resName);
+ await ApiRequestHandler.FilesDeleteAsync(resName, cancellationToken);
}
catch (ApiEntityDoesNotExistException) { }
}
else
{
- if(resource.Resources != null)
+ if (resource.Resources != null)
{
foreach (var file in resource.Resources)
{
- await DeleteAsync(file);
+ await DeleteAsync(file, cancellationToken);
}
}
else
@@ -99,10 +99,10 @@ public async Task DeleteAsync(ApiFileResource resource)
var dirName = resource.GetVarNameForMethods();
try
{
- await ApiRequestHandler.FilesDeleteDirectoryAsync(dirName);
+ await ApiRequestHandler.FilesDeleteDirectoryAsync(dirName, cancellationToken);
}
catch (ApiEntityDoesNotExistException) { }
-
+
}
}
@@ -118,12 +118,12 @@ public void Delete(ApiFileResource resource)
///
/// resouce to be browsed
/// A resource containing everything that is present underneath
- public async Task BrowseAndBuildResourceAsync(ApiFileResource resource)
+ public async Task BrowseAndBuildResourceAsync(ApiFileResource resource, CancellationToken cancellationToken = default(CancellationToken))
{
// should we clone here?
var res = (ApiFileResource)resource.Clone();
res.Resources = new List();
- var browseResponse = await ApiRequestHandler.FilesBrowseAsync(resource.GetVarNameForMethods());
+ var browseResponse = await ApiRequestHandler.FilesBrowseAsync(resource.GetVarNameForMethods(), cancellationToken);
if (resource.Type == Enums.ApiFileResourceType.Dir)
{
res.Resources = browseResponse.Result.Resources;
@@ -137,7 +137,7 @@ public async Task BrowseAndBuildResourceAsync(ApiFileResource r
foreach (var subRes in res.Resources)
{
subRes.Parents = parentsForChildren;
- var toAdd = await BrowseAndBuildResourceAsync(subRes);
+ var toAdd = await BrowseAndBuildResourceAsync(subRes, cancellationToken);
toAdd.Parents = parentsForChildren;
toSet.Add(toAdd);
}
@@ -161,16 +161,16 @@ public ApiFileResource BrowseAndBuildResource(ApiFileResource resource)
/// the resource to be updated
/// the resource returned by browsing the plc - make sure the sub-Nodes are present (!)
/// Task to update the resource
- public async Task UpdateResourceAsync(ApiFileResource resource, ApiFileResource browsedResource)
+ public async Task UpdateResourceAsync(ApiFileResource resource, ApiFileResource browsedResource, CancellationToken cancellationToken = default(CancellationToken))
{
if (browsedResource.Type != resource.Type)
{
- await DeleteAsync(browsedResource);
- await DeployAsync(resource);
+ await DeleteAsync(browsedResource, cancellationToken);
+ await DeployAsync(resource, cancellationToken);
}
if (resource.Type == Enums.ApiFileResourceType.File)
{
- await UpdateFileResourceAsync(resource, browsedResource);
+ await UpdateFileResourceAsync(resource, browsedResource, cancellationToken);
}
else
{
@@ -183,9 +183,9 @@ public async Task UpdateResourceAsync(ApiFileResource resource, ApiFileResource
}
else
{
- var browseResult = await ApiRequestHandler.FilesBrowseAsync(subResource.GetVarNameForMethods());
+ var browseResult = await ApiRequestHandler.FilesBrowseAsync(subResource.GetVarNameForMethods(), cancellationToken);
match.Resources = browseResult.Result.Resources;
- await UpdateResourceAsync(subResource, match);
+ await UpdateResourceAsync(subResource, match, cancellationToken);
}
}
}
@@ -205,7 +205,7 @@ public void UpdateResource(ApiFileResource resource, ApiFileResource browsedReso
/// the file to be updated
/// the file returned by browsing the plc
/// Task to update the File
- public async Task UpdateFileResourceAsync(ApiFileResource resource, ApiFileResource browsedResource)
+ public async Task UpdateFileResourceAsync(ApiFileResource resource, ApiFileResource browsedResource, CancellationToken cancellationToken = default(CancellationToken))
{
if (resource.Type != Enums.ApiFileResourceType.File)
{
@@ -218,8 +218,8 @@ public async Task UpdateFileResourceAsync(ApiFileResource resource, ApiFileResou
// compare if an update is necessary
if (!resource.Equals(browsedResource))
{
- await ApiRequestHandler.FilesDeleteAsync(resource.GetVarNameForMethods());
- await ApiFileHandler.DeployFileAsync(resource);
+ await ApiRequestHandler.FilesDeleteAsync(resource.GetVarNameForMethods(), cancellationToken);
+ await ApiFileHandler.DeployFileAsync(resource, cancellationToken);
}
}
@@ -244,7 +244,7 @@ public void UpdateFileResource(ApiFileResource resource, ApiFileResource browsed
/// optional parameter:
/// used to determine wether the DirectoryHandler should retry a upload and compare of the resources found or give up right away (default)
///
- public async Task DeployOrUpdateAsync(ApiFileResource resource, int amountOfTriesForResourceDeployment = 1)
+ public async Task DeployOrUpdateAsync(ApiFileResource resource, int amountOfTriesForResourceDeployment = 1, CancellationToken cancellationToken = default(CancellationToken))
{
if (amountOfTriesForResourceDeployment < 1)
{
@@ -252,14 +252,14 @@ public async Task DeployOrUpdateAsync(ApiFileResource resource, int amountOfTrie
}
try
{
- var browsedResource = await BrowseAndBuildResourceAsync(resource);
+ var browsedResource = await BrowseAndBuildResourceAsync(resource, cancellationToken);
int tries = 0;
while (!browsedResource.Equals(resource) && tries < amountOfTriesForResourceDeployment)
{
- await UpdateResourceAsync(resource, browsedResource);
+ await UpdateResourceAsync(resource, browsedResource, cancellationToken);
tries++;
// make sure the browsedResource now is Equal to the one we have - for a directory this means all subNodes are also equal, they are not browsed during the "standard" BRowse
- browsedResource = await BrowseAndBuildResourceAsync(resource);
+ browsedResource = await BrowseAndBuildResourceAsync(resource, cancellationToken);
resource.Resources = resource.Resources.OrderBy(el => el.Type).ThenBy(el => el.Size).ToList();
browsedResource.Resources = browsedResource.Resources.OrderBy(el => el.Type).ThenBy(el => el.Size).ToList();
}
@@ -285,9 +285,9 @@ public async Task DeployOrUpdateAsync(ApiFileResource resource, int amountOfTrie
throw new InvalidOperationException(errorMessage.ToString());
}
}
- catch(ApiEntityDoesNotExistException)
+ catch (ApiEntityDoesNotExistException)
{
- await DeployAsync(resource);
+ await DeployAsync(resource, cancellationToken);
}
}
///
diff --git a/src/Webserver.API/Services/FileHandling/ApiFileHandler.cs b/src/Webserver.API/Services/FileHandling/ApiFileHandler.cs
index a7a06ec..201f24a 100644
--- a/src/Webserver.API/Services/FileHandling/ApiFileHandler.cs
+++ b/src/Webserver.API/Services/FileHandling/ApiFileHandler.cs
@@ -2,15 +2,11 @@
//
// SPDX-License-Identifier: MIT
using Siemens.Simatic.S7.Webserver.API.Models;
-using Siemens.Simatic.S7.Webserver.API.Models.Responses;
using Siemens.Simatic.S7.Webserver.API.Services.RequestHandling;
using Siemens.Simatic.S7.Webserver.API.Services.Ticketing;
using System;
using System.IO;
-using System.Linq;
-using System.Net;
-using System.Net.Http;
-using System.Net.Http.Headers;
+using System.Threading;
using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Services.FileHandling
@@ -50,14 +46,14 @@ public ApiFileHandler(IApiRequestHandler apiRequestHandler, IApiTicketHandler ap
/// will default to Downloads but will determine path from -DESKTOP-, replaced "Desktop" by "Downloads"
/// choose wether you want to replace an existing file or add another file with that name to you download directory in case one already exists
/// FileInfo
- public async Task DownloadFileAsync(string resource, string pathToDownloadDirectory = null, bool overwriteExistingFile = false)
+ public async Task DownloadFileAsync(string resource, string pathToDownloadDirectory = null, bool overwriteExistingFile = false, CancellationToken cancellationToken = default(CancellationToken))
{
if (pathToDownloadDirectory != null && !Directory.Exists(pathToDownloadDirectory))
{
throw new DirectoryNotFoundException($"the given directory at {Environment.NewLine}{pathToDownloadDirectory}{Environment.NewLine} has not been found!");
}
- var ticketId = (await ApiRequestHandler.FilesDownloadAsync(resource)).Result;
- return (await ApiTicketHandler.HandleDownloadAsync(ticketId, pathToDownloadDirectory, overwriteExistingFile)).File_Downloaded;
+ var ticketId = (await ApiRequestHandler.FilesDownloadAsync(resource, cancellationToken)).Result;
+ return (await ApiTicketHandler.HandleDownloadAsync(ticketId, pathToDownloadDirectory, overwriteExistingFile, cancellationToken)).File_Downloaded;
}
///
@@ -79,14 +75,14 @@ public FileInfo DownloadFile(string resource, string pathToDownloadDirectory = n
/// choose wether you want to replace an existing file or add another file with that name to you download directory in case one already exists
/// FileInfo
///
- public async Task DataLogs_DownloadAndClearAsync(string resource, string pathToDownloadDirectory = null, bool overwriteExistingFile = false)
+ public async Task DataLogs_DownloadAndClearAsync(string resource, string pathToDownloadDirectory = null, bool overwriteExistingFile = false, CancellationToken cancellationToken = default(CancellationToken))
{
if (pathToDownloadDirectory != null && !Directory.Exists(pathToDownloadDirectory))
{
throw new DirectoryNotFoundException($"the given directory at {Environment.NewLine}{pathToDownloadDirectory}{Environment.NewLine} has not been found!");
}
- var ticketId = (await ApiRequestHandler.DatalogsDownloadAndClearAsync(resource)).Result;
- return (await ApiTicketHandler.HandleDownloadAsync(ticketId, pathToDownloadDirectory, overwriteExistingFile)).File_Downloaded;
+ var ticketId = (await ApiRequestHandler.DatalogsDownloadAndClearAsync(resource, cancellationToken)).Result;
+ return (await ApiTicketHandler.HandleDownloadAsync(ticketId, pathToDownloadDirectory, overwriteExistingFile, cancellationToken)).File_Downloaded;
}
///
@@ -106,10 +102,10 @@ public FileInfo DataLogs_DownloadAndClear(string resource, string pathToDownload
/// resource name on the PLC File API endpoint
/// path to the local file to upload
/// Task to upload the file
- public async Task DeployFileAsync(string resource, string filePath)
+ public async Task DeployFileAsync(string resource, string filePath, CancellationToken cancellationToken = default(CancellationToken))
{
- var ticket = await ApiRequestHandler.FilesCreateAsync(resource);
- await ApiTicketHandler.HandleUploadAsync(ticket.Result, filePath);
+ var ticket = await ApiRequestHandler.FilesCreateAsync(resource, cancellationToken);
+ await ApiTicketHandler.HandleUploadAsync(ticket.Result, filePath, cancellationToken);
}
///
/// Upload a resource to the File API
@@ -123,13 +119,13 @@ public void DeployFile(string resource, string filePath)
/// Upload a resource to the File API
///
/// resource to upload - filepath built via the ResourcePathResolver, name on PLC File Api built via GetVarNameForMethods()
- public async Task DeployFileAsync(ApiFileResource resource)
+ public async Task DeployFileAsync(ApiFileResource resource, CancellationToken cancellationToken = default(CancellationToken))
{
var varNameForMethods = resource.GetVarNameForMethods();
var accordingFile = Path.Combine(resource.PathToLocalDirectory, resource.Name);
- await DeployFileAsync(varNameForMethods, accordingFile);
+ await DeployFileAsync(varNameForMethods, accordingFile, cancellationToken);
}
-
+
///
/// Upload a resource to the File API
diff --git a/src/Webserver.API/Services/FileHandling/ApiFileResourceBuilder.cs b/src/Webserver.API/Services/FileHandling/ApiFileResourceBuilder.cs
index 9d455d6..2f77a62 100644
--- a/src/Webserver.API/Services/FileHandling/ApiFileResourceBuilder.cs
+++ b/src/Webserver.API/Services/FileHandling/ApiFileResourceBuilder.cs
@@ -3,9 +3,7 @@
// SPDX-License-Identifier: MIT
using Siemens.Simatic.S7.Webserver.API.Models;
using System;
-using System.Collections.Generic;
using System.IO;
-using System.Text;
namespace Siemens.Simatic.S7.Webserver.API.Services.FileHandling
{
diff --git a/src/Webserver.API/Services/FileHandling/IApiDirectoryHandler.cs b/src/Webserver.API/Services/FileHandling/IApiDirectoryHandler.cs
index 242bf83..6eef028 100644
--- a/src/Webserver.API/Services/FileHandling/IApiDirectoryHandler.cs
+++ b/src/Webserver.API/Services/FileHandling/IApiDirectoryHandler.cs
@@ -2,6 +2,7 @@
//
// SPDX-License-Identifier: MIT
using Siemens.Simatic.S7.Webserver.API.Models;
+using System.Threading;
using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Services.FileHandling
@@ -22,7 +23,7 @@ public interface IApiDirectoryHandler
///
/// resouce to be browsed
/// A resource containing everything that is present underneath
- Task BrowseAndBuildResourceAsync(ApiFileResource resource);
+ Task BrowseAndBuildResourceAsync(ApiFileResource resource, CancellationToken cancellationToken = default(CancellationToken));
///
/// Delete the given resource (and all its sub-resources)
///
@@ -33,7 +34,7 @@ public interface IApiDirectoryHandler
///
/// the resource to delete
/// Task for deletion
- Task DeleteAsync(ApiFileResource resource);
+ Task DeleteAsync(ApiFileResource resource, CancellationToken cancellationToken = default(CancellationToken));
///
/// make very sure the given resource contains all the data:
/// Resources
@@ -51,7 +52,7 @@ public interface IApiDirectoryHandler
/// the function will only upload the resource and its direct sub-resources
///
/// - e.g. from parsed directory
- Task DeployAsync(ApiFileResource resource);
+ Task DeployAsync(ApiFileResource resource, CancellationToken cancellationToken = default(CancellationToken));
///
/// make very sure the given resource contains all the data:
/// Resources
@@ -79,14 +80,14 @@ public interface IApiDirectoryHandler
/// optional parameter:
/// used to determine wether the DirectoryHandler should retry a upload and compare of the resources found or give up right away (default)
///
- Task DeployOrUpdateAsync(ApiFileResource resource, int amountOfTriesForResourceDeployment = 1);
+ Task DeployOrUpdateAsync(ApiFileResource resource, int amountOfTriesForResourceDeployment = 1, CancellationToken cancellationToken = default(CancellationToken));
///
/// Update the given File Resource when necessary
///
/// the file to be updated
/// the file returned by browsing the plc
/// Task to update the File
- Task UpdateFileResourceAsync(ApiFileResource resource, ApiFileResource browsedResource);
+ Task UpdateFileResourceAsync(ApiFileResource resource, ApiFileResource browsedResource, CancellationToken cancellationToken = default(CancellationToken));
///
/// Update the given File Resource when necessary
///
@@ -100,13 +101,13 @@ public interface IApiDirectoryHandler
/// the resource to be updated
/// the resource returned by browsing the plc - make sure the sub-Nodes are present (!)
/// Task to update the resource
- Task UpdateResourceAsync(ApiFileResource resource, ApiFileResource browsedResource);
+ Task UpdateResourceAsync(ApiFileResource resource, ApiFileResource browsedResource, CancellationToken cancellationToken = default(CancellationToken));
///
/// Update the given Resource - and SubResources, when necessary
///
/// the resource to be updated
/// the resource returned by browsing the plc - make sure the sub-Nodes are present (!)
void UpdateResource(ApiFileResource resource, ApiFileResource browsedResource);
-
+
}
}
\ No newline at end of file
diff --git a/src/Webserver.API/Services/FileHandling/IApiFileHandler.cs b/src/Webserver.API/Services/FileHandling/IApiFileHandler.cs
index 9a56389..5e1c433 100644
--- a/src/Webserver.API/Services/FileHandling/IApiFileHandler.cs
+++ b/src/Webserver.API/Services/FileHandling/IApiFileHandler.cs
@@ -2,12 +2,8 @@
//
// SPDX-License-Identifier: MIT
using Siemens.Simatic.S7.Webserver.API.Models;
-using Siemens.Simatic.S7.Webserver.API.Models.Responses;
-using System;
-using System.Collections.Generic;
using System.IO;
-using System.Net.Http.Headers;
-using System.Text;
+using System.Threading;
using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Services.FileHandling
@@ -24,7 +20,7 @@ public interface IApiFileHandler
/// will default to Downloads but will determine path from -DESKTOP-, replaced "Desktop" by "Downloads"
/// choose wether you want to replace an existing file or add another file with that name to you download directory in case one already exists
/// FileInfo
- Task DownloadFileAsync(string resource, string pathToDownloadDirectory = null, bool overrideExistingFile = false);
+ Task DownloadFileAsync(string resource, string pathToDownloadDirectory = null, bool overrideExistingFile = false, CancellationToken cancellationToken = default(CancellationToken));
///
/// Send a Downloadresource, Downloadticket and Closeticket request to the API. Creates a file ticket which the client can use to retrieve a file from the PLC.
@@ -41,14 +37,14 @@ public interface IApiFileHandler
/// Path of the file relative to the memory card root.
/// Path of the file to upload
/// Task
- Task DeployFileAsync(string resource, string filePath);
+ Task DeployFileAsync(string resource, string filePath, CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates a file on the PLC : creates a file ticket which the client can use to transfer a file to the PLC. This is referred to as "uploading" a file to the PLC.
///
/// Path of the file relative to the memory card root.
/// Path of the file to upload
- /// void
+ /// void
void DeployFile(string resource, string filePath);
///
@@ -56,7 +52,7 @@ public interface IApiFileHandler
///
/// Path of the file relative to the memory card root.
/// Task
- Task DeployFileAsync(ApiFileResource resource);
+ Task DeployFileAsync(ApiFileResource resource, CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates a file on the PLC : creates a file ticket which the client can use to transfer a file to the PLC. This is referred to as "uploading" a file to the PLC.
@@ -73,7 +69,7 @@ public interface IApiFileHandler
/// will default to Downloads but will determine path from -DESKTOP-, replaced "Desktop" by "Downloads"
/// choose wether you want to replace an existing file or add another file with that name to you download directory in case one already exists
/// FileInfo
- Task DataLogs_DownloadAndClearAsync(string resource, string pathToDownloadDirectory = null, bool overrideExistingFile = false);
+ Task DataLogs_DownloadAndClearAsync(string resource, string pathToDownloadDirectory = null, bool overrideExistingFile = false, CancellationToken cancellationToken = default(CancellationToken));
///
/// Download and clear a datalog on the PLC. Creates a file ticket which the client can use to retrieve a data log from the PLC and clear it upon completion.
diff --git a/src/Webserver.API/Services/FileHandling/IApiFileResourceBuilder.cs b/src/Webserver.API/Services/FileHandling/IApiFileResourceBuilder.cs
index 6053581..586a1cb 100644
--- a/src/Webserver.API/Services/FileHandling/IApiFileResourceBuilder.cs
+++ b/src/Webserver.API/Services/FileHandling/IApiFileResourceBuilder.cs
@@ -16,7 +16,7 @@ public interface IApiFileResourceBuilder
/// Path to the File/Directory to build the resource from
/// the ApiFileResource
ApiFileResource BuildResourceFromFile(string resourcePath);
-
+
///// Local Directory Path - used to determine the filename (Path!)
}
}
\ No newline at end of file
diff --git a/src/Webserver.API/Services/FileParser/ApiWebAppConfigParser.cs b/src/Webserver.API/Services/FileParser/ApiWebAppConfigParser.cs
index 3facc0b..ef0df38 100644
--- a/src/Webserver.API/Services/FileParser/ApiWebAppConfigParser.cs
+++ b/src/Webserver.API/Services/FileParser/ApiWebAppConfigParser.cs
@@ -6,13 +6,10 @@
using Siemens.Simatic.S7.Webserver.API.Exceptions;
using Siemens.Simatic.S7.Webserver.API.Models;
using Siemens.Simatic.S7.Webserver.API.Services.WebApp;
-using Siemens.Simatic.S7.Webserver.API.StaticHelpers;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Services.FileParser
{
@@ -94,17 +91,17 @@ public ApiWebAppData Parse()
webApp.ApplicationResources = RecursiveGetResources(PathToWebAppDirectory, webApp);
return webApp;
}
- catch(Newtonsoft.Json.JsonSerializationException serializationException)
+ catch (Newtonsoft.Json.JsonSerializationException serializationException)
{
- if(serializationException.Message.Contains("Error setting value to 'State'"))
+ if (serializationException.Message.Contains("Error setting value to 'State'"))
{
throw new ApiWebAppConfigParserException("Missing parameter 'State' or State was invalid => 'None' or 0 ", serializationException);
}
- if(serializationException.Message.Contains("Error setting value to 'Type'"))
+ if (serializationException.Message.Contains("Error setting value to 'Type'"))
{
throw new ApiWebAppConfigParserException("Missing parameter 'Type' or Type was invalid => 'None' or 0 ", serializationException);
}
- throw serializationException;
+ throw;
}
}
diff --git a/src/Webserver.API/Services/IApiServiceFactory.cs b/src/Webserver.API/Services/IApiServiceFactory.cs
index 0f4becb..e85fcdc 100644
--- a/src/Webserver.API/Services/IApiServiceFactory.cs
+++ b/src/Webserver.API/Services/IApiServiceFactory.cs
@@ -1,8 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System.Net.Http;
-using System.Threading.Tasks;
using Siemens.Simatic.S7.Webserver.API.Models;
using Siemens.Simatic.S7.Webserver.API.Services.Backup;
using Siemens.Simatic.S7.Webserver.API.Services.FileHandling;
@@ -10,6 +8,9 @@
using Siemens.Simatic.S7.Webserver.API.Services.PlcProgram;
using Siemens.Simatic.S7.Webserver.API.Services.RequestHandling;
using Siemens.Simatic.S7.Webserver.API.Services.WebApp;
+using System.Net.Http;
+using System.Threading;
+using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Services
{
@@ -39,13 +40,27 @@ public interface IApiServiceFactory
/// A usable and authenticated
Task GetApiHttpClientRequestHandlerAsync(HttpClientConnectionConfiguration connectionConfiguration);
///
+ /// Get an using the given
+ ///
+ /// Connection configuration to use
+ /// Cancellation token to cancel pending requests.
+ /// A usable and authenticated
+ Task GetApiHttpClientRequestHandlerAsync(HttpClientConnectionConfiguration connectionConfiguration, CancellationToken cancellationToken = default(CancellationToken));
+ ///
+ /// Get an httpclient using the given
+ ///
+ /// Connection Configuration which should contains the base address, username, passwort etc.
+ /// Token used to cancel requests without waiting for the response
+ /// an authorized httpclient (client with header value x-auth-token set)
+ Task GetHttpClientAsync(HttpClientConnectionConfiguration connectionConfiguration, CancellationToken cancellationToken = default(CancellationToken));
+ ///
/// Get an
///
/// ip address or dns name of your plc
/// username to login with
/// password to login with
/// A usable and authenticated
- Task GetApiHttpClientRequestHandlerAsync(string baseAddress, string username, string password);
+ Task GetApiHttpClientRequestHandlerAsync(string baseAddress, string username, string password, CancellationToken cancellationToken = default(CancellationToken));
///
/// Get A resourceHandler with the given requestHandler and the set resourcebuilder
///
@@ -96,23 +111,22 @@ public interface IApiServiceFactory
/// an authorized httpclient (client with header value x-auth-token set) and the according webappcookie
HttpClientAndWebAppCookie GetHttpClient(string baseAddress, string username, string password, bool include_web_application_cookie);
///
- /// Get an httpclient using the given
- ///
- /// an authorized httpclient (client with header value x-auth-token set)
- Task GetHttpClientAsync(HttpClientConnectionConfiguration connectionConfiguration);
- ///
/// Get an httpclient and a webappcookie (for accessing userdefined web pages) using the given
///
+ /// Connection Configuration which should contains the base address, username, passwort etc.
+ /// bool used to determine if the response should include a valid application cookie value for protected pages access
+ /// Cancellation token to cancel pending requests.
/// an authorized httpclient (client with header value x-auth-token set) and the according webappcookie
- Task GetHttpClientAsync(HttpClientConnectionConfiguration connectionConfiguration, bool include_web_application_cookie);
+ Task GetHttpClientAsync(HttpClientConnectionConfiguration connectionConfiguration, bool include_web_application_cookie, CancellationToken cancellationToken = default(CancellationToken));
///
/// Get an httpclient
///
/// ip address or dns name of your plc
/// username to login with
/// password to login with
+ /// Cancellation token to cancel pending requests.
/// an authorized httpclient (client with header value x-auth-token set)
- Task GetHttpClientAsync(string baseAddress, string username, string password);
+ Task GetHttpClientAsync(string baseAddress, string username, string password, CancellationToken cancellationToken = default(CancellationToken));
///
/// Get an httpclient and a webappcookie (for accessing userdefined web pages)
///
@@ -120,8 +134,9 @@ public interface IApiServiceFactory
/// username to login with
/// password to login with
/// bool used to determine if the response should include a valid application cookie value for protected pages access
+ /// Cancellation token to cancel pending requests.
/// an authorized httpclient (client with header value x-auth-token set) and the according webappcookie
- Task GetHttpClientAsync(string baseAddress, string username, string password, bool include_web_application_cookie);
+ Task GetHttpClientAsync(string baseAddress, string username, string password, bool include_web_application_cookie, CancellationToken cancellationToken = default(CancellationToken));
///
/// Get A apiPlcProgramHandler with the given requestHandler and the set apiRequestFactory
///
diff --git a/src/Webserver.API/Services/IdGenerator/CharSetIdGenerator.cs b/src/Webserver.API/Services/IdGenerator/CharSetIdGenerator.cs
index 74dd53a..a73d7d9 100644
--- a/src/Webserver.API/Services/IdGenerator/CharSetIdGenerator.cs
+++ b/src/Webserver.API/Services/IdGenerator/CharSetIdGenerator.cs
@@ -1,13 +1,10 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using Siemens.Simatic.S7.Webserver.API.Models.Requests;
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
using System.Threading;
-using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Services.IdGenerator
{
@@ -50,7 +47,7 @@ public CharSetIdGenerator()
DeterminedThreadSleepTime = DetermineThreadSleepTime();
ThreadSleepTime = DeterminedThreadSleepTime;
}
-
+
///
/// Create a charsetgenerator with userdefined values
///
@@ -70,7 +67,7 @@ public CharSetIdGenerator(string charSet, int length) : this()
/// charset to be used
/// time to sleep after generate calls
/// Length of the Id to be generated
- public CharSetIdGenerator(string charSet, TimeSpan threadSleepTime,
+ public CharSetIdGenerator(string charSet, TimeSpan threadSleepTime,
int length) : this()
{
ThreadSleepTime = threadSleepTime;
@@ -106,7 +103,7 @@ private void CheckLength(int length)
public TimeSpan DetermineThreadSleepTime()
{
List MillisecondsDetermined = new List();
- for(int i = 0; i < 3; i++)
+ for (int i = 0; i < 3; i++)
{
DateTime start = DateTime.Now;
var generated = Generate();
@@ -119,9 +116,9 @@ public TimeSpan DetermineThreadSleepTime()
MillisecondsDetermined.Add(end - start);
}
TimeSpan result = TimeSpan.FromSeconds(0);
- foreach(var element in MillisecondsDetermined)
+ foreach (var element in MillisecondsDetermined)
{
- if(element > result)
+ if (element > result)
{
result = element;
}
diff --git a/src/Webserver.API/Services/IdGenerator/GUIDGenerator.cs b/src/Webserver.API/Services/IdGenerator/GUIDGenerator.cs
index b186ff3..3c02013 100644
--- a/src/Webserver.API/Services/IdGenerator/GUIDGenerator.cs
+++ b/src/Webserver.API/Services/IdGenerator/GUIDGenerator.cs
@@ -2,9 +2,6 @@
//
// SPDX-License-Identifier: MIT
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
namespace Siemens.Simatic.S7.Webserver.API.Services.IdGenerator
{
@@ -38,7 +35,7 @@ public GUIDGenerator()
///
public GUIDGenerator(int length) : this()
{
- if(length <= 0 || length > DefaultLength)
+ if (length <= 0 || length > DefaultLength)
{
throw new ArgumentOutOfRangeException(nameof(length));
}
diff --git a/src/Webserver.API/Services/IdGenerator/IIdGenerator.cs b/src/Webserver.API/Services/IdGenerator/IIdGenerator.cs
index dbf4c3d..f69dd41 100644
--- a/src/Webserver.API/Services/IdGenerator/IIdGenerator.cs
+++ b/src/Webserver.API/Services/IdGenerator/IIdGenerator.cs
@@ -1,7 +1,6 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
namespace Siemens.Simatic.S7.Webserver.API.Services.IdGenerator
{
diff --git a/src/Webserver.API/Services/PlcProgram/ApiPlcProgramHandler.cs b/src/Webserver.API/Services/PlcProgram/ApiPlcProgramHandler.cs
index 33db0df..79e2c32 100644
--- a/src/Webserver.API/Services/PlcProgram/ApiPlcProgramHandler.cs
+++ b/src/Webserver.API/Services/PlcProgram/ApiPlcProgramHandler.cs
@@ -5,12 +5,10 @@
using Siemens.Simatic.S7.Webserver.API.Models;
using Siemens.Simatic.S7.Webserver.API.Models.Requests;
using Siemens.Simatic.S7.Webserver.API.Models.Responses;
-using Siemens.Simatic.S7.Webserver.API.Services.IdGenerator;
using Siemens.Simatic.S7.Webserver.API.Services.RequestHandling;
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Text;
using System.Threading;
using System.Threading.Tasks;
@@ -42,9 +40,9 @@ public ApiPlcProgramHandler(IApiRequestHandler asyncRequestHandler, IApiRequestF
/// Mode for PlcProgramBrowse function
/// the db/structure of which the children should be browsed
/// ApiResultResponse of List of ApiPlcProgramData containing the children of the given var
- public async Task PlcProgramBrowseSetChildrenAndParentsAsync(ApiPlcProgramBrowseMode plcProgramBrowseMode, ApiPlcProgramData var)
+ public async Task PlcProgramBrowseSetChildrenAndParentsAsync(ApiPlcProgramBrowseMode plcProgramBrowseMode, ApiPlcProgramData var, CancellationToken cancellationToken = default(CancellationToken))
{
- var response = await _apiRequestHandler.PlcProgramBrowseAsync(plcProgramBrowseMode, var);
+ var response = await _apiRequestHandler.PlcProgramBrowseAsync(plcProgramBrowseMode, var, cancellationToken);
if (plcProgramBrowseMode == ApiPlcProgramBrowseMode.Children)
{
response.Result.ForEach(el =>
@@ -87,7 +85,8 @@ public ApiPlcProgramBrowseResponse PlcProgramBrowseSetChildrenAndParents(ApiPlcP
/// Struct of which the Children should be Read by Bulk Request
/// Mode in which the child values should be read - defaults to simple (easy user handling)
/// The Struct containing the Children with their according Values
- public async Task PlcProgramReadStructByChildValuesAsync(ApiPlcProgramData structToRead, ApiPlcProgramReadOrWriteMode childrenReadMode = ApiPlcProgramReadOrWriteMode.Simple)
+ public async Task PlcProgramReadStructByChildValuesAsync(ApiPlcProgramData structToRead, ApiPlcProgramReadOrWriteMode childrenReadMode = ApiPlcProgramReadOrWriteMode.Simple
+ , CancellationToken cancellationToken = default(CancellationToken))
{
var toReturn = structToRead.ShallowCopy();
toReturn.Children = new List(structToRead.Children);
@@ -95,14 +94,14 @@ public async Task PlcProgramReadStructByChildValuesAsync(ApiP
toReturn.Parents = new List(structToRead.Parents);
if (toReturn.Children == null || toReturn.Children.Count == 0)
{
- await PlcProgramBrowseSetChildrenAndParentsAsync(ApiPlcProgramBrowseMode.Children, toReturn);
+ await PlcProgramBrowseSetChildrenAndParentsAsync(ApiPlcProgramBrowseMode.Children, toReturn, cancellationToken);
}
List requests = new List();
foreach (var child in toReturn.Children)
{
if (!child.Datatype.IsSupportedByPlcProgramReadOrWrite())
{
- await PlcProgramReadStructByChildValuesAsync(child, childrenReadMode);
+ await PlcProgramReadStructByChildValuesAsync(child, childrenReadMode, cancellationToken);
}
else if (child.ArrayElements?.Count != 0)
{
@@ -110,7 +109,7 @@ public async Task PlcProgramReadStructByChildValuesAsync(ApiP
{
if (!child.Datatype.IsSupportedByPlcProgramReadOrWrite())
{
- await PlcProgramReadStructByChildValuesAsync(arrayElement, childrenReadMode);
+ await PlcProgramReadStructByChildValuesAsync(arrayElement, childrenReadMode, cancellationToken);
}
else
{
@@ -132,7 +131,7 @@ public async Task PlcProgramReadStructByChildValuesAsync(ApiP
requests = _requestFactory.GetApiBulkRequestWithUniqueIds(requests).ToList();
if (requests.Count > 0)
{
- var childvalues = await _apiRequestHandler.ApiBulkAsync(requests);
+ var childvalues = await _apiRequestHandler.ApiBulkAsync(requests, cancellationToken);
foreach (var childval in childvalues.SuccessfulResponses)
{
var accordingRequest = requests.First(el => el.Id == childval.Id);
@@ -161,7 +160,7 @@ public ApiPlcProgramData PlcProgramReadStructByChildValues(ApiPlcProgramData str
/// Struct of which the Children should be written by Bulk Request
/// Mode in which the child values should be written - defaults to simple (easy user handling)
/// The Struct containing the Children with their according Values
- public async Task PlcProgramWriteStructByChildValuesAsync(ApiPlcProgramData structToWrite, ApiPlcProgramReadOrWriteMode childrenWriteMode = ApiPlcProgramReadOrWriteMode.Simple)
+ public async Task PlcProgramWriteStructByChildValuesAsync(ApiPlcProgramData structToWrite, ApiPlcProgramReadOrWriteMode childrenWriteMode = ApiPlcProgramReadOrWriteMode.Simple, CancellationToken cancellationToken = default(CancellationToken))
{
var toReturn = structToWrite.ShallowCopy();
if (toReturn.Children == null || toReturn.Children.Count == 0)
@@ -174,7 +173,7 @@ public async Task PlcProgramWriteStructByChildValuesAsync(ApiPl
requests.Add(_requestFactory.GetApiPlcProgramWriteRequest(child.GetVarNameForMethods(), child.Value, childrenWriteMode));
}
requests = _requestFactory.GetApiBulkRequestWithUniqueIds(requests).ToList();
- return await _apiRequestHandler.ApiBulkAsync(requests);
+ return await _apiRequestHandler.ApiBulkAsync(requests, cancellationToken);
}
///
diff --git a/src/Webserver.API/Services/PlcProgram/IApiPlcProgramHandler.cs b/src/Webserver.API/Services/PlcProgram/IApiPlcProgramHandler.cs
index b35097a..8ad2626 100644
--- a/src/Webserver.API/Services/PlcProgram/IApiPlcProgramHandler.cs
+++ b/src/Webserver.API/Services/PlcProgram/IApiPlcProgramHandler.cs
@@ -1,11 +1,11 @@
// Copyright (c) 2023, Siemens AG
//
// SPDX-License-Identifier: MIT
-using System;
-using System.Threading.Tasks;
using Siemens.Simatic.S7.Webserver.API.Enums;
using Siemens.Simatic.S7.Webserver.API.Models;
using Siemens.Simatic.S7.Webserver.API.Models.Responses;
+using System.Threading;
+using System.Threading.Tasks;
namespace Siemens.Simatic.S7.Webserver.API.Services.PlcProgram
{
@@ -29,7 +29,7 @@ public interface IApiPlcProgramHandler
/// Mode for PlcProgramBrowse function
/// the db/structure of which the children should be browsed
/// ApiResultResponse of List of ApiPlcProgramData containing the children of the given var
- Task PlcProgramBrowseSetChildrenAndParentsAsync(ApiPlcProgramBrowseMode plcProgramBrowseMode, ApiPlcProgramData var);
+ Task PlcProgramBrowseSetChildrenAndParentsAsync(ApiPlcProgramBrowseMode plcProgramBrowseMode, ApiPlcProgramData var, CancellationToken cancellationToken = default(CancellationToken));
///
/// Method to comfortably read all Children of a struct using a Bulk Request
///
@@ -43,7 +43,7 @@ public interface IApiPlcProgramHandler
/// Struct of which the Children should be Read by Bulk Request
/// Mode in which the child values should be read - defaults to simple (easy user handling)
/// The Struct containing the Children with their according Values
- Task PlcProgramReadStructByChildValuesAsync(ApiPlcProgramData structToRead, ApiPlcProgramReadOrWriteMode childrenReadMode = ApiPlcProgramReadOrWriteMode.Simple);
+ Task PlcProgramReadStructByChildValuesAsync(ApiPlcProgramData structToRead, ApiPlcProgramReadOrWriteMode childrenReadMode = ApiPlcProgramReadOrWriteMode.Simple, CancellationToken cancellationToken = default(CancellationToken));
///
/// Method to comfortably write all Children of a struct using a Bulk Request
///
@@ -57,6 +57,6 @@ public interface IApiPlcProgramHandler
/// Struct of which the Children should be written by Bulk Request
/// Mode in which the child values should be written - defaults to simple (easy user handling)
/// The Struct containing the Children with their according Values
- Task PlcProgramWriteStructByChildValuesAsync(ApiPlcProgramData structToWrite, ApiPlcProgramReadOrWriteMode childrenWriteMode = ApiPlcProgramReadOrWriteMode.Simple);
+ Task PlcProgramWriteStructByChildValuesAsync(ApiPlcProgramData structToWrite, ApiPlcProgramReadOrWriteMode childrenWriteMode = ApiPlcProgramReadOrWriteMode.Simple, CancellationToken cancellationToken = default(CancellationToken));
}
}
\ No newline at end of file
diff --git a/src/Webserver.API/Services/RequestHandling/ApiHttpClientRequestHandler.cs b/src/Webserver.API/Services/RequestHandling/ApiHttpClientRequestHandler.cs
index 89b4c41..7aec347 100644
--- a/src/Webserver.API/Services/RequestHandling/ApiHttpClientRequestHandler.cs
+++ b/src/Webserver.API/Services/RequestHandling/ApiHttpClientRequestHandler.cs
@@ -1,2426 +1,2596 @@
-// Copyright (c) 2023, Siemens AG
-//
-// SPDX-License-Identifier: MIT
-using Newtonsoft.Json;
-using Newtonsoft.Json.Serialization;
-using Siemens.Simatic.S7.Webserver.API.Enums;
-using Siemens.Simatic.S7.Webserver.API.Exceptions;
-using Siemens.Simatic.S7.Webserver.API.Models;
-using Siemens.Simatic.S7.Webserver.API.Models.Requests;
-using Siemens.Simatic.S7.Webserver.API.Models.Responses;
-using Siemens.Simatic.S7.Webserver.API.StaticHelpers;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Net.Http;
-using System.Text;
-using System.Threading.Tasks;
-using System.Xml;
-
-namespace Siemens.Simatic.S7.Webserver.API.Services.RequestHandling
-{
- ///
- /// Request Handlerusing the Microsoft.Net.HttpClient to send the requests to the API
- ///
- public class ApiHttpClientRequestHandler : IApiRequestHandler
- {
- private readonly HttpClient _httpClient;
- private readonly IApiRequestFactory _apiRequestFactory;
- private readonly IApiResponseChecker _apiResponseChecker;
-
- ///
- /// Should prob not be changed!
- /// appilication/json for requests to the jsonrpc api endpoint
- ///
- public string ContentType => "application/json";
-
- ///
- /// Should prob not be changed!
- /// Encoding.UTF8
- ///
- public Encoding Encoding => Encoding.UTF8;
-
- ///
- /// Should prob not be changed!
- /// api/jsonrpc endpoint of plc
- ///
+// Copyright (c) 2023, Siemens AG
+//
+// SPDX-License-Identifier: MIT
+using Newtonsoft.Json;
+using Newtonsoft.Json.Serialization;
+using Siemens.Simatic.S7.Webserver.API.Enums;
+using Siemens.Simatic.S7.Webserver.API.Exceptions;
+using Siemens.Simatic.S7.Webserver.API.Models;
+using Siemens.Simatic.S7.Webserver.API.Models.AlarmsBrowse;
+using Siemens.Simatic.S7.Webserver.API.Models.ApiDiagnosticBuffer;
+using Siemens.Simatic.S7.Webserver.API.Models.Requests;
+using Siemens.Simatic.S7.Webserver.API.Models.Responses;
+using Siemens.Simatic.S7.Webserver.API.Models.TimeSettings;
+using Siemens.Simatic.S7.Webserver.API.StaticHelpers;
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.IO;
+using System.Linq;
+using System.Net.Http;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Xml;
+
+namespace Siemens.Simatic.S7.Webserver.API.Services.RequestHandling
+{
+ ///
+ /// Request Handlerusing the Microsoft.Net.HttpClient to send the requests to the API
+ ///
+ public class ApiHttpClientRequestHandler : IApiRequestHandler
+ {
+ private readonly HttpClient _httpClient;
+ private readonly IApiRequestFactory _apiRequestFactory;
+ private readonly IApiResponseChecker _apiResponseChecker;
+
+ ///
+ /// Should prob not be changed!
+ /// appilication/json for requests to the jsonrpc api endpoint
+ ///
+ public string ContentType => "application/json";
+
+ ///
+ /// Should prob not be changed!
+ /// Encoding.UTF8
+ ///
+ public Encoding Encoding => Encoding.UTF8;
+
+ ///
+ /// Should prob not be changed!
+ /// api/jsonrpc endpoint of plc
+ ///
public string JsonRpcApi => "api/jsonrpc";
- ///
- /// The ApiHttpClientRequestHandler will Send Post Requests,
- /// before sending the Request it'll remove those Parameters that have the value null for their keys
- /// (keep in mind when using - when not using the ApiRequestFactory)
- ///
- /// authorized httpClient with set Header: 'X-Auth-Token'
- ///
- /// response checker for the requestfactory and requesthandler...
- public ApiHttpClientRequestHandler(HttpClient httpClient, IApiRequestFactory apiRequestFactory, IApiResponseChecker apiResponseChecker)
- {
- this._httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
- this._apiRequestFactory = apiRequestFactory ?? throw new ArgumentNullException(nameof(apiRequestFactory));
- this._apiResponseChecker = apiResponseChecker ?? throw new ArgumentNullException(nameof(apiResponseChecker));
- }
-
- ///
- /// only use this function if you know how to build up apiRequests on your own!
- /// will remove those Params that have the value Null and send the request using the HttpClient.
- ///
- /// Api Request to send to the plc (Json Serialized - null properties are deleted)
- /// string: response from thePLC
- public async Task SendPostRequestAsync(IApiRequest apiRequest)
- {
- if (apiRequest.Params != null)
- {
- apiRequest.Params = apiRequest.Params
- .Where(el => el.Value != null)
- .ToDictionary(x => x.Key, x => x.Value);
- }
- string apiRequestString = JsonConvert.SerializeObject(apiRequest, new JsonSerializerSettings()
- { NullValueHandling = NullValueHandling.Ignore, ContractResolver = new CamelCasePropertyNamesContractResolver() });
- byte[] byteArr = Encoding.GetBytes(apiRequestString);
- return await SendPostRequestAsync(apiRequestString);
- }
-
-
-
- ///
- /// only use this function if you know how to build up apiRequests on your own!
- /// will remove those Params that have the value Null and send the request using the HttpClient.
- ///
- /// Api Request to send to the plc (Json Serialized - null properties are deleted)
- /// string: response from thePLC
- public string SendPostRequest(IApiRequest apiRequest) => SendPostRequestAsync(apiRequest).GetAwaiter().GetResult();
-
- ///
- /// only use this function if you know how to build up apiRequests on your own!
- /// will remove those Params that have the value Null and send the request using the HttpClient.
- ///
- /// Api Request to send to the plc (Json Serialized - null properties are deleted)
- /// string: response from thePLC
- public async Task SendPostRequestAsync(IApiRequestIntId apiRequestWithIntId)
- {
- if (apiRequestWithIntId.Params != null)
- {
- apiRequestWithIntId.Params = apiRequestWithIntId.Params
- .Where(el => el.Value != null)
- .ToDictionary(x => x.Key, x => x.Value);
- }
- string apiRequestString = JsonConvert.SerializeObject(apiRequestWithIntId, new JsonSerializerSettings()
- { NullValueHandling = NullValueHandling.Ignore, ContractResolver = new CamelCasePropertyNamesContractResolver() });
- byte[] byteArr = Encoding.GetBytes(apiRequestString);
- return await SendPostRequestAsync(apiRequestString);
- }
-
- ///
- /// only use this function if you know how to build up apiRequests on your own!
- /// will remove those Params that have the value Null and send the request using the HttpClient.
- ///
- /// Api Request to send to the plc (Json Serialized - null properties are deleted)
- /// string: response from thePLC
- public string SendPostRequest(IApiRequestIntId apiRequestWithIntId) => SendPostRequestAsync(apiRequestWithIntId).GetAwaiter().GetResult();
-
- ///
- /// only use this function if you know how to build up apiRequests on your own!
- /// will remove those Params that have the value Null and send the request using the HttpClient.
- ///
- /// further information about the Api requeest the user tried to send (or was trying to send)
- /// string: response from thePLC
- public async Task SendPostRequestAsync(string apiRequestString)
- {
- byte[] byteArr = Encoding.GetBytes(apiRequestString);
- ByteArrayContent request_body = new ByteArrayContent(byteArr);
- request_body.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(ContentType);
- var response = await _httpClient.PostAsync(JsonRpcApi, request_body);
- _apiResponseChecker.CheckHttpResponseForErrors(response, apiRequestString);
- var responseString = await response.Content.ReadAsStringAsync();
- _apiResponseChecker.CheckResponseStringForErros(responseString, apiRequestString);
- return responseString;
- }
-
- ///
- /// only use this function if you know how to build up apiRequests on your own!
- /// will remove those Params that have the value Null and send the request using the HttpClient.
- ///
- /// further information about the Api requeest the user tried to send (or was trying to send)
- /// string: response from thePLC
- public async Task> SendPostRequestAsyncFileName(string apiRequestString)
- {
- List result = new List();
- byte[] byteArr = Encoding.GetBytes(apiRequestString);
- ByteArrayContent request_body = new ByteArrayContent(byteArr);
- request_body.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(ContentType);
- var response = await _httpClient.PostAsync(JsonRpcApi, request_body);
- _apiResponseChecker.CheckHttpResponseForErrors(response, apiRequestString);
- var responseString = await response.Content.ReadAsStringAsync();
- _apiResponseChecker.CheckResponseStringForErros(responseString, apiRequestString);
- result.Add(responseString);
- //result.Add(response.Content.Headers.ContentDisposition.FileName);
- return result;
- }
-
- ///
- /// only use this function if you know how to build up apiRequests on your own!
- /// will remove those Params that have the value Null and send the request using the HttpClient.
- ///
- /// further information about the Api requeest the user tried to send (or was trying to send)
- /// string: response from thePLC
- public string SendPostRequest(string apiRequestString) => SendPostRequestAsync(apiRequestString).GetAwaiter().GetResult();
-
- ///
- /// Send an Api.Browse Request using the Request from the ApiRequestFactory
- ///
- /// An Array of ApiClass (and Id,Jsonrpc)
- public async Task ApiBrowseAsync()
- {
- var req = _apiRequestFactory.GetApiBrowseRequest();
- var responseString = await SendPostRequestAsync(req);
- var arrOfApiClassResponse = JsonConvert.DeserializeObject(responseString);
- if (arrOfApiClassResponse.Result.Count == 0)
- {
- throw new ApiInvalidResponseException("Api.Browse returned an empty array!");
- }
- return arrOfApiClassResponse;
- }
- ///
- /// Send an Api.Browse Request using the Request from the ApiRequestFactory
- ///
- /// An Array of ApiClass (and Id,Jsonrpc)
- public ApiArrayOfApiClassResponse ApiBrowse() => ApiBrowseAsync().GetAwaiter().GetResult();
-
- ///
- /// Send an Api.BrowseTickets Request using the Request from the ApiRequestFactory
- ///
- /// ticket to be browsed (null to browse all)
- /// BrowseTickets Response containing: Max_Tickets:uint, Tickets:Array of Ticket
- public async Task ApiBrowseTicketsAsync(string ticketId = null)
- {
- var req = _apiRequestFactory.GetApiBrowseTicketsRequest(ticketId);
- var responseString = await SendPostRequestAsync(req);
- var arrOfApiClassResponse = JsonConvert.DeserializeObject(responseString);
- return arrOfApiClassResponse;
- }
-
- ///
- /// Send an Api.BrowseTickets Request using the Request from the ApiRequestFactory
- ///
- /// ticket to be browsed (null to browse all)
- /// BrowseTickets Response containing: Max_Tickets:uint, Tickets:Array of Ticket
-
- public ApiBrowseTicketsResponse ApiBrowseTickets(string ticketId = null) => ApiBrowseTicketsAsync(ticketId).GetAwaiter().GetResult();
-
- ///
- /// Send an Api.BrowseTickets Request using the Request from the ApiRequestFactory
- ///
- /// ticket to be browsed (null to browse all)
- /// BrowseTickets Response containing: Max_Tickets:uint, Tickets:Array of Ticket
- public async Task ApiBrowseTicketsAsync(ApiTicket ticket) => await ApiBrowseTicketsAsync(ticket.Id);
- ///
- /// Send an Api.BrowseTickets Request using the Request from the ApiRequestFactory
- ///
- /// ticket to be browsed (null to browse all)
- /// BrowseTickets Response containing: Max_Tickets:uint, Tickets:Array of Ticket
- public ApiBrowseTicketsResponse ApiBrowseTickets(ApiTicket ticket) => ApiBrowseTicketsAsync(ticket).GetAwaiter().GetResult();
-
- ///
- /// Send an Api.CloseTicket Request using the Request from the ApiRequestFactory
- ///
- /// ticket id (28 chars)
- /// True to indicate Success
- public async Task ApiCloseTicketAsync(string ticketId)
- {
- var req = _apiRequestFactory.GetApiCloseTicketRequest(ticketId);
- var responseString = await SendPostRequestAsync(req);
- var apiTrueOnSuccessResponse = JsonConvert.DeserializeObject(responseString);
- return apiTrueOnSuccessResponse;
- }
-
- ///
- /// Send an Api.CloseTicket Request using the Request from the ApiRequestFactory
- ///
- /// ticket id (28 chars)
- public ApiTrueOnSuccessResponse ApiCloseTicket(string ticketId) => ApiCloseTicketAsync(ticketId).GetAwaiter().GetResult();
-
- ///
- /// Send an Api.CloseTicket Request using the Request from the ApiRequestFactory
- ///
- /// ticket containing ticket id (28 chars)
- /// True to indicate Success
- public async Task ApiCloseTicketAsync(ApiTicket ticket) => await ApiCloseTicketAsync(ticket.Id);
-
- ///
- /// Send an Api.CloseTicket Request using the Request from the ApiRequestFactory
- ///
- /// ticket containing ticket id (28 chars)
- /// True to indicate Success
- public ApiTrueOnSuccessResponse ApiCloseTicket(ApiTicket ticket) => ApiCloseTicketAsync(ticket).GetAwaiter().GetResult();
-
- ///
- /// Send an Api.GetCertificateUrl Request using the Request from the ApiRequestFactory
- ///
- /// ApiSingleStringResponse that contians the URL to the certificate
- public async Task ApiGetCertificateUrlAsync()
- {
- var req = _apiRequestFactory.GetApiGetCertificateUrlRequest();
- string response = await SendPostRequestAsync(req);
- if (!response.Contains("/MiniWebCA_Cer.crt"))
- Console.WriteLine("unexpected response: " + response + " for Api.GetCertificateUrl!");
- return JsonConvert.DeserializeObject(response);
- }
- ///
- /// Send an Api.GetCertificateUrl Request using the Request from the ApiRequestFactory
- ///
- /// ApiSingleStringResponse that contians the URL to the certificate
- public ApiSingleStringResponse ApiGetCertificateUrl() => ApiGetCertificateUrlAsync().GetAwaiter().GetResult();
-
- ///
- /// Send an Api.GetPermissions Request using the Request from the ApiRequestFactory
- ///
- /// Array of ApiClass (in this case permissions)
- public async Task ApiGetPermissionsAsync()
- {
- var req = _apiRequestFactory.GetApiGetPermissionsRequest();
- string response = await SendPostRequestAsync(req);
- return JsonConvert.DeserializeObject(response);
- }
- ///
- /// Send an Api.GetPermissions Request using the Request from the ApiRequestFactory
- ///
- /// Array of ApiClass (in this case permissions)
- public ApiArrayOfApiClassResponse ApiGetPermissions() => ApiGetPermissionsAsync().GetAwaiter().GetResult();
-
- ///
- /// Send an Api.Logout Request using the Request from the ApiRequestFactory
- ///
- /// True to indicate success
- public async Task ApiLogoutAsync()
- {
- var req = _apiRequestFactory.GetApiLogoutRequest();
- string response = await SendPostRequestAsync(req);
- var responseObj = JsonConvert.DeserializeObject(response);
- _httpClient.DefaultRequestHeaders.Remove("X-Auth-Token");
- return responseObj;
- }
- ///
- /// Send an Api.Logout Request using the Request from the ApiRequestFactory
- ///
- /// True to indicate success
- public ApiTrueOnSuccessResponse ApiLogout() => ApiLogoutAsync().GetAwaiter().GetResult();
-
- ///
- /// Send an Api.Ping Request using the Request from the ApiRequestFactory
- ///
- /// ApiSingleStringResponse - an Id that'll stay the same for the users session
- public async Task ApiPingAsync()
- {
- var req = _apiRequestFactory.GetApiPingRequest();
- string response = await SendPostRequestAsync(req);
- var responseObj = JsonConvert.DeserializeObject(response);
- return responseObj;
- }
- ///
- /// Send an Api.Ping Request using the Request from the ApiRequestFactory
- ///
- /// ApiSingleStringResponse - an Id that'll stay the same for the users session
- public ApiSingleStringResponse ApiPing() => ApiPingAsync().GetAwaiter().GetResult();
-
- ///
- /// Send an Api.Version Request using the Request from the ApiRequestFactory
- ///
- /// a double that contains the value for the current ApiVersion
- public async Task ApiVersionAsync()
- {
- var req = _apiRequestFactory.GetApiVersionRequest();
- string response = await SendPostRequestAsync(req);
- var responseObj = JsonConvert.DeserializeObject(response);
- return responseObj;
- }
- ///
- /// Send an Api.Version Request using the Request from the ApiRequestFactory
- ///
- /// a double that contains the value for the current ApiVersion
- public ApiDoubleResponse ApiVersion() => ApiVersionAsync().GetAwaiter().GetResult();
-
- ///
- /// Send a Plc.ReadOperatingMode Request using the Request from the ApiRequestFactory
- ///
- /// The current Plc OperatingMode
- public async Task PlcReadOperatingModeAsync()
- {
- var req = _apiRequestFactory.GetApiPlcReadOperatingModeRequest();
- string response = await SendPostRequestAsync(req);
- var responseObj = JsonConvert.DeserializeObject(response);
- return responseObj;
- }
- ///
- /// Send a Plc.ReadOperatingMode Request using the Request from the ApiRequestFactory
- ///
- /// The current Plc OperatingMode
- public ApiReadOperatingModeResponse PlcReadOperatingMode() => PlcReadOperatingModeAsync().GetAwaiter().GetResult();
-
- ///
- /// Send a Plc.RequestChangeOperatingMode Request using the Request from the ApiRequestFactory
- /// Method to change the plc operating mode
- /// valid plcOperatingModes are: "run", "stop" - others will lead to an invalid params exception.
- ///
- /// valid plcOperatingModes are: "run", "stop" - others will lead to an invalid params exception.
- public async Task PlcRequestChangeOperatingModeAsync(ApiPlcOperatingMode plcOperatingMode)
- {
- var req = _apiRequestFactory.GetApiPlcRequestChangeOperatingModeRequest(plcOperatingMode);
- string response = await SendPostRequestAsync(req);
- var responseObj = JsonConvert.DeserializeObject(response);
- return responseObj;
- }
- ///
- /// Send a Plc.RequestChangeOperatingMode Request using the Request from the ApiRequestFactory
- /// Method to change the plc operating mode
- /// valid plcOperatingModes are: "run", "stop" - others will lead to an invalid params exception.
- ///
- /// valid plcOperatingModes are: "run", "stop" - others will lead to an invalid params exception.
- public ApiTrueOnSuccessResponse PlcRequestChangeOperatingMode(ApiPlcOperatingMode plcOperatingMode)
- => PlcRequestChangeOperatingModeAsync(plcOperatingMode).GetAwaiter().GetResult();
-
- ///
- /// Send a PlcProgram.Browse Request using the Request from the ApiRequestFactory
- ///
- ///
- /// Name of the variable to browse (symbolic)
- /// • if "mode" ="var" this Attribut is required. The Browse-Method
- /// searches for the variable to find the metadata of it.
- /// • if "mode" = "children", this attribute is optional. The Browse-Method
- /// searches for the variable and returns a list of child elements and metadata.
- ///
- /// Name der zu durchsuchenden Variable
- /// • Wenn "mode" ="var", ist dieses Attribut erforderlich.Die Browse-Methode
- /// sucht nach der Variable, um die Metadaten der Variable zu finden.
- /// • Wenn "mode" = "children", ist dieses Attribut optional. Die Browse-Methode
- /// sucht die Variable und liefert eine Liste an Kind-Variablen und Metadaten.
- ///
- /// PlcProgramBrowseResponse: An Array of ApiPlcProgramData
- public async Task PlcProgramBrowseAsync(ApiPlcProgramBrowseMode plcProgramBrowseMode, string var = null)
- {
- var req = _apiRequestFactory.GetApiPlcProgramBrowseRequest(plcProgramBrowseMode, var);
- string response = await SendPostRequestAsync(req);
- var responseObj = JsonConvert.DeserializeObject(response);
- return responseObj;
- }
- ///
- /// Send a PlcProgram.Browse Request using the Request from the ApiRequestFactory
- ///
- ///
- /// Name of the variable to browse (symbolic)
- /// • if "mode" ="var" this Attribut is required. The Browse-Method
- /// searches for the variable to find the metadata of it.
- /// • if "mode" = "children", this attribute is optional. The Browse-Method
- /// searches for the variable and returns a list of child elements and metadata.
- ///
- /// Name der zu durchsuchenden Variable
- /// • Wenn "mode" ="var", ist dieses Attribut erforderlich.Die Browse-Methode
- /// sucht nach der Variable, um die Metadaten der Variable zu finden.
- /// • Wenn "mode" = "children", ist dieses Attribut optional. Die Browse-Methode
- /// sucht die Variable und liefert eine Liste an Kind-Variablen und Metadaten.
- ///
- /// PlcProgramBrowseResponse: An Array of ApiPlcProgramData
- public ApiPlcProgramBrowseResponse PlcProgramBrowse(ApiPlcProgramBrowseMode plcProgramBrowseMode, string var = null) => PlcProgramBrowseAsync(plcProgramBrowseMode, var).GetAwaiter().GetResult();
-
- ///
- /// Send a PlcProgram.Browse Request using the Request from the ApiRequestFactory
- ///
- ///
- /// Name of the variable to browse (symbolic)
- /// • if "mode" ="var" this Attribut is required. The Browse-Method
- /// searches for the variable to find the metadata of it.
- /// • if "mode" = "children", this attribute is optional. The Browse-Method
- /// searches for the variable and returns a list of child elements and metadata.
- ///
- /// Name der zu durchsuchenden Variable
- /// • Wenn "mode" ="var", ist dieses Attribut erforderlich.Die Browse-Methode
- /// sucht nach der Variable, um die Metadaten der Variable zu finden.
- /// • Wenn "mode" = "children", ist dieses Attribut optional. Die Browse-Methode
- /// sucht die Variable und liefert eine Liste an Kind-Variablen und Metadaten.
- ///
- /// PlcProgramBrowseResponse: An Array of ApiPlcProgramData
- public async Task PlcProgramBrowseAsync(ApiPlcProgramBrowseMode plcProgramBrowseMode, ApiPlcProgramData var)
- {
- string varName = var.GetVarNameForMethods();
- return await PlcProgramBrowseAsync(plcProgramBrowseMode, varName);
- }
- ///
- /// Send a PlcProgram.Browse Request using the Request from the ApiRequestFactory
- ///
- ///
- /// Name of the variable to browse (symbolic)
- /// • if "mode" ="var" this Attribut is required. The Browse-Method
- /// searches for the variable to find the metadata of it.
- /// • if "mode" = "children", this attribute is optional. The Browse-Method
- /// searches for the variable and returns a list of child elements and metadata.
- ///
- /// Name der zu durchsuchenden Variable
- /// • Wenn "mode" ="var", ist dieses Attribut erforderlich.Die Browse-Methode
- /// sucht nach der Variable, um die Metadaten der Variable zu finden.
- /// • Wenn "mode" = "children", ist dieses Attribut optional. Die Browse-Methode
- /// sucht die Variable und liefert eine Liste an Kind-Variablen und Metadaten.
- ///
- /// PlcProgramBrowseResponse: An Array of ApiPlcProgramData
- public ApiPlcProgramBrowseResponse PlcProgramBrowse(ApiPlcProgramBrowseMode plcProgramBrowseMode, ApiPlcProgramData var) => PlcProgramBrowseAsync(plcProgramBrowseMode, var).GetAwaiter().GetResult();
+ ///
+ /// The ApiHttpClientRequestHandler will Send Post Requests,
+ /// before sending the Request it'll remove those Parameters that have the value null for their keys
+ /// (keep in mind when using - when not using the ApiRequestFactory)
+ ///
+ /// authorized httpClient with set Header: 'X-Auth-Token'
+ ///
+ /// response checker for the requestfactory and requesthandler...
+ public ApiHttpClientRequestHandler(HttpClient httpClient, IApiRequestFactory apiRequestFactory, IApiResponseChecker apiResponseChecker)
+ {
+ this._httpClient = httpClient ?? throw new ArgumentNullException(nameof(httpClient));
+ this._apiRequestFactory = apiRequestFactory ?? throw new ArgumentNullException(nameof(apiRequestFactory));
+ this._apiResponseChecker = apiResponseChecker ?? throw new ArgumentNullException(nameof(apiResponseChecker));
+ }
+
+ ///
+ /// only use this function if you know how to build up apiRequests on your own!
+ /// will remove those Params that have the value Null and send the request using the HttpClient.
+ ///
+ /// Api Request to send to the plc (Json Serialized - null properties are deleted)
+ /// Cancellation token to cancel pending requests.
+ /// string: response from thePLC
+ public async Task SendPostRequestAsync(IApiRequest apiRequest, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (apiRequest.Params != null)
+ {
+ apiRequest.Params = apiRequest.Params
+ .Where(el => el.Value != null)
+ .ToDictionary(x => x.Key, x => x.Value);
+ }
+ string apiRequestString = JsonConvert.SerializeObject(apiRequest, new JsonSerializerSettings()
+ { NullValueHandling = NullValueHandling.Ignore, ContractResolver = new CamelCasePropertyNamesContractResolver() });
+ byte[] byteArr = Encoding.GetBytes(apiRequestString);
+ return await SendPostRequestAsync(apiRequestString, cancellationToken);
+ }
+
+
+
+ ///
+ /// only use this function if you know how to build up apiRequests on your own!
+ /// will remove those Params that have the value Null and send the request using the HttpClient.
+ ///
+ /// Api Request to send to the plc (Json Serialized - null properties are deleted)
+ /// string: response from thePLC
+ public string SendPostRequest(IApiRequest apiRequest) => SendPostRequestAsync(apiRequest).GetAwaiter().GetResult();
+
+ ///
+ /// only use this function if you know how to build up apiRequests on your own!
+ /// will remove those Params that have the value Null and send the request using the HttpClient.
+ ///
+ /// Api Request to send to the plc (Json Serialized - null properties are deleted)
+ /// Cancellation token to cancel pending requests.
+ /// string: response from thePLC
+ public async Task SendPostRequestAsync(IApiRequestIntId apiRequestWithIntId, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ if (apiRequestWithIntId.Params != null)
+ {
+ apiRequestWithIntId.Params = apiRequestWithIntId.Params
+ .Where(el => el.Value != null)
+ .ToDictionary(x => x.Key, x => x.Value);
+ }
+ string apiRequestString = JsonConvert.SerializeObject(apiRequestWithIntId, new JsonSerializerSettings()
+ { NullValueHandling = NullValueHandling.Ignore, ContractResolver = new CamelCasePropertyNamesContractResolver() });
+ byte[] byteArr = Encoding.GetBytes(apiRequestString);
+ return await SendPostRequestAsync(apiRequestString, cancellationToken);
+ }
+
+ ///
+ /// only use this function if you know how to build up apiRequests on your own!
+ /// will remove those Params that have the value Null and send the request using the HttpClient.
+ ///
+ /// Api Request to send to the plc (Json Serialized - null properties are deleted)
+ /// string: response from thePLC
+ public string SendPostRequest(IApiRequestIntId apiRequestWithIntId) => SendPostRequestAsync(apiRequestWithIntId).GetAwaiter().GetResult();
+
+ ///
+ /// only use this function if you know how to build up apiRequests on your own!
+ /// will remove those Params that have the value Null and send the request using the HttpClient.
+ ///
+ /// further information about the Api requeest the user tried to send (or was trying to send)
+ /// Cancellation token to cancel pending requests.
+ /// string: response from thePLC
+ public async Task SendPostRequestAsync(string apiRequestString, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ byte[] byteArr = Encoding.GetBytes(apiRequestString);
+ ByteArrayContent request_body = new ByteArrayContent(byteArr);
+ request_body.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(ContentType);
+ var response = await _httpClient.PostAsync(JsonRpcApi, request_body, cancellationToken);
+ _apiResponseChecker.CheckHttpResponseForErrors(response, apiRequestString);
+#if NET6_0_OR_GREATER
+ var responseString = await response.Content.ReadAsStringAsync(cancellationToken);
+#else
+ var responseString = await response.Content.ReadAsStringAsync();
+#endif
+ _apiResponseChecker.CheckResponseStringForErros(responseString, apiRequestString);
+ return responseString;
+ }
+
+ ///
+ /// only use this function if you know how to build up apiRequests on your own!
+ /// will remove those Params that have the value Null and send the request using the HttpClient.
+ ///
+ /// further information about the Api requeest the user tried to send (or was trying to send)
+ /// string: response from thePLC
+ public async Task> SendPostRequestAsyncFileName(string apiRequestString, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ List result = new List();
+ byte[] byteArr = Encoding.GetBytes(apiRequestString);
+ ByteArrayContent request_body = new ByteArrayContent(byteArr);
+ request_body.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(ContentType);
+ var response = await _httpClient.PostAsync(JsonRpcApi, request_body);
+ _apiResponseChecker.CheckHttpResponseForErrors(response, apiRequestString);
+ var responseString = await response.Content.ReadAsStringAsync();
+ _apiResponseChecker.CheckResponseStringForErros(responseString, apiRequestString);
+ result.Add(responseString);
+ //result.Add(response.Content.Headers.ContentDisposition.FileName);
+ return result;
+ }
+
+ ///
+ /// only use this function if you know how to build up apiRequests on your own!
+ /// will remove those Params that have the value Null and send the request using the HttpClient.
+ ///
+ /// further information about the Api requeest the user tried to send (or was trying to send)
+ /// string: response from thePLC
+ public string SendPostRequest(string apiRequestString) => SendPostRequestAsync(apiRequestString).GetAwaiter().GetResult();
+
+ ///
+ /// Send an Api.Browse Request using the Request from the ApiRequestFactory
+ ///
+ /// Cancellation token to cancel pending requests.
+ /// An Array of ApiClass (and Id,Jsonrpc)
+ public async Task ApiBrowseAsync(CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiBrowseRequest();
+ var responseString = await SendPostRequestAsync(req, cancellationToken);
+ var arrOfApiClassResponse = JsonConvert.DeserializeObject(responseString);
+ if (arrOfApiClassResponse.Result.Count == 0)
+ {
+ throw new ApiInvalidResponseException("Api.Browse returned an empty array!");
+ }
+ return arrOfApiClassResponse;
+ }
+ ///
+ /// Send an Api.Browse Request using the Request from the ApiRequestFactory
+ ///
+ /// An Array of ApiClass (and Id,Jsonrpc)
+ public ApiArrayOfApiClassResponse ApiBrowse() => ApiBrowseAsync().GetAwaiter().GetResult();
+
+ ///
+ /// Send an Api.BrowseTickets Request using the Request from the ApiRequestFactory
+ ///
+ /// Cancellation token to cancel pending requests.
+ /// BrowseTickets Response containing: Max_Tickets:uint, Tickets:Array of Ticket
+ public async Task ApiBrowseTicketsAsync(CancellationToken cancellationToken) => await ApiBrowseTicketsAsync((string)null, cancellationToken);
+
+ ///
+ /// Send an Api.BrowseTickets Request using the Request from the ApiRequestFactory
+ ///
+ /// ticket to be browsed (null to browse all)
+ /// Cancellation token to cancel pending requests.
+ /// BrowseTickets Response containing: Max_Tickets:uint, Tickets:Array of Ticket
+ public async Task ApiBrowseTicketsAsync(string ticketId = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiBrowseTicketsRequest(ticketId);
+ var responseString = await SendPostRequestAsync(req, cancellationToken);
+ var arrOfApiClassResponse = JsonConvert.DeserializeObject(responseString);
+ return arrOfApiClassResponse;
+ }
+
+ ///
+ /// Send an Api.BrowseTickets Request using the Request from the ApiRequestFactory
+ ///
+ /// ticket to be browsed (null to browse all)
+ /// BrowseTickets Response containing: Max_Tickets:uint, Tickets:Array of Ticket
+
+ public ApiBrowseTicketsResponse ApiBrowseTickets(string ticketId = null) => ApiBrowseTicketsAsync(ticketId).GetAwaiter().GetResult();
+
+ ///
+ /// Send an Api.BrowseTickets Request using the Request from the ApiRequestFactory
+ ///
+ /// ticket to be browsed (null to browse all)
+ /// Cancellation token to cancel pending requests.
+ /// BrowseTickets Response containing: Max_Tickets:uint, Tickets:Array of Ticket
+ public async Task ApiBrowseTicketsAsync(ApiTicket ticket, CancellationToken cancellationToken = default(CancellationToken)) => await ApiBrowseTicketsAsync(ticket.Id, cancellationToken);
+
+ ///
+ /// Send an Api.BrowseTickets Request using the Request from the ApiRequestFactory
+ ///
+ /// ticket to be browsed (null to browse all)
+ /// BrowseTickets Response containing: Max_Tickets:uint, Tickets:Array of Ticket
+ public ApiBrowseTicketsResponse ApiBrowseTickets(ApiTicket ticket) => ApiBrowseTicketsAsync(ticket).GetAwaiter().GetResult();
+
+ ///
+ /// Send an Api.CloseTicket Request using the Request from the ApiRequestFactory
+ ///
+ /// ticket id (28 chars)
+ /// Cancellation token to cancel pending requests.
+ /// True to indicate Success
+ public async Task ApiCloseTicketAsync(string ticketId, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiCloseTicketRequest(ticketId);
+ var responseString = await SendPostRequestAsync(req, cancellationToken);
+ var apiTrueOnSuccessResponse = JsonConvert.DeserializeObject(responseString);
+ return apiTrueOnSuccessResponse;
+ }
+
+ ///
+ /// Send an Api.CloseTicket Request using the Request from the ApiRequestFactory
+ ///
+ /// ticket id (28 chars)
+ public ApiTrueOnSuccessResponse ApiCloseTicket(string ticketId) => ApiCloseTicketAsync(ticketId).GetAwaiter().GetResult();
+
+ ///
+ /// Send an Api.CloseTicket Request using the Request from the ApiRequestFactory
+ ///
+ /// ticket containing ticket id (28 chars)
+ /// Cancellation token to cancel pending requests.
+ /// True to indicate Success
+ public async Task ApiCloseTicketAsync(ApiTicket ticket, CancellationToken cancellationToken = default(CancellationToken)) => await ApiCloseTicketAsync(ticket.Id);
+
+ ///
+ /// Send an Api.CloseTicket Request using the Request from the ApiRequestFactory
+ ///
+ /// ticket containing ticket id (28 chars)
+ /// True to indicate Success
+ public ApiTrueOnSuccessResponse ApiCloseTicket(ApiTicket ticket) => ApiCloseTicketAsync(ticket).GetAwaiter().GetResult();
+
+ ///
+ /// Send an Api.ChangePassword request
+ ///
+ /// The user account for which the password shall be changed
+ /// The current password for the user
+ /// The new password for the user
+ /// True if changing password for the user was successful
+ public async Task ApiChangePasswordAsync(string username, string currentPassword, string newPassword, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiChangePasswordRequest(username, currentPassword, newPassword);
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject(response);
+ return responseObj;
+ }
+ ///
+ /// Send an Api.ChangePassword request
+ ///
+ /// The user account for which the password shall be changed
+ /// The current password for the user
+ /// The new password for the user
+ /// True if changing password for the user was successful
+ public ApiTrueOnSuccessResponse ApiChangePassword(string username, string currentPassword, string newPassword) =>
+ ApiChangePasswordAsync(username, currentPassword, newPassword).GetAwaiter().GetResult();
+ ///
+ /// Send an Api.GetCertificateUrl Request using the Request from the ApiRequestFactory
+ ///
+ /// ApiSingleStringResponse that contians the URL to the certificate
+ public async Task ApiGetCertificateUrlAsync(CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiGetCertificateUrlRequest();
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ if (!response.Contains("/MiniWebCA_Cer.crt"))
+ Console.WriteLine("unexpected response: " + response + " for Api.GetCertificateUrl!");
+ return JsonConvert.DeserializeObject(response);
+ }
+ ///
+ /// Send an Api.GetCertificateUrl Request using the Request from the ApiRequestFactory
+ ///
+ /// ApiSingleStringResponse that contians the URL to the certificate
+ public ApiSingleStringResponse ApiGetCertificateUrl() => ApiGetCertificateUrlAsync().GetAwaiter().GetResult();
+
+ ///
+ /// Send an Api.GetPermissions Request using the Request from the ApiRequestFactory
+ ///
+ /// Cancellation token to cancel pending requests.
+ /// Array of ApiClass (in this case permissions)
+ public async Task ApiGetPermissionsAsync(CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiGetPermissionsRequest();
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ return JsonConvert.DeserializeObject(response);
+ }
+ ///
+ /// Send an Api.GetQuantityStructures Request using the Request from the ApiRequestFactory
+ ///
+ /// Api Quantity Structure object
+ public async Task ApiGetQuantityStructuresAsync(CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiGetQuantityStructuresRequest();
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ return JsonConvert.DeserializeObject(response);
+ }
+
+ ///
+ /// Send an Api.GetQuantityStructures Request
+ ///
+ /// A QuantityStructure object
+ public ApiGetQuantityStructuresResponse ApiGetQuantityStructures() => ApiGetQuantityStructuresAsync().GetAwaiter().GetResult();
+
+ ///
+ /// Send an Api.GetPermissions Request using the Request from the ApiRequestFactory
+ ///
+ /// Array of ApiClass (in this case permissions)
+ public ApiArrayOfApiClassResponse ApiGetPermissions() => ApiGetPermissionsAsync().GetAwaiter().GetResult();
+
+ ///
+ /// Send an Api.Logout Request using the Request from the ApiRequestFactory
+ ///
+ /// Cancellation token to cancel pending requests.
+ /// True to indicate success
+ public async Task ApiLogoutAsync(CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiLogoutRequest();
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject(response);
+ _httpClient.DefaultRequestHeaders.Remove("X-Auth-Token");
+ return responseObj;
+ }
+ ///
+ /// Send an Api.Logout Request using the Request from the ApiRequestFactory
+ ///
+ /// True to indicate success
+ public ApiTrueOnSuccessResponse ApiLogout() => ApiLogoutAsync().GetAwaiter().GetResult();
+
+ ///
+ /// Send an Api.Ping Request using the Request from the ApiRequestFactory
+ ///
+ /// ApiSingleStringResponse - an Id that'll stay the same for the users session
+ public async Task ApiPingAsync(CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiPingRequest();
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject(response);
+ return responseObj;
+ }
+ ///
+ /// Send an Api.Ping Request using the Request from the ApiRequestFactory
+ ///
+ /// ApiSingleStringResponse - an Id that'll stay the same for the users session
+ public ApiSingleStringResponse ApiPing() => ApiPingAsync().GetAwaiter().GetResult();
+
+ ///
+ /// Send an Api.Version Request using the Request from the ApiRequestFactory
+ ///
+ /// a double that contains the value for the current ApiVersion
+ public async Task ApiVersionAsync(CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiVersionRequest();
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject(response);
+ return responseObj;
+ }
+ ///
+ /// Send an Api.Version Request using the Request from the ApiRequestFactory
+ ///
+ /// a double that contains the value for the current ApiVersion
+ public ApiDoubleResponse ApiVersion() => ApiVersionAsync().GetAwaiter().GetResult();
+
+ ///
+ /// Perform a service data download on the corresponding module with hwid
+ ///
+ /// The HWID of a node (module) for which a service data file can be downloaded
+ /// Ticket to use for downloading the service data
+ public async Task ModulesDownloadServiceDataAsync(ApiPlcHwId hwid, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetModulesDownloadServiceData(hwid);
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject(response);
+ return responseObj;
+ }
+ ///
+ /// Perform a service data download on the corresponding module with hwid
+ ///
+ /// The HWID of a node (module) for which a service data file can be downloaded
+ /// Ticket to use for downloading the service data
+ public ApiTicketIdResponse ModulesDownloadServiceData(ApiPlcHwId hwid) =>
+ ModulesDownloadServiceDataAsync(hwid).GetAwaiter().GetResult();
+
+ ///
+ /// Send a Plc.ReadOperatingMode Request using the Request from the ApiRequestFactory
+ ///
+ /// The current Plc OperatingMode
+ public async Task PlcReadOperatingModeAsync(CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiPlcReadOperatingModeRequest();
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject(response);
+ return responseObj;
+ }
+ ///
+ /// Send a Plc.ReadOperatingMode Request using the Request from the ApiRequestFactory
+ ///
+ /// The current Plc OperatingMode
+ public ApiReadOperatingModeResponse PlcReadOperatingMode() => PlcReadOperatingModeAsync().GetAwaiter().GetResult();
+
+ ///
+ /// Send a Plc.RequestChangeOperatingMode Request using the Request from the ApiRequestFactory
+ /// Method to change the plc operating mode
+ /// valid plcOperatingModes are: "run", "stop" - others will lead to an invalid params exception.
+ ///
+ /// valid plcOperatingModes are: "run", "stop" - others will lead to an invalid params exception.
+ public async Task PlcRequestChangeOperatingModeAsync(ApiPlcOperatingMode plcOperatingMode, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiPlcRequestChangeOperatingModeRequest(plcOperatingMode);
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject(response);
+ return responseObj;
+ }
+ ///
+ /// Send a Plc.RequestChangeOperatingMode Request using the Request from the ApiRequestFactory
+ /// Method to change the plc operating mode
+ /// valid plcOperatingModes are: "run", "stop" - others will lead to an invalid params exception.
+ ///
+ /// valid plcOperatingModes are: "run", "stop" - others will lead to an invalid params exception.
+ public ApiTrueOnSuccessResponse PlcRequestChangeOperatingMode(ApiPlcOperatingMode plcOperatingMode)
+ => PlcRequestChangeOperatingModeAsync(plcOperatingMode).GetAwaiter().GetResult();
+
+ ///
+ /// Send a PlcProgram.Browse Request using the Request from the ApiRequestFactory
+ ///
+ ///
+ /// Name of the variable to browse (symbolic)
+ /// • if "mode" ="var" this Attribut is required. The Browse-Method
+ /// searches for the variable to find the metadata of it.
+ /// • if "mode" = "children", this attribute is optional. The Browse-Method
+ /// searches for the variable and returns a list of child elements and metadata.
+ ///
+ /// Name der zu durchsuchenden Variable
+ /// • Wenn "mode" ="var", ist dieses Attribut erforderlich.Die Browse-Methode
+ /// sucht nach der Variable, um die Metadaten der Variable zu finden.
+ /// • Wenn "mode" = "children", ist dieses Attribut optional. Die Browse-Methode
+ /// sucht die Variable und liefert eine Liste an Kind-Variablen und Metadaten.
+ ///
+ /// PlcProgramBrowseResponse: An Array of ApiPlcProgramData
+ public async Task PlcProgramBrowseAsync(ApiPlcProgramBrowseMode plcProgramBrowseMode, string var = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiPlcProgramBrowseRequest(plcProgramBrowseMode, var);
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject(response);
+ return responseObj;
+ }
+ ///
+ /// Send a PlcProgram.Browse Request using the Request from the ApiRequestFactory
+ ///
+ ///
+ /// Name of the variable to browse (symbolic)
+ /// • if "mode" ="var" this Attribut is required. The Browse-Method
+ /// searches for the variable to find the metadata of it.
+ /// • if "mode" = "children", this attribute is optional. The Browse-Method
+ /// searches for the variable and returns a list of child elements and metadata.
+ ///
+ /// Name der zu durchsuchenden Variable
+ /// • Wenn "mode" ="var", ist dieses Attribut erforderlich.Die Browse-Methode
+ /// sucht nach der Variable, um die Metadaten der Variable zu finden.
+ /// • Wenn "mode" = "children", ist dieses Attribut optional. Die Browse-Methode
+ /// sucht die Variable und liefert eine Liste an Kind-Variablen und Metadaten.
+ ///
+ /// PlcProgramBrowseResponse: An Array of ApiPlcProgramData
+ public ApiPlcProgramBrowseResponse PlcProgramBrowse(ApiPlcProgramBrowseMode plcProgramBrowseMode, string var = null) => PlcProgramBrowseAsync(plcProgramBrowseMode, var).GetAwaiter().GetResult();
+
+ ///
+ /// Send a PlcProgram.Browse Request using the Request from the ApiRequestFactory
+ ///
+ ///
+ /// Name of the variable to browse (symbolic)
+ /// • if "mode" ="var" this Attribut is required. The Browse-Method
+ /// searches for the variable to find the metadata of it.
+ /// • if "mode" = "children", this attribute is optional. The Browse-Method
+ /// searches for the variable and returns a list of child elements and metadata.
+ ///
+ /// Name der zu durchsuchenden Variable
+ /// • Wenn "mode" ="var", ist dieses Attribut erforderlich.Die Browse-Methode
+ /// sucht nach der Variable, um die Metadaten der Variable zu finden.
+ /// • Wenn "mode" = "children", ist dieses Attribut optional. Die Browse-Methode
+ /// sucht die Variable und liefert eine Liste an Kind-Variablen und Metadaten.
+ ///
+ /// PlcProgramBrowseResponse: An Array of ApiPlcProgramData
+ public async Task PlcProgramBrowseAsync(ApiPlcProgramBrowseMode plcProgramBrowseMode, ApiPlcProgramData var, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ string varName = var.GetVarNameForMethods();
+ return await PlcProgramBrowseAsync(plcProgramBrowseMode, varName, cancellationToken);
+ }
+ ///
+ /// Send a PlcProgram.Browse Request using the Request from the ApiRequestFactory
+ ///
+ ///
+ /// Name of the variable to browse (symbolic)
+ /// • if "mode" ="var" this Attribut is required. The Browse-Method
+ /// searches for the variable to find the metadata of it.
+ /// • if "mode" = "children", this attribute is optional. The Browse-Method
+ /// searches for the variable and returns a list of child elements and metadata.
+ ///
+ /// Name der zu durchsuchenden Variable
+ /// • Wenn "mode" ="var", ist dieses Attribut erforderlich.Die Browse-Methode
+ /// sucht nach der Variable, um die Metadaten der Variable zu finden.
+ /// • Wenn "mode" = "children", ist dieses Attribut optional. Die Browse-Methode
+ /// sucht die Variable und liefert eine Liste an Kind-Variablen und Metadaten.
+ ///
+ /// PlcProgramBrowseResponse: An Array of ApiPlcProgramData
+ public ApiPlcProgramBrowseResponse PlcProgramBrowse(ApiPlcProgramBrowseMode plcProgramBrowseMode, ApiPlcProgramData var) => PlcProgramBrowseAsync(plcProgramBrowseMode, var).GetAwaiter().GetResult();
+
+ ///
+ /// Send a PlcProgram.Browse request for the code blocks.
+ ///
+ /// ApiPlcProgramBrowseCodeBlocksResponse: A collection of ApiPlcProgramBrowseCodeBlocksData objects.
+ public ApiPlcProgramBrowseCodeBlocksResponse PlcProgramBrowseCodeBlocks() => PlcProgramBrowseCodeBlocksAsync().GetAwaiter().GetResult();
+
+ ///
+ /// Send a PlcProgram.Browse request for the code blocks.
+ ///
+ /// Cancellation token to cancel pending requests.
+ /// ApiPlcProgramBrowseCodeBlocksResponse: A collection of ApiPlcProgramBrowseCodeBlocksData objects.
+ public async Task PlcProgramBrowseCodeBlocksAsync(CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiPlcProgramBrowseCodeBlocksRequest();
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject(response);
+ return responseObj;
+ }
+
+ ///
+ /// Send a PlcProgram.DownloadProfilingData request.
+ ///
+ /// ApiSingleStringResponse: Object containing the ticket ID for the data download.
+ public ApiSingleStringResponse PlcProgramDownloadProfilingData() => PlcProgramDownloadProfilingDataAsync().GetAwaiter().GetResult();
+
+ ///
+ /// Send a PlcProgram.DownloadProfilingData request.
+ ///
+ /// Cancellation token to cancel pending requests.
+ /// ApiSingleStringResponse: Object containing the ticket ID for the data download.
+ public async Task PlcProgramDownloadProfilingDataAsync(CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiPlcProgramDownloadProfilingDataRequest();
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject(response);
+ return responseObj;
+ }
+
+ ///
+ /// Send a PlcProgram.Read Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the variable to be read
+ ///
+ /// Name der zu lesenden Variable
+ ///
+ /// this parameter is optional and defaults to "simple":
+ /// "simple" will get the variable values according to the presentation of the manual - "supported Datatypes"
+ /// "raw" : will get the variable values according to the presentation of the manual "raw"
+ ///
+ /// Aufzählung, die das Antwortformat für diese Methode festlegt:
+ /// • "simple": liefert Variablenwerte gemäß der Darstellung
+ /// "simple" in Kapitel "Unterstützte Datentypen (Seite 162)"
+ /// • "raw": liefert Variablenwerte gemäß der Darstellung "raw"
+ /// in Kapitel "Unterstützte Datentypen"
+ /// ApiPlcProgramReadResponse: object with the value for the variables value to be read
+ public async Task> PlcProgramReadAsync(string var, ApiPlcProgramReadOrWriteMode? plcProgramReadMode = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiPlcProgramReadRequest(var, plcProgramReadMode);
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject>(response);
+ return responseObj;
+ }
+ ///
+ /// Send a PlcProgram.Read Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the variable to be read
+ ///
+ /// Name der zu lesenden Variable
+ ///
+ /// this parameter is optional and defaults to "simple":
+ /// "simple" will get the variable values according to the presentation of the manual - "supported Datatypes"
+ /// "raw" : will get the variable values according to the presentation of the manual "raw"
+ ///
+ /// Aufzählung, die das Antwortformat für diese Methode festlegt:
+ /// • "simple": liefert Variablenwerte gemäß der Darstellung
+ /// "simple" in Kapitel "Unterstützte Datentypen (Seite 162)"
+ /// • "raw": liefert Variablenwerte gemäß der Darstellung "raw"
+ /// in Kapitel "Unterstützte Datentypen"
+ /// ApiPlcProgramReadResponse: object with the value for the variables value to be read
+ public ApiResultResponse PlcProgramRead(ApiPlcProgramData var, ApiPlcProgramReadOrWriteMode? plcProgramReadMode = null) => PlcProgramReadAsync(var, plcProgramReadMode).GetAwaiter().GetResult();
+
+ ///
+ /// Send a PlcProgram.Browse Request using the Request from the ApiRequestFactory
+ /// This function will build up the name with quotes from the parents given with the ApiPlcProgramDataand call PlcProgramRead
+ ///
+ ///
+ /// Name of the variable to be read
+ /// Name der zu lesenden Variable
+ ///
+ /// this parameter is optional and defaults to "simple":
+ /// "simple" will get the variable values according to the presentation of the manual - "supported Datatypes"
+ /// "raw" : will get the variable values according to the presentation of the manual "raw"
+ ///
+ /// Aufzählung, die das Antwortformat für diese Methode festlegt:
+ /// • "simple": liefert Variablenwerte gemäß der Darstellung
+ /// "simple" in Kapitel "Unterstützte Datentypen (Seite 162)"
+ /// • "raw": liefert Variablenwerte gemäß der Darstellung "raw"
+ /// in Kapitel "Unterstützte Datentypen"
+ /// ApiPlcProgramReadResponse: object with the value for the variables value to be read
+ /// will be thrown if a ApiPlcProgramDatathat is an array will be given without an index
+ public async Task> PlcProgramReadAsync(ApiPlcProgramData var, ApiPlcProgramReadOrWriteMode? plcProgramReadMode = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ //RequestParameterChecker.CheckPlcProgramReadOrWriteDataType(var.Datatype, true);
+ string varName = var.GetVarNameForMethods();
+ return await PlcProgramReadAsync(varName, plcProgramReadMode, cancellationToken);
+ }
+ ///
+ /// Send a PlcProgram.Browse Request using the Request from the ApiRequestFactory
+ /// This function will build up the name with quotes from the parents given with the ApiPlcProgramDataand call PlcProgramRead
+ ///
+ ///
+ /// Name of the variable to be read
+ /// Name der zu lesenden Variable
+ ///
+ /// this parameter is optional and defaults to "simple":
+ /// "simple" will get the variable values according to the presentation of the manual - "supported Datatypes"
+ /// "raw" : will get the variable values according to the presentation of the manual "raw"
+ ///
+ /// Aufzählung, die das Antwortformat für diese Methode festlegt:
+ /// • "simple": liefert Variablenwerte gemäß der Darstellung
+ /// "simple" in Kapitel "Unterstützte Datentypen (Seite 162)"
+ /// • "raw": liefert Variablenwerte gemäß der Darstellung "raw"
+ /// in Kapitel "Unterstützte Datentypen"
+ /// ApiPlcProgramReadResponse: object with the value for the variables value to be read
+ /// will be thrown if a ApiPlcProgramDatathat is an array will be given without an index
+ public ApiResultResponse PlcProgramRead(string var, ApiPlcProgramReadOrWriteMode? plcProgramReadMode = null) => PlcProgramReadAsync(var, plcProgramReadMode).GetAwaiter().GetResult();
+
+ ///
+ /// Send a PlcProgram.Write Request using the Request from the ApiRequestFactory
+ /// This function will build up the name with quotes from the parents given with the ApiPlcProgramDataand call PlcProgramWrite
+ ///
+ ///
+ /// Name of the variable to be read
+ /// Name der zu lesenden Variable
+ ///
+ ///
+ /// true to indicate success
+ /// will be thrown if a ApiPlcProgramDatathat is an array will be given without an index
+ public async Task PlcProgramWriteAsync(ApiPlcProgramData var, object valueToBeSet, ApiPlcProgramReadOrWriteMode? plcProgramWriteMode = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ string varName = var.GetVarNameForMethods();
+ // ApiRequestFactory.CheckPlcProgramReadOrWriteDataType(var.Datatype); will also be called by GetApiPlcProgramWriteValueToBeSet!
+ var writeVal = _apiRequestFactory.GetApiPlcProgramWriteValueToBeSet(var.Datatype, valueToBeSet);
+ return await PlcProgramWriteAsync(varName, writeVal, plcProgramWriteMode, cancellationToken);
+ }
+ ///
+ /// Send a PlcProgram.Write Request using the Request from the ApiRequestFactory
+ /// This function will build up the name with quotes from the parents given with the ApiPlcProgramDataand call PlcProgramWrite
+ ///
+ ///
+ /// Name of the variable to be read
+ /// Name der zu lesenden Variable
+ ///
+ ///
+ /// true to indicate success
+ /// will be thrown if a ApiPlcProgramDatathat is an array will be given without an index
+ public ApiTrueOnSuccessResponse PlcProgramWrite(ApiPlcProgramData var, object valueToBeSet, ApiPlcProgramReadOrWriteMode? plcProgramWriteMode = null)
+ => PlcProgramWriteAsync(var, valueToBeSet, plcProgramWriteMode).GetAwaiter().GetResult();
+
+ ///
+ /// Send a PlcProgram.Write Request using the Request from the ApiRequestFactory
+ ///
+ ///
+ /// Name of the variable to be read
+ /// Name der zu lesenden Variable
+ ///
+ ///
+ /// true to indicate success
+ /// will be thrown if a ApiPlcProgramDatathat is an array will be given without an index
+ public async Task PlcProgramWriteAsync(string var, object valueToBeSet, ApiPlcProgramReadOrWriteMode? plcProgramWriteMode = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiPlcProgramWriteRequest(var, valueToBeSet, plcProgramWriteMode);
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject(response);
+ return responseObj;
+ }
+ ///
+ /// Send a PlcProgram.Write Request using the Request from the ApiRequestFactory
+ ///
+ ///
+ /// Name of the variable to be read
+ /// Name der zu lesenden Variable
+ ///
+ ///
+ /// true to indicate success
+ /// will be thrown if a ApiPlcProgramDatathat is an array will be given without an index
+ public ApiTrueOnSuccessResponse PlcProgramWrite(string var, object valueToBeSet, ApiPlcProgramReadOrWriteMode? plcProgramWriteMode = null)
+ => PlcProgramWriteAsync(var, valueToBeSet, plcProgramWriteMode).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.Browse Request using the Request from the ApiRequestFactory
+ ///
+ /// webappdata that should be requested
+ /// ApiWebAppBrowseResponse: Containing WebAppBrowseResult: Max_Applications:uint,
+ /// Applications: Array of ApiWebAppdata containing one element: the webappdata that has been requested
+ public async Task WebAppBrowseAsync(ApiWebAppData webAppData, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ return await WebAppBrowseAsync(webAppData.Name, cancellationToken);
+ }
+ ///
+ /// Send a WebApp.Browse Request using the Request from the ApiRequestFactory
+ ///
+ /// webappdata that should be requested
+ /// ApiWebAppBrowseResponse: Containing WebAppBrowseResult: Max_Applications:uint,
+ /// Applications: Array of ApiWebAppdata containing one element: the webappdata that has been requested
+ public ApiWebAppBrowseResponse WebAppBrowse(ApiWebAppData webAppData) => WebAppBrowseAsync(webAppData).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.Browse Request using the Request from the ApiRequestFactory
+ ///
+ /// webapp name in case only one is requested
+ /// ApiWebAppBrowseResponse: Containing WebAppBrowseResult: Max_Applications:uint,
+ /// Applications: Array of ApiWebAppdata containing one element: the webappdata that has been requested
+ public async Task WebAppBrowseAsync(string webAppName = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiWebAppBrowseRequest(webAppName);
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject(response);
+ return responseObj;
+ }
+ ///
+ /// Send a WebApp.Browse Request using the Request from the ApiRequestFactory
+ ///
+ /// webapp name in case only one is requested
+ /// ApiWebAppBrowseResponse: Containing WebAppBrowseResult: Max_Applications:uint,
+ /// Applications: Array of ApiWebAppdata containing one element: the webappdata that has been requested
+ public ApiWebAppBrowseResponse WebAppBrowse(string webAppName = null) => WebAppBrowseAsync(webAppName).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.BrowseResources Request using the Request from the ApiRequestFactory
+ /// Will return the Api Response "straight away"
+ /// A user can use the List of ApiWebAppResources to set those to an ApiWebAppData
+ /// (care to also add those who are protected to the protected resources in case you want to do that)
+ ///
+ /// WebApp name to browse resources of
+ /// If given only that resource will be inside the array (in case it exists)
+ /// ApiWebAppBrowseResourcesResponse:containing ApiWebAppBrowseResourcesResult: Max_Resources:uint,
+ /// Resources:Array of ApiWebAppResource (only 1 if one is requested)
+ public async Task WebAppBrowseResourcesAsync(string webAppName, string resourceName = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiWebAppBrowseResourcesRequest(webAppName, resourceName);
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject(response);
+ return responseObj;
+ }
+ ///
+ /// Send a WebApp.BrowseResources Request using the Request from the ApiRequestFactory
+ /// Will return the Api Response "straight away"
+ /// A user can use the List of ApiWebAppResources to set those to an ApiWebAppData
+ /// (care to also add those who are protected to the protected resources in case you want to do that)
+ ///
+ /// WebApp name to browse resources of
+ /// If given only that resource will be inside the array (in case it exists)
+ /// ApiWebAppBrowseResourcesResponse:containing ApiWebAppBrowseResourcesResult: Max_Resources:uint,
+ /// Resources:Array of ApiWebAppResource (only 1 if one is requested)
+ public ApiWebAppBrowseResourcesResponse WebAppBrowseResources(string webAppName, string resourceName = null) => WebAppBrowseResourcesAsync(webAppName, resourceName).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.BrowseResources Request using the Request from the ApiRequestFactory
+ /// Will return the Api Response "straight away"
+ /// A user can use the List of ApiWebAppResources to set those to an ApiWebAppData
+ /// (care to also add those who are protected to the protected resources in case you want to do that)
+ ///
+ /// WebApp.Name to browse resources of
+ /// If given only that resource will be inside the array (in case it exists)
+ /// ApiWebAppBrowseResourcesResponse:containing ApiWebAppBrowseResourcesResult: Max_Resources:uint,
+ /// Resources:Array of ApiWebAppResource (only 1 if one is requested)
+ public async Task WebAppBrowseResourcesAsync(ApiWebAppData webApp, string resourceName = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ return await WebAppBrowseResourcesAsync(webApp.Name, resourceName, cancellationToken);
+ }
+ ///
+ /// Send a WebApp.BrowseResources Request using the Request from the ApiRequestFactory
+ /// Will return the Api Response "straight away"
+ /// A user can use the List of ApiWebAppResources to set those to an ApiWebAppData
+ /// (care to also add those who are protected to the protected resources in case you want to do that)
+ ///
+ /// WebApp.Name to browse resources of
+ /// If given only that resource will be inside the array (in case it exists)
+ /// ApiWebAppBrowseResourcesResponse:containing ApiWebAppBrowseResourcesResult: Max_Resources:uint,
+ /// Resources:Array of ApiWebAppResource (only 1 if one is requested)
+ public ApiWebAppBrowseResourcesResponse WebAppBrowseResources(ApiWebAppData webApp, string resourceName = null) => WebAppBrowseResourcesAsync(webApp, resourceName).GetAwaiter().GetResult();
+ ///
+ /// Send a WebApp.BrowseResources Request using the Request from the ApiRequestFactory
+ /// Will return the Api Response "straight away"
+ /// A user can use the List of ApiWebAppResources to set those to an ApiWebAppData
+ /// (care to also add those who are protected to the protected resources in case you want to do that)
+ ///
+ /// WebApp Name to browse resources of
+ /// resource.Name to browse for
+ /// ApiWebAppBrowseResourcesResponse:containing ApiWebAppBrowseResourcesResult: Max_Resources:uint,
+ /// Resources:Array of ApiWebAppResource (only 1 if one is requested)
+ public async Task WebAppBrowseResourcesAsync(string webAppName, ApiWebAppResource resource, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ return await WebAppBrowseResourcesAsync(webAppName, resource.Name, cancellationToken);
+ }
+ ///
+ /// Send a WebApp.BrowseResources Request using the Request from the ApiRequestFactory
+ /// Will return the Api Response "straight away"
+ /// A user can use the List of ApiWebAppResources to set those to an ApiWebAppData
+ /// (care to also add those who are protected to the protected resources in case you want to do that)
+ ///
+ /// WebApp Name to browse resources of
+ /// resource.Name to browse for
+ /// ApiWebAppBrowseResourcesResponse:containing ApiWebAppBrowseResourcesResult: Max_Resources:uint,
+ /// Resources:Array of ApiWebAppResource (only 1 if one is requested)
+ public ApiWebAppBrowseResourcesResponse WebAppBrowseResources(string webAppName, ApiWebAppResource resource) => WebAppBrowseResourcesAsync(webAppName, resource).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.BrowseResources Request using the Request from the ApiRequestFactory
+ /// Will return the Api Response "straight away"
+ /// A user can use the List of ApiWebAppResources to set those to an ApiWebAppData
+ /// (care to also add those who are protected to the protected resources in case you want to do that)
+ ///
+ /// webApp.Name to browse resources of
+ /// resource.Name to browse for
+ /// ApiWebAppBrowseResourcesResponse:containing ApiWebAppBrowseResourcesResult: Max_Resources:uint,
+ /// Resources:Array of ApiWebAppResource (only 1 if one is requested)
+ public async Task WebAppBrowseResourcesAsync(ApiWebAppData webApp, ApiWebAppResource resource, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ return await WebAppBrowseResourcesAsync(webApp.Name, resource.Name, cancellationToken);
+ }
+ ///
+ /// Send a WebApp.BrowseResources Request using the Request from the ApiRequestFactory
+ /// Will return the Api Response "straight away"
+ /// A user can use the List of ApiWebAppResources to set those to an ApiWebAppData
+ /// (care to also add those who are protected to the protected resources in case you want to do that)
+ ///
+ /// webApp.Name to browse resources of
+ /// resource.Name to browse for
+ /// ApiWebAppBrowseResourcesResponse:containing ApiWebAppBrowseResourcesResult: Max_Resources:uint,
+ /// Resources:Array of ApiWebAppResource (only 1 if one is requested)
+ public ApiWebAppBrowseResourcesResponse WebAppBrowseResources(ApiWebAppData webApp, ApiWebAppResource resource) => WebAppBrowseResourcesAsync(webApp, resource).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.Create Request using the Request from the ApiRequestFactory
+ ///
+ /// webapp name for the app to be created
+ /// optional parameter: state the webapp should be in
+ /// true to indicate success
+ public async Task WebAppCreateAsync(string webAppName, ApiWebAppState? apiWebAppState = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiWebAppCreateRequest(webAppName, apiWebAppState);
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject(response);
+ return responseObj;
+ }
+ ///
+ /// Send a WebApp.Create Request using the Request from the ApiRequestFactory
+ ///
+ /// webapp name for the app to be created
+ /// optional parameter: state the webapp should be in
+ /// true to indicate success
+ public ApiTrueOnSuccessResponse WebAppCreate(string webAppName, ApiWebAppState? apiWebAppState = null) => WebAppCreateAsync(webAppName, apiWebAppState).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.Create Request using the Request from the ApiRequestFactory
+ ///
+ /// containing information about name and state for the app to be created
+ /// true to indicate success
+ public async Task WebAppCreateAsync(ApiWebAppData webApp, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ // ApiRequestFactory.CheckState(webApp.State); will be called in WebAppCreate in Factory.GetApiWebAppCreateRequest
+ return await WebAppCreateAsync(webApp.Name, webApp.State, cancellationToken);
+ }
+ ///
+ /// Send a WebApp.Create Request using the Request from the ApiRequestFactory
+ ///
+ /// containing information about name and state for the app to be created
+ /// true to indicate success
+ public ApiTrueOnSuccessResponse WebAppCreate(ApiWebAppData webApp) => WebAppCreateAsync(webApp).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.CreateResource Request using the Request from the ApiRequestFactory
+ ///
+ /// name of the webapp to create the resource on
+ /// resource name to be created with (typically provided with extension)
+ /// resource media type - see MIMEType.mapping
+ /// Be sure to provide the RFC3339 format!
+ /// resource visibility (protect your confidential data)
+ /// you can provide an etag as identification,... for your resource
+ /// TicketId for the Ticketing Endpoint to perform the Upload on
+ public async Task WebAppCreateResourceAsync(string webAppName, string resourceName, string media_type,
+ string last_modified, ApiWebAppResourceVisibility? apiWebAppResourceVisibility = null, string etag = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiWebAppCreateResourceRequest(webAppName, resourceName, media_type,
+ last_modified, apiWebAppResourceVisibility, etag);
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject(response);
+ return responseObj;
+ }
+ ///
+ /// Send a WebApp.CreateResource Request using the Request from the ApiRequestFactory
+ ///
+ /// name of the webapp to create the resource on
+ /// resource name to be created with (typically provided with extension)
+ /// resource media type - see MIMEType.mapping
+ /// Be sure to provide the RFC3339 format!
+ /// resource visibility (protect your confidential data)
+ /// you can provide an etag as identification,... for your resource
+ /// TicketId for the Ticketing Endpoint to perform the Upload on
+ public ApiTicketIdResponse WebAppCreateResource(string webAppName, string resourceName, string media_type, string last_modified, ApiWebAppResourceVisibility? apiWebAppResourceVisibility = null, string etag = null)
+ => WebAppCreateResourceAsync(webAppName, resourceName, media_type, last_modified, apiWebAppResourceVisibility, etag).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.CreateResource Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp to create the resource on
+ /// resource name to be created with (typically provided with extension)
+ /// resource media type - see MIMEType.mapping
+ /// Be sure to provide the RFC3339 format!
+ /// resource visibility (protect your confidential data)
+ /// you can provide an etag as identification,... for your resource
+ /// TicketId for the Ticketing Endpoint to perform the Upload on
+ public async Task WebAppCreateResourceAsync(ApiWebAppData webApp, string resourceName, string media_type,
+ string last_modified, ApiWebAppResourceVisibility? apiWebAppResourceVisibility = null, string etag = null, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ return await WebAppCreateResourceAsync(webApp.Name, resourceName, media_type, last_modified, apiWebAppResourceVisibility, etag, cancellationToken);
+ }
+ ///
+ /// Send a WebApp.CreateResource Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp to create the resource on
+ /// resource name to be created with (typically provided with extension)
+ /// resource media type - see MIMEType.mapping
+ /// Be sure to provide the RFC3339 format!
+ /// resource visibility (protect your confidential data)
+ /// you can provide an etag as identification,... for your resource
+ /// TicketId for the Ticketing Endpoint to perform the Upload on
+ public ApiTicketIdResponse WebAppCreateResource(ApiWebAppData webApp, string resourceName, string media_type, string last_modified, ApiWebAppResourceVisibility? apiWebAppResourceVisibility = null, string etag = null)
+ => WebAppCreateResourceAsync(webApp, resourceName, media_type, last_modified, apiWebAppResourceVisibility, etag).GetAwaiter().GetResult();
+ ///
+ /// Send a WebApp.CreateResource Request using the Request from the ApiRequestFactory
+ ///
+ /// name of the webapp to create the resource on
+ /// resource containing all the information:
+ /// Name: name to be created with (typically provided with extension)
+ /// Media_type: resource media type - see MIMEType.mapping
+ /// Last_modified: Be sure to provide the RFC3339 format!
+ /// Visibility: resource visibility (protect your confidential data)
+ /// Etag: you can provide an etag as identification,... for your resource
+ /// TicketId for the Ticketing Endpoint to perform the Upload on
+ public async Task WebAppCreateResourceAsync(string webAppName, ApiWebAppResource resource, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ return await WebAppCreateResourceAsync(webAppName, resource.Name, resource.Media_type,
+ resource.Last_modified.ToString(DateTimeFormatting.ApiDateTimeFormat), resource.Visibility, resource.Etag, cancellationToken);
+ }
+ ///
+ /// Send a WebApp.CreateResource Request using the Request from the ApiRequestFactory
+ ///
+ /// name of the webapp to create the resource on
+ /// resource containing all the information:
+ /// Name: name to be created with (typically provided with extension)
+ /// Media_type: resource media type - see MIMEType.mapping
+ /// Last_modified: Be sure to provide the RFC3339 format!
+ /// Visibility: resource visibility (protect your confidential data)
+ /// Etag: you can provide an etag as identification,... for your resource
+ /// TicketId for the Ticketing Endpoint to perform the Upload on
+ public ApiTicketIdResponse WebAppCreateResource(string webAppName, ApiWebAppResource resource) => WebAppCreateResourceAsync(webAppName, resource).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.CreateResource Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp to create the resource on
+ /// resource containing all the information:
+ /// Name: name to be created with (typically provided with extension)
+ /// Media_type: resource media type - see MIMEType.mapping
+ /// Last_modified: Be sure to provide the RFC3339 format!
+ /// Visibility: resource visibility (protect your confidential data)
+ /// Etag: you can provide an etag as identification,... for your resource
+ /// TicketId for the Ticketing Endpoint to perform the Upload on
+ public async Task WebAppCreateResourceAsync(ApiWebAppData webApp, ApiWebAppResource resource, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ return await WebAppCreateResourceAsync(webApp.Name, resource.Name, resource.Media_type,
+ resource.Last_modified.ToString(DateTimeFormatting.ApiDateTimeFormat), resource.Visibility, resource.Etag, cancellationToken);
+ }
+ ///
+ /// Send a WebApp.CreateResource Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp to create the resource on
+ /// resource containing all the information:
+ /// Name: name to be created with (typically provided with extension)
+ /// Media_type: resource media type - see MIMEType.mapping
+ /// Last_modified: Be sure to provide the RFC3339 format!
+ /// Visibility: resource visibility (protect your confidential data)
+ /// Etag: you can provide an etag as identification,... for your resource
+ /// TicketId for the Ticketing Endpoint to perform the Upload on
+ public ApiTicketIdResponse WebAppCreateResource(ApiWebAppData webApp, ApiWebAppResource resource) => WebAppCreateResourceAsync(webApp, resource).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.Delete Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp to delete
+ /// true to indicate success
+ public async Task WebAppDeleteAsync(string webAppName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiWebAppDeleteRequest(webAppName);
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject(response);
+ return responseObj;
+ }
+ ///
+ /// Send a WebApp.Delete Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp to delete
+ /// true to indicate success
+ public ApiTrueOnSuccessResponse WebAppDelete(string webAppName) => WebAppDeleteAsync(webAppName).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.Delete Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp to delete
+ /// true to indicate success
+ public async Task WebAppDeleteAsync(ApiWebAppData webApp, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ return await WebAppDeleteAsync(webApp.Name, cancellationToken);
+ }
+ ///
+ /// Send a WebApp.Delete Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp to delete
+ /// true to indicate success
+ public ApiTrueOnSuccessResponse WebAppDelete(ApiWebAppData webApp) => WebAppDeleteAsync(webApp).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.DeleteRespource Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that contains the resource
+ /// Name of the resource to delete
+ /// true to indicate success
+ public async Task WebAppDeleteResourceAsync(string webAppName, string resourceName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiWebAppDeleteResourceRequest(webAppName, resourceName);
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject(response);
+ return responseObj;
+ }
+ ///
+ /// Send a WebApp.DeleteRespource Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that contains the resource
+ /// Name of the resource to delete
+ /// true to indicate success
+ public ApiTrueOnSuccessResponse WebAppDeleteResource(string webAppName, string resourceName) => WebAppDeleteResourceAsync(webAppName, resourceName).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.DeleteRespource Request using the Request from the ApiRequestFactory
+ ///
+ /// webapp.Name of the webapp that contains the resource
+ /// Name of the resource to delete
+ /// true to indicate success
+ public async Task WebAppDeleteResourceAsync(ApiWebAppData webApp, string resourceName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ return await WebAppDeleteResourceAsync(webApp.Name, resourceName, cancellationToken);
+ }
+ ///
+ /// Send a WebApp.DeleteRespource Request using the Request from the ApiRequestFactory
+ ///
+ /// webapp.Name of the webapp that contains the resource
+ /// Name of the resource to delete
+ /// true to indicate success
+ public ApiTrueOnSuccessResponse WebAppDeleteResource(ApiWebAppData webApp, string resourceName) => WebAppDeleteResourceAsync(webApp, resourceName).GetAwaiter().GetResult();
+ ///
+ /// Send a WebApp.DeleteRespource Request using the Request from the ApiRequestFactory
+ ///
+ /// webapp.Name of the webapp that contains the resource
+ /// Name of the resource to delete
+ /// true to indicate success
+ public ApiTrueOnSuccessResponse WebAppDeleteResource(string webAppName, ApiWebAppResource resource) => WebAppDeleteResourceAsync(webAppName, resource).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.DeleteRespource Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that contains the resource
+ /// resource.Name of the resource to delete
+ /// true to indicate success
+ public async Task WebAppDeleteResourceAsync(ApiWebAppData webApp, ApiWebAppResource resource, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ return await WebAppDeleteResourceAsync(webApp.Name, resource.Name, cancellationToken);
+ }
+ ///
+ /// Send a WebApp.DeleteRespource Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that contains the resource
+ /// resource.Name of the resource to delete
+ /// true to indicate success
+ public ApiTrueOnSuccessResponse WebAppDeleteResource(ApiWebAppData webApp, ApiWebAppResource resource) => WebAppDeleteResourceAsync(webApp, resource).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.DeleteRespource Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that contains the resource
+ /// resource.Name of the resource to delete
+ /// true to indicate success
+ public async Task WebAppDeleteResourceAsync(string webAppName, ApiWebAppResource resource, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ return await WebAppDeleteResourceAsync(webAppName, resource.Name, cancellationToken);
+ }
+
+ ///
+ /// Send a WebApp.DownloadResource Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that contains the resource
+ /// Name of the resource to download
+ /// Ticket id for Ticketing Endpoint to trigger the download on
+ public async Task WebAppDownloadResourceAsync(string webAppName, string resourceName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiWebAppDownloadResourceRequest(webAppName, resourceName);
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = JsonConvert.DeserializeObject(response);
+ return responseObj;
+ }
+ ///
+ /// Send a WebApp.DownloadResource Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that contains the resource
+ /// Name of the resource to download
+ /// Ticket id for Ticketing Endpoint to trigger the download on
+ public ApiTicketIdResponse WebAppDownloadResource(string webAppName, string resourceName) => WebAppDownloadResourceAsync(webAppName, resourceName).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.DownloadResource Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that contains the resource
+ /// Name of the resource to download
+ /// Ticket id for Ticketing Endpoint to trigger the download on
+ public async Task WebAppDownloadResourceAsync(ApiWebAppData webApp, string resourceName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ return await WebAppDownloadResourceAsync(webApp.Name, resourceName, cancellationToken);
+ }
+ ///
+ /// Send a WebApp.DownloadResource Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that contains the resource
+ /// Name of the resource to download
+ /// Ticket id for Ticketing Endpoint to trigger the download on
+ public ApiTicketIdResponse WebAppDownloadResource(ApiWebAppData webApp, string resourceName) => WebAppDownloadResourceAsync(webApp, resourceName).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.DownloadResource Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that contains the resource
+ /// resource.Name of the resource to download
+ /// Ticket id for Ticketing Endpoint to trigger the download on
+ public async Task WebAppDownloadResourceAsync(ApiWebAppData webApp, ApiWebAppResource resource, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ return await WebAppDownloadResourceAsync(webApp.Name, resource.Name, cancellationToken);
+ }
+ ///
+ /// Send a WebApp.DownloadResource Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that contains the resource
+ /// resource.Name of the resource to download
+ /// Ticket id for Ticketing Endpoint to trigger the download on
+ public ApiTicketIdResponse WebAppDownloadResource(ApiWebAppData webApp, ApiWebAppResource resource) => WebAppDownloadResourceAsync(webApp, resource).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.DownloadResource Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that contains the resource
+ /// resource.Name of the resource to download
+ /// Ticket id for Ticketing Endpoint to trigger the download on
+ public async Task WebAppDownloadResourceAsync(string webAppName, ApiWebAppResource resource, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ return await WebAppDownloadResourceAsync(webAppName, resource.Name, cancellationToken);
+ }
+ ///
+ /// Send a WebApp.DownloadResource Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that contains the resource
+ /// resource.Name of the resource to download
+ /// Ticket id for Ticketing Endpoint to trigger the download on
+ public ApiTicketIdResponse WebAppDownloadResource(string webAppName, ApiWebAppResource resource) => WebAppDownloadResourceAsync(webAppName, resource).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.Rename Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that should be renamed
+ /// New name for the WebApp
+ /// This function will return the TrueOnSuccessResponse and a WebApp that only has the information:
+ /// name which equals the newname
+ public async Task WebAppRenameAsync(string webAppName, string newWebAppName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiWebAppRenameRequest(webAppName, newWebAppName);
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = new ApiTrueWithWebAppResponse();
+ responseObj.TrueOnSuccesResponse = JsonConvert.DeserializeObject(response);
+ if (responseObj.TrueOnSuccesResponse.Result)
+ {
+ responseObj.NewWebApp = new ApiWebAppData() { Name = newWebAppName };
+ }
+ return responseObj;
+ }
+ ///
+ /// Send a WebApp.Rename Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that should be renamed
+ /// New name for the WebApp
+ /// This function will return the TrueOnSuccessResponse and a WebApp that only has the information:
+ /// name which equals the newname
+ public ApiTrueWithWebAppResponse WebAppRename(string webAppName, string newWebAppName) => WebAppRenameAsync(webAppName, newWebAppName).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.Rename Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that should be renamed
+ /// New name for the WebApp
+ /// This function will return the TrueOnSuccessResponse and a copy of the given WebApp that has the change:
+ /// name which equals the newname
+ public async Task WebAppRenameAsync(ApiWebAppData webApp, string newWebAppName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var resp = await WebAppRenameAsync(webApp.Name, newWebAppName, cancellationToken);
+ resp.NewWebApp = webApp.ShallowCopy();
+ resp.NewWebApp.Name = newWebAppName;
+ return resp;
+ }
+ ///
+ /// Send a WebApp.Rename Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that should be renamed
+ /// New name for the WebApp
+ /// This function will return the TrueOnSuccessResponse and a copy of the given WebApp that has the change:
+ /// name which equals the newname
+ public ApiTrueWithWebAppResponse WebAppRename(ApiWebAppData webApp, string newWebAppName) => WebAppRenameAsync(webApp, newWebAppName).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.RenameResource Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that contains the resource
+ /// Name of the resource that should be renamed
+ /// New name for the resource
+ /// This function will return the TrueOnSuccessResponse and a Resource that only has the information:
+ /// name which equals the newname
+ public async Task WebAppRenameResourceAsync(string webAppName, string resourceName,
+ string newResourceName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiWebAppRenameResourceRequest(webAppName, resourceName, newResourceName);
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ ApiTrueWithResourceResponse responseObj = new ApiTrueWithResourceResponse();
+ responseObj.TrueOnSuccesResponse = JsonConvert.DeserializeObject(response);
+ if (responseObj.TrueOnSuccesResponse.Result)
+ {
+ responseObj.NewResource = new ApiWebAppResource() { Name = newResourceName };
+ }
+ return responseObj;
+ }
+ ///
+ /// Send a WebApp.RenameResource Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that contains the resource
+ /// Name of the resource that should be renamed
+ /// New name for the resource
+ /// This function will return the TrueOnSuccessResponse and a Resource that only has the information:
+ /// name which equals the newname
+ public ApiTrueWithResourceResponse WebAppRenameResource(string webAppName, string resourceName, string newResourceName)
+ => WebAppRenameResourceAsync(webAppName, resourceName, newResourceName).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.RenameResource Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that contains the resource
+ /// Name of the resource that should be renamed
+ /// New name for the resource
+ /// This function will return the TrueOnSuccessResponse and a Resource that only has the information:
+ /// name which equals the newname
+ public async Task WebAppRenameResourceAsync(ApiWebAppData webApp, string resourceName,
+ string newResourceName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ return await WebAppRenameResourceAsync(webApp.Name, resourceName, newResourceName, cancellationToken);
+ }
+ ///
+ /// Send a WebApp.RenameResource Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that contains the resource
+ /// Name of the resource that should be renamed
+ /// New name for the resource
+ /// This function will return the TrueOnSuccessResponse and a Resource that only has the information:
+ /// name which equals the newname
+ public ApiTrueWithResourceResponse WebAppRenameResource(ApiWebAppData webApp, string resourceName, string newResourceName)
+ => WebAppRenameResourceAsync(webApp, resourceName, newResourceName).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.RenameResource Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that contains the resource
+ /// resource.Name of the resource that should be renamed
+ /// New name for the resource
+ /// This function will return the TrueOnSuccessResponse and a copy of the Resource given that has the following change:
+ /// name which equals the newname
+ public async Task WebAppRenameResourceAsync(ApiWebAppData webApp, ApiWebAppResource resource,
+ string newResourceName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var basicResp = await WebAppRenameResourceAsync(webApp.Name, resource.Name, newResourceName, cancellationToken);
+ basicResp.NewResource = resource.ShallowCopy();
+ basicResp.NewResource.Name = newResourceName;
+ return basicResp;
+ }
+ ///
+ /// Send a WebApp.RenameResource Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that contains the resource
+ /// resource.Name of the resource that should be renamed
+ /// New name for the resource
+ /// This function will return the TrueOnSuccessResponse and a copy of the Resource given that has the following change:
+ /// name which equals the newname
+ public ApiTrueWithResourceResponse WebAppRenameResource(ApiWebAppData webApp, ApiWebAppResource resource, string newResourceName)
+ => WebAppRenameResourceAsync(webApp, resource, newResourceName).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.RenameResource Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that contains the resource
+ /// resource.Name of the resource that should be renamed
+ /// New name for the resource
+ /// This function will return the TrueOnSuccessResponse and a copy of the Resource given that has the following change:
+ /// name which equals the newname
+ public async Task WebAppRenameResourceAsync(string webAppName, ApiWebAppResource resource,
+ string newResourceName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var basicResp = await WebAppRenameResourceAsync(webAppName, resource.Name, newResourceName, cancellationToken);
+ basicResp.NewResource = resource.ShallowCopy();
+ basicResp.NewResource.Name = newResourceName;
+ return basicResp;
+ }
+ ///
+ /// Send a WebApp.RenameResource Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that contains the resource
+ /// resource.Name of the resource that should be renamed
+ /// New name for the resource
+ /// This function will return the TrueOnSuccessResponse and a copy of the Resource given that has the following change:
+ /// name which equals the newname
+ public ApiTrueWithResourceResponse WebAppRenameResource(string webAppName, ApiWebAppResource resource, string newResourceName)
+ => WebAppRenameResourceAsync(webAppName, resource, newResourceName).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.SetDefaultPage Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that the default page should be set for
+ /// Name of the resource that should be the webapps default page
+ /// This function will return the TrueOnSuccessResponse and webapp containing only the information:
+ /// Name: which equals the webAppName
+ /// Default_Page: which equals the resourceName
+ ///
+ public async Task WebAppSetDefaultPageAsync(string webAppName, string resourceName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiWebAppSetDefaultPageRequest(webAppName, resourceName ?? "");
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = new ApiTrueWithWebAppResponse();
+ responseObj.TrueOnSuccesResponse = JsonConvert.DeserializeObject(response);
+ if (responseObj.TrueOnSuccesResponse.Result)
+ {
+ responseObj.NewWebApp = new ApiWebAppData() { Name = webAppName, Default_page = (resourceName == "" ? null : resourceName) };
+ }
+ return responseObj;
+ }
+ ///
+ /// Send a WebApp.SetDefaultPage Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that the default page should be set for
+ /// Name of the resource that should be the webapps default page
+ /// This function will return the TrueOnSuccessResponse and webapp containing only the information:
+ /// Name: which equals the webAppName
+ /// Default_Page: which equals the resourceName
+ ///
+ public ApiTrueWithWebAppResponse WebAppSetDefaultPage(string webAppName, string resourceName) => WebAppSetDefaultPageAsync(webAppName, resourceName).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.SetDefaultPage Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that the default page should be set for
+ /// Name of the resource that should be the webapps default page
+ /// This function will return the TrueOnSuccessResponse and a copy of the webapp given containing only the change:
+ /// Default_Page: which equals the resourceName
+ ///
+ public async Task WebAppSetDefaultPageAsync(ApiWebAppData webApp, string resourceName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var resp = await WebAppSetDefaultPageAsync(webApp.Name, resourceName, cancellationToken);
+ resp.NewWebApp = webApp.ShallowCopy();
+ resp.NewWebApp.Default_page = (resourceName == "" ? null : resourceName);
+ return resp;
+ }
+ ///
+ /// Send a WebApp.SetDefaultPage Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that the default page should be set for
+ /// Name of the resource that should be the webapps default page
+ /// This function will return the TrueOnSuccessResponse and a copy of the webapp given containing only the change:
+ /// Default_Page: which equals the resourceName
+ ///
+ public ApiTrueWithWebAppResponse WebAppSetDefaultPage(ApiWebAppData webApp, string resourceName) => WebAppSetDefaultPageAsync(webApp, resourceName).GetAwaiter().GetResult();
+
+ ///
+ /// Send a WebApp.SetDefaultPage Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that the default page should be set for
+ /// resource.Name of the resource that should be the webapps default page
+ /// This function will return the TrueOnSuccessResponse and a copy of the webapp given containing only the change:
+ /// Default_Page: which equals the resource.Name
+ ///
+ public async Task WebAppSetDefaultPageAsync(ApiWebAppData webApp, ApiWebAppResource resource, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var resp = await WebAppSetDefaultPageAsync(webApp.Name, resource.Name, cancellationToken);
+ resp.NewWebApp = webApp.ShallowCopy();
+ resp.NewWebApp.Default_page = (resource.Name == "" ? null : resource.Name);
+ return resp;
+ }
+ ///
+ /// Send a WebApp.SetDefaultPage Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that the default page should be set for
+ /// resource.Name of the resource that should be the webapps default page
+ /// This function will return the TrueOnSuccessResponse and a copy of the webapp given containing only the change:
+ /// Default_Page: which equals the resource.Name
+ ///
+ public ApiTrueWithWebAppResponse WebAppSetDefaultPage(ApiWebAppData webApp, ApiWebAppResource resource) => WebAppSetDefaultPageAsync(webApp, resource).GetAwaiter().GetResult();
+ ///
+ /// Send a WebApp.SetDefaultPage Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that the default page should be set for
+ /// resource.Name of the resource that should be the webapps default page
+ /// This function will return the TrueOnSuccessResponse and webapp containing only the information:
+ /// Name: which equals the webAppName
+ /// Default_Page: which equals the resourceName
+ ///
+ public async Task WebAppSetDefaultPageAsync(string webAppName, ApiWebAppResource resource, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ return await WebAppSetDefaultPageAsync(webAppName, resource.Name, cancellationToken);
+ }
+ ///
+ /// Send a WebApp.SetDefaultPage Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that the default page should be set for
+ /// resource.Name of the resource that should be the webapps default page
+ /// This function will return the TrueOnSuccessResponse and webapp containing only the information:
+ /// Name: which equals the webAppName
+ /// Default_Page: which equals the resourceName
+ ///
+ public ApiTrueWithWebAppResponse WebAppSetDefaultPage(string webAppName, ApiWebAppResource resource) => WebAppSetDefaultPageAsync(webAppName, resource).GetAwaiter().GetResult();
- ///
- /// Send a PlcProgram.Read Request using the Request from the ApiRequestFactory
- ///
- /// Name of the variable to be read
- ///
- /// Name der zu lesenden Variable
- ///
- /// this parameter is optional and defaults to "simple":
- /// "simple" will get the variable values according to the presentation of the manual - "supported Datatypes"
- /// "raw" : will get the variable values according to the presentation of the manual "raw"
- ///
- /// Aufzählung, die das Antwortformat für diese Methode festlegt:
- /// • "simple": liefert Variablenwerte gemäß der Darstellung
- /// "simple" in Kapitel "Unterstützte Datentypen (Seite 162)"
- /// • "raw": liefert Variablenwerte gemäß der Darstellung "raw"
- /// in Kapitel "Unterstützte Datentypen"
- /// ApiPlcProgramReadResponse: object with the value for the variables value to be read
- public async Task> PlcProgramReadAsync(string var, ApiPlcProgramReadOrWriteMode? plcProgramReadMode = null)
- {
- var req = _apiRequestFactory.GetApiPlcProgramReadRequest(var, plcProgramReadMode);
- string response = await SendPostRequestAsync(req);
- var responseObj = JsonConvert.DeserializeObject>(response);
- return responseObj;
- }
- ///
- /// Send a PlcProgram.Read Request using the Request from the ApiRequestFactory
- ///
- /// Name of the variable to be read
- ///
- /// Name der zu lesenden Variable
- ///
- /// this parameter is optional and defaults to "simple":
- /// "simple" will get the variable values according to the presentation of the manual - "supported Datatypes"
- /// "raw" : will get the variable values according to the presentation of the manual "raw"
- ///
- /// Aufzählung, die das Antwortformat für diese Methode festlegt:
- /// • "simple": liefert Variablenwerte gemäß der Darstellung
- /// "simple" in Kapitel "Unterstützte Datentypen (Seite 162)"
- /// • "raw": liefert Variablenwerte gemäß der Darstellung "raw"
- /// in Kapitel "Unterstützte Datentypen"
- /// ApiPlcProgramReadResponse: object with the value for the variables value to be read
- public ApiResultResponse PlcProgramRead(ApiPlcProgramData var, ApiPlcProgramReadOrWriteMode? plcProgramReadMode = null) => PlcProgramReadAsync(var, plcProgramReadMode).GetAwaiter().GetResult();
-
- ///
- /// Send a PlcProgram.Browse Request using the Request from the ApiRequestFactory
- /// This function will build up the name with quotes from the parents given with the ApiPlcProgramDataand call PlcProgramRead
- ///
- ///
- /// Name of the variable to be read
- /// Name der zu lesenden Variable
- ///
- /// this parameter is optional and defaults to "simple":
- /// "simple" will get the variable values according to the presentation of the manual - "supported Datatypes"
- /// "raw" : will get the variable values according to the presentation of the manual "raw"
- ///
- /// Aufzählung, die das Antwortformat für diese Methode festlegt:
- /// • "simple": liefert Variablenwerte gemäß der Darstellung
- /// "simple" in Kapitel "Unterstützte Datentypen (Seite 162)"
- /// • "raw": liefert Variablenwerte gemäß der Darstellung "raw"
- /// in Kapitel "Unterstützte Datentypen"
- /// ApiPlcProgramReadResponse: object with the value for the variables value to be read
- /// will be thrown if a ApiPlcProgramDatathat is an array will be given without an index
- public async Task> PlcProgramReadAsync(ApiPlcProgramData var, ApiPlcProgramReadOrWriteMode? plcProgramReadMode = null)
- {
- //RequestParameterChecker.CheckPlcProgramReadOrWriteDataType(var.Datatype, true);
- string varName = var.GetVarNameForMethods();
- return await PlcProgramReadAsync(varName, plcProgramReadMode);
- }
- ///
- /// Send a PlcProgram.Browse Request using the Request from the ApiRequestFactory
- /// This function will build up the name with quotes from the parents given with the ApiPlcProgramDataand call PlcProgramRead
- ///
- ///
- /// Name of the variable to be read
- /// Name der zu lesenden Variable
- ///
- /// this parameter is optional and defaults to "simple":
- /// "simple" will get the variable values according to the presentation of the manual - "supported Datatypes"
- /// "raw" : will get the variable values according to the presentation of the manual "raw"
- ///
- /// Aufzählung, die das Antwortformat für diese Methode festlegt:
- /// • "simple": liefert Variablenwerte gemäß der Darstellung
- /// "simple" in Kapitel "Unterstützte Datentypen (Seite 162)"
- /// • "raw": liefert Variablenwerte gemäß der Darstellung "raw"
- /// in Kapitel "Unterstützte Datentypen"
- /// ApiPlcProgramReadResponse: object with the value for the variables value to be read
- /// will be thrown if a ApiPlcProgramDatathat is an array will be given without an index
- public ApiResultResponse PlcProgramRead(string var, ApiPlcProgramReadOrWriteMode? plcProgramReadMode = null) => PlcProgramReadAsync(var, plcProgramReadMode).GetAwaiter().GetResult();
-
- ///
- /// Send a PlcProgram.Write Request using the Request from the ApiRequestFactory
- /// This function will build up the name with quotes from the parents given with the ApiPlcProgramDataand call PlcProgramWrite
- ///
- ///
- /// Name of the variable to be read
- /// Name der zu lesenden Variable
- ///
- ///
- /// true to indicate success
- /// will be thrown if a ApiPlcProgramDatathat is an array will be given without an index
- public async Task PlcProgramWriteAsync(ApiPlcProgramData var, object valueToBeSet, ApiPlcProgramReadOrWriteMode? plcProgramWriteMode = null)
- {
- string varName = var.GetVarNameForMethods();
- // ApiRequestFactory.CheckPlcProgramReadOrWriteDataType(var.Datatype); will also be called by GetApiPlcProgramWriteValueToBeSet!
- var writeVal = _apiRequestFactory.GetApiPlcProgramWriteValueToBeSet(var.Datatype, valueToBeSet);
- return await PlcProgramWriteAsync(varName, writeVal, plcProgramWriteMode);
- }
- ///
- /// Send a PlcProgram.Write Request using the Request from the ApiRequestFactory
- /// This function will build up the name with quotes from the parents given with the ApiPlcProgramDataand call PlcProgramWrite
- ///
- ///
- /// Name of the variable to be read
- /// Name der zu lesenden Variable
- ///
- ///
- /// true to indicate success
- /// will be thrown if a ApiPlcProgramDatathat is an array will be given without an index
- public ApiTrueOnSuccessResponse PlcProgramWrite(ApiPlcProgramData var, object valueToBeSet, ApiPlcProgramReadOrWriteMode? plcProgramWriteMode = null)
- => PlcProgramWriteAsync(var, valueToBeSet, plcProgramWriteMode).GetAwaiter().GetResult();
-
- ///
- /// Send a PlcProgram.Write Request using the Request from the ApiRequestFactory
- ///
- ///
- /// Name of the variable to be read
- /// Name der zu lesenden Variable
- ///
- ///
- /// true to indicate success
- /// will be thrown if a ApiPlcProgramDatathat is an array will be given without an index
- public async Task PlcProgramWriteAsync(string var, object valueToBeSet, ApiPlcProgramReadOrWriteMode? plcProgramWriteMode = null)
- {
- var req = _apiRequestFactory.GetApiPlcProgramWriteRequest(var, valueToBeSet, plcProgramWriteMode);
- string response = await SendPostRequestAsync(req);
- var responseObj = JsonConvert.DeserializeObject(response);
- return responseObj;
- }
- ///
- /// Send a PlcProgram.Write Request using the Request from the ApiRequestFactory
- ///
- ///
- /// Name of the variable to be read
- /// Name der zu lesenden Variable
- ///
- ///
- /// true to indicate success
- /// will be thrown if a ApiPlcProgramDatathat is an array will be given without an index
- public ApiTrueOnSuccessResponse PlcProgramWrite(string var, object valueToBeSet, ApiPlcProgramReadOrWriteMode? plcProgramWriteMode = null)
- => PlcProgramWriteAsync(var, valueToBeSet, plcProgramWriteMode).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.Browse Request using the Request from the ApiRequestFactory
- ///
- /// webappdata that should be requested
- /// ApiWebAppBrowseResponse: Containing WebAppBrowseResult: Max_Applications:uint,
- /// Applications: Array of ApiWebAppdata containing one element: the webappdata that has been requested
- public async Task WebAppBrowseAsync(ApiWebAppData webAppData)
- {
- return await WebAppBrowseAsync(webAppData.Name);
- }
- ///
- /// Send a WebApp.Browse Request using the Request from the ApiRequestFactory
- ///
- /// webappdata that should be requested
- /// ApiWebAppBrowseResponse: Containing WebAppBrowseResult: Max_Applications:uint,
- /// Applications: Array of ApiWebAppdata containing one element: the webappdata that has been requested
- public ApiWebAppBrowseResponse WebAppBrowse(ApiWebAppData webAppData) => WebAppBrowseAsync(webAppData).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.Browse Request using the Request from the ApiRequestFactory
- ///
- /// webapp name in case only one is requested
- /// ApiWebAppBrowseResponse: Containing WebAppBrowseResult: Max_Applications:uint,
- /// Applications: Array of ApiWebAppdata containing one element: the webappdata that has been requested
- public async Task WebAppBrowseAsync(string webAppName = null)
- {
- var req = _apiRequestFactory.GetApiWebAppBrowseRequest(webAppName);
- string response = await SendPostRequestAsync(req);
- var responseObj = JsonConvert.DeserializeObject(response);
- return responseObj;
- }
- ///
- /// Send a WebApp.Browse Request using the Request from the ApiRequestFactory
- ///
- /// webapp name in case only one is requested
- /// ApiWebAppBrowseResponse: Containing WebAppBrowseResult: Max_Applications:uint,
- /// Applications: Array of ApiWebAppdata containing one element: the webappdata that has been requested
- public ApiWebAppBrowseResponse WebAppBrowse(string webAppName = null) => WebAppBrowseAsync(webAppName).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.BrowseResources Request using the Request from the ApiRequestFactory
- /// Will return the Api Response "straight away"
- /// A user can use the List of ApiWebAppResources to set those to an ApiWebAppData
- /// (care to also add those who are protected to the protected resources in case you want to do that)
- ///
- /// WebApp name to browse resources of
- /// If given only that resource will be inside the array (in case it exists)
- /// ApiWebAppBrowseResourcesResponse:containing ApiWebAppBrowseResourcesResult: Max_Resources:uint,
- /// Resources:Array of ApiWebAppResource (only 1 if one is requested)
- public async Task WebAppBrowseResourcesAsync(string webAppName, string resourceName = null)
- {
- var req = _apiRequestFactory.GetApiWebAppBrowseResourcesRequest(webAppName, resourceName);
- string response = await SendPostRequestAsync(req);
- var responseObj = JsonConvert.DeserializeObject(response);
- return responseObj;
- }
- ///
- /// Send a WebApp.BrowseResources Request using the Request from the ApiRequestFactory
- /// Will return the Api Response "straight away"
- /// A user can use the List of ApiWebAppResources to set those to an ApiWebAppData
- /// (care to also add those who are protected to the protected resources in case you want to do that)
- ///
- /// WebApp name to browse resources of
- /// If given only that resource will be inside the array (in case it exists)
- /// ApiWebAppBrowseResourcesResponse:containing ApiWebAppBrowseResourcesResult: Max_Resources:uint,
- /// Resources:Array of ApiWebAppResource (only 1 if one is requested)
- public ApiWebAppBrowseResourcesResponse WebAppBrowseResources(string webAppName, string resourceName = null) => WebAppBrowseResourcesAsync(webAppName, resourceName).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.BrowseResources Request using the Request from the ApiRequestFactory
- /// Will return the Api Response "straight away"
- /// A user can use the List of ApiWebAppResources to set those to an ApiWebAppData
- /// (care to also add those who are protected to the protected resources in case you want to do that)
- ///
- /// WebApp.Name to browse resources of
- /// If given only that resource will be inside the array (in case it exists)
- /// ApiWebAppBrowseResourcesResponse:containing ApiWebAppBrowseResourcesResult: Max_Resources:uint,
- /// Resources:Array of ApiWebAppResource (only 1 if one is requested)
- public async Task WebAppBrowseResourcesAsync(ApiWebAppData webApp, string resourceName = null)
- {
- return await WebAppBrowseResourcesAsync(webApp.Name, resourceName);
- }
- ///
- /// Send a WebApp.BrowseResources Request using the Request from the ApiRequestFactory
- /// Will return the Api Response "straight away"
- /// A user can use the List of ApiWebAppResources to set those to an ApiWebAppData
- /// (care to also add those who are protected to the protected resources in case you want to do that)
- ///
- /// WebApp.Name to browse resources of
- /// If given only that resource will be inside the array (in case it exists)
- /// ApiWebAppBrowseResourcesResponse:containing ApiWebAppBrowseResourcesResult: Max_Resources:uint,
- /// Resources:Array of ApiWebAppResource (only 1 if one is requested)
- public ApiWebAppBrowseResourcesResponse WebAppBrowseResources(ApiWebAppData webApp, string resourceName = null) => WebAppBrowseResourcesAsync(webApp, resourceName).GetAwaiter().GetResult();
- ///
- /// Send a WebApp.BrowseResources Request using the Request from the ApiRequestFactory
- /// Will return the Api Response "straight away"
- /// A user can use the List of ApiWebAppResources to set those to an ApiWebAppData
- /// (care to also add those who are protected to the protected resources in case you want to do that)
- ///
- /// WebApp Name to browse resources of
- /// resource.Name to browse for
- /// ApiWebAppBrowseResourcesResponse:containing ApiWebAppBrowseResourcesResult: Max_Resources:uint,
- /// Resources:Array of ApiWebAppResource (only 1 if one is requested)
- public async Task WebAppBrowseResourcesAsync(string webAppName, ApiWebAppResource resource)
- {
- return await WebAppBrowseResourcesAsync(webAppName, resource.Name);
- }
- ///
- /// Send a WebApp.BrowseResources Request using the Request from the ApiRequestFactory
- /// Will return the Api Response "straight away"
- /// A user can use the List of ApiWebAppResources to set those to an ApiWebAppData
- /// (care to also add those who are protected to the protected resources in case you want to do that)
- ///
- /// WebApp Name to browse resources of
- /// resource.Name to browse for
- /// ApiWebAppBrowseResourcesResponse:containing ApiWebAppBrowseResourcesResult: Max_Resources:uint,
- /// Resources:Array of ApiWebAppResource (only 1 if one is requested)
- public ApiWebAppBrowseResourcesResponse WebAppBrowseResources(string webAppName, ApiWebAppResource resource) => WebAppBrowseResourcesAsync(webAppName, resource).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.BrowseResources Request using the Request from the ApiRequestFactory
- /// Will return the Api Response "straight away"
- /// A user can use the List of ApiWebAppResources to set those to an ApiWebAppData
- /// (care to also add those who are protected to the protected resources in case you want to do that)
- ///
- /// webApp.Name to browse resources of
- /// resource.Name to browse for
- /// ApiWebAppBrowseResourcesResponse:containing ApiWebAppBrowseResourcesResult: Max_Resources:uint,
- /// Resources:Array of ApiWebAppResource (only 1 if one is requested)
- public async Task WebAppBrowseResourcesAsync(ApiWebAppData webApp, ApiWebAppResource resource)
- {
- return await WebAppBrowseResourcesAsync(webApp.Name, resource.Name);
- }
- ///
- /// Send a WebApp.BrowseResources Request using the Request from the ApiRequestFactory
- /// Will return the Api Response "straight away"
- /// A user can use the List of ApiWebAppResources to set those to an ApiWebAppData
- /// (care to also add those who are protected to the protected resources in case you want to do that)
- ///
- /// webApp.Name to browse resources of
- /// resource.Name to browse for
- /// ApiWebAppBrowseResourcesResponse:containing ApiWebAppBrowseResourcesResult: Max_Resources:uint,
- /// Resources:Array of ApiWebAppResource (only 1 if one is requested)
- public ApiWebAppBrowseResourcesResponse WebAppBrowseResources(ApiWebAppData webApp, ApiWebAppResource resource) => WebAppBrowseResourcesAsync(webApp, resource).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.Create Request using the Request from the ApiRequestFactory
- ///
- /// webapp name for the app to be created
- /// optional parameter: state the webapp should be in
- /// true to indicate success
- public async Task WebAppCreateAsync(string webAppName, ApiWebAppState? apiWebAppState = null)
- {
- var req = _apiRequestFactory.GetApiWebAppCreateRequest(webAppName, apiWebAppState);
- string response = await SendPostRequestAsync(req);
- var responseObj = JsonConvert.DeserializeObject(response);
- return responseObj;
- }
- ///
- /// Send a WebApp.Create Request using the Request from the ApiRequestFactory
- ///
- /// webapp name for the app to be created
- /// optional parameter: state the webapp should be in
- /// true to indicate success
- public ApiTrueOnSuccessResponse WebAppCreate(string webAppName, ApiWebAppState? apiWebAppState = null) => WebAppCreateAsync(webAppName, apiWebAppState).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.Create Request using the Request from the ApiRequestFactory
- ///
- /// containing information about name and state for the app to be created
- /// true to indicate success
- public async Task WebAppCreateAsync(ApiWebAppData webApp)
- {
- // ApiRequestFactory.CheckState(webApp.State); will be called in WebAppCreate in Factory.GetApiWebAppCreateRequest
- return await WebAppCreateAsync(webApp.Name, webApp.State);
- }
- ///
- /// Send a WebApp.Create Request using the Request from the ApiRequestFactory
- ///
- /// containing information about name and state for the app to be created
- /// true to indicate success
- public ApiTrueOnSuccessResponse WebAppCreate(ApiWebAppData webApp) => WebAppCreateAsync(webApp).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.CreateResource Request using the Request from the ApiRequestFactory
- ///
- /// name of the webapp to create the resource on
- /// resource name to be created with (typically provided with extension)
- /// resource media type - see MIMEType.mapping
- /// Be sure to provide the RFC3339 format!
- /// resource visibility (protect your confidential data)
- /// you can provide an etag as identification,... for your resource
- /// TicketId for the Ticketing Endpoint to perform the Upload on
- public async Task WebAppCreateResourceAsync(string webAppName, string resourceName, string media_type,
- string last_modified, ApiWebAppResourceVisibility? apiWebAppResourceVisibility = null, string etag = null)
- {
- var req = _apiRequestFactory.GetApiWebAppCreateResourceRequest(webAppName, resourceName, media_type,
- last_modified, apiWebAppResourceVisibility, etag);
- string response = await SendPostRequestAsync(req);
- var responseObj = JsonConvert.DeserializeObject(response);
- return responseObj;
- }
- ///
- /// Send a WebApp.CreateResource Request using the Request from the ApiRequestFactory
- ///
- /// name of the webapp to create the resource on
- /// resource name to be created with (typically provided with extension)
- /// resource media type - see MIMEType.mapping
- /// Be sure to provide the RFC3339 format!
- /// resource visibility (protect your confidential data)
- /// you can provide an etag as identification,... for your resource
- /// TicketId for the Ticketing Endpoint to perform the Upload on
- public ApiTicketIdResponse WebAppCreateResource(string webAppName, string resourceName, string media_type, string last_modified, ApiWebAppResourceVisibility? apiWebAppResourceVisibility = null, string etag = null)
- => WebAppCreateResourceAsync(webAppName, resourceName, media_type, last_modified, apiWebAppResourceVisibility, etag).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.CreateResource Request using the Request from the ApiRequestFactory
- ///
- /// webApp.Name of the webapp to create the resource on
- /// resource name to be created with (typically provided with extension)
- /// resource media type - see MIMEType.mapping
- /// Be sure to provide the RFC3339 format!
- /// resource visibility (protect your confidential data)
- /// you can provide an etag as identification,... for your resource
- /// TicketId for the Ticketing Endpoint to perform the Upload on
- public async Task WebAppCreateResourceAsync(ApiWebAppData webApp, string resourceName, string media_type,
- string last_modified, ApiWebAppResourceVisibility? apiWebAppResourceVisibility = null, string etag = null)
- {
- return await WebAppCreateResourceAsync(webApp.Name, resourceName, media_type, last_modified, apiWebAppResourceVisibility, etag);
- }
- ///
- /// Send a WebApp.CreateResource Request using the Request from the ApiRequestFactory
- ///
- /// webApp.Name of the webapp to create the resource on
- /// resource name to be created with (typically provided with extension)
- /// resource media type - see MIMEType.mapping
- /// Be sure to provide the RFC3339 format!
- /// resource visibility (protect your confidential data)
- /// you can provide an etag as identification,... for your resource
- /// TicketId for the Ticketing Endpoint to perform the Upload on
- public ApiTicketIdResponse WebAppCreateResource(ApiWebAppData webApp, string resourceName, string media_type, string last_modified, ApiWebAppResourceVisibility? apiWebAppResourceVisibility = null, string etag = null)
- => WebAppCreateResourceAsync(webApp, resourceName, media_type, last_modified, apiWebAppResourceVisibility, etag).GetAwaiter().GetResult();
- ///
- /// Send a WebApp.CreateResource Request using the Request from the ApiRequestFactory
- ///
- /// name of the webapp to create the resource on
- /// resource containing all the information:
- /// Name: name to be created with (typically provided with extension)
- /// Media_type: resource media type - see MIMEType.mapping
- /// Last_modified: Be sure to provide the RFC3339 format!
- /// Visibility: resource visibility (protect your confidential data)
- /// Etag: you can provide an etag as identification,... for your resource
- /// TicketId for the Ticketing Endpoint to perform the Upload on
- public async Task WebAppCreateResourceAsync(string webAppName, ApiWebAppResource resource)
- {
- return await WebAppCreateResourceAsync(webAppName, resource.Name, resource.Media_type,
- resource.Last_modified.ToString(DateTimeFormatting.ApiDateTimeFormat), resource.Visibility, resource.Etag);
- }
- ///
- /// Send a WebApp.CreateResource Request using the Request from the ApiRequestFactory
- ///
- /// name of the webapp to create the resource on
- /// resource containing all the information:
- /// Name: name to be created with (typically provided with extension)
- /// Media_type: resource media type - see MIMEType.mapping
- /// Last_modified: Be sure to provide the RFC3339 format!
- /// Visibility: resource visibility (protect your confidential data)
- /// Etag: you can provide an etag as identification,... for your resource
- /// TicketId for the Ticketing Endpoint to perform the Upload on
- public ApiTicketIdResponse WebAppCreateResource(string webAppName, ApiWebAppResource resource) => WebAppCreateResourceAsync(webAppName, resource).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.CreateResource Request using the Request from the ApiRequestFactory
- ///
- /// webApp.Name of the webapp to create the resource on
- /// resource containing all the information:
- /// Name: name to be created with (typically provided with extension)
- /// Media_type: resource media type - see MIMEType.mapping
- /// Last_modified: Be sure to provide the RFC3339 format!
- /// Visibility: resource visibility (protect your confidential data)
- /// Etag: you can provide an etag as identification,... for your resource
- /// TicketId for the Ticketing Endpoint to perform the Upload on
- public async Task WebAppCreateResourceAsync(ApiWebAppData webApp, ApiWebAppResource resource)
- {
- return await WebAppCreateResourceAsync(webApp.Name, resource.Name, resource.Media_type,
- resource.Last_modified.ToString(DateTimeFormatting.ApiDateTimeFormat), resource.Visibility, resource.Etag);
- }
- ///
- /// Send a WebApp.CreateResource Request using the Request from the ApiRequestFactory
- ///
- /// webApp.Name of the webapp to create the resource on
- /// resource containing all the information:
- /// Name: name to be created with (typically provided with extension)
- /// Media_type: resource media type - see MIMEType.mapping
- /// Last_modified: Be sure to provide the RFC3339 format!
- /// Visibility: resource visibility (protect your confidential data)
- /// Etag: you can provide an etag as identification,... for your resource
- /// TicketId for the Ticketing Endpoint to perform the Upload on
- public ApiTicketIdResponse WebAppCreateResource(ApiWebAppData webApp, ApiWebAppResource resource) => WebAppCreateResourceAsync(webApp, resource).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.Delete Request using the Request from the ApiRequestFactory
- ///
- /// Name of the webapp to delete
- /// true to indicate success
- public async Task WebAppDeleteAsync(string webAppName)
- {
- var req = _apiRequestFactory.GetApiWebAppDeleteRequest(webAppName);
- string response = await SendPostRequestAsync(req);
- var responseObj = JsonConvert.DeserializeObject(response);
- return responseObj;
- }
- ///
- /// Send a WebApp.Delete Request using the Request from the ApiRequestFactory
- ///
- /// Name of the webapp to delete
- /// true to indicate success
- public ApiTrueOnSuccessResponse WebAppDelete(string webAppName) => WebAppDeleteAsync(webAppName).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.Delete Request using the Request from the ApiRequestFactory
- ///
- /// webApp.Name of the webapp to delete
- /// true to indicate success
- public async Task WebAppDeleteAsync(ApiWebAppData webApp)
- {
- return await WebAppDeleteAsync(webApp.Name);
- }
- ///
- /// Send a WebApp.Delete Request using the Request from the ApiRequestFactory
- ///
- /// webApp.Name of the webapp to delete
- /// true to indicate success
- public ApiTrueOnSuccessResponse WebAppDelete(ApiWebAppData webApp) => WebAppDeleteAsync(webApp).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.DeleteRespource Request using the Request from the ApiRequestFactory
- ///
- /// Name of the webapp that contains the resource
- /// Name of the resource to delete
- /// true to indicate success
- public async Task WebAppDeleteResourceAsync(string webAppName, string resourceName)
- {
- var req = _apiRequestFactory.GetApiWebAppDeleteResourceRequest(webAppName, resourceName);
- string response = await SendPostRequestAsync(req);
- var responseObj = JsonConvert.DeserializeObject(response);
- return responseObj;
- }
- ///
- /// Send a WebApp.DeleteRespource Request using the Request from the ApiRequestFactory
- ///
- /// Name of the webapp that contains the resource
- /// Name of the resource to delete
- /// true to indicate success
- public ApiTrueOnSuccessResponse WebAppDeleteResource(string webAppName, string resourceName) => WebAppDeleteResourceAsync(webAppName, resourceName).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.DeleteRespource Request using the Request from the ApiRequestFactory
- ///
- /// webapp.Name of the webapp that contains the resource
- /// Name of the resource to delete
- /// true to indicate success
- public async Task WebAppDeleteResourceAsync(ApiWebAppData webApp, string resourceName)
- {
- return await WebAppDeleteResourceAsync(webApp.Name, resourceName);
- }
- ///
- /// Send a WebApp.DeleteRespource Request using the Request from the ApiRequestFactory
- ///
- /// webapp.Name of the webapp that contains the resource
- /// Name of the resource to delete
- /// true to indicate success
- public ApiTrueOnSuccessResponse WebAppDeleteResource(ApiWebAppData webApp, string resourceName) => WebAppDeleteResourceAsync(webApp, resourceName).GetAwaiter().GetResult();
- ///
- /// Send a WebApp.DeleteRespource Request using the Request from the ApiRequestFactory
- ///
- /// webapp.Name of the webapp that contains the resource
- /// Name of the resource to delete
- /// true to indicate success
- public ApiTrueOnSuccessResponse WebAppDeleteResource(string webAppName, ApiWebAppResource resource) => WebAppDeleteResourceAsync(webAppName, resource).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.DeleteRespource Request using the Request from the ApiRequestFactory
- ///
- /// webApp.Name of the webapp that contains the resource
- /// resource.Name of the resource to delete
- /// true to indicate success
- public async Task WebAppDeleteResourceAsync(ApiWebAppData webApp, ApiWebAppResource resource)
- {
- return await WebAppDeleteResourceAsync(webApp.Name, resource.Name);
- }
- ///
- /// Send a WebApp.DeleteRespource Request using the Request from the ApiRequestFactory
- ///
- /// webApp.Name of the webapp that contains the resource
- /// resource.Name of the resource to delete
- /// true to indicate success
- public ApiTrueOnSuccessResponse WebAppDeleteResource(ApiWebAppData webApp, ApiWebAppResource resource) => WebAppDeleteResourceAsync(webApp, resource).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.DeleteRespource Request using the Request from the ApiRequestFactory
- ///
- /// Name of the webapp that contains the resource
- /// resource.Name of the resource to delete
- /// true to indicate success
- public async Task WebAppDeleteResourceAsync(string webAppName, ApiWebAppResource resource)
- {
- return await WebAppDeleteResourceAsync(webAppName, resource.Name);
- }
-
- ///
- /// Send a WebApp.DownloadResource Request using the Request from the ApiRequestFactory
- ///
- /// Name of the webapp that contains the resource
- /// Name of the resource to download
- /// Ticket id for Ticketing Endpoint to trigger the download on
- public async Task WebAppDownloadResourceAsync(string webAppName, string resourceName)
- {
- var req = _apiRequestFactory.GetApiWebAppDownloadResourceRequest(webAppName, resourceName);
- string response = await SendPostRequestAsync(req);
- var responseObj = JsonConvert.DeserializeObject(response);
- return responseObj;
- }
- ///
- /// Send a WebApp.DownloadResource Request using the Request from the ApiRequestFactory
- ///
- /// Name of the webapp that contains the resource
- /// Name of the resource to download
- /// Ticket id for Ticketing Endpoint to trigger the download on
- public ApiTicketIdResponse WebAppDownloadResource(string webAppName, string resourceName) => WebAppDownloadResourceAsync(webAppName, resourceName).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.DownloadResource Request using the Request from the ApiRequestFactory
- ///
- /// webApp.Name of the webapp that contains the resource
- /// Name of the resource to download
- /// Ticket id for Ticketing Endpoint to trigger the download on
- public async Task WebAppDownloadResourceAsync(ApiWebAppData webApp, string resourceName)
- {
- return await WebAppDownloadResourceAsync(webApp.Name, resourceName);
- }
- ///
- /// Send a WebApp.DownloadResource Request using the Request from the ApiRequestFactory
- ///
- /// webApp.Name of the webapp that contains the resource
- /// Name of the resource to download
- /// Ticket id for Ticketing Endpoint to trigger the download on
- public ApiTicketIdResponse WebAppDownloadResource(ApiWebAppData webApp, string resourceName) => WebAppDownloadResourceAsync(webApp, resourceName).GetAwaiter().GetResult();
+ ///
+ /// Send a WebApp.SetNotAuthorizedPage Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that the not authorized page should be set for
+ /// Name of the resource that should be the webapps not authorized page
+ /// This function will return the TrueOnSuccessResponse and webapp containing only the information:
+ /// Name: which equals webAppName
+ /// Not_authorized_page: which equals the resourceName
+ ///
+ public async Task WebAppSetNotAuthorizedPageAsync(string webAppName, string resourceName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiWebAppSetNotAuthorizedPageRequest(webAppName, resourceName ?? "");
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = new ApiTrueWithWebAppResponse();
+ responseObj.TrueOnSuccesResponse = JsonConvert.DeserializeObject(response);
+ if (responseObj.TrueOnSuccesResponse.Result)
+ {
+ responseObj.NewWebApp = new ApiWebAppData() { Name = webAppName, Not_authorized_page = (resourceName == "" ? null : resourceName) };
+ }
+ return responseObj;
+ }
+ ///
+ /// Send a WebApp.SetNotAuthorizedPage Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that the not authorized page should be set for
+ /// Name of the resource that should be the webapps not authorized page
+ /// This function will return the TrueOnSuccessResponse and webapp containing only the information:
+ /// Name: which equals webAppName
+ /// Not_authorized_page: which equals the resourceName
+ ///
+ public ApiTrueWithWebAppResponse WebAppSetNotAuthorizedPage(string webAppName, string resourceName) => WebAppSetNotAuthorizedPageAsync(webAppName, resourceName).GetAwaiter().GetResult();
+ ///
+ /// Send a WebApp.SetNotAuthorizedPage Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that the not authorized page should be set for
+ /// Name of the resource that should be the webapps not authorized page
+ /// This function will return the TrueOnSuccessResponse and a copy of the webapp given containing only the change:
+ /// Not_authorized_page: which equals the resourceName
+ ///
+ public async Task WebAppSetNotAuthorizedPageAsync(ApiWebAppData webApp, string resourceName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var resp = await WebAppSetNotAuthorizedPageAsync(webApp.Name, resourceName, cancellationToken);
+ resp.NewWebApp = webApp.ShallowCopy();
+ resp.NewWebApp.Not_authorized_page = (resourceName == "" ? null : resourceName);
+ return resp;
+ }
+ ///
+ /// Send a WebApp.SetNotAuthorizedPage Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that the not authorized page should be set for
+ /// Name of the resource that should be the webapps not authorized page
+ /// This function will return the TrueOnSuccessResponse and a copy of the webapp given containing only the change:
+ /// Not_authorized_page: which equals the resourceName
+ ///
+ public ApiTrueWithWebAppResponse WebAppSetNotAuthorizedPage(ApiWebAppData webApp, string resourceName) => WebAppSetNotAuthorizedPageAsync(webApp, resourceName).GetAwaiter().GetResult();
+ ///
+ /// Send a WebApp.SetNotAuthorizedPage Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that the not authorized page should be set for
+ /// resource.Name of the resource that should be the webapps not authorized page
+ /// This function will return the TrueOnSuccessResponse and a copy of the webapp given containing only the change:
+ /// Not_authorized_page: which equals the resourceName
+ ///
+ public async Task WebAppSetNotAuthorizedPageAsync(ApiWebAppData webApp, ApiWebAppResource resource, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var resp = await WebAppSetNotAuthorizedPageAsync(webApp.Name, resource.Name, cancellationToken);
+ resp.NewWebApp = webApp.ShallowCopy();
+ resp.NewWebApp.Not_authorized_page = (resource.Name == "" ? null : resource.Name);
+ return resp;
+ }
+ ///
+ /// Send a WebApp.SetNotAuthorizedPage Request using the Request from the ApiRequestFactory
+ ///
+ /// webApp.Name of the webapp that the not authorized page should be set for
+ /// resource.Name of the resource that should be the webapps not authorized page
+ /// This function will return the TrueOnSuccessResponse and a copy of the webapp given containing only the change:
+ /// Not_authorized_page: which equals the resourceName
+ ///
+ public ApiTrueWithWebAppResponse WebAppSetNotAuthorizedPage(ApiWebAppData webApp, ApiWebAppResource resource) => WebAppSetNotAuthorizedPageAsync(webApp, resource).GetAwaiter().GetResult();
- ///
- /// Send a WebApp.DownloadResource Request using the Request from the ApiRequestFactory
- ///
- /// webApp.Name of the webapp that contains the resource
- /// resource.Name of the resource to download
- /// Ticket id for Ticketing Endpoint to trigger the download on
- public async Task WebAppDownloadResourceAsync(ApiWebAppData webApp, ApiWebAppResource resource)
- {
- return await WebAppDownloadResourceAsync(webApp.Name, resource.Name);
- }
- ///
- /// Send a WebApp.DownloadResource Request using the Request from the ApiRequestFactory
- ///
- /// webApp.Name of the webapp that contains the resource
- /// resource.Name of the resource to download
- /// Ticket id for Ticketing Endpoint to trigger the download on
- public ApiTicketIdResponse WebAppDownloadResource(ApiWebAppData webApp, ApiWebAppResource resource) => WebAppDownloadResourceAsync(webApp, resource).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.DownloadResource Request using the Request from the ApiRequestFactory
- ///
- /// Name of the webapp that contains the resource
- /// resource.Name of the resource to download
- /// Ticket id for Ticketing Endpoint to trigger the download on
- public async Task WebAppDownloadResourceAsync(string webAppName, ApiWebAppResource resource)
- {
- return await WebAppDownloadResourceAsync(webAppName, resource.Name);
- }
- ///
- /// Send a WebApp.DownloadResource Request using the Request from the ApiRequestFactory
- ///
- /// Name of the webapp that contains the resource
- /// resource.Name of the resource to download
- /// Ticket id for Ticketing Endpoint to trigger the download on
- public ApiTicketIdResponse WebAppDownloadResource(string webAppName, ApiWebAppResource resource) => WebAppDownloadResourceAsync(webAppName, resource).GetAwaiter().GetResult();
+ ///
+ /// Send a WebApp.SetNotAuthorizedPage Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that the not authorized page should be set for
+ /// resource.Name of the resource that should be the webapps not authorized page
+ /// This function will return the TrueOnSuccessResponse and webapp containing only the information:
+ /// Name: which equals webAppName
+ /// Not_authorized_page: which equals the resource.Name
+ ///
+ public async Task WebAppSetNotAuthorizedPageAsync(string webAppName, ApiWebAppResource resource, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ return await WebAppSetNotAuthorizedPageAsync(webAppName, resource.Name, cancellationToken);
+ }
+ ///
+ /// Send a WebApp.SetNotAuthorizedPage Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that the not authorized page should be set for
+ /// resource.Name of the resource that should be the webapps not authorized page
+ /// This function will return the TrueOnSuccessResponse and webapp containing only the information:
+ /// Name: which equals webAppName
+ /// Not_authorized_page: which equals the resource.Name
+ ///
+ public ApiTrueWithWebAppResponse WebAppSetNotAuthorizedPage(string webAppName, ApiWebAppResource resource) => WebAppSetNotAuthorizedPageAsync(webAppName, resource).GetAwaiter().GetResult();
- ///
- /// Send a WebApp.Rename Request using the Request from the ApiRequestFactory
- ///
- /// Name of the webapp that should be renamed
- /// New name for the WebApp
- /// This function will return the TrueOnSuccessResponse and a WebApp that only has the information:
- /// name which equals the newname
- public async Task WebAppRenameAsync(string webAppName, string newWebAppName)
- {
- var req = _apiRequestFactory.GetApiWebAppRenameRequest(webAppName, newWebAppName);
- string response = await SendPostRequestAsync(req);
- var responseObj = new ApiTrueWithWebAppResponse();
- responseObj.TrueOnSuccesResponse = JsonConvert.DeserializeObject(response);
- if (responseObj.TrueOnSuccesResponse.Result)
- {
- responseObj.NewWebApp = new ApiWebAppData() { Name = newWebAppName };
- }
- return responseObj;
- }
- ///
- /// Send a WebApp.Rename Request using the Request from the ApiRequestFactory
- ///
- /// Name of the webapp that should be renamed
- /// New name for the WebApp
- /// This function will return the TrueOnSuccessResponse and a WebApp that only has the information:
- /// name which equals the newname
- public ApiTrueWithWebAppResponse WebAppRename(string webAppName, string newWebAppName) => WebAppRenameAsync(webAppName, newWebAppName).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.Rename Request using the Request from the ApiRequestFactory
- ///
- /// webApp.Name of the webapp that should be renamed
- /// New name for the WebApp
- /// This function will return the TrueOnSuccessResponse and a copy of the given WebApp that has the change:
- /// name which equals the newname
- public async Task WebAppRenameAsync(ApiWebAppData webApp, string newWebAppName)
- {
- var resp = await WebAppRenameAsync(webApp.Name, newWebAppName);
- resp.NewWebApp = webApp.ShallowCopy();
- resp.NewWebApp.Name = newWebAppName;
- return resp;
- }
- ///
- /// Send a WebApp.Rename Request using the Request from the ApiRequestFactory
- ///
- /// webApp.Name of the webapp that should be renamed
- /// New name for the WebApp
- /// This function will return the TrueOnSuccessResponse and a copy of the given WebApp that has the change:
- /// name which equals the newname
- public ApiTrueWithWebAppResponse WebAppRename(ApiWebAppData webApp, string newWebAppName) => WebAppRenameAsync(webApp, newWebAppName).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.RenameResource Request using the Request from the ApiRequestFactory
- ///
- /// Name of the webapp that contains the resource
- /// Name of the resource that should be renamed
- /// New name for the resource
- /// This function will return the TrueOnSuccessResponse and a Resource that only has the information:
- /// name which equals the newname
- public async Task WebAppRenameResourceAsync(string webAppName, string resourceName,
- string newResourceName)
- {
- var req = _apiRequestFactory.GetApiWebAppRenameResourceRequest(webAppName, resourceName, newResourceName);
- string response = await SendPostRequestAsync(req);
- ApiTrueWithResourceResponse responseObj = new ApiTrueWithResourceResponse();
- responseObj.TrueOnSuccesResponse = JsonConvert.DeserializeObject(response);
- if (responseObj.TrueOnSuccesResponse.Result)
- {
- responseObj.NewResource = new ApiWebAppResource() { Name = newResourceName };
- }
- return responseObj;
- }
- ///
- /// Send a WebApp.RenameResource Request using the Request from the ApiRequestFactory
- ///
- /// Name of the webapp that contains the resource
- /// Name of the resource that should be renamed
- /// New name for the resource
- /// This function will return the TrueOnSuccessResponse and a Resource that only has the information:
- /// name which equals the newname
- public ApiTrueWithResourceResponse WebAppRenameResource(string webAppName, string resourceName, string newResourceName)
- => WebAppRenameResourceAsync(webAppName, resourceName, newResourceName).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.RenameResource Request using the Request from the ApiRequestFactory
- ///
- /// webApp.Name of the webapp that contains the resource
- /// Name of the resource that should be renamed
- /// New name for the resource
- /// This function will return the TrueOnSuccessResponse and a Resource that only has the information:
- /// name which equals the newname
- public async Task WebAppRenameResourceAsync(ApiWebAppData webApp, string resourceName,
- string newResourceName)
- {
- return await WebAppRenameResourceAsync(webApp.Name, resourceName, newResourceName);
- }
- ///
- /// Send a WebApp.RenameResource Request using the Request from the ApiRequestFactory
- ///
- /// webApp.Name of the webapp that contains the resource
- /// Name of the resource that should be renamed
- /// New name for the resource
- /// This function will return the TrueOnSuccessResponse and a Resource that only has the information:
- /// name which equals the newname
- public ApiTrueWithResourceResponse WebAppRenameResource(ApiWebAppData webApp, string resourceName, string newResourceName)
- => WebAppRenameResourceAsync(webApp, resourceName, newResourceName).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.RenameResource Request using the Request from the ApiRequestFactory
- ///
- /// webApp.Name of the webapp that contains the resource
- /// resource.Name of the resource that should be renamed
- /// New name for the resource
- /// This function will return the TrueOnSuccessResponse and a copy of the Resource given that has the following change:
- /// name which equals the newname
- public async Task WebAppRenameResourceAsync(ApiWebAppData webApp, ApiWebAppResource resource,
- string newResourceName)
- {
- var basicResp = await WebAppRenameResourceAsync(webApp.Name, resource.Name, newResourceName);
- basicResp.NewResource = resource.ShallowCopy();
- basicResp.NewResource.Name = newResourceName;
- return basicResp;
- }
- ///
- /// Send a WebApp.RenameResource Request using the Request from the ApiRequestFactory
- ///
- /// webApp.Name of the webapp that contains the resource
- /// resource.Name of the resource that should be renamed
- /// New name for the resource
- /// This function will return the TrueOnSuccessResponse and a copy of the Resource given that has the following change:
- /// name which equals the newname
- public ApiTrueWithResourceResponse WebAppRenameResource(ApiWebAppData webApp, ApiWebAppResource resource, string newResourceName)
- => WebAppRenameResourceAsync(webApp, resource, newResourceName).GetAwaiter().GetResult();
-
- ///
- /// Send a WebApp.RenameResource Request using the Request from the ApiRequestFactory
- ///
- /// Name of the webapp that contains the resource
- /// resource.Name of the resource that should be renamed
- /// New name for the resource
- /// This function will return the TrueOnSuccessResponse and a copy of the Resource given that has the following change:
- /// name which equals the newname
- public async Task WebAppRenameResourceAsync(string webAppName, ApiWebAppResource resource,
- string newResourceName)
- {
- var basicResp = await WebAppRenameResourceAsync(webAppName, resource.Name, newResourceName);
- basicResp.NewResource = resource.ShallowCopy();
- basicResp.NewResource.Name = newResourceName;
- return basicResp;
- }
- ///
- /// Send a WebApp.RenameResource Request using the Request from the ApiRequestFactory
- ///
- /// Name of the webapp that contains the resource
- /// resource.Name of the resource that should be renamed
- /// New name for the resource
- /// This function will return the TrueOnSuccessResponse and a copy of the Resource given that has the following change:
- /// name which equals the newname
- public ApiTrueWithResourceResponse WebAppRenameResource(string webAppName, ApiWebAppResource resource, string newResourceName)
- => WebAppRenameResourceAsync(webAppName, resource, newResourceName).GetAwaiter().GetResult();
+ ///
+ /// Send a WebApp.SetNotFoundPage Request using the Request from the ApiRequestFactory
+ ///
+ /// Name of the webapp that the not found page should be set for
+ /// Name of the resource that should be the webapps not found page
+ /// This function will return the TrueOnSuccessResponse and webapp containing only the information:
+ /// Name: which equals the webAppName
+ /// Not_found_page: which equals the resourceName
+ ///
+ public async Task WebAppSetNotFoundPageAsync(string webAppName, string resourceName, CancellationToken cancellationToken = default(CancellationToken))
+ {
+ var req = _apiRequestFactory.GetApiWebAppSetNotFoundPageRequest(webAppName, resourceName ?? "");
+ string response = await SendPostRequestAsync(req, cancellationToken);
+ var responseObj = new ApiTrueWithWebAppResponse();
+ responseObj.TrueOnSuccesResponse = JsonConvert.DeserializeObject