diff --git a/Editor/Scripts/Graph/ARFGraphView.cs b/Editor/Scripts/Graph/ARFGraphView.cs index e81b95467ceba497663465851ab6e9202a4ca593..7053c84a38e9bc4d882ea05f630836f2277dda8d 100644 --- a/Editor/Scripts/Graph/ARFGraphView.cs +++ b/Editor/Scripts/Graph/ARFGraphView.cs @@ -562,7 +562,7 @@ namespace ETSI.ARF.WorldStorage.UI TrackableRequest.CreateTrackableAsync(worldStorageServer, trackable, (response) => { //change the uuid in its edges, if there is a new edge to be added in the world storage it needs to have the correct uuid - String uuid = response.result; + String uuid = response.result.Message; uuid = uuid.Replace("\"", ""); foreach (ARFEdgeLink edge in aRFNodeTrackable.portIn.connections) @@ -592,8 +592,7 @@ namespace ETSI.ARF.WorldStorage.UI WorldAnchorRequest.CreateWorldAnchorAsync(worldStorageServer, worldAnchor, (response) => { - - String uuid = response.result; + String uuid = response.result.Message; //change the uuid in its edges, if there is a new edge to be added in the world storage it needs to have the correct uuid uuid = uuid.Replace("\"", ""); foreach (ARFEdgeLink edge in aRFNodeWorldAnchor.portIn.connections) @@ -659,7 +658,7 @@ namespace ETSI.ARF.WorldStorage.UI WorldLink worldLink = aRFEdgeLink.worldLink; WorldLinkRequest.CreateWorldLinkAsync(worldStorageServer, worldLink, (response) => { - string uuid = response.result; + string uuid = response.result.Message; uuid = uuid.Replace("\"", ""); aRFEdgeLink.worldLink.UUID = Guid.Parse(uuid); diff --git a/Editor/Scripts/Windows/GraphEditorWindow.cs b/Editor/Scripts/Windows/GraphEditorWindow.cs index d1d7aaf861b11439d91eb568d2165c96b141094e..33d15ae875a4f5ba21a55325bc6055fa908e226e 100644 --- a/Editor/Scripts/Windows/GraphEditorWindow.cs +++ b/Editor/Scripts/Windows/GraphEditorWindow.cs @@ -524,7 +524,7 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows WorldAnchorRequest.CreateWorldAnchorAsync(SaveInfo.instance.worldStorageServer, worldAnchor, (response) => { - String uuid = response.result; + String uuid = response.result.Message; //change the uuid in its edges, if there is a new edge to be added in the world storage it needs to have the correct uuid uuid = uuid.Replace("\"", ""); @@ -977,7 +977,7 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows trackable.KeyvalueTags["unityAuthoringPosY"] = posY; TrackableRequest.CreateTrackableAsync(SaveInfo.instance.worldStorageServer, trackable, (response) => { - String uuid = response.result; + String uuid = response.result.Message; //change the uuid in its edges, if there is a new edge to be added in the world storage it needs to have the correct uuid uuid = uuid.Replace("\"", ""); @@ -1239,7 +1239,7 @@ namespace ETSI.ARF.WorldStorage.Editor.Windows { WorldLinkRequest.CreateWorldLinkAsync(SaveInfo.instance.worldStorageServer, worldLink, (response) => { - String uuid = response.result; + String uuid = response.result.Message; //Add the newly saved WorldLink to the SaveInfo singleton uuid = uuid.Replace("\"", ""); diff --git a/Editor/Scripts/Windows/TrackableWindow.cs b/Editor/Scripts/Windows/TrackableWindow.cs index 6360d7a67ac4f30d6babda6faefded66996657c1..38b7bf6a5cbb6bb2635a670f6b5a743dc633a63a 100644 --- a/Editor/Scripts/Windows/TrackableWindow.cs +++ b/Editor/Scripts/Windows/TrackableWindow.cs @@ -166,7 +166,7 @@ namespace ETSI.ARF.WorldStorage.UI Trackable obj = GenerateObject(); TrackableRequest.UpdateTrackableAsync(worldStorageServer, obj, (response) => { - UUID = response.result; + UUID = response.result.Message; UUID = UUID.Trim('"'); //Bugfix: remove " from server return value if (WorldStorageWindow.WorldStorageWindowSingleton != null) @@ -313,7 +313,7 @@ namespace ETSI.ARF.WorldStorage.UI Trackable obj = GenerateObject(); TrackableRequest.CreateTrackableAsync(worldStorageServer, obj, (response) => { - UUID = response.result; + UUID = response.result.Message; UUID = UUID.Trim('"'); //Bugfix: remove " from server return value WorldStorageWindow.WorldStorageWindowSingleton.GetTrackables(); }); diff --git a/Editor/Scripts/Windows/WorldAnchorWindow.cs b/Editor/Scripts/Windows/WorldAnchorWindow.cs index 2fb8dd0044ef6faf28442e7315b596ba2eb641e4..5e958747e4d20f420cf3c8bf6d0f29d527a5bd72 100644 --- a/Editor/Scripts/Windows/WorldAnchorWindow.cs +++ b/Editor/Scripts/Windows/WorldAnchorWindow.cs @@ -163,7 +163,7 @@ namespace ETSI.ARF.WorldStorage.UI WorldAnchor obj = GenerateObject(); WorldAnchorRequest.UpdateWorldAnchorAsync(worldStorageServer, obj, (response) => { - UUID = response.result; + UUID = response.result.Message; UUID = UUID.Trim('"'); //Bugfix: remove " from server return value if (WorldStorageWindow.WorldStorageWindowSingleton != null) @@ -291,7 +291,7 @@ namespace ETSI.ARF.WorldStorage.UI WorldAnchor obj = GenerateObject(); WorldAnchorRequest.CreateWorldAnchorAsync(worldStorageServer, obj, (response) => { - UUID = response.result; + UUID = response.result.Message; UUID = UUID.Trim('"'); //Bugfix: remove " from server return value WorldStorageWindow.WorldStorageWindowSingleton.GetWorldAnchors(); }); diff --git a/Editor/Scripts/Windows/WorldLinkWindow.cs b/Editor/Scripts/Windows/WorldLinkWindow.cs index 147417bf23d42ea6db7232923836bf4d4b341cbc..0dbb9be92a3da1e994b74bb43805d1d92c66eb20 100644 --- a/Editor/Scripts/Windows/WorldLinkWindow.cs +++ b/Editor/Scripts/Windows/WorldLinkWindow.cs @@ -275,7 +275,7 @@ namespace ETSI.ARF.WorldStorage.UI WorldLink obj = GenerateObject(); WorldLinkRequest.UpdateWorldLinkAsync(worldStorageServer, obj, (response) => { - UUID = response.result; + UUID = response.result.Message; UUID = UUID.Trim('"'); //Bugfix: remove " from server return value if (WorldStorageWindow.WorldStorageWindowSingleton != null) @@ -469,7 +469,7 @@ namespace ETSI.ARF.WorldStorage.UI WorldLink obj = GenerateObject(); WorldLinkRequest.CreateWorldLinkAsync(worldStorageServer, obj, (response) => { - UUID = response.result; + UUID = response.result.Message; UUID = UUID.Trim('"'); //Bugfix: remove " from server return value WorldStorageWindow.WorldStorageWindowSingleton.GetWorldLinks(); }); diff --git a/Editor/Scripts/Windows/WorldStorageWindow.cs b/Editor/Scripts/Windows/WorldStorageWindow.cs index d8d036ec13150a818fa3d01f95afccea2fedd182..22301597a6e2508998d886b996307ce681e6eebb 100644 --- a/Editor/Scripts/Windows/WorldStorageWindow.cs +++ b/Editor/Scripts/Windows/WorldStorageWindow.cs @@ -545,14 +545,16 @@ namespace ETSI.ARF.WorldStorage.UI return text.Split('[', ']')[1]; } } + public void GetCreators() { // Get all objects Debug.Log("Get all creators id"); TrackableRequest.GetTrackablesAsync(worldStorageServer, (response) => { + // Workaround creators.Clear(); - foreach (var item in response.result) + foreach (var item in response.result.Trackables) { if (!creators.Contains(item.CreatorUUID.ToString())) creators.Add(item.CreatorUUID.ToString()); } @@ -585,8 +587,8 @@ namespace ETSI.ARF.WorldStorage.UI repaint = true; TrackableRequest.GetTrackablesAsync(worldStorageServer, (response) => { - Debug.Log("Get objects num = " + response.result.Count); - foreach (var item in response.result) + Debug.Log("Get objects num = " + response.result.Trackables.Count); + foreach (var item in response.result.Trackables) { if (filterByKeyValueTag != "") { @@ -608,7 +610,8 @@ namespace ETSI.ARF.WorldStorage.UI repaint = true; WorldAnchorRequest.GetWorldAnchorsAsync(worldStorageServer, (response) => { - foreach (var item in response.result) + Debug.Log("Get objects num = " + response.result.WorldAnchors.Count); + foreach (var item in response.result.WorldAnchors) { if (filterByKeyValueTag != "") { @@ -630,7 +633,8 @@ namespace ETSI.ARF.WorldStorage.UI repaint = true; WorldLinkRequest.GetWorldLinksAsync(worldStorageServer, (response) => { - foreach (var item in response.result) + Debug.Log("Get objects num = " + response.result.WorldLinks.Count); + foreach (var item in response.result.WorldLinks) { links.Add(item.UUID.ToString()); } diff --git a/Runtime/Scenes/OpenAPITest.cs b/Runtime/Scenes/OpenAPITest.cs index b3fa21cd56b2efe736ce715a2b218d32e7543c97..e4298c6f64e14a6455a8e8a88bda60aef43d5219 100644 --- a/Runtime/Scenes/OpenAPITest.cs +++ b/Runtime/Scenes/OpenAPITest.cs @@ -119,7 +119,7 @@ public class OpenAPITest : MonoBehaviour return; } - ResponseObject<List<Trackable>> token = TrackableRequest.GetTrackablesAsync(server, (response) => + ResponseObject<TrackablesResponse> token = TrackableRequest.GetTrackablesAsync(server, (response) => { handleResponseQ.Enqueue(response); }); @@ -136,9 +136,9 @@ public class OpenAPITest : MonoBehaviour Trackable tr = new Trackable(DateTime.Now.ToFileTime().ToString()); tr.TrackableType = TrackableType.OTHER; - ResponseObject<string> token = TrackableRequest.CreateTrackableAsync(server, tr, (response) => + ResponseObject<Success> token = TrackableRequest.CreateTrackableAsync(server, tr, (response) => { - lastUUID = Guid.Parse(response.result); + lastUUID = Guid.Parse(response.result.Message); handleResponseQ.Enqueue(response); }); lastUUID = Guid.Empty; @@ -161,9 +161,9 @@ public class OpenAPITest : MonoBehaviour ResponseObject<Trackable> token = TrackableRequest.GetTrackableAsync(server, lastUUID, (response) => { response.result.Name += "'"; - ResponseObject<string> token = TrackableRequest.UpdateTrackableAsync(server, response.result, (response) => + ResponseObject<Success> token = TrackableRequest.UpdateTrackableAsync(server, response.result, (response) => { - handleResponseQ.Enqueue(response); + handleResponseQ.Enqueue(response.result.Message); }); }); } @@ -182,9 +182,9 @@ public class OpenAPITest : MonoBehaviour return; } - ResponseObject<string> token = TrackableRequest.DeleteTrackableAsync(server, lastUUID, (response) => + ResponseObject<Success> token = TrackableRequest.DeleteTrackableAsync(server, lastUUID, (response) => { - handleResponseQ.Enqueue(response); + handleResponseQ.Enqueue(response.result.Message); lastUUID = Guid.Empty; }); } diff --git a/Runtime/Scripts/GraphEditor/WorldStorageRequest.cs b/Runtime/Scripts/GraphEditor/WorldStorageRequest.cs index a7706675519ae61284151768d46610eca778e50e..4b6999f8f7da02353635f84e7fcbd64b4b7e47c0 100644 --- a/Runtime/Scripts/GraphEditor/WorldStorageRequest.cs +++ b/Runtime/Scripts/GraphEditor/WorldStorageRequest.cs @@ -124,17 +124,17 @@ namespace ETSI.ARF.WorldStorage //public Task<int> GetNumOfAssets() => apiClient.NumOfAssetsAsync(); //public bool IsAssetExists(Guid id) => apiClient.IsAssetId(id); - public ResponseObject<string> AddTrackableAsync(Action<ResponseObject<string>> func, Trackable trackable) + public ResponseObject<Success> AddTrackableAsync(Action<ResponseObject<Success>> func, Trackable trackable) { return TrackableRequest.CreateTrackableAsync(wsServer, trackable, func); } - public ResponseObject<string> DeleteTrackableAsync(Action<ResponseObject<string>> func, Guid id) + public ResponseObject<Success> DeleteTrackableAsync(Action<ResponseObject<Success>> func, Guid id) { return TrackableRequest.DeleteTrackableAsync(wsServer, id, func); } - public ResponseObject<string> ModifyTrackableAsync(Action<ResponseObject<string>> func, Trackable trackable) + public ResponseObject<Success> ModifyTrackableAsync(Action<ResponseObject<Success>> func, Trackable trackable) { return TrackableRequest.UpdateTrackableAsync(wsServer, trackable, func); } @@ -144,7 +144,7 @@ namespace ETSI.ARF.WorldStorage return TrackableRequest.GetTrackableAsync(wsServer, id, func); } - public ResponseObject<List<Trackable>> GetTrackableListAsync(Action<ResponseObject<List<Trackable>>> func, int? max = 1) + public ResponseObject<TrackablesResponse> GetTrackableListAsync(Action<ResponseObject<TrackablesResponse>> func, int? max = 1) { return TrackableRequest.GetTrackablesAsync(wsServer, func); } diff --git a/Runtime/Scripts/OpenAPI/Generated/WorldStorageOpenAPI.cs b/Runtime/Scripts/OpenAPI/Generated/WorldStorageOpenAPI.cs index ba07b09e8b7d04733a10489233037b985a42e9df..df770434f5f429f67d4fe2850afcacb3fbbc1aa1 100644 --- a/Runtime/Scripts/OpenAPI/Generated/WorldStorageOpenAPI.cs +++ b/Runtime/Scripts/OpenAPI/Generated/WorldStorageOpenAPI.cs @@ -1,6 +1,6 @@ //---------------------- // <auto-generated> -// Generated using the NSwag toolchain v14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org) +// Generated using the NSwag toolchain v14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org) // </auto-generated> //---------------------- @@ -8,6 +8,7 @@ #pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword." #pragma warning disable 472 // Disable "CS0472 The result of the expression is always 'false' since a value of type 'Int32' is never equal to 'null' of type 'Int32?' #pragma warning disable 612 // Disable "CS0612 '...' is obsolete" +#pragma warning disable 649 // Disable "CS0649 Field is never assigned to, and will always have its default value null" #pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ... #pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..." #pragma warning disable 8073 // Disable "CS8073 The result of the expression is always 'false' since a value of type 'T' is never equal to 'null' of type 'T?'" @@ -15,23 +16,25 @@ #pragma warning disable 8603 // Disable "CS8603 Possible null reference return" #pragma warning disable 8604 // Disable "CS8604 Possible null reference argument for parameter" #pragma warning disable 8625 // Disable "CS8625 Cannot convert null literal to non-nullable reference type" -#pragma warning disable CS8765 // Nullability of type of parameter doesn't match overridden member (possibly because of nullability attributes). +#pragma warning disable 8765 // Disable "CS8765 Nullability of type of parameter doesn't match overridden member (possibly because of nullability attributes)." namespace ETSI.ARF.OpenAPI.WorldStorage { using System = global::System; - [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public partial class WorldStorageClient { private ETSI.ARF.OpenAPI.WorldStorage.IHttpClient _httpClient; private static System.Lazy<Newtonsoft.Json.JsonSerializerSettings> _settings = new System.Lazy<Newtonsoft.Json.JsonSerializerSettings>(CreateSerializerSettings, true); + private Newtonsoft.Json.JsonSerializerSettings _instanceSettings; #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. public WorldStorageClient(ETSI.ARF.OpenAPI.WorldStorage.IHttpClient httpClient) #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. { _httpClient = httpClient; + Initialize(); } private static Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings() @@ -41,10 +44,12 @@ namespace ETSI.ARF.OpenAPI.WorldStorage return settings; } - protected Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get { return _settings.Value; } } + protected Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get { return _instanceSettings ?? _settings.Value; } } static partial void UpdateJsonSerializerSettings(Newtonsoft.Json.JsonSerializerSettings settings); + partial void Initialize(); + partial void PrepareRequest(ETSI.ARF.OpenAPI.WorldStorage.IHttpClient client, System.Net.Http.HttpRequestMessage request, string url); partial void PrepareRequest(ETSI.ARF.OpenAPI.WorldStorage.IHttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder); partial void ProcessResponse(ETSI.ARF.OpenAPI.WorldStorage.IHttpClient client, System.Net.Http.HttpResponseMessage response); @@ -329,7 +334,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <param name="capabilities">the list of all trackables and his encoding structure associated representing the supported data of the User</param> /// <returns>Successful operation.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual System.Threading.Tasks.Task<Response> GetRelocalizationInformationAsync(string token, System.Collections.Generic.IEnumerable<Anonymous> uuids, System.Collections.Generic.IEnumerable<Capability> capabilities) + public virtual System.Threading.Tasks.Task<RelocalizationInformations> GetRelocalizationInformationAsync(string token, System.Collections.Generic.IEnumerable<UuidAndMode> uuids, System.Collections.Generic.IEnumerable<Capability> capabilities) { return GetRelocalizationInformationAsync(token, uuids, capabilities, System.Threading.CancellationToken.None); } @@ -341,7 +346,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <param name="capabilities">the list of all trackables and his encoding structure associated representing the supported data of the User</param> /// <returns>Successful operation.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual Response GetRelocalizationInformation(string token, System.Collections.Generic.IEnumerable<Anonymous> uuids, System.Collections.Generic.IEnumerable<Capability> capabilities) + public virtual RelocalizationInformations GetRelocalizationInformation(string token, System.Collections.Generic.IEnumerable<UuidAndMode> uuids, System.Collections.Generic.IEnumerable<Capability> capabilities) { return System.Threading.Tasks.Task.Run(async () => await GetRelocalizationInformationAsync(token, uuids, capabilities, System.Threading.CancellationToken.None)).GetAwaiter().GetResult(); } @@ -354,7 +359,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <param name="capabilities">the list of all trackables and his encoding structure associated representing the supported data of the User</param> /// <returns>Successful operation.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual async System.Threading.Tasks.Task<Response> GetRelocalizationInformationAsync(string token, System.Collections.Generic.IEnumerable<Anonymous> uuids, System.Collections.Generic.IEnumerable<Capability> capabilities, System.Threading.CancellationToken cancellationToken) + public virtual async System.Threading.Tasks.Task<RelocalizationInformations> GetRelocalizationInformationAsync(string token, System.Collections.Generic.IEnumerable<UuidAndMode> uuids, System.Collections.Generic.IEnumerable<Capability> capabilities, System.Threading.CancellationToken cancellationToken) { if (uuids == null) throw new System.ArgumentNullException("uuids"); @@ -408,7 +413,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage var status_ = (int)response_.StatusCode; if (status_ == 200) { - var objectResponse_ = await ReadObjectResponseAsync<Response>(response_, headers_, cancellationToken).ConfigureAwait(false); + var objectResponse_ = await ReadObjectResponseAsync<RelocalizationInformations>(response_, headers_, cancellationToken).ConfigureAwait(false); if (objectResponse_.Object == null) { throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); @@ -418,16 +423,32 @@ namespace ETSI.ARF.OpenAPI.WorldStorage else if (status_ == 400) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Invalid UUID supplied.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Invalid UUID supplied.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else if (status_ == 404) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Not found, could not find UUID in database.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Not found, could not find UUID in database.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + if (status_ == 511) + { + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("The secret token is not valid. Please ask an ISG ARF team member for a valid token.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { @@ -462,7 +483,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <param name="body">The Trackable to be added to the world storage.</param> /// <returns>OK, return the UUID of the Trackable defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual System.Threading.Tasks.Task<string> AddTrackableAsync(string token, Trackable body) + public virtual System.Threading.Tasks.Task<Success> AddTrackableAsync(string token, Trackable body) { return AddTrackableAsync(token, body, System.Threading.CancellationToken.None); } @@ -476,7 +497,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <param name="body">The Trackable to be added to the world storage.</param> /// <returns>OK, return the UUID of the Trackable defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual string AddTrackable(string token, Trackable body) + public virtual Success AddTrackable(string token, Trackable body) { return System.Threading.Tasks.Task.Run(async () => await AddTrackableAsync(token, body, System.Threading.CancellationToken.None)).GetAwaiter().GetResult(); } @@ -491,7 +512,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <param name="body">The Trackable to be added to the world storage.</param> /// <returns>OK, return the UUID of the Trackable defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual async System.Threading.Tasks.Task<string> AddTrackableAsync(string token, Trackable body, System.Threading.CancellationToken cancellationToken) + public virtual async System.Threading.Tasks.Task<Success> AddTrackableAsync(string token, Trackable body, System.Threading.CancellationToken cancellationToken) { if (body == null) throw new System.ArgumentNullException("body"); @@ -505,12 +526,12 @@ namespace ETSI.ARF.OpenAPI.WorldStorage if (token != null) request_.Headers.TryAddWithoutValidation("token", ConvertToString(token, System.Globalization.CultureInfo.InvariantCulture)); - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, _settings.Value); + var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, JsonSerializerSettings); var content_ = new System.Net.Http.StringContent(json_); content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain")); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); var urlBuilder_ = new System.Text.StringBuilder(); @@ -542,30 +563,42 @@ namespace ETSI.ARF.OpenAPI.WorldStorage var status_ = (int)response_.StatusCode; if (status_ == 200) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - return result_; + var objectResponse_ = await ReadObjectResponseAsync<Success>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; } else - if (status_ == 201) + if (status_ == 400) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - return result_; + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Bad request.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else - if (status_ == 400) + if (status_ == 409) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Bad request.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Invalid UUID, id must be a Nil value.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else - if (status_ == 409) + if (status_ == 511) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Invalid UUID, id must be a Nil value.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("The secret token is not valid. Please ask an ISG ARF team member for a valid token.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { @@ -598,9 +631,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Modify an existing Trackable given a json object containing all the required information. <br> **Please note that ID of the object is required in the JSON** /// </remarks> /// <param name="body">The Trackable to be modified in the world storage.</param> - /// <returns>OK, return the UUID of the modified Trackable.</returns> + /// <returns>OK, return the UUID of the Trackable defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual System.Threading.Tasks.Task<string> ModifyTrackableAsync(string token, Trackable body) + public virtual System.Threading.Tasks.Task<Success> ModifyTrackableAsync(string token, Trackable body) { return ModifyTrackableAsync(token, body, System.Threading.CancellationToken.None); } @@ -612,9 +645,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Modify an existing Trackable given a json object containing all the required information. <br> **Please note that ID of the object is required in the JSON** /// </remarks> /// <param name="body">The Trackable to be modified in the world storage.</param> - /// <returns>OK, return the UUID of the modified Trackable.</returns> + /// <returns>OK, return the UUID of the Trackable defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual string ModifyTrackable(string token, Trackable body) + public virtual Success ModifyTrackable(string token, Trackable body) { return System.Threading.Tasks.Task.Run(async () => await ModifyTrackableAsync(token, body, System.Threading.CancellationToken.None)).GetAwaiter().GetResult(); } @@ -627,9 +660,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Modify an existing Trackable given a json object containing all the required information. <br> **Please note that ID of the object is required in the JSON** /// </remarks> /// <param name="body">The Trackable to be modified in the world storage.</param> - /// <returns>OK, return the UUID of the modified Trackable.</returns> + /// <returns>OK, return the UUID of the Trackable defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual async System.Threading.Tasks.Task<string> ModifyTrackableAsync(string token, Trackable body, System.Threading.CancellationToken cancellationToken) + public virtual async System.Threading.Tasks.Task<Success> ModifyTrackableAsync(string token, Trackable body, System.Threading.CancellationToken cancellationToken) { if (body == null) throw new System.ArgumentNullException("body"); @@ -643,12 +676,12 @@ namespace ETSI.ARF.OpenAPI.WorldStorage if (token != null) request_.Headers.TryAddWithoutValidation("token", ConvertToString(token, System.Globalization.CultureInfo.InvariantCulture)); - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, _settings.Value); + var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, JsonSerializerSettings); var content_ = new System.Net.Http.StringContent(json_); content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("PUT"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain")); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); var urlBuilder_ = new System.Text.StringBuilder(); @@ -680,23 +713,42 @@ namespace ETSI.ARF.OpenAPI.WorldStorage var status_ = (int)response_.StatusCode; if (status_ == 200) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - return result_; + var objectResponse_ = await ReadObjectResponseAsync<Success>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; } else if (status_ == 400) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Bad request.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Bad request.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else if (status_ == 404) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Not found, could not find UUID in database.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Not found, could not find UUID in database.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + if (status_ == 511) + { + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("The secret token is not valid. Please ask an ISG ARF team member for a valid token.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { @@ -730,7 +782,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// </remarks> /// <returns>OK, return all the Trackables defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual System.Threading.Tasks.Task<System.Collections.Generic.List<Trackable>> GetTrackablesAsync(string token) + public virtual System.Threading.Tasks.Task<TrackablesResponse> GetTrackablesAsync(string token) { return GetTrackablesAsync(token, System.Threading.CancellationToken.None); } @@ -743,7 +795,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// </remarks> /// <returns>OK, return all the Trackables defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual System.Collections.Generic.List<Trackable> GetTrackables(string token) + public virtual TrackablesResponse GetTrackables(string token) { return System.Threading.Tasks.Task.Run(async () => await GetTrackablesAsync(token, System.Threading.CancellationToken.None)).GetAwaiter().GetResult(); } @@ -757,7 +809,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// </remarks> /// <returns>OK, return all the Trackables defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual async System.Threading.Tasks.Task<System.Collections.Generic.List<Trackable>> GetTrackablesAsync(string token, System.Threading.CancellationToken cancellationToken) + public virtual async System.Threading.Tasks.Task<TrackablesResponse> GetTrackablesAsync(string token, System.Threading.CancellationToken cancellationToken) { var client_ = _httpClient; var disposeClient_ = false; @@ -801,7 +853,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage var status_ = (int)response_.StatusCode; if (status_ == 200) { - var objectResponse_ = await ReadObjectResponseAsync<System.Collections.Generic.List<Trackable>>(response_, headers_, cancellationToken).ConfigureAwait(false); + var objectResponse_ = await ReadObjectResponseAsync<TrackablesResponse>(response_, headers_, cancellationToken).ConfigureAwait(false); if (objectResponse_.Object == null) { throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); @@ -809,11 +861,24 @@ namespace ETSI.ARF.OpenAPI.WorldStorage return objectResponse_.Object; } else - if (status_ == 201) + if (status_ == 401) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Null response.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Null response.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + if (status_ == 511) + { + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("The secret token is not valid. Please ask an ISG ARF team member for a valid token.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { @@ -935,16 +1000,42 @@ namespace ETSI.ARF.OpenAPI.WorldStorage else if (status_ == 400) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Invalid UUID supplied.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Invalid UUID supplied.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + if (status_ == 401) + { + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Null response.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else if (status_ == 404) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Not found, could not find UUID in database.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Not found, could not find UUID in database.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + if (status_ == 511) + { + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("The secret token is not valid. Please ask an ISG ARF team member for a valid token.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { @@ -973,9 +1064,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Delete a single Trackable stored in the world storage from its ID. /// </remarks> /// <param name="trackableUUID">Trackable UUID to delete.</param> - /// <returns>OK, delete successful.</returns> + /// <returns>Success request.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual System.Threading.Tasks.Task<string> DeleteTrackableAsync(string token, System.Guid trackableUUID) + public virtual System.Threading.Tasks.Task<Success> DeleteTrackableAsync(string token, System.Guid trackableUUID) { return DeleteTrackableAsync(token, trackableUUID, System.Threading.CancellationToken.None); } @@ -987,9 +1078,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Delete a single Trackable stored in the world storage from its ID. /// </remarks> /// <param name="trackableUUID">Trackable UUID to delete.</param> - /// <returns>OK, delete successful.</returns> + /// <returns>Success request.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual string DeleteTrackable(string token, System.Guid trackableUUID) + public virtual Success DeleteTrackable(string token, System.Guid trackableUUID) { return System.Threading.Tasks.Task.Run(async () => await DeleteTrackableAsync(token, trackableUUID, System.Threading.CancellationToken.None)).GetAwaiter().GetResult(); } @@ -1002,9 +1093,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Delete a single Trackable stored in the world storage from its ID. /// </remarks> /// <param name="trackableUUID">Trackable UUID to delete.</param> - /// <returns>OK, delete successful.</returns> + /// <returns>Success request.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual async System.Threading.Tasks.Task<string> DeleteTrackableAsync(string token, System.Guid trackableUUID, System.Threading.CancellationToken cancellationToken) + public virtual async System.Threading.Tasks.Task<Success> DeleteTrackableAsync(string token, System.Guid trackableUUID, System.Threading.CancellationToken cancellationToken) { if (trackableUUID == null) throw new System.ArgumentNullException("trackableUUID"); @@ -1019,7 +1110,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage if (token != null) request_.Headers.TryAddWithoutValidation("token", ConvertToString(token, System.Globalization.CultureInfo.InvariantCulture)); request_.Method = new System.Net.Http.HttpMethod("DELETE"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain")); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); var urlBuilder_ = new System.Text.StringBuilder(); @@ -1052,23 +1143,42 @@ namespace ETSI.ARF.OpenAPI.WorldStorage var status_ = (int)response_.StatusCode; if (status_ == 200) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - return result_; + var objectResponse_ = await ReadObjectResponseAsync<Success>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; } else if (status_ == 400) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Invalid UUID supplied.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Invalid UUID supplied.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else if (status_ == 404) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Not found, could not find UUID in database.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Not found, could not find UUID in database.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + if (status_ == 511) + { + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("The secret token is not valid. Please ask an ISG ARF team member for a valid token.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { @@ -1097,9 +1207,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Create a new World Anchor from a json object containing all the required information and add it to the world storage. <br>As a result you will get the ID of the newly created World Anchor. /// </remarks> /// <param name="body">The World Anchor to be added to the world storage.</param> - /// <returns>OK, return the UUID of the World Anchor defined by the world storage.</returns> + /// <returns>OK, return the UUID of the Trackable defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual System.Threading.Tasks.Task<string> AddWorldAnchorAsync(string token, WorldAnchor body) + public virtual System.Threading.Tasks.Task<Success> AddWorldAnchorAsync(string token, WorldAnchor body) { return AddWorldAnchorAsync(token, body, System.Threading.CancellationToken.None); } @@ -1111,9 +1221,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Create a new World Anchor from a json object containing all the required information and add it to the world storage. <br>As a result you will get the ID of the newly created World Anchor. /// </remarks> /// <param name="body">The World Anchor to be added to the world storage.</param> - /// <returns>OK, return the UUID of the World Anchor defined by the world storage.</returns> + /// <returns>OK, return the UUID of the Trackable defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual string AddWorldAnchor(string token, WorldAnchor body) + public virtual Success AddWorldAnchor(string token, WorldAnchor body) { return System.Threading.Tasks.Task.Run(async () => await AddWorldAnchorAsync(token, body, System.Threading.CancellationToken.None)).GetAwaiter().GetResult(); } @@ -1126,9 +1236,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Create a new World Anchor from a json object containing all the required information and add it to the world storage. <br>As a result you will get the ID of the newly created World Anchor. /// </remarks> /// <param name="body">The World Anchor to be added to the world storage.</param> - /// <returns>OK, return the UUID of the World Anchor defined by the world storage.</returns> + /// <returns>OK, return the UUID of the Trackable defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual async System.Threading.Tasks.Task<string> AddWorldAnchorAsync(string token, WorldAnchor body, System.Threading.CancellationToken cancellationToken) + public virtual async System.Threading.Tasks.Task<Success> AddWorldAnchorAsync(string token, WorldAnchor body, System.Threading.CancellationToken cancellationToken) { if (body == null) throw new System.ArgumentNullException("body"); @@ -1142,12 +1252,12 @@ namespace ETSI.ARF.OpenAPI.WorldStorage if (token != null) request_.Headers.TryAddWithoutValidation("token", ConvertToString(token, System.Globalization.CultureInfo.InvariantCulture)); - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, _settings.Value); + var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, JsonSerializerSettings); var content_ = new System.Net.Http.StringContent(json_); content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain")); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); var urlBuilder_ = new System.Text.StringBuilder(); @@ -1179,30 +1289,42 @@ namespace ETSI.ARF.OpenAPI.WorldStorage var status_ = (int)response_.StatusCode; if (status_ == 200) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - return result_; + var objectResponse_ = await ReadObjectResponseAsync<Success>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; } else - if (status_ == 201) + if (status_ == 400) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - return result_; + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Bad request.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else - if (status_ == 400) + if (status_ == 409) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Bad request.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Invalid UUID, id must be a Nil value.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else - if (status_ == 409) + if (status_ == 511) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Invalid UUID, id must be a Nil value.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("The secret token is not valid. Please ask an ISG ARF team member for a valid token.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { @@ -1235,9 +1357,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Modify an existing World Anchor given a json object containing all the required information. <br> **Please note that ID of the object is required in the JSON** /// </remarks> /// <param name="body">The World Anchor to be modified in the world storage.</param> - /// <returns>OK, return the UUID of the modified World Anchor.</returns> + /// <returns>OK, return the UUID of the Trackable defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual System.Threading.Tasks.Task<string> ModifyWorldAnchorAsync(string token, WorldAnchor body) + public virtual System.Threading.Tasks.Task<Success> ModifyWorldAnchorAsync(string token, WorldAnchor body) { return ModifyWorldAnchorAsync(token, body, System.Threading.CancellationToken.None); } @@ -1249,9 +1371,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Modify an existing World Anchor given a json object containing all the required information. <br> **Please note that ID of the object is required in the JSON** /// </remarks> /// <param name="body">The World Anchor to be modified in the world storage.</param> - /// <returns>OK, return the UUID of the modified World Anchor.</returns> + /// <returns>OK, return the UUID of the Trackable defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual string ModifyWorldAnchor(string token, WorldAnchor body) + public virtual Success ModifyWorldAnchor(string token, WorldAnchor body) { return System.Threading.Tasks.Task.Run(async () => await ModifyWorldAnchorAsync(token, body, System.Threading.CancellationToken.None)).GetAwaiter().GetResult(); } @@ -1264,9 +1386,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Modify an existing World Anchor given a json object containing all the required information. <br> **Please note that ID of the object is required in the JSON** /// </remarks> /// <param name="body">The World Anchor to be modified in the world storage.</param> - /// <returns>OK, return the UUID of the modified World Anchor.</returns> + /// <returns>OK, return the UUID of the Trackable defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual async System.Threading.Tasks.Task<string> ModifyWorldAnchorAsync(string token, WorldAnchor body, System.Threading.CancellationToken cancellationToken) + public virtual async System.Threading.Tasks.Task<Success> ModifyWorldAnchorAsync(string token, WorldAnchor body, System.Threading.CancellationToken cancellationToken) { if (body == null) throw new System.ArgumentNullException("body"); @@ -1280,12 +1402,12 @@ namespace ETSI.ARF.OpenAPI.WorldStorage if (token != null) request_.Headers.TryAddWithoutValidation("token", ConvertToString(token, System.Globalization.CultureInfo.InvariantCulture)); - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, _settings.Value); + var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, JsonSerializerSettings); var content_ = new System.Net.Http.StringContent(json_); content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("PUT"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain")); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); var urlBuilder_ = new System.Text.StringBuilder(); @@ -1317,23 +1439,42 @@ namespace ETSI.ARF.OpenAPI.WorldStorage var status_ = (int)response_.StatusCode; if (status_ == 200) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - return result_; + var objectResponse_ = await ReadObjectResponseAsync<Success>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; } else if (status_ == 400) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Bad request.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Bad request.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else if (status_ == 404) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Not found, could not find UUID in database.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Not found, could not find UUID in database.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + if (status_ == 511) + { + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("The secret token is not valid. Please ask an ISG ARF team member for a valid token.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { @@ -1367,7 +1508,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// </remarks> /// <returns>OK, return all the World Anchors defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual System.Threading.Tasks.Task<System.Collections.Generic.List<WorldAnchor>> GetWorldAnchorsAsync(string token) + public virtual System.Threading.Tasks.Task<WorldAnchorsResponse> GetWorldAnchorsAsync(string token) { return GetWorldAnchorsAsync(token, System.Threading.CancellationToken.None); } @@ -1380,7 +1521,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// </remarks> /// <returns>OK, return all the World Anchors defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual System.Collections.Generic.List<WorldAnchor> GetWorldAnchors(string token) + public virtual WorldAnchorsResponse GetWorldAnchors(string token) { return System.Threading.Tasks.Task.Run(async () => await GetWorldAnchorsAsync(token, System.Threading.CancellationToken.None)).GetAwaiter().GetResult(); } @@ -1394,7 +1535,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// </remarks> /// <returns>OK, return all the World Anchors defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual async System.Threading.Tasks.Task<System.Collections.Generic.List<WorldAnchor>> GetWorldAnchorsAsync(string token, System.Threading.CancellationToken cancellationToken) + public virtual async System.Threading.Tasks.Task<WorldAnchorsResponse> GetWorldAnchorsAsync(string token, System.Threading.CancellationToken cancellationToken) { var client_ = _httpClient; var disposeClient_ = false; @@ -1438,7 +1579,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage var status_ = (int)response_.StatusCode; if (status_ == 200) { - var objectResponse_ = await ReadObjectResponseAsync<System.Collections.Generic.List<WorldAnchor>>(response_, headers_, cancellationToken).ConfigureAwait(false); + var objectResponse_ = await ReadObjectResponseAsync<WorldAnchorsResponse>(response_, headers_, cancellationToken).ConfigureAwait(false); if (objectResponse_.Object == null) { throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); @@ -1446,24 +1587,37 @@ namespace ETSI.ARF.OpenAPI.WorldStorage return objectResponse_.Object; } else - if (status_ == 201) + if (status_ == 401) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Null response.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Null response.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else + if (status_ == 511) { var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); if (objectResponse_.Object == null) { throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); } - throw new ApiException<Error>("Unexpected error.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + throw new ApiException<Error>("The secret token is not valid. Please ask an ISG ARF team member for a valid token.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } - } - finally - { + else + { + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Unexpected error.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + } + finally + { if (disposeResponse_) response_.Dispose(); } @@ -1572,16 +1726,42 @@ namespace ETSI.ARF.OpenAPI.WorldStorage else if (status_ == 400) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Invalid UUID supplied.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Invalid UUID supplied.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + if (status_ == 401) + { + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Null response.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else if (status_ == 404) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Not found, could not find UUID in database.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Not found, could not find UUID in database.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + if (status_ == 511) + { + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("The secret token is not valid. Please ask an ISG ARF team member for a valid token.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { @@ -1610,9 +1790,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Delete a single World Anchor stored in the world storage from its ID. /// </remarks> /// <param name="worldAnchorUUID">World Anchor UUID to delete.</param> - /// <returns>OK, delete successful.</returns> + /// <returns>Success request.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual System.Threading.Tasks.Task<string> DeleteWorldAnchorAsync(string token, System.Guid worldAnchorUUID) + public virtual System.Threading.Tasks.Task<Success> DeleteWorldAnchorAsync(string token, System.Guid worldAnchorUUID) { return DeleteWorldAnchorAsync(token, worldAnchorUUID, System.Threading.CancellationToken.None); } @@ -1624,9 +1804,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Delete a single World Anchor stored in the world storage from its ID. /// </remarks> /// <param name="worldAnchorUUID">World Anchor UUID to delete.</param> - /// <returns>OK, delete successful.</returns> + /// <returns>Success request.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual string DeleteWorldAnchor(string token, System.Guid worldAnchorUUID) + public virtual Success DeleteWorldAnchor(string token, System.Guid worldAnchorUUID) { return System.Threading.Tasks.Task.Run(async () => await DeleteWorldAnchorAsync(token, worldAnchorUUID, System.Threading.CancellationToken.None)).GetAwaiter().GetResult(); } @@ -1639,9 +1819,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Delete a single World Anchor stored in the world storage from its ID. /// </remarks> /// <param name="worldAnchorUUID">World Anchor UUID to delete.</param> - /// <returns>OK, delete successful.</returns> + /// <returns>Success request.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual async System.Threading.Tasks.Task<string> DeleteWorldAnchorAsync(string token, System.Guid worldAnchorUUID, System.Threading.CancellationToken cancellationToken) + public virtual async System.Threading.Tasks.Task<Success> DeleteWorldAnchorAsync(string token, System.Guid worldAnchorUUID, System.Threading.CancellationToken cancellationToken) { if (worldAnchorUUID == null) throw new System.ArgumentNullException("worldAnchorUUID"); @@ -1656,7 +1836,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage if (token != null) request_.Headers.TryAddWithoutValidation("token", ConvertToString(token, System.Globalization.CultureInfo.InvariantCulture)); request_.Method = new System.Net.Http.HttpMethod("DELETE"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain")); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); var urlBuilder_ = new System.Text.StringBuilder(); @@ -1689,23 +1869,42 @@ namespace ETSI.ARF.OpenAPI.WorldStorage var status_ = (int)response_.StatusCode; if (status_ == 200) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - return result_; + var objectResponse_ = await ReadObjectResponseAsync<Success>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; } else if (status_ == 400) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Invalid UUID supplied.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Invalid UUID supplied.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else if (status_ == 404) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Not found, could not find UUID in database.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Not found, could not find UUID in database.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + if (status_ == 511) + { + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("The secret token is not valid. Please ask an ISG ARF team member for a valid token.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { @@ -1734,9 +1933,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Create a new World Link from a json object containing all the required information and add it to the world storage. <br>As a result you will get the ID of the newly created World Link. /// </remarks> /// <param name="body">The link to be added to the world storage.</param> - /// <returns>OK, return the UUID of the World Link defined by the world storage.</returns> + /// <returns>OK, return the UUID of the Trackable defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual System.Threading.Tasks.Task<string> AddWorldLinkAsync(string token, WorldLink body) + public virtual System.Threading.Tasks.Task<Success> AddWorldLinkAsync(string token, WorldLink body) { return AddWorldLinkAsync(token, body, System.Threading.CancellationToken.None); } @@ -1748,9 +1947,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Create a new World Link from a json object containing all the required information and add it to the world storage. <br>As a result you will get the ID of the newly created World Link. /// </remarks> /// <param name="body">The link to be added to the world storage.</param> - /// <returns>OK, return the UUID of the World Link defined by the world storage.</returns> + /// <returns>OK, return the UUID of the Trackable defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual string AddWorldLink(string token, WorldLink body) + public virtual Success AddWorldLink(string token, WorldLink body) { return System.Threading.Tasks.Task.Run(async () => await AddWorldLinkAsync(token, body, System.Threading.CancellationToken.None)).GetAwaiter().GetResult(); } @@ -1763,9 +1962,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Create a new World Link from a json object containing all the required information and add it to the world storage. <br>As a result you will get the ID of the newly created World Link. /// </remarks> /// <param name="body">The link to be added to the world storage.</param> - /// <returns>OK, return the UUID of the World Link defined by the world storage.</returns> + /// <returns>OK, return the UUID of the Trackable defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual async System.Threading.Tasks.Task<string> AddWorldLinkAsync(string token, WorldLink body, System.Threading.CancellationToken cancellationToken) + public virtual async System.Threading.Tasks.Task<Success> AddWorldLinkAsync(string token, WorldLink body, System.Threading.CancellationToken cancellationToken) { if (body == null) throw new System.ArgumentNullException("body"); @@ -1779,12 +1978,12 @@ namespace ETSI.ARF.OpenAPI.WorldStorage if (token != null) request_.Headers.TryAddWithoutValidation("token", ConvertToString(token, System.Globalization.CultureInfo.InvariantCulture)); - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, _settings.Value); + var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, JsonSerializerSettings); var content_ = new System.Net.Http.StringContent(json_); content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("POST"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain")); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); var urlBuilder_ = new System.Text.StringBuilder(); @@ -1816,30 +2015,42 @@ namespace ETSI.ARF.OpenAPI.WorldStorage var status_ = (int)response_.StatusCode; if (status_ == 200) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - return result_; + var objectResponse_ = await ReadObjectResponseAsync<Success>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; } else - if (status_ == 201) + if (status_ == 400) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - return result_; + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Bad request.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else - if (status_ == 400) + if (status_ == 409) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Bad request.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Invalid UUID, id must be a Nil value.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else - if (status_ == 409) + if (status_ == 511) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Invalid UUID, id must be a Nil value.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("The secret token is not valid. Please ask an ISG ARF team member for a valid token.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { @@ -1872,9 +2083,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Modify an existing World Link given a json object containing all the required information. <br> **Please note that ID of the object is required in the JSON** /// </remarks> /// <param name="body">The World Link to be modified in the world storage.</param> - /// <returns>OK, return the UUID of the modified World Link.</returns> + /// <returns>OK, return the UUID of the Trackable defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual System.Threading.Tasks.Task<string> ModifyWorldLinkAsync(string token, WorldLink body) + public virtual System.Threading.Tasks.Task<Success> ModifyWorldLinkAsync(string token, WorldLink body) { return ModifyWorldLinkAsync(token, body, System.Threading.CancellationToken.None); } @@ -1886,9 +2097,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Modify an existing World Link given a json object containing all the required information. <br> **Please note that ID of the object is required in the JSON** /// </remarks> /// <param name="body">The World Link to be modified in the world storage.</param> - /// <returns>OK, return the UUID of the modified World Link.</returns> + /// <returns>OK, return the UUID of the Trackable defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual string ModifyWorldLink(string token, WorldLink body) + public virtual Success ModifyWorldLink(string token, WorldLink body) { return System.Threading.Tasks.Task.Run(async () => await ModifyWorldLinkAsync(token, body, System.Threading.CancellationToken.None)).GetAwaiter().GetResult(); } @@ -1901,9 +2112,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Modify an existing World Link given a json object containing all the required information. <br> **Please note that ID of the object is required in the JSON** /// </remarks> /// <param name="body">The World Link to be modified in the world storage.</param> - /// <returns>OK, return the UUID of the modified World Link.</returns> + /// <returns>OK, return the UUID of the Trackable defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual async System.Threading.Tasks.Task<string> ModifyWorldLinkAsync(string token, WorldLink body, System.Threading.CancellationToken cancellationToken) + public virtual async System.Threading.Tasks.Task<Success> ModifyWorldLinkAsync(string token, WorldLink body, System.Threading.CancellationToken cancellationToken) { if (body == null) throw new System.ArgumentNullException("body"); @@ -1917,12 +2128,12 @@ namespace ETSI.ARF.OpenAPI.WorldStorage if (token != null) request_.Headers.TryAddWithoutValidation("token", ConvertToString(token, System.Globalization.CultureInfo.InvariantCulture)); - var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, _settings.Value); + var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, JsonSerializerSettings); var content_ = new System.Net.Http.StringContent(json_); content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); request_.Content = content_; request_.Method = new System.Net.Http.HttpMethod("PUT"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain")); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); var urlBuilder_ = new System.Text.StringBuilder(); @@ -1954,23 +2165,42 @@ namespace ETSI.ARF.OpenAPI.WorldStorage var status_ = (int)response_.StatusCode; if (status_ == 200) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - return result_; + var objectResponse_ = await ReadObjectResponseAsync<Success>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; } else if (status_ == 400) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Bad request.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Bad request.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else if (status_ == 404) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Not found, could not find UUID in database.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Not found, could not find UUID in database.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + if (status_ == 511) + { + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("The secret token is not valid. Please ask an ISG ARF team member for a valid token.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { @@ -2004,7 +2234,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// </remarks> /// <returns>OK return all the World Links defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual System.Threading.Tasks.Task<System.Collections.Generic.List<WorldLink>> GetWorldLinksAsync(string token) + public virtual System.Threading.Tasks.Task<WorldLinksResponse> GetWorldLinksAsync(string token) { return GetWorldLinksAsync(token, System.Threading.CancellationToken.None); } @@ -2017,7 +2247,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// </remarks> /// <returns>OK return all the World Links defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual System.Collections.Generic.List<WorldLink> GetWorldLinks(string token) + public virtual WorldLinksResponse GetWorldLinks(string token) { return System.Threading.Tasks.Task.Run(async () => await GetWorldLinksAsync(token, System.Threading.CancellationToken.None)).GetAwaiter().GetResult(); } @@ -2031,7 +2261,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// </remarks> /// <returns>OK return all the World Links defined by the world storage.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual async System.Threading.Tasks.Task<System.Collections.Generic.List<WorldLink>> GetWorldLinksAsync(string token, System.Threading.CancellationToken cancellationToken) + public virtual async System.Threading.Tasks.Task<WorldLinksResponse> GetWorldLinksAsync(string token, System.Threading.CancellationToken cancellationToken) { var client_ = _httpClient; var disposeClient_ = false; @@ -2075,7 +2305,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage var status_ = (int)response_.StatusCode; if (status_ == 200) { - var objectResponse_ = await ReadObjectResponseAsync<System.Collections.Generic.List<WorldLink>>(response_, headers_, cancellationToken).ConfigureAwait(false); + var objectResponse_ = await ReadObjectResponseAsync<WorldLinksResponse>(response_, headers_, cancellationToken).ConfigureAwait(false); if (objectResponse_.Object == null) { throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); @@ -2083,11 +2313,24 @@ namespace ETSI.ARF.OpenAPI.WorldStorage return objectResponse_.Object; } else - if (status_ == 201) + if (status_ == 401) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Null response.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Null response.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + if (status_ == 511) + { + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("The secret token is not valid. Please ask an ISG ARF team member for a valid token.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { @@ -2209,16 +2452,42 @@ namespace ETSI.ARF.OpenAPI.WorldStorage else if (status_ == 400) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Invalid UUID supplied.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Invalid UUID supplied.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + if (status_ == 401) + { + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Null response.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else if (status_ == 404) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Not found, could not find UUID in database.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Not found, could not find UUID in database.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + if (status_ == 511) + { + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("The secret token is not valid. Please ask an ISG ARF team member for a valid token.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { @@ -2247,9 +2516,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Delete a single World Link stored in the world storage from its ID. /// </remarks> /// <param name="worldLinkUUID">World Link id to delete.</param> - /// <returns>OK, delete successful.</returns> + /// <returns>Success request.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual System.Threading.Tasks.Task<string> DeleteWorldLinkAsync(string token, System.Guid worldLinkUUID) + public virtual System.Threading.Tasks.Task<Success> DeleteWorldLinkAsync(string token, System.Guid worldLinkUUID) { return DeleteWorldLinkAsync(token, worldLinkUUID, System.Threading.CancellationToken.None); } @@ -2261,9 +2530,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Delete a single World Link stored in the world storage from its ID. /// </remarks> /// <param name="worldLinkUUID">World Link id to delete.</param> - /// <returns>OK, delete successful.</returns> + /// <returns>Success request.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual string DeleteWorldLink(string token, System.Guid worldLinkUUID) + public virtual Success DeleteWorldLink(string token, System.Guid worldLinkUUID) { return System.Threading.Tasks.Task.Run(async () => await DeleteWorldLinkAsync(token, worldLinkUUID, System.Threading.CancellationToken.None)).GetAwaiter().GetResult(); } @@ -2276,9 +2545,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// Delete a single World Link stored in the world storage from its ID. /// </remarks> /// <param name="worldLinkUUID">World Link id to delete.</param> - /// <returns>OK, delete successful.</returns> + /// <returns>Success request.</returns> /// <exception cref="ApiException">A server side error occurred.</exception> - public virtual async System.Threading.Tasks.Task<string> DeleteWorldLinkAsync(string token, System.Guid worldLinkUUID, System.Threading.CancellationToken cancellationToken) + public virtual async System.Threading.Tasks.Task<Success> DeleteWorldLinkAsync(string token, System.Guid worldLinkUUID, System.Threading.CancellationToken cancellationToken) { if (worldLinkUUID == null) throw new System.ArgumentNullException("worldLinkUUID"); @@ -2293,7 +2562,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage if (token != null) request_.Headers.TryAddWithoutValidation("token", ConvertToString(token, System.Globalization.CultureInfo.InvariantCulture)); request_.Method = new System.Net.Http.HttpMethod("DELETE"); - request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("text/plain")); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); var urlBuilder_ = new System.Text.StringBuilder(); @@ -2326,23 +2595,32 @@ namespace ETSI.ARF.OpenAPI.WorldStorage var status_ = (int)response_.StatusCode; if (status_ == 200) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - return result_; + var objectResponse_ = await ReadObjectResponseAsync<Success>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; } else if (status_ == 400) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Invalid UUID supplied.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Invalid UUID supplied.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else if (status_ == 404) { - var responseData_ = response_.Content == null ? null : await response_.Content.ReadAsStringAsync().ConfigureAwait(false); - var result_ = (string)System.Convert.ChangeType(responseData_, typeof(string)); - throw new ApiException<string>("Not found, could not find UUID in database.", status_, responseData_, headers_, result_, null); + var objectResponse_ = await ReadObjectResponseAsync<Error>(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException<Error>("Not found, could not find UUID in database.", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); } else { @@ -2479,7 +2757,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <summary> /// An element representing all information needed in relation with a Trackable or a WorldAnchor. /// </summary> - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public partial class RelocalizationInformation { /// <summary> @@ -2512,7 +2790,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <summary> /// An element representing a Trackable object in the real world. /// </summary> - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public partial class Trackable { /// <summary> @@ -2576,7 +2854,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <summary> /// An element describing a pose in the world graph. /// </summary> - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public partial class WorldAnchor { /// <summary> @@ -2624,7 +2902,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <summary> /// An object holding the info of a transform between two elements. /// </summary> - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public partial class WorldLink { /// <summary> @@ -2683,7 +2961,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <summary> /// List of additional parameters to be stored with the object. /// </summary> - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public partial class KeyvalueTagList : System.Collections.Generic.Dictionary<string, System.Collections.ObjectModel.Collection<string>> { @@ -2692,7 +2970,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <summary> /// An object representing a supported capability of the World Analysis and its associated metadata /// </summary> - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public partial class Capability { [Newtonsoft.Json.JsonProperty("trackableType", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] @@ -2734,7 +3012,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <summary> /// An object holding the info of a Trackable`'`s encoding information `:` the data format and the version. /// </summary> - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public partial class EncodingInformationStructure { /// <summary> @@ -2761,13 +3039,10 @@ namespace ETSI.ARF.OpenAPI.WorldStorage } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public partial class Error { - [Newtonsoft.Json.JsonProperty("code", Required = Newtonsoft.Json.Required.Always)] - public int Code { get; set; } - - [Newtonsoft.Json.JsonProperty("message", Required = Newtonsoft.Json.Required.Always)] + [Newtonsoft.Json.JsonProperty("message", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public string Message { get; set; } private System.Collections.Generic.IDictionary<string, object> _additionalProperties; @@ -2784,7 +3059,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <summary> /// Mode representing the context of the relocalization information (AR device to WorldAnchor/Trackable or WorldAnchor/Trackable to AR device) /// </summary> - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public enum Mode_WorldStorage { @@ -2799,16 +3074,33 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <summary> /// Size object in format {width, length, depth}. /// </summary> - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public partial class Size : System.Collections.ObjectModel.Collection<double> { } + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class Success + { + [Newtonsoft.Json.JsonProperty("message", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Message { get; set; } + + private System.Collections.Generic.IDictionary<string, object> _additionalProperties; + + [Newtonsoft.Json.JsonExtensionData] + public System.Collections.Generic.IDictionary<string, object> AdditionalProperties + { + get { return _additionalProperties ?? (_additionalProperties = new System.Collections.Generic.Dictionary<string, object>()); } + set { _additionalProperties = value; } + } + + } + /// <summary> /// Type for trackable /// </summary> - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public enum TrackableType { @@ -2835,7 +3127,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <summary> /// Coordinate reference system of the world anchor, a 4*4 matrix (rowmajor) represented by a float vector. /// </summary> - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public partial class Transform3D : System.Collections.ObjectModel.Collection<float> { @@ -2844,7 +3136,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <summary> /// Trackable or Anchor /// </summary> - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public enum TypeWorldStorage { @@ -2862,7 +3154,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <summary> /// Unit of length. /// </summary> - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public enum UnitSystem { @@ -2901,8 +3193,8 @@ namespace ETSI.ARF.OpenAPI.WorldStorage } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] - public partial class Anonymous + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class UuidAndMode { [Newtonsoft.Json.JsonProperty("uuid", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Guid Uuid { get; set; } @@ -2922,8 +3214,8 @@ namespace ETSI.ARF.OpenAPI.WorldStorage } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] - public partial class Response + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class RelocalizationInformations { [Newtonsoft.Json.JsonProperty("RelocInfo", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public System.Collections.Generic.ICollection<RelocalizationInformation> RelocInfo { get; set; } @@ -2939,7 +3231,58 @@ namespace ETSI.ARF.OpenAPI.WorldStorage } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class TrackablesResponse + { + [Newtonsoft.Json.JsonProperty("trackables", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.ICollection<Trackable> Trackables { get; set; } + + private System.Collections.Generic.IDictionary<string, object> _additionalProperties; + + [Newtonsoft.Json.JsonExtensionData] + public System.Collections.Generic.IDictionary<string, object> AdditionalProperties + { + get { return _additionalProperties ?? (_additionalProperties = new System.Collections.Generic.Dictionary<string, object>()); } + set { _additionalProperties = value; } + } + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class WorldAnchorsResponse + { + [Newtonsoft.Json.JsonProperty("worldAnchors", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.ICollection<WorldAnchor> WorldAnchors { get; set; } + + private System.Collections.Generic.IDictionary<string, object> _additionalProperties; + + [Newtonsoft.Json.JsonExtensionData] + public System.Collections.Generic.IDictionary<string, object> AdditionalProperties + { + get { return _additionalProperties ?? (_additionalProperties = new System.Collections.Generic.Dictionary<string, object>()); } + set { _additionalProperties = value; } + } + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class WorldLinksResponse + { + [Newtonsoft.Json.JsonProperty("worldLinks", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.ICollection<WorldLink> WorldLinks { get; set; } + + private System.Collections.Generic.IDictionary<string, object> _additionalProperties; + + [Newtonsoft.Json.JsonExtensionData] + public System.Collections.Generic.IDictionary<string, object> AdditionalProperties + { + get { return _additionalProperties ?? (_additionalProperties = new System.Collections.Generic.Dictionary<string, object>()); } + set { _additionalProperties = value; } + } + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public partial class RelocObjects { [Newtonsoft.Json.JsonProperty("trackable", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] @@ -2963,7 +3306,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage } - [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public enum EncodingInformationStructureDataFormat { @@ -2989,7 +3332,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage - [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public partial class ApiException : System.Exception { public int StatusCode { get; private set; } @@ -3012,7 +3355,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage } } - [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.0.7.0 (NJsonSchema v11.0.0.0 (Newtonsoft.Json v13.0.0.0))")] + [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")] public partial class ApiException<TResult> : ApiException { public TResult Result { get; private set; } diff --git a/Runtime/Scripts/OpenAPI/UnityWebRequestHttpClient.cs b/Runtime/Scripts/OpenAPI/UnityWebRequestHttpClient.cs index a119a0375914003c13a4416c08a6a837f45ab65e..43fd7f0d1fdcb5fa8ebd46b7ef7cec46463e618c 100644 --- a/Runtime/Scripts/OpenAPI/UnityWebRequestHttpClient.cs +++ b/Runtime/Scripts/OpenAPI/UnityWebRequestHttpClient.cs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // -// Last change: June 2024 +// Last change: September 2024 // // Depends on UniTask to support cancellation token and GetAwaiter: https://github.com/Cysharp/UniTask @@ -55,10 +55,10 @@ namespace ETSI.ARF.OpenAPI.WorldStorage public BasicHTTPClient(string baseUri) { BaseAddress = new Uri(baseUri); - _httpClient.BaseAddress = BaseAddress; + _httpClient.BaseAddress = BaseAddress; } - public BasicHTTPClient (Uri baseUri) + public BasicHTTPClient(Uri baseUri) { BaseAddress = baseUri; _httpClient.BaseAddress = BaseAddress; @@ -71,10 +71,10 @@ namespace ETSI.ARF.OpenAPI.WorldStorage public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage message, HttpCompletionOption option, CancellationToken token) { - return await _httpClient.SendAsync(message, option, token); + return await _httpClient.SendAsync(message, option, token); } - public void Dispose() + public void Dispose() { _httpClient.Dispose(); DefaultRequestHeaders.Clear(); @@ -101,6 +101,21 @@ namespace ETSI.ARF.OpenAPI.WorldStorage private readonly HttpClient _httpClient = new HttpClient(); + private void AppendARFHeaders(HttpRequestMessage message, UnityWebRequest webRequest) + { + // Add some ARF headers + foreach (var item in message.Headers) + { + try + { + List<string> li = item.Value as List<string>; + if (item.Key == "token") webRequest.SetRequestHeader(item.Key, li[0].ToString()); // add it + if (item.Key == "sessionID") webRequest.SetRequestHeader(item.Key, li[0].ToString()); // add it + } + catch { } // ignore it + } + } + public async Task<HttpResponseMessage> SendAsync(HttpRequestMessage message, HttpCompletionOption option, CancellationToken token) { var content = await (message.Content?.ReadAsStringAsync() ?? Task.FromResult("")); @@ -108,6 +123,9 @@ namespace ETSI.ARF.OpenAPI.WorldStorage AppendHeaders(webRequest); + // Add the ARF API headers + AppendARFHeaders(message, webRequest); + Debug.Log("[HTTP] Request " + webRequest.uri.ToString()); try { @@ -178,6 +196,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage var (key, value) = enumerator.Current; webRequest.SetRequestHeader(key, value.First()); } + } private HttpResponseMessage CreateHttpResponseMessage(UnityWebRequest webRequest) diff --git a/Runtime/Scripts/REST/RelocalizationInformationRequest.cs b/Runtime/Scripts/REST/RelocalizationInformationRequest.cs index 5223399ae86e82e3be0aa011c423c7f079ac3f3e..1113d6a8307730aa71b485ec9747f93402504735 100644 --- a/Runtime/Scripts/REST/RelocalizationInformationRequest.cs +++ b/Runtime/Scripts/REST/RelocalizationInformationRequest.cs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // -// Last change: May 2024 +// Last change: September 2024 // using System; using System.Collections.Generic; @@ -25,53 +25,53 @@ using Newtonsoft.Json; namespace ETSI.ARF.WorldStorage.REST { - public class RelocalizationInformationRequest : RequestBase<Response> + public class RelocalizationInformationRequest : RequestBase<RelocalizationInformations> { - static public ResponseObject<Response> GetRelocalizationInformationAsync(WorldStorageServer ws, List<Guid> uuids, List<Mode_WorldStorage> modes, List<Capability> capabilities, Action<ResponseObject<Response>> func) + static public ResponseObject<RelocalizationInformations> GetRelocalizationInformationAsync(WorldStorageServer ws, List<Guid> uuids, List<Mode_WorldStorage> modes, List<Capability> capabilities, Action<ResponseObject<RelocalizationInformations>> func) { wsServer = ws; var httpClient = new UnityWebRequestHttpClient(ws.URI); apiClient = new MyWorldStorageClient(httpClient); - ResponseObject<Response> ro = new ResponseObject<Response>("Request Reloc Information ", func); + ResponseObject<RelocalizationInformations> ro = new ResponseObject<RelocalizationInformations>("Request Reloc Information ", func); - List<Anonymous> anonymous = new List<Anonymous>(); + List<UuidAndMode> anonymous = new List<UuidAndMode>(); for (int i = 0; i< uuids.Count; i++) { // Check same size or give anonymous as parameter? - Anonymous newOne = new Anonymous(); + UuidAndMode newOne = new UuidAndMode(); newOne.Uuid = uuids[i]; newOne.Mode = modes[i]; anonymous.Add(newOne); } - apiClient.GetRelocalizationInformationAsync(token, anonymous, capabilities, ro.cancellationToken).ContinueWith(OnReceiveObject<Response>, ro); + apiClient.GetRelocalizationInformationAsync(token, anonymous, capabilities, ro.cancellationToken).ContinueWith(OnReceiveObject<RelocalizationInformations>, ro); return ro; } - static public Response GetRelocalizationInformation(WorldStorageServer ws, List<Guid> uuids, List<Mode_WorldStorage> modes, List<Capability> capabilities) + static public RelocalizationInformations GetRelocalizationInformation(WorldStorageServer ws, List<Guid> uuids, List<Mode_WorldStorage> modes, List<Capability> capabilities) { return GetRelocalizationInformationSync(ws, uuids, modes, capabilities); } - static public Response GetRelocalizationInformationSync(WorldStorageServer ws, List<Guid> uuids, List<Mode_WorldStorage> modes, List<Capability> capabilities) + static public RelocalizationInformations GetRelocalizationInformationSync(WorldStorageServer ws, List<Guid> uuids, List<Mode_WorldStorage> modes, List<Capability> capabilities) { wsServer = ws; var httpClient = new BasicHTTPClient(ws.URI); apiClient = new MyWorldStorageClient(httpClient); - List<Anonymous> anonymous = new List<Anonymous>(); + List<UuidAndMode> anonymous = new List<UuidAndMode>(); for (int i = 0; i < uuids.Count; i++) { // Check same size or give anonymous as parameter? - Anonymous newOne = new Anonymous(); + UuidAndMode newOne = new UuidAndMode(); newOne.Uuid = uuids[i]; newOne.Mode = modes[i]; anonymous.Add(newOne); } - Response ro = apiClient.GetRelocalizationInformation(token, anonymous, capabilities); + RelocalizationInformations ro = apiClient.GetRelocalizationInformation(token, anonymous, capabilities); return ro; } } @@ -125,7 +125,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage /// <exception cref="ApiException"></exception> /// <exception cref="ApiException{string}"></exception> /// <exception cref="ApiException{Error}"></exception> - public override async System.Threading.Tasks.Task<Response> GetRelocalizationInformationAsync(string token, System.Collections.Generic.IEnumerable<Anonymous> uuids, System.Collections.Generic.IEnumerable<Capability> capabilities, System.Threading.CancellationToken cancellationToken) + public override async System.Threading.Tasks.Task<RelocalizationInformations> GetRelocalizationInformationAsync(string token, System.Collections.Generic.IEnumerable<UuidAndMode> uuids, System.Collections.Generic.IEnumerable<Capability> capabilities, System.Threading.CancellationToken cancellationToken) { if (uuids == null) throw new System.ArgumentNullException("uuids"); @@ -178,7 +178,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage var status_ = (int)response_.StatusCode; if (status_ == 200) { - var objectResponse_ = await ReadObjectResponseAsync<Response>(response_, headers_, cancellationToken).ConfigureAwait(false); + var objectResponse_ = await ReadObjectResponseAsync<RelocalizationInformations>(response_, headers_, cancellationToken).ConfigureAwait(false); if (objectResponse_.Object == null) { throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); diff --git a/Runtime/Scripts/REST/RequestBase.cs b/Runtime/Scripts/REST/RequestBase.cs index 776541f15886e6473a20d3ebbc060804f26b673a..8a369f5b1fe43be45caf2562444b9197a817b453 100644 --- a/Runtime/Scripts/REST/RequestBase.cs +++ b/Runtime/Scripts/REST/RequestBase.cs @@ -15,7 +15,7 @@ // See the License for the specific language governing permissions and // limitations under the License. // -// Last change: March 2024 +// Last change: September 2024 // using System; @@ -33,7 +33,7 @@ namespace ETSI.ARF.WorldStorage.REST static protected WorldStorageServer wsServer; static protected WorldStorageClient apiClient; - static protected string token = "ARF_Permission"; + static protected string token = "dev"; // only for development // Cache the current list static public Dictionary<Guid, object> listOfObjects = new Dictionary<Guid, object>(); @@ -56,7 +56,58 @@ namespace ETSI.ARF.WorldStorage.REST else Debug.Log("[REST] OpenAPI Timeout!"); } - static protected void OnReceiveListOfObjects<TObj>(Task<List<TObj>> t, object id) where TObj : IModel + static protected void OnReceiveListOfObjects<TObj>(Task<TObj> t, object id) // where TObj : IModel + { + if (t.IsCompleted) + { + ResponseObject<TObj> o = (ResponseObject<TObj>)id; + o.responseTime = DateTime.Now; + o.result = t.Result; + Debug.Log($"[REST] " + o.result.GetType()); + + // Adapation for new API, SylR + int cnt = 0; + + // Remember the new list + listOfObjects.Clear(); + + // Get the new list + if (o.result.GetType() == typeof(TrackablesResponse)) + { + Debug.Log($"[REST] TR"); + TrackablesResponse res = o.result as TrackablesResponse; + foreach (var item in res.Trackables) + { + listOfObjects.Add(item.UUID, item); + cnt++; + } + } + else if (o.GetType() == typeof(WorldAnchorsResponse)) + { + WorldAnchorsResponse res = o as WorldAnchorsResponse; + foreach (var item in res.WorldAnchors) + { + listOfObjects.Add(item.UUID, item); + cnt++; + } + } + else if (o.GetType() == typeof(WorldLinksResponse)) + { + WorldLinksResponse res = o as WorldLinksResponse; + foreach (var item in res.WorldLinks) + { + listOfObjects.Add(item.UUID, item); + cnt++; + } + } + + Debug.Log($"[REST] Server Response = Got {cnt} entrie(s) (ID={o.transactionId}, Msg={o.message})"); + o.callback?.Invoke(o); + } + else Debug.Log("[REST] OpenAPI Timeout!"); + } + + static protected void old_OnReceiveListOfObjects<TObj>(Task<List<TObj>> t, object id) where TObj : IModel { if (t.IsCompleted) { diff --git a/Runtime/Scripts/REST/TrackableRequest.cs b/Runtime/Scripts/REST/TrackableRequest.cs index 9aa9adfc9db327db1cd42097c5516cad3354c468..ec208b3512f3f4cb31774074dff207ba4b704762 100644 --- a/Runtime/Scripts/REST/TrackableRequest.cs +++ b/Runtime/Scripts/REST/TrackableRequest.cs @@ -60,20 +60,20 @@ namespace ETSI.ARF.WorldStorage.REST wsServer = ws; var httpClient = new BasicHTTPClient(ws.URI); apiClient = new WorldStorageClient(httpClient); - + Debug.Log("[REST] Request Trackables..."); - return apiClient.GetTrackables(token); + return apiClient.GetTrackables(token).Trackables as List<Trackable>; } - static public ResponseObject<List<Trackable>> GetTrackablesAsync(WorldStorageServer ws, Action<ResponseObject<List<Trackable>>> func) + static public ResponseObject<TrackablesResponse> GetTrackablesAsync(WorldStorageServer ws, Action<ResponseObject<TrackablesResponse>> func) { wsServer = ws; var httpClient = new UnityWebRequestHttpClient(ws.URI); apiClient = new WorldStorageClient(httpClient); Debug.Log("[REST] Request Trackables..."); - ResponseObject<List<Trackable>> ro = new ResponseObject<List<Trackable>>("Request Trackables", func); - apiClient.GetTrackablesAsync(token, ro.cancellationToken).ContinueWith(OnReceiveListOfObjects<Trackable>, ro); + ResponseObject<TrackablesResponse> ro = new ResponseObject<TrackablesResponse>("Request Trackables", func); + apiClient.GetTrackablesAsync(token, ro.cancellationToken).ContinueWith(OnReceiveListOfObjects<TrackablesResponse>, ro); return ro; } @@ -88,10 +88,10 @@ namespace ETSI.ARF.WorldStorage.REST if (trackable.CreatorUUID == Guid.Empty) trackable.CreatorUUID = System.Guid.Parse("8fb169e2-8910-4cd5-a8f9-b7abff38d013"); Debug.Log($"[REST] Create Trackable {trackable.UUID}..."); - return apiClient.AddTrackable(token, trackable); + return apiClient.AddTrackable(token, trackable).Message; } - static public ResponseObject<string> CreateTrackableAsync(WorldStorageServer ws, Trackable trackable, Action<ResponseObject<string>> func) + static public ResponseObject<Success> CreateTrackableAsync(WorldStorageServer ws, Trackable trackable, Action<ResponseObject<Success>> func) { wsServer = ws; var httpClient = new UnityWebRequestHttpClient(ws.URI); @@ -103,8 +103,8 @@ namespace ETSI.ARF.WorldStorage.REST Debug.Log($"[REST] Create Trackable {trackable.UUID}..."); - ResponseObject<string> ro = new ResponseObject<string>("Create Trackable " + trackable.Name + " (no UUID)", func); - apiClient.AddTrackableAsync(token, trackable, ro.cancellationToken).ContinueWith(OnReceiveObject<string>, ro); + ResponseObject<Success> ro = new ResponseObject<Success>("Create Trackable " + trackable.Name + " (no UUID)", func); + apiClient.AddTrackableAsync(token, trackable, ro.cancellationToken).ContinueWith(OnReceiveObject<Success>, ro); return ro; } @@ -115,18 +115,18 @@ namespace ETSI.ARF.WorldStorage.REST apiClient = new WorldStorageClient(httpClient); Debug.Log($"[REST] Update Trackable {trackable.UUID}..."); - return apiClient.ModifyTrackable(token, trackable); + return apiClient.ModifyTrackable(token, trackable).Message; } - static public ResponseObject<string> UpdateTrackableAsync(WorldStorageServer ws, Trackable trackable, Action<ResponseObject<string>> func) + static public ResponseObject<Success> UpdateTrackableAsync(WorldStorageServer ws, Trackable trackable, Action<ResponseObject<Success>> func) { wsServer = ws; var httpClient = new UnityWebRequestHttpClient(ws.URI); apiClient = new WorldStorageClient(httpClient); Debug.Log($"[REST] Update Trackable {trackable.UUID}..."); - ResponseObject<string> ro = new ResponseObject<string>("Update Trackable " + trackable.UUID.ToString(), func); - apiClient.ModifyTrackableAsync(token, trackable,ro.cancellationToken).ContinueWith(OnReceiveObject<string>, ro); + ResponseObject<Success> ro = new ResponseObject<Success>("Update Trackable " + trackable.UUID.ToString(), func); + apiClient.ModifyTrackableAsync(token, trackable,ro.cancellationToken).ContinueWith(OnReceiveObject<Success>, ro); return ro; } @@ -137,18 +137,18 @@ namespace ETSI.ARF.WorldStorage.REST apiClient = new WorldStorageClient(httpClient); Debug.Log($"[REST] Delete Trackable {UUID}..."); - return apiClient.DeleteTrackable(token, UUID); + return apiClient.DeleteTrackable(token, UUID).Message; } - static public ResponseObject<string> DeleteTrackableAsync(WorldStorageServer ws, Guid UUID, Action<ResponseObject<string>> func) + static public ResponseObject<Success> DeleteTrackableAsync(WorldStorageServer ws, Guid UUID, Action<ResponseObject<Success>> func) { wsServer = ws; var httpClient = new UnityWebRequestHttpClient(ws.URI); apiClient = new WorldStorageClient(httpClient); Debug.Log($"[REST] Delete Trackable {UUID}..."); - ResponseObject<string> ro = new ResponseObject<string>("Delete Trackable " + UUID.ToString(), func); - apiClient.DeleteTrackableAsync(token, UUID, ro.cancellationToken).ContinueWith(OnReceiveObject<string>, ro); + ResponseObject<Success> ro = new ResponseObject<Success>("Delete Trackable " + UUID.ToString(), func); + apiClient.DeleteTrackableAsync(token, UUID, ro.cancellationToken).ContinueWith(OnReceiveObject<Success>, ro); return ro; } } diff --git a/Runtime/Scripts/REST/WorldAnchorRequest.cs b/Runtime/Scripts/REST/WorldAnchorRequest.cs index d6b2c958f418aa4adc891bff387c7ea9cd65a895..07495de6871eba1663260427d7de94c229198b20 100644 --- a/Runtime/Scripts/REST/WorldAnchorRequest.cs +++ b/Runtime/Scripts/REST/WorldAnchorRequest.cs @@ -63,18 +63,18 @@ namespace ETSI.ARF.WorldStorage.REST apiClient = new WorldStorageClient(httpClient); Debug.Log("[REST] Request WorldAnchors..."); - return apiClient.GetWorldAnchors(token); + return apiClient.GetWorldAnchors(token).WorldAnchors as List<WorldAnchor>; } - static public ResponseObject<List<WorldAnchor>> GetWorldAnchorsAsync(WorldStorageServer ws, Action<ResponseObject<List<WorldAnchor>>> func) + static public ResponseObject<WorldAnchorsResponse> GetWorldAnchorsAsync(WorldStorageServer ws, Action<ResponseObject<WorldAnchorsResponse>> func) { wsServer = ws; var httpClient = new UnityWebRequestHttpClient(ws.URI); apiClient = new WorldStorageClient(httpClient); Debug.Log("[REST] Request WorldAnchors..."); - ResponseObject<List<WorldAnchor>> ro = new ResponseObject<List<WorldAnchor>>("Request WorldAnchors", func); - apiClient.GetWorldAnchorsAsync(token, ro.cancellationToken).ContinueWith(OnReceiveListOfObjects<WorldAnchor>, ro); + ResponseObject<WorldAnchorsResponse> ro = new ResponseObject<WorldAnchorsResponse>("Request WorldAnchors", func); + apiClient.GetWorldAnchorsAsync(token, ro.cancellationToken).ContinueWith(OnReceiveListOfObjects<WorldAnchorsResponse>, ro); return ro; } @@ -89,10 +89,10 @@ namespace ETSI.ARF.WorldStorage.REST if (worldAnchor.CreatorUUID == Guid.Empty) worldAnchor.CreatorUUID = System.Guid.Parse("8fb169e2-8910-4cd5-a8f9-b7abff38d013"); Debug.Log($"[REST] Create WorldAnchor {worldAnchor.UUID}..."); - return apiClient.AddWorldAnchor(token, worldAnchor); + return apiClient.AddWorldAnchor(token, worldAnchor).Message; } - static public ResponseObject<string> CreateWorldAnchorAsync(WorldStorageServer ws, WorldAnchor worldAnchor, Action<ResponseObject<string>> func) + static public ResponseObject<Success> CreateWorldAnchorAsync(WorldStorageServer ws, WorldAnchor worldAnchor, Action<ResponseObject<Success>> func) { wsServer = ws; var httpClient = new UnityWebRequestHttpClient(ws.URI); @@ -103,8 +103,8 @@ namespace ETSI.ARF.WorldStorage.REST if (worldAnchor.CreatorUUID == Guid.Empty) worldAnchor.CreatorUUID = System.Guid.Parse("8fb169e2-8910-4cd5-a8f9-b7abff38d013"); Debug.Log($"[REST] Create WorldAnchor {worldAnchor.UUID}..."); - ResponseObject<string> ro = new ResponseObject<string>("Create WorldAnchor " + worldAnchor.Name + " (no UUID)", func); - apiClient.AddWorldAnchorAsync(token, worldAnchor, ro.cancellationToken).ContinueWith(OnReceiveObject<string>, ro); + ResponseObject<Success> ro = new ResponseObject<Success>("Create WorldAnchor " + worldAnchor.Name + " (no UUID)", func); + apiClient.AddWorldAnchorAsync(token, worldAnchor, ro.cancellationToken).ContinueWith(OnReceiveObject<Success>, ro); return ro; } @@ -115,18 +115,18 @@ namespace ETSI.ARF.WorldStorage.REST apiClient = new WorldStorageClient(httpClient); Debug.Log($"[REST] Update WorldAnchor {worldAnchor.UUID}..."); - return apiClient.ModifyWorldAnchor(token, worldAnchor); + return apiClient.ModifyWorldAnchor(token, worldAnchor).Message; } - static public ResponseObject<string> UpdateWorldAnchorAsync(WorldStorageServer ws, WorldAnchor worldAnchor, Action<ResponseObject<string>> func) + static public ResponseObject<Success> UpdateWorldAnchorAsync(WorldStorageServer ws, WorldAnchor worldAnchor, Action<ResponseObject<Success>> func) { wsServer = ws; var httpClient = new UnityWebRequestHttpClient(ws.URI); apiClient = new WorldStorageClient(httpClient); Debug.Log($"[REST] Update WorldAnchor {worldAnchor.UUID}..."); - ResponseObject<string> ro = new ResponseObject<string>("Update WorldAnchor " + worldAnchor.UUID.ToString(), func); - apiClient.ModifyWorldAnchorAsync(token, worldAnchor, ro.cancellationToken).ContinueWith(OnReceiveObject<string>, ro); + ResponseObject<Success> ro = new ResponseObject<Success>("Update WorldAnchor " + worldAnchor.UUID.ToString(), func); + apiClient.ModifyWorldAnchorAsync(token, worldAnchor, ro.cancellationToken).ContinueWith(OnReceiveObject<Success>, ro); return ro; } @@ -137,18 +137,18 @@ namespace ETSI.ARF.WorldStorage.REST apiClient = new WorldStorageClient(httpClient); Debug.Log($"[REST] Delete WorldAnchor {UUID}..."); - return apiClient.DeleteWorldAnchor(token, UUID); + return apiClient.DeleteWorldAnchor(token, UUID).Message; } - static public ResponseObject<string> DeleteWorldAnchorAsync(WorldStorageServer ws, Guid UUID, Action<ResponseObject<string>> func) + static public ResponseObject<Success> DeleteWorldAnchorAsync(WorldStorageServer ws, Guid UUID, Action<ResponseObject<Success>> func) { wsServer = ws; var httpClient = new UnityWebRequestHttpClient(ws.URI); apiClient = new WorldStorageClient(httpClient); Debug.Log($"[REST] Delete WorldAnchor {UUID}..."); - ResponseObject<string> ro = new ResponseObject<string>("Delete WorldAnchor " + UUID.ToString(), func); - apiClient.DeleteWorldAnchorAsync(token, UUID, ro.cancellationToken).ContinueWith(OnReceiveObject<string>, ro); + ResponseObject<Success> ro = new ResponseObject<Success>("Delete WorldAnchor " + UUID.ToString(), func); + apiClient.DeleteWorldAnchorAsync(token, UUID, ro.cancellationToken).ContinueWith(OnReceiveObject<Success>, ro); return ro; } } diff --git a/Runtime/Scripts/REST/WorldLinkRequest.cs b/Runtime/Scripts/REST/WorldLinkRequest.cs index 44b489fc9c4e2d5661de513c994b0c0aeeb751f2..d38e1d56f88760eba9468bcae2f834969d496f24 100644 --- a/Runtime/Scripts/REST/WorldLinkRequest.cs +++ b/Runtime/Scripts/REST/WorldLinkRequest.cs @@ -62,18 +62,18 @@ namespace ETSI.ARF.WorldStorage.REST apiClient = new WorldStorageClient(httpClient); Debug.Log("[REST] Request WorldLinks..."); - return apiClient.GetWorldLinks(token); + return apiClient.GetWorldLinks(token).WorldLinks as List<WorldLink>; } - static public ResponseObject<List<WorldLink>> GetWorldLinksAsync(WorldStorageServer ws, Action<ResponseObject<List<WorldLink>>> func) + static public ResponseObject<WorldLinksResponse> GetWorldLinksAsync(WorldStorageServer ws, Action<ResponseObject<WorldLinksResponse>> func) { wsServer = ws; var httpClient = new UnityWebRequestHttpClient(ws.URI); apiClient = new WorldStorageClient(httpClient); Debug.Log("[REST] Request WorldLinks..."); - ResponseObject<List<WorldLink>> ro = new ResponseObject<List<WorldLink>>("Request WorldLinks", func); - apiClient.GetWorldLinksAsync(token, ro.cancellationToken).ContinueWith(OnReceiveListOfObjects<WorldLink>, ro); + ResponseObject<WorldLinksResponse> ro = new ResponseObject<WorldLinksResponse>("Request WorldLinks", func); + apiClient.GetWorldLinksAsync(token, ro.cancellationToken).ContinueWith(OnReceiveListOfObjects<WorldLinksResponse>, ro); return ro; } @@ -88,10 +88,10 @@ namespace ETSI.ARF.WorldStorage.REST if (worldLink.CreatorUUID == Guid.Empty) worldLink.CreatorUUID = System.Guid.Parse("8fb169e2-8910-4cd5-a8f9-b7abff38d013"); Debug.Log($"[REST] Create WorldLink {worldLink.UUID}..."); - return apiClient.AddWorldLink(token, worldLink); + return apiClient.AddWorldLink(token, worldLink).Message; } - static public ResponseObject<string> CreateWorldLinkAsync(WorldStorageServer ws, WorldLink worldLink, Action<ResponseObject<string>> func) + static public ResponseObject<Success> CreateWorldLinkAsync(WorldStorageServer ws, WorldLink worldLink, Action<ResponseObject<Success>> func) { wsServer = ws; var httpClient = new UnityWebRequestHttpClient(ws.URI); @@ -102,8 +102,8 @@ namespace ETSI.ARF.WorldStorage.REST if (worldLink.CreatorUUID == Guid.Empty) worldLink.CreatorUUID = System.Guid.Parse("8fb169e2-8910-4cd5-a8f9-b7abff38d013"); Debug.Log($"[REST] Create WorldLink {worldLink.UUID}..."); - ResponseObject<string> ro = new ResponseObject<string>("Create WorldLink (no UUID)", func); - apiClient.AddWorldLinkAsync(token, worldLink, ro.cancellationToken).ContinueWith(OnReceiveObject<string>, ro); + ResponseObject<Success> ro = new ResponseObject<Success>("Create WorldLink (no UUID)", func); + apiClient.AddWorldLinkAsync(token, worldLink, ro.cancellationToken).ContinueWith(OnReceiveObject<Success>, ro); return ro; } @@ -114,18 +114,18 @@ namespace ETSI.ARF.WorldStorage.REST apiClient = new WorldStorageClient(httpClient); Debug.Log($"[REST] Update WorldLink {worldLink.UUID}..."); - return apiClient.ModifyWorldLink(token, worldLink); + return apiClient.ModifyWorldLink(token, worldLink).Message; } - static public ResponseObject<string> UpdateWorldLinkAsync(WorldStorageServer ws, WorldLink worldLink, Action<ResponseObject<string>> func) + static public ResponseObject<Success> UpdateWorldLinkAsync(WorldStorageServer ws, WorldLink worldLink, Action<ResponseObject<Success>> func) { wsServer = ws; var httpClient = new UnityWebRequestHttpClient(ws.URI); apiClient = new WorldStorageClient(httpClient); Debug.Log($"[REST] Update WorldLink {worldLink.UUID}..."); - ResponseObject<string> ro = new ResponseObject<string>("Update WorldLink " + worldLink.UUID.ToString(), func); - apiClient.ModifyWorldLinkAsync(token, worldLink, ro.cancellationToken).ContinueWith(OnReceiveObject<string>, ro); + ResponseObject<Success> ro = new ResponseObject<Success>("Update WorldLink " + worldLink.UUID.ToString(), func); + apiClient.ModifyWorldLinkAsync(token, worldLink, ro.cancellationToken).ContinueWith(OnReceiveObject<Success>, ro); return ro; } @@ -136,18 +136,18 @@ namespace ETSI.ARF.WorldStorage.REST apiClient = new WorldStorageClient(httpClient); Debug.Log($"[REST] Delete WorldLink {UUID}..."); - return apiClient.DeleteWorldLink(token, UUID); + return apiClient.DeleteWorldLink(token, UUID).Message; } - static public ResponseObject<string> DeleteWorldLinkAsync(WorldStorageServer ws, Guid UUID, Action<ResponseObject<string>> func) + static public ResponseObject<Success> DeleteWorldLinkAsync(WorldStorageServer ws, Guid UUID, Action<ResponseObject<Success>> func) { wsServer = ws; var httpClient = new UnityWebRequestHttpClient(ws.URI); apiClient = new WorldStorageClient(httpClient); Debug.Log($"[REST] Delete WorldLink {UUID}..."); - ResponseObject<string> ro = new ResponseObject<string>("Delete WorldLink " + UUID.ToString(), func); - apiClient.DeleteWorldLinkAsync(token, UUID, ro.cancellationToken).ContinueWith(OnReceiveObject<string>, ro); + ResponseObject<Success> ro = new ResponseObject<Success>("Delete WorldLink " + UUID.ToString(), func); + apiClient.DeleteWorldLinkAsync(token, UUID, ro.cancellationToken).ContinueWith(OnReceiveObject<Success>, ro); return ro; } }