Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2020 Robert Bosch GmbH |
| 3 | * Author: Constantin Ziesche (constantin.ziesche@bosch.com) |
| 4 | * |
| 5 | * This program and the accompanying materials are made available under the |
| 6 | * terms of the Eclipse Public License 2.0 which is available at |
| 7 | * http://www.eclipse.org/legal/epl-2.0 |
| 8 | * |
| 9 | * SPDX-License-Identifier: EPL-2.0 |
| 10 | *******************************************************************************/ |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 11 | using Microsoft.AspNetCore.Mvc; |
| 12 | using BaSyx.Models.Core.AssetAdministrationShell.Generics; |
| 13 | using BaSyx.Utils.ResultHandling; |
| 14 | using BaSyx.API.Components; |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 15 | using BaSyx.Utils.Client; |
| 16 | using System; |
| 17 | using BaSyx.API.AssetAdministrationShell; |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 18 | using Newtonsoft.Json.Linq; |
| 19 | using BaSyx.Models.Extensions; |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 20 | using BaSyx.Models.Core.AssetAdministrationShell.Implementations; |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 21 | using BaSyx.Models.Core.AssetAdministrationShell.Generics.SubmodelElementTypes; |
| 22 | using BaSyx.Models.Core.AssetAdministrationShell.Implementations.SubmodelElementTypes; |
| 23 | using BaSyx.Models.Connectivity.Descriptors; |
| 24 | using BaSyx.Models.Core.Common; |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 25 | using BaSyx.Models.Communication; |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 26 | |
| 27 | namespace BaSyx.API.Http.Controllers |
| 28 | { |
| 29 | /// <summary> |
| 30 | /// All Asset Administration Shell Services provided by the component |
| 31 | /// </summary> |
| 32 | public class SubmodelServices : Controller, ISubmodelServiceProvider |
| 33 | { |
| 34 | private readonly ISubmodelServiceProvider submodelServiceProvider; |
| 35 | |
| 36 | public ISubmodel Submodel => submodelServiceProvider?.GetBinding(); |
| 37 | public ISubmodelDescriptor ServiceDescriptor { get; } |
| 38 | |
| 39 | public SubmodelServices(ISubmodelServiceProvider submodelServiceProvider) |
| 40 | { |
| 41 | this.submodelServiceProvider = submodelServiceProvider; |
| 42 | ServiceDescriptor = submodelServiceProvider?.ServiceDescriptor; |
| 43 | } |
| 44 | |
| 45 | public void BindTo(ISubmodel element) |
| 46 | { |
| 47 | submodelServiceProvider.BindTo(element); |
| 48 | } |
| 49 | public ISubmodel GetBinding() |
| 50 | { |
| 51 | return submodelServiceProvider.GetBinding(); |
| 52 | } |
| 53 | |
| 54 | |
| 55 | #region REST-Interface Submodel |
| 56 | |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 57 | |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 58 | /// <summary> |
| 59 | /// Retrieves a customizable table version of a Submodel |
| 60 | /// </summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 61 | /// <param name="columns">A comma-separated list of field names to structure the payload beeing returned</param> |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 62 | /// <returns></returns> |
| 63 | /// <response code="200">Success</response> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 64 | /// <response code="404">Submodel not found</response> |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 65 | [HttpGet("submodel/table", Name = "GetSubmodelAsTable")] |
| 66 | [ProducesResponseType(typeof(Result), 404)] |
| 67 | public IActionResult GetSubmodelAsTable([FromQuery] string columns) |
| 68 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 69 | if (string.IsNullOrEmpty(columns)) |
| 70 | return ResultHandling.NullResult(nameof(columns)); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 71 | |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 72 | var result = RetrieveSubmodel(); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 73 | if (result != null && result.Entity != null) |
| 74 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 75 | string[] columnNames = columns.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 76 | JToken customizedSubmodel = result.Entity.CustomizeSubmodel(columnNames); |
| 77 | return new JsonResult(customizedSubmodel); |
| 78 | } |
| 79 | |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 80 | return result.CreateActionResult(CrudOperation.Retrieve); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | |
| 84 | /// <summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 85 | /// Retrieves the minimized version of a Submodel, i.e. only the values of SubmodelElements are serialized and returned |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 86 | /// </summary> |
| 87 | /// <returns></returns> |
| 88 | /// <response code="200">Success</response> |
| 89 | /// <response code="404">Submodel not found</response> |
| 90 | [HttpGet("submodel/values", Name = "GetSubmodelValues")] |
| 91 | [ProducesResponseType(typeof(Result), 404)] |
| 92 | public IActionResult GetMinimizedSubmodel() |
| 93 | { |
| 94 | var result = RetrieveSubmodel(); |
| 95 | |
| 96 | if (result != null && result.Entity != null) |
| 97 | { |
| 98 | JObject minimizedSubmodel = result.Entity.MinimizeSubmodel(); |
| 99 | return new JsonResult(minimizedSubmodel); |
| 100 | } |
| 101 | |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 102 | return result.CreateActionResult(CrudOperation.Retrieve); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | /// <summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 106 | /// Retrieves the entire Submodel |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 107 | /// </summary> |
| 108 | /// <returns></returns> |
| 109 | /// <response code="200">Success</response> |
| 110 | /// <response code="404">Submodel not found</response> |
| 111 | [HttpGet("submodel", Name = "GetSubmodel")] |
| 112 | [ProducesResponseType(typeof(BaSyx.Models.Core.AssetAdministrationShell.Implementations.Submodel), 200)] |
| 113 | [ProducesResponseType(typeof(Result), 404)] |
| 114 | public IActionResult GetSubmodel() |
| 115 | { |
| 116 | var result = RetrieveSubmodel(); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 117 | return result.CreateActionResult(CrudOperation.Retrieve); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | /// <summary> |
| 121 | /// Retrieves all SubmodelElements from the current Submodel |
| 122 | /// </summary> |
| 123 | /// <returns></returns> |
| 124 | /// <response code="200">Returns a list of found SubmodelElements</response> |
| 125 | /// <response code="404">Submodel not found / No SubmodelElements found</response> |
| 126 | [HttpGet("submodel/submodelElements", Name = "GetSubmodelElements")] |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 127 | [ProducesResponseType(typeof(SubmodelElement[]), 200)] |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 128 | [ProducesResponseType(typeof(Result), 404)] |
| 129 | public IActionResult GetSubmodelElements() |
| 130 | { |
| 131 | var result = RetrieveSubmodelElements(); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 132 | return result.CreateActionResult(CrudOperation.Retrieve); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | /// <summary> |
| 136 | /// Retrieves all Properties from the current Submodel |
| 137 | /// </summary> |
| 138 | /// <returns></returns> |
| 139 | /// <response code="200">Returns a list of found Properties</response> |
| 140 | /// <response code="404">Submodel not found / No Properties found</response> |
| 141 | [HttpGet("submodel/properties", Name = "GetProperties")] |
| 142 | [ProducesResponseType(typeof(Property[]), 200)] |
| 143 | [ProducesResponseType(typeof(Result), 404)] |
| 144 | public IActionResult GetProperties() |
| 145 | { |
| 146 | var result = RetrieveProperties(); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 147 | return result.CreateActionResult(CrudOperation.Retrieve); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | /// <summary> |
| 151 | /// Retrieves all Operations from the current Submodel |
| 152 | /// </summary> |
| 153 | /// <returns></returns> |
| 154 | /// <response code="200">Success</response> |
| 155 | /// <response code="404">Submodel not found / No Operations found</response> |
| 156 | [HttpGet("submodel/operations", Name = "GetOperations")] |
| 157 | [ProducesResponseType(typeof(Operation[]), 200)] |
| 158 | [ProducesResponseType(typeof(Result), 404)] |
| 159 | public IActionResult GetOperations() |
| 160 | { |
| 161 | var result = RetrieveOperations(); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 162 | return result.CreateActionResult(CrudOperation.Retrieve); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | /// <summary> |
| 166 | /// Retrieves all Events from the current Submodel |
| 167 | /// </summary> |
| 168 | /// <returns></returns> |
| 169 | /// <response code="200">Success</response> |
| 170 | /// <response code="404">Submodel not found / No Events found</response> |
| 171 | [HttpGet("submodel/events", Name = "GetEvents")] |
| 172 | [ProducesResponseType(typeof(Event[]), 200)] |
| 173 | [ProducesResponseType(typeof(Result), 404)] |
| 174 | public IActionResult GetEvents() |
| 175 | { |
| 176 | var result = RetrieveEvents(); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 177 | return result.CreateActionResult(CrudOperation.Retrieve); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | |
Constantin Ziesche | 95d5109 | 2020-03-04 17:58:10 +0100 | [diff] [blame] | 181 | #region SubmodelElement - REST-Calls |
| 182 | /// <summary> |
| 183 | /// Adds a new Submodel Element to the Submodel |
| 184 | /// </summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 185 | /// <param name="submodelElement">The serialized Submodel Element object</param> |
Constantin Ziesche | 95d5109 | 2020-03-04 17:58:10 +0100 | [diff] [blame] | 186 | /// <returns></returns> |
| 187 | /// <response code="201">Submodel Element created successfully</response> |
| 188 | /// <response code="400">Bad Request</response> |
| 189 | /// <response code="404">Submodel not found</response> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 190 | [HttpPut("submodel/submodelElements", Name = "PutSubmodelElement")] |
| 191 | [ProducesResponseType(typeof(SubmodelElement), 201)] |
Constantin Ziesche | 95d5109 | 2020-03-04 17:58:10 +0100 | [diff] [blame] | 192 | [ProducesResponseType(typeof(Result), 400)] |
| 193 | [ProducesResponseType(typeof(Result), 404)] |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 194 | public IActionResult PutSubmodelElement([FromBody] ISubmodelElement submodelElement) |
Constantin Ziesche | 95d5109 | 2020-03-04 17:58:10 +0100 | [diff] [blame] | 195 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 196 | if(submodelElement == null) |
| 197 | return ResultHandling.NullResult(nameof(submodelElement)); |
| 198 | |
Constantin Ziesche | 95d5109 | 2020-03-04 17:58:10 +0100 | [diff] [blame] | 199 | var result = CreateSubmodelElement(submodelElement); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 200 | return result.CreateActionResult(CrudOperation.Create, "submodel/submodelElements/" + submodelElement.IdShort); |
Constantin Ziesche | 95d5109 | 2020-03-04 17:58:10 +0100 | [diff] [blame] | 201 | } |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 202 | |
| 203 | |
Constantin Ziesche | 95d5109 | 2020-03-04 17:58:10 +0100 | [diff] [blame] | 204 | /// <summary> |
| 205 | /// Retrieves a specific Submodel Element from the Submodel |
| 206 | /// </summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 207 | /// <param name="submodelElementIdShort">The Submodel Element's short id</param> |
Constantin Ziesche | 95d5109 | 2020-03-04 17:58:10 +0100 | [diff] [blame] | 208 | /// <returns></returns> |
| 209 | /// <response code="200">Returns the requested Submodel Element</response> |
| 210 | /// <response code="404">Submodel/Submodel Element not found</response> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 211 | [HttpGet("submodel/submodelElements/{*submodelElementIdShort}", Name = "GetSubmodelElementByIdShort")] |
Constantin Ziesche | 95d5109 | 2020-03-04 17:58:10 +0100 | [diff] [blame] | 212 | [ProducesResponseType(typeof(Property), 200)] |
| 213 | [ProducesResponseType(typeof(Result), 404)] |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 214 | public IActionResult GetSubmodelElementByIdShort(string submodelElementIdShort) |
Constantin Ziesche | 95d5109 | 2020-03-04 17:58:10 +0100 | [diff] [blame] | 215 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 216 | if (string.IsNullOrEmpty(submodelElementIdShort)) |
| 217 | return ResultHandling.NullResult(nameof(submodelElementIdShort)); |
| 218 | |
| 219 | var result = RetrieveSubmodelElement(submodelElementIdShort); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 220 | return result.CreateActionResult(CrudOperation.Retrieve); |
Constantin Ziesche | 95d5109 | 2020-03-04 17:58:10 +0100 | [diff] [blame] | 221 | } |
| 222 | |
| 223 | /// <summary> |
| 224 | /// Deletes a specific Submodel Element from the Submodel |
| 225 | /// </summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 226 | /// <param name="submodelElementIdShort">The Submodel Element's short id</param> |
Constantin Ziesche | 95d5109 | 2020-03-04 17:58:10 +0100 | [diff] [blame] | 227 | /// <returns></returns> |
| 228 | /// <response code="204">Submodel Element deleted successfully</response> |
| 229 | /// <response code="404">Submodel/Submodel Element not found</response> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 230 | [HttpDelete("submodel/submodelElements/{*submodelElementIdShort}", Name = "DeleteSubmodelElementByIdShort")] |
| 231 | [ProducesResponseType(typeof(Result), 200)] |
| 232 | public IActionResult DeleteSubmodelElementByIdShort(string submodelElementIdShort) |
Constantin Ziesche | 95d5109 | 2020-03-04 17:58:10 +0100 | [diff] [blame] | 233 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 234 | if (string.IsNullOrEmpty(submodelElementIdShort)) |
| 235 | return ResultHandling.NullResult(nameof(submodelElementIdShort)); |
| 236 | |
| 237 | var result = DeleteSubmodelElement(submodelElementIdShort); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 238 | return result.CreateActionResult(CrudOperation.Delete); |
Constantin Ziesche | 95d5109 | 2020-03-04 17:58:10 +0100 | [diff] [blame] | 239 | } |
| 240 | #endregion |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 241 | #region Property - REST-Calls |
| 242 | /// <summary> |
| 243 | /// Adds a new Property to the Asset Administration Shell's Submodel |
| 244 | /// </summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 245 | /// <param name="property">The serialized Property object</param> |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 246 | /// <returns></returns> |
| 247 | /// <response code="201">Property created successfully</response> |
| 248 | /// <response code="400">Bad Request</response> |
| 249 | /// <response code="404">Submodel not found</response> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 250 | [HttpPut("submodel/properties", Name = "PutProperty")] |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 251 | [ProducesResponseType(typeof(Property), 201)] |
| 252 | [ProducesResponseType(typeof(Result), 400)] |
| 253 | [ProducesResponseType(typeof(Result), 404)] |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 254 | public IActionResult PutProperty([FromBody] IProperty property) |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 255 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 256 | if (property == null) |
| 257 | return ResultHandling.NullResult(nameof(property)); |
| 258 | |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 259 | var result = CreateProperty(property); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 260 | return result.CreateActionResult(CrudOperation.Create, "submodel/properties/" + property.IdShort); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 261 | } |
| 262 | /// <summary> |
| 263 | /// Retrieves a specific Property from the Asset Administrations's Submodel |
| 264 | /// </summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 265 | /// <param name="propertyIdShort">The Property's short id</param> |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 266 | /// <returns></returns> |
| 267 | /// <response code="200">Returns the requested Property</response> |
| 268 | /// <response code="404">Submodel/Property not found</response> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 269 | [HttpGet("submodel/properties/{propertyIdShort}", Name = "GetPropertyByIdShort")] |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 270 | [ProducesResponseType(typeof(Property), 200)] |
| 271 | [ProducesResponseType(typeof(Result), 404)] |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 272 | public IActionResult GetPropertyByIdShort(string propertyIdShort) |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 273 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 274 | if (string.IsNullOrEmpty(propertyIdShort)) |
| 275 | return ResultHandling.NullResult(nameof(propertyIdShort)); |
| 276 | |
| 277 | var result = RetrieveProperty(propertyIdShort); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 278 | return result.CreateActionResult(CrudOperation.Retrieve); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | /// <summary> |
| 282 | /// Retrieves the value of a specific Property from the Asset Administrations Shell's Submodel |
| 283 | /// </summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 284 | /// <param name="propertyIdShort">The Property's short id</param> |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 285 | /// <returns></returns> |
| 286 | /// <response code="200">Returns the requested Property's value</response> |
| 287 | /// <response code="404">Submodel/Property not found</response> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 288 | [HttpGet("submodel/properties/{propertyIdShort}/value", Name = "GetPropertyValueByIdShort")] |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 289 | [ProducesResponseType(typeof(ElementValue), 200)] |
| 290 | [ProducesResponseType(typeof(Result), 404)] |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 291 | public IActionResult GetPropertyValueByIdShort(string propertyIdShort) |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 292 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 293 | if (string.IsNullOrEmpty(propertyIdShort)) |
| 294 | return ResultHandling.NullResult(nameof(propertyIdShort)); |
| 295 | |
| 296 | var result = RetrievePropertyValue(propertyIdShort); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 297 | return result.CreateActionResult(CrudOperation.Retrieve); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 298 | } |
| 299 | |
| 300 | /// <summary> |
| 301 | /// Updates the Asset Administration Shell's Submodel's Property |
| 302 | /// </summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 303 | /// <param name="propertyIdShort">The Property's short id</param> |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 304 | /// <param name="value">The new value</param> |
| 305 | /// <returns></returns> |
| 306 | /// <response code="200">Property's value changed successfully</response> |
| 307 | /// <response code="404">Submodel/Property not found</response> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 308 | [HttpPut("submodel/properties/{propertyIdShort}/value", Name = "PutPropertyValueByIdShort")] |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 309 | [ProducesResponseType(typeof(ElementValue), 200)] |
| 310 | [ProducesResponseType(typeof(Result), 404)] |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 311 | public IActionResult PutPropertyValueByIdShort(string propertyIdShort, [FromBody] IValue value) |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 312 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 313 | if (string.IsNullOrEmpty(propertyIdShort)) |
| 314 | return ResultHandling.NullResult(nameof(propertyIdShort)); |
| 315 | |
| 316 | var result = UpdatePropertyValue(propertyIdShort, value); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 317 | return result.CreateActionResult(CrudOperation.Update); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 318 | } |
| 319 | /// <summary> |
| 320 | /// Deletes a specific Property from the Asset Administration Shell's Submodel |
| 321 | /// </summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 322 | /// <param name="propertyIdShort">The Property's short id</param> |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 323 | /// <returns></returns> |
| 324 | /// <response code="204">Property deleted successfully</response> |
| 325 | /// <response code="404">Submodel not found</response> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 326 | [HttpDelete("submodel/properties/{propertyIdShort}", Name = "DeletePropertyByIdShort")] |
| 327 | [ProducesResponseType(typeof(Result), 200)] |
| 328 | public IActionResult DeletePropertyByIdShort(string propertyIdShort) |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 329 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 330 | if (string.IsNullOrEmpty(propertyIdShort)) |
| 331 | return ResultHandling.NullResult(nameof(propertyIdShort)); |
| 332 | |
| 333 | var result = DeleteProperty(propertyIdShort); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 334 | return result.CreateActionResult(CrudOperation.Delete); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 335 | } |
| 336 | #endregion |
| 337 | #region Operation - REST-Calls |
| 338 | /// <summary> |
| 339 | /// Adds a new operation to the Asset Administraiton Shell's Submodel |
| 340 | /// </summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 341 | /// <param name="operation">The serialized Operation object</param> |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 342 | /// <returns></returns> |
| 343 | /// <response code="201">Operation created successfully</response> |
| 344 | /// <response code="400">Bad Request</response> |
| 345 | /// <response code="404">Submodel not found</response> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 346 | [HttpPut("submodel/operations", Name = "PutOperation")] |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 347 | [ProducesResponseType(typeof(Operation), 201)] |
| 348 | [ProducesResponseType(typeof(Result), 400)] |
| 349 | [ProducesResponseType(typeof(Result), 404)] |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 350 | public IActionResult PutOperation([FromBody] IOperation operation) |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 351 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 352 | if (operation == null) |
| 353 | return ResultHandling.NullResult(nameof(operation)); |
| 354 | |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 355 | var result = CreateOperation(operation); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 356 | return result.CreateActionResult(CrudOperation.Create, "submodel/operations/" + operation.IdShort); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 357 | } |
| 358 | /// <summary> |
| 359 | /// Retrieves a specific Operation from the Asset Administration Shell's Submodel |
| 360 | /// </summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 361 | /// <param name="operationIdShort">The Operation's short id</param> |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 362 | /// <returns></returns> |
| 363 | /// <response code="200">Success</response> |
| 364 | /// <response code="404">Submodel/Operation not found</response> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 365 | [HttpGet("submodel/operations/{operationIdShort}", Name = "GetOperationByIdShort")] |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 366 | [ProducesResponseType(typeof(Operation), 200)] |
| 367 | [ProducesResponseType(typeof(Result), 404)] |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 368 | public IActionResult GetOperationByIdShort(string operationIdShort) |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 369 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 370 | if (string.IsNullOrEmpty(operationIdShort)) |
| 371 | return ResultHandling.NullResult(nameof(operationIdShort)); |
| 372 | |
| 373 | var result = RetrieveOperation(operationIdShort); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 374 | return result.CreateActionResult(CrudOperation.Retrieve); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 375 | } |
| 376 | /// <summary> |
| 377 | /// Deletes a specific Operation from the Asset Administration Shell's Submodel |
| 378 | /// </summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 379 | /// <param name="operationIdShort">The Operation's short id</param> |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 380 | /// <returns></returns> |
| 381 | /// <response code="204">Operation deleted successfully</response> |
| 382 | /// <response code="404">Submodel not found</response> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 383 | [HttpDelete("submodel/operations/{operationIdShort}", Name = "DeleteOperationByIdShort")] |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 384 | [ProducesResponseType(typeof(Result), 404)] |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 385 | public IActionResult DeleteOperationByIdShort(string operationIdShort) |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 386 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 387 | if (string.IsNullOrEmpty(operationIdShort)) |
| 388 | return ResultHandling.NullResult(nameof(operationIdShort)); |
| 389 | |
| 390 | var result = DeleteOperation(operationIdShort); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 391 | return result.CreateActionResult(CrudOperation.Delete); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 392 | } |
| 393 | /// <summary> |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 394 | /// Synchronously invokes a specific operation from the Submodel |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 395 | /// </summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 396 | /// <param name="operationIdShort">The Operation's short id</param> |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 397 | /// <param name="invocationRequest">The parameterized request object for the invocation</param> |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 398 | /// <returns></returns> |
| 399 | /// <response code="200">Operation invoked successfully</response> |
| 400 | /// <response code="400">Bad Request</response> |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 401 | /// <response code="404">Submodel / Method handler not found</response> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 402 | [HttpPost("submodel/operations/{operationIdShort}", Name = "InvokeOperationByIdShort")] |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 403 | [ProducesResponseType(typeof(InvocationResponse), 200)] |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 404 | [ProducesResponseType(typeof(Result), 400)] |
| 405 | [ProducesResponseType(typeof(Result), 404)] |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 406 | public IActionResult InvokeOperationByIdShort(string operationIdShort, [FromBody] InvocationRequest invocationRequest) |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 407 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 408 | if (string.IsNullOrEmpty(operationIdShort)) |
| 409 | return ResultHandling.NullResult(nameof(operationIdShort)); |
| 410 | if (invocationRequest == null) |
| 411 | return ResultHandling.NullResult(nameof(invocationRequest)); |
| 412 | |
| 413 | IResult<InvocationResponse> result = InvokeOperation(operationIdShort, invocationRequest); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 414 | return result.CreateActionResult(CrudOperation.Invoke); |
| 415 | } |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 416 | |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 417 | /// <summary> |
| 418 | /// Asynchronously invokes a specific operation from the Submodel |
| 419 | /// </summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 420 | /// <param name="operationIdShort">The Operation's short id</param> |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 421 | /// <param name="invocationRequest">The parameterized request object for the invocation</param> |
| 422 | /// <returns></returns> |
| 423 | /// <response code="200">Operation invoked successfully</response> |
| 424 | /// <response code="400">Bad Request</response> |
| 425 | /// <response code="404">Submodel / Method handler not found</response> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 426 | [HttpPost("submodel/operations/{operationIdShort}/async", Name = "InvokeOperationByIdShortAsync")] |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 427 | [ProducesResponseType(typeof(CallbackResponse), 200)] |
| 428 | [ProducesResponseType(typeof(Result), 400)] |
| 429 | [ProducesResponseType(typeof(Result), 404)] |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 430 | public IActionResult InvokeOperationByIdShortAsync(string operationIdShort, [FromBody] InvocationRequest invocationRequest) |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 431 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 432 | if (string.IsNullOrEmpty(operationIdShort)) |
| 433 | return ResultHandling.NullResult(nameof(operationIdShort)); |
| 434 | if (invocationRequest == null) |
| 435 | return ResultHandling.NullResult(nameof(invocationRequest)); |
| 436 | |
| 437 | IResult<CallbackResponse> result = InvokeOperationAsync(operationIdShort, invocationRequest); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 438 | return result.CreateActionResult(CrudOperation.Invoke); |
| 439 | } |
| 440 | |
| 441 | /// <summary> |
| 442 | /// Retrieves the result of an asynchronously started operation |
| 443 | /// </summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 444 | /// <param name="operationIdShort">The Operation's short id</param> |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 445 | /// <param name="requestId">The request id</param> |
| 446 | /// <returns></returns> |
| 447 | /// <response code="200">Result found</response> |
| 448 | /// <response code="400">Bad Request</response> |
| 449 | /// <response code="404">Submodel / Operation / Request not found</response> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 450 | [HttpGet("submodel/operations/{operationIdShort}/invocationList/{requestId}", Name = "GetInvocationResultByIdShort")] |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 451 | [ProducesResponseType(typeof(InvocationResponse), 200)] |
| 452 | [ProducesResponseType(typeof(Result), 400)] |
| 453 | [ProducesResponseType(typeof(Result), 404)] |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 454 | public IActionResult GetInvocationResultByIdShort(string operationIdShort, string requestId) |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 455 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 456 | if (string.IsNullOrEmpty(operationIdShort)) |
| 457 | return ResultHandling.NullResult(nameof(operationIdShort)); |
| 458 | if (string.IsNullOrEmpty(requestId)) |
| 459 | return ResultHandling.NullResult(nameof(requestId)); |
| 460 | |
| 461 | IResult<InvocationResponse> result = GetInvocationResult(operationIdShort, requestId); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 462 | return result.CreateActionResult(CrudOperation.Invoke); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 463 | } |
| 464 | |
| 465 | #endregion |
| 466 | #region Event - REST-Calls |
| 467 | /// <summary> |
| 468 | /// Adds a new event to the Asset Administration Shell's Submodel |
| 469 | /// </summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 470 | /// <param name="eventable">The serialized Event object</param> |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 471 | /// <returns></returns> |
| 472 | /// <response code="201">Event created successfully</response> |
| 473 | /// <response code="400">Bad Request</response> |
| 474 | /// <response code="404">Submodel not found</response> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 475 | [HttpPut("submodel/events", Name = "PutEvent")] |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 476 | [ProducesResponseType(typeof(Event), 201)] |
| 477 | [ProducesResponseType(typeof(Result), 400)] |
| 478 | [ProducesResponseType(typeof(Result), 404)] |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 479 | public IActionResult PutEvent([FromBody] IEvent eventable) |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 480 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 481 | if (eventable == null) |
| 482 | return ResultHandling.NullResult(nameof(eventable)); |
| 483 | |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 484 | var result = CreateEvent(eventable); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 485 | return result.CreateActionResult(CrudOperation.Create, "submodel/events/" + eventable.IdShort); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 486 | } |
| 487 | /// <summary> |
| 488 | /// Retrieves a specific event from the Asset Administration Shell's Submodel |
| 489 | /// </summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 490 | /// <param name="eventIdShort">The Event's short id</param> |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 491 | /// <returns></returns> |
| 492 | /// <response code="200">Success</response> |
| 493 | /// <response code="404">Submodel/Event not found</response> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 494 | [HttpGet("submodel/events/{eventIdShort}", Name = "GetEventByIdShort")] |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 495 | [ProducesResponseType(typeof(Event), 200)] |
| 496 | [ProducesResponseType(typeof(Result), 404)] |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 497 | public IActionResult GetEventByIdShort(string eventIdShort) |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 498 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 499 | if (string.IsNullOrEmpty(eventIdShort)) |
| 500 | return ResultHandling.NullResult(nameof(eventIdShort)); |
| 501 | |
| 502 | var result = RetrieveEvent(eventIdShort); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 503 | return result.CreateActionResult(CrudOperation.Retrieve); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 504 | } |
| 505 | /// <summary> |
| 506 | /// Deletes a specific event from the Asset Administration Shell's Submodel |
| 507 | /// </summary> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 508 | /// <param name="eventIdShort">The Event's short id</param> |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 509 | /// <returns></returns> |
| 510 | /// <response code="204">Event deleted successfully</response> |
| 511 | /// <response code="404">Submodel not found</response> |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 512 | [HttpDelete("submodel/events/{eventIdShort}", Name = "DeleteEventByIdShort")] |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 513 | [ProducesResponseType(typeof(Result), 404)] |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 514 | public IActionResult DeleteEventByIdShort(string eventIdShort) |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 515 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 516 | if (string.IsNullOrEmpty(eventIdShort)) |
| 517 | return ResultHandling.NullResult(nameof(eventIdShort)); |
| 518 | |
| 519 | var result = DeleteEvent(eventIdShort); |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 520 | return result.CreateActionResult(CrudOperation.Delete); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 521 | } |
| 522 | |
| 523 | |
| 524 | #endregion |
| 525 | |
| 526 | #endregion |
| 527 | |
| 528 | #region Interface Implementation SubmodelServiceProvider |
| 529 | |
| 530 | public IResult<IOperation> CreateOperation(IOperation operation) |
| 531 | { |
| 532 | return submodelServiceProvider.CreateOperation(operation); |
| 533 | } |
| 534 | |
| 535 | public IResult<IElementContainer<IOperation>> RetrieveOperations() |
| 536 | { |
| 537 | return submodelServiceProvider.RetrieveOperations(); |
| 538 | } |
| 539 | |
| 540 | public IResult<IOperation> RetrieveOperation(string operationId) |
| 541 | { |
| 542 | return submodelServiceProvider.RetrieveOperation(operationId); |
| 543 | } |
| 544 | |
| 545 | public IResult DeleteOperation(string operationId) |
| 546 | { |
| 547 | return submodelServiceProvider.DeleteOperation(operationId); |
| 548 | } |
| 549 | |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 550 | public IResult<InvocationResponse> InvokeOperation(string operationId, InvocationRequest invocationRequest) |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 551 | { |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 552 | return submodelServiceProvider.InvokeOperation(operationId, invocationRequest); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 553 | } |
| 554 | |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 555 | public IResult<IProperty> CreateProperty(IProperty property) |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 556 | { |
Constantin Ziesche | 02817f1 | 2020-08-04 21:40:43 +0200 | [diff] [blame] | 557 | return submodelServiceProvider.CreateProperty(property); |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 558 | } |
| 559 | |
| 560 | public IResult<IElementContainer<IProperty>> RetrieveProperties() |
| 561 | { |
| 562 | return submodelServiceProvider.RetrieveProperties(); |
| 563 | } |
| 564 | |
| 565 | public IResult<IProperty> RetrieveProperty(string propertyId) |
| 566 | { |
| 567 | return submodelServiceProvider.RetrieveProperty(propertyId); |
| 568 | } |
| 569 | |
| 570 | public IResult UpdatePropertyValue(string propertyId, IValue propertyValue) |
| 571 | { |
| 572 | return submodelServiceProvider.UpdatePropertyValue(propertyId, propertyValue); |
| 573 | } |
| 574 | |
| 575 | public IResult DeleteProperty(string propertyId) |
| 576 | { |
| 577 | return submodelServiceProvider.DeleteProperty(propertyId); |
| 578 | } |
| 579 | |
| 580 | public IResult<IEvent> CreateEvent(IEvent eventable) |
| 581 | { |
| 582 | return submodelServiceProvider.CreateEvent(eventable); |
| 583 | } |
| 584 | |
| 585 | public IResult<IElementContainer<IEvent>> RetrieveEvents() |
| 586 | { |
| 587 | return submodelServiceProvider.RetrieveEvents(); |
| 588 | } |
| 589 | |
| 590 | public IResult<IEvent> RetrieveEvent(string eventId) |
| 591 | { |
| 592 | return submodelServiceProvider.RetrieveEvent(eventId); |
| 593 | } |
| 594 | |
| 595 | public IResult ThrowEvent(IPublishableEvent publishableEvent, string topic, Action<IMessagePublishedEventArgs> MessagePublished, byte qosLevel, bool retain) |
| 596 | { |
| 597 | return submodelServiceProvider.ThrowEvent(publishableEvent, topic, MessagePublished, qosLevel, retain); |
| 598 | } |
| 599 | |
| 600 | public IResult DeleteEvent(string eventId) |
| 601 | { |
| 602 | return submodelServiceProvider.DeleteEvent(eventId); |
| 603 | } |
| 604 | |
| 605 | public Delegate RetrieveMethodDelegate(string operationId) |
| 606 | { |
| 607 | return submodelServiceProvider.RetrieveMethodDelegate(operationId); |
| 608 | } |
| 609 | |
| 610 | public void RegisterMethodCalledHandler(string operationId, Delegate handler) |
| 611 | { |
| 612 | submodelServiceProvider.RegisterMethodCalledHandler(operationId, handler); |
| 613 | } |
| 614 | |
| 615 | public void ConfigureEventHandler(IMessageClient messageClient) |
| 616 | { |
| 617 | submodelServiceProvider.ConfigureEventHandler(messageClient); |
| 618 | } |
| 619 | |
| 620 | public IResult<IValue> RetrievePropertyValue(string propertyId) |
| 621 | { |
| 622 | return submodelServiceProvider.RetrievePropertyValue(propertyId); |
| 623 | } |
| 624 | |
| 625 | public PropertyHandler RetrievePropertyHandler(string propertyId) |
| 626 | { |
| 627 | return submodelServiceProvider.RetrievePropertyHandler(propertyId); |
| 628 | } |
| 629 | |
| 630 | public void RegisterPropertyHandler(string propertyId, PropertyHandler handler) |
| 631 | { |
| 632 | submodelServiceProvider.RegisterPropertyHandler(propertyId, handler); |
| 633 | } |
| 634 | |
| 635 | public void SubscribeUpdates(string propertyId, Action<IValue> updateFunction) |
| 636 | { |
| 637 | submodelServiceProvider.SubscribeUpdates(propertyId, updateFunction); |
| 638 | } |
| 639 | |
| 640 | public void PublishUpdate(string propertyId, IValue propertyValue) |
| 641 | { |
| 642 | submodelServiceProvider.PublishUpdate(propertyId, propertyValue); |
| 643 | } |
| 644 | |
| 645 | public IResult<ISubmodel> RetrieveSubmodel() |
| 646 | { |
| 647 | return submodelServiceProvider.RetrieveSubmodel(); |
| 648 | } |
| 649 | |
| 650 | public void RegisterEventDelegate(string eventId, EventDelegate eventDelegate) |
| 651 | { |
| 652 | submodelServiceProvider.RegisterEventDelegate(eventId, eventDelegate); |
| 653 | } |
| 654 | |
| 655 | public IResult<ISubmodelElement> CreateSubmodelElement(ISubmodelElement submodelElement) |
| 656 | { |
| 657 | return submodelServiceProvider.CreateSubmodelElement(submodelElement); |
| 658 | } |
| 659 | |
| 660 | public IResult<IElementContainer<ISubmodelElement>> RetrieveSubmodelElements() |
| 661 | { |
| 662 | return submodelServiceProvider.RetrieveSubmodelElements(); |
| 663 | } |
| 664 | |
| 665 | public IResult<ISubmodelElement> RetrieveSubmodelElement(string submodelElementId) |
| 666 | { |
| 667 | return submodelServiceProvider.RetrieveSubmodelElement(submodelElementId); |
| 668 | } |
| 669 | |
| 670 | public IResult<IValue> RetrieveSubmodelElementValue(string submodelElementId) |
| 671 | { |
| 672 | return submodelServiceProvider.RetrieveSubmodelElementValue(submodelElementId); |
| 673 | } |
| 674 | |
| 675 | public IResult UpdateSubmodelElement(string submodelElementId, ISubmodelElement submodelElement) |
| 676 | { |
| 677 | return submodelServiceProvider.UpdateSubmodelElement(submodelElementId, submodelElement); |
| 678 | } |
| 679 | |
| 680 | public IResult DeleteSubmodelElement(string submodelElementId) |
| 681 | { |
| 682 | return submodelServiceProvider.DeleteSubmodelElement(submodelElementId); |
| 683 | } |
| 684 | |
Constantin Ziesche | fa61208 | 2020-04-03 09:54:56 +0200 | [diff] [blame] | 685 | public IResult<CallbackResponse> InvokeOperationAsync(string operationId, InvocationRequest invocationRequest) |
| 686 | { |
| 687 | return submodelServiceProvider.InvokeOperationAsync(operationId, invocationRequest); |
| 688 | } |
| 689 | |
| 690 | public IResult<InvocationResponse> GetInvocationResult(string operationId, string requestId) |
| 691 | { |
| 692 | return submodelServiceProvider.GetInvocationResult(operationId, requestId); |
| 693 | } |
| 694 | |
Constantin Ziesche | 857c7ab | 2020-02-25 11:24:51 +0100 | [diff] [blame] | 695 | #endregion |
| 696 | |
| 697 | #region Helper Methods |
| 698 | |
| 699 | |
| 700 | #endregion |
| 701 | } |
| 702 | } |