Commit f36b78ff authored by Stephane LOUIS DIT PICARD's avatar Stephane LOUIS DIT PICARD
Browse files

refactor: add missing sync methods for trackables, world anchors and links requests

parent 5e91e323
Loading
Loading
Loading
Loading
+25 −5
Original line number Diff line number Diff line
@@ -32,10 +32,10 @@ namespace ETSI.ARF.WorldStorage.REST
        //
        // Wrapper for the endpoints
        //
        static private string Ping(WorldStorageServer ws)
        static public string PingSync(WorldStorageServer ws)
        {
            wsServer = ws;
            var httpClient = new UnityWebRequestHttpClient(ws.URI);
            var httpClient = new BasicHTTPClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            string response = apiClient.GetPing();
@@ -50,10 +50,20 @@ namespace ETSI.ARF.WorldStorage.REST

            Debug.Log("[REST] Request Ping...");
            ResponseObject<string> ro = new ResponseObject<string>("Request Ping", func);
            apiClient.GetPingAsync().ContinueWith(OnReceiveObject<string>, ro);
            apiClient.GetPingAsync(ro.cancellationToken).ContinueWith(OnReceiveObject<string>, ro);
            return ro;
        }

        static public string AdminSync(WorldStorageServer ws)
        {
            wsServer = ws;
            var httpClient = new BasicHTTPClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            string response = apiClient.GetAdmin();
            return response;
        }

        static public ResponseObject<string> AdminAsync(WorldStorageServer ws, Action<ResponseObject<string>> func)
        {
            wsServer = ws;
@@ -62,10 +72,20 @@ namespace ETSI.ARF.WorldStorage.REST

            Debug.Log("[REST] Request Admin...");
            ResponseObject<string> ro = new ResponseObject<string>("Request Admin", func);
            apiClient.GetAdminAsync().ContinueWith(OnReceiveObject<string>, ro);
            apiClient.GetAdminAsync(ro.cancellationToken).ContinueWith(OnReceiveObject<string>, ro);
            return ro;
        }

        static public string VersionSync(WorldStorageServer ws)
        {
            wsServer = ws;
            var httpClient = new BasicHTTPClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            string response = apiClient.GetVersion();
            return response;
        }

        static public ResponseObject<string> VersionAsync(WorldStorageServer ws, Action<ResponseObject<string>> func)
        {
            wsServer = ws;
@@ -74,7 +94,7 @@ namespace ETSI.ARF.WorldStorage.REST

            Debug.Log("[REST] Request Version...");
            ResponseObject<string> ro = new ResponseObject<string>("Request Version", func);
            apiClient.GetVersionAsync().ContinueWith(OnReceiveObject<string>, ro);
            apiClient.GetVersionAsync(ro.cancellationToken).ContinueWith(OnReceiveObject<string>, ro);
            return ro;
        }
    }
+8 −3
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ namespace ETSI.ARF.WorldStorage.REST
        {
            wsServer = ws;
            var httpClient = new UnityWebRequestHttpClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);
            apiClient = new MyWorldStorageClient(httpClient);

            ResponseObject<Response> ro = new ResponseObject<Response>("Request Reloc Information ", func);
           
@@ -45,12 +45,16 @@ namespace ETSI.ARF.WorldStorage.REST
                newOne.Mode = modes[i];
                anonymous.Add(newOne);
            }
            apiClient.GetRelocalizationInformationAsync(token, anonymous, capabilities).ContinueWith(OnReceiveObject<Response>, ro);
            apiClient.GetRelocalizationInformationAsync(token, anonymous, capabilities, ro.cancellationToken).ContinueWith(OnReceiveObject<Response>, ro);
            return ro;
        }


        static public Response 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)
        {
            wsServer = ws;
            var httpClient = new BasicHTTPClient(ws.URI);
@@ -102,6 +106,7 @@ namespace ETSI.ARF.OpenAPI.WorldStorage
        }
    }

    // Custom client to be able to properly serialize objects in the query string
    public partial class MyWorldStorageClient : WorldStorageClient
    {
        public MyWorldStorageClient(IHttpClient httpClient) : base(httpClient)
+50 −5
Original line number Diff line number Diff line
@@ -33,13 +33,23 @@ namespace ETSI.ARF.WorldStorage.REST
        //
        // Wrapper for the endpoints
        //
        static public Trackable GetTrackableSync(WorldStorageServer ws, Guid UUID)
        {
            wsServer = ws;
            var httpClient = new BasicHTTPClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log($"[REST] Request Trackable {UUID}...");
            return apiClient.GetTrackableById(token, UUID);
        }
        
        static public ResponseObject<Trackable> GetTrackableAsync(WorldStorageServer ws, Guid UUID, Action<ResponseObject<Trackable>> func)
        {
            wsServer = ws;
            var httpClient = new UnityWebRequestHttpClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log("[REST] Request 1 Trackable...");
            Debug.Log($"[REST] Request Trackable {UUID}...");
            ResponseObject<Trackable> ro = new ResponseObject<Trackable>("Request Trackable " + UUID.ToString(), func);
            apiClient.GetTrackableByIdAsync(token, UUID, ro.cancellationToken).ContinueWith(OnReceiveObject<Trackable>, ro);
            return ro;
@@ -67,41 +77,76 @@ namespace ETSI.ARF.WorldStorage.REST
            return ro;
        }

        static public string CreateTrackableSync(WorldStorageServer ws, Trackable trackable)
        {
            wsServer = ws;
            var httpClient = new BasicHTTPClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            // Add some management stuffs
            if (trackable.UUID == Guid.Empty) trackable.UUID = Guid.NewGuid();
            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);
        }

        static public ResponseObject<string> CreateTrackableAsync(WorldStorageServer ws, Trackable trackable, Action<ResponseObject<string>> func)
        {
            wsServer = ws;
            var httpClient = new UnityWebRequestHttpClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log("[REST] Create 1 Trackable...");

            // Add some management stuffs
            if (trackable.UUID == Guid.Empty) trackable.UUID = Guid.NewGuid();
            if (trackable.CreatorUUID == Guid.Empty) trackable.CreatorUUID = System.Guid.Parse("8fb169e2-8910-4cd5-a8f9-b7abff38d013");

            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);
            return ro;
        }

        static public string UpdateTrackableSync(WorldStorageServer ws, Trackable trackable)
        {
            wsServer = ws;
            var httpClient = new BasicHTTPClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log($"[REST] Update Trackable {trackable.UUID}...");
            return apiClient.ModifyTrackable(token, trackable);
        }

        static public ResponseObject<string> UpdateTrackableAsync(WorldStorageServer ws, Trackable trackable, Action<ResponseObject<string>> func)
        {
            wsServer = ws;
            var httpClient = new UnityWebRequestHttpClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log("[REST] Update Trackable...");
            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);
            return ro;
        }

        static public string DeleteTrackableSync(WorldStorageServer ws, Guid UUID)
        {
            wsServer = ws;
            var httpClient = new BasicHTTPClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log($"[REST] Delete Trackable {UUID}...");
            return apiClient.DeleteTrackable(token, UUID);
        }

        static public ResponseObject<string> DeleteTrackableAsync(WorldStorageServer ws, Guid UUID, Action<ResponseObject<string>> func)
        {
            wsServer = ws;
            var httpClient = new UnityWebRequestHttpClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log("[REST] Delete 1 Trackable...");
            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);
            return ro;
+50 −5
Original line number Diff line number Diff line
@@ -34,13 +34,23 @@ namespace ETSI.ARF.WorldStorage.REST
        //
        // Wrapper for the endpoints
        //
        static public WorldAnchor GetWorldAnchorSync(WorldStorageServer ws, Guid UUID)
        {
            wsServer = ws;
            var httpClient = new BasicHTTPClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log($"[REST] Request WorldAnchor {UUID}...");
            return apiClient.GetWorldAnchorById(token, UUID);
        }

        static public ResponseObject<WorldAnchor> GetWorldAnchorAsync(WorldStorageServer ws, Guid UUID, Action<ResponseObject<WorldAnchor>> func)
        {
            wsServer = ws;
            var httpClient = new UnityWebRequestHttpClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log("[REST] Request 1 WorldAnchor...");
            Debug.Log($"[REST] Request WorldAnchor {UUID}...");
            ResponseObject<WorldAnchor> ro = new ResponseObject<WorldAnchor>("Request WorldAnchor " + UUID.ToString(), func);
            apiClient.GetWorldAnchorByIdAsync(token, UUID, ro.cancellationToken).ContinueWith(OnReceiveObject<WorldAnchor>, ro);
            return ro;
@@ -52,6 +62,7 @@ namespace ETSI.ARF.WorldStorage.REST
            var httpClient = new BasicHTTPClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log("[REST] Request WorldAnchors...");
            return apiClient.GetWorldAnchors(token);
        }

@@ -67,41 +78,75 @@ namespace ETSI.ARF.WorldStorage.REST
            return ro;
        }

        static public string CreateWorldAnchorSync(WorldStorageServer ws, WorldAnchor worldAnchor)
        {
            wsServer = ws;
            var httpClient = new BasicHTTPClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            // Add some management stuffs
            if (worldAnchor.UUID == Guid.Empty) worldAnchor.UUID = Guid.NewGuid();
            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);
        }

        static public ResponseObject<string> CreateWorldAnchorAsync(WorldStorageServer ws, WorldAnchor worldAnchor, Action<ResponseObject<string>> func)
        {
            wsServer = ws;
            var httpClient = new UnityWebRequestHttpClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log("[REST] Create 1 WorldAnchor...");

            // Add some management stuffs
            if (worldAnchor.UUID == Guid.Empty) worldAnchor.UUID = Guid.NewGuid();
            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);
            return ro;
        }

        static public string UpdateWorldAnchorSync(WorldStorageServer ws, WorldAnchor worldAnchor)
        {
            wsServer = ws;
            var httpClient = new BasicHTTPClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log($"[REST] Update WorldAnchor {worldAnchor.UUID}...");
            return apiClient.ModifyWorldAnchor(token, worldAnchor);
        }

        static public ResponseObject<string> UpdateWorldAnchorAsync(WorldStorageServer ws, WorldAnchor worldAnchor, Action<ResponseObject<string>> func)
        {
            wsServer = ws;
            var httpClient = new UnityWebRequestHttpClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log("[REST] Update WorldAnchor...");
            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);
            return ro;
        }

        static public string DeleteWorldAnchorSync(WorldStorageServer ws, Guid UUID)
        {
            wsServer = ws;
            var httpClient = new BasicHTTPClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log($"[REST] Delete WorldAnchor {UUID}...");
            return apiClient.DeleteWorldAnchor(token, UUID);
        }

        static public ResponseObject<string> DeleteWorldAnchorAsync(WorldStorageServer ws, Guid UUID, Action<ResponseObject<string>> func)
        {
            wsServer = ws;
            var httpClient = new UnityWebRequestHttpClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log("[REST] Delete 1 WorldAnchor...");
            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);
            return ro;
+50 −5
Original line number Diff line number Diff line
@@ -33,13 +33,23 @@ namespace ETSI.ARF.WorldStorage.REST
        //
        // Wrapper for the endpoints
        //
        static public WorldLink GetWorldLinkSync(WorldStorageServer ws, Guid UUID)
        {
            wsServer = ws;
            var httpClient = new BasicHTTPClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log($"[REST] Request WorldLink {UUID}...");
            return apiClient.GetWorldLinkById(token, UUID);
        }

        static public ResponseObject<WorldLink> GetWorldLinkAsync(WorldStorageServer ws, Guid UUID, Action<ResponseObject<WorldLink>> func)
        {
            wsServer = ws;
            var httpClient = new UnityWebRequestHttpClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log("[REST] Request 1 WorldLink...");
            Debug.Log($"[REST] Request WorldLink {UUID}...");
            ResponseObject<WorldLink> ro = new ResponseObject<WorldLink>("Request WorldLink " + UUID.ToString(), func);
            apiClient.GetWorldLinkByIdAsync(token, UUID, ro.cancellationToken).ContinueWith(OnReceiveObject<WorldLink>, ro);
            return ro;
@@ -51,6 +61,7 @@ namespace ETSI.ARF.WorldStorage.REST
            var httpClient = new BasicHTTPClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log("[REST] Request WorldLinks...");
            return apiClient.GetWorldLinks(token);
        }

@@ -66,41 +77,75 @@ namespace ETSI.ARF.WorldStorage.REST
            return ro;
        }

        static public string CreateWorldLinkSync(WorldStorageServer ws, WorldLink worldLink)
        {
            wsServer = ws;
            var httpClient = new BasicHTTPClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            // Add some management stuffs
            if (worldLink.UUID == Guid.Empty) worldLink.UUID = Guid.NewGuid();
            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);
        }

        static public ResponseObject<string> CreateWorldLinkAsync(WorldStorageServer ws, WorldLink worldLink, Action<ResponseObject<string>> func)
        {
            wsServer = ws;
            var httpClient = new UnityWebRequestHttpClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log("[REST] Create 1 WorldLink...");

            // Add some management stuffs
            if (worldLink.UUID == Guid.Empty) worldLink.UUID = Guid.NewGuid();
            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);
            return ro;
        }

        static public string UpdateWorldLinkSync(WorldStorageServer ws, WorldLink worldLink)
        {
            wsServer = ws;
            var httpClient = new BasicHTTPClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log($"[REST] Update WorldLink {worldLink.UUID}...");
            return apiClient.ModifyWorldLink(token, worldLink);
        }

        static public ResponseObject<string> UpdateWorldLinkAsync(WorldStorageServer ws, WorldLink worldLink, Action<ResponseObject<string>> func)
        {
            wsServer = ws;
            var httpClient = new UnityWebRequestHttpClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log("[REST] Update WorldLink...");
            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);
            return ro;
        }

        static public string DeleteWorldLinkSync(WorldStorageServer ws, Guid UUID)
        {
            wsServer = ws;
            var httpClient = new BasicHTTPClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log($"[REST] Delete WorldLink {UUID}...");
            return apiClient.DeleteWorldLink(token, UUID);
        }

        static public ResponseObject<string> DeleteWorldLinkAsync(WorldStorageServer ws, Guid UUID, Action<ResponseObject<string>> func)
        {
            wsServer = ws;
            var httpClient = new UnityWebRequestHttpClient(ws.URI);
            apiClient = new WorldStorageClient(httpClient);

            Debug.Log("[REST] Delete 1 WorldLink...");
            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);
            return ro;