From 14e1e679ed253a6760c78f05fe1250d1a6b86f06 Mon Sep 17 00:00:00 2001 From: Sylvain Renault Date: Tue, 31 May 2022 18:15:12 +0200 Subject: [PATCH] Refacturing server, user. Changed some folder, script names, namespace... --- Assets/Editor/WorldStorageInfoEditor.cs | 22 +++++++ ...cs.meta => WorldStorageInfoEditor.cs.meta} | 0 Assets/Editor/WorldStorageServerEditor.cs | 18 ------ Assets/Runtime.meta | 8 +++ Assets/Runtime/REST.meta | 8 +++ Assets/Runtime/REST/AdminRequest.cs | 57 +++++++++++++++++ Assets/Runtime/REST/AdminRequest.cs.meta | 11 ++++ Assets/Runtime/REST/TrackableRequest.cs | 64 +++++++++++++++++++ Assets/Runtime/REST/TrackableRequest.cs.meta | 11 ++++ Assets/Runtime/REST/WorldAnchorRequest.cs | 64 +++++++++++++++++++ .../Runtime/REST/WorldAnchorRequest.cs.meta | 11 ++++ Assets/Runtime/WorldStorageInfo.cs | 40 ++++++++++++ Assets/Runtime/WorldStorageInfo.cs.meta | 11 ++++ Assets/Scriptables.meta | 8 +++ Assets/Scriptables/WorldStorageServer.cs | 21 ++++++ Assets/Scriptables/WorldStorageServer.cs.meta | 11 ++++ Assets/Scriptables/WorldStorageUser.cs | 15 +++++ Assets/Scriptables/WorldStorageUser.cs.meta | 11 ++++ package.json | 5 +- 19 files changed, 375 insertions(+), 21 deletions(-) create mode 100644 Assets/Editor/WorldStorageInfoEditor.cs rename Assets/Editor/{WorldStorageServerEditor.cs.meta => WorldStorageInfoEditor.cs.meta} (100%) delete mode 100644 Assets/Editor/WorldStorageServerEditor.cs create mode 100644 Assets/Runtime.meta create mode 100644 Assets/Runtime/REST.meta create mode 100644 Assets/Runtime/REST/AdminRequest.cs create mode 100644 Assets/Runtime/REST/AdminRequest.cs.meta create mode 100644 Assets/Runtime/REST/TrackableRequest.cs create mode 100644 Assets/Runtime/REST/TrackableRequest.cs.meta create mode 100644 Assets/Runtime/REST/WorldAnchorRequest.cs create mode 100644 Assets/Runtime/REST/WorldAnchorRequest.cs.meta create mode 100644 Assets/Runtime/WorldStorageInfo.cs create mode 100644 Assets/Runtime/WorldStorageInfo.cs.meta create mode 100644 Assets/Scriptables.meta create mode 100644 Assets/Scriptables/WorldStorageServer.cs create mode 100644 Assets/Scriptables/WorldStorageServer.cs.meta create mode 100644 Assets/Scriptables/WorldStorageUser.cs create mode 100644 Assets/Scriptables/WorldStorageUser.cs.meta diff --git a/Assets/Editor/WorldStorageInfoEditor.cs b/Assets/Editor/WorldStorageInfoEditor.cs new file mode 100644 index 0000000..b211fd3 --- /dev/null +++ b/Assets/Editor/WorldStorageInfoEditor.cs @@ -0,0 +1,22 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +[CustomEditor(typeof(WorldStorageInfo))] +public class WorldStorageInfoEditor : Editor +{ + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + + EditorGUILayout.Space(); + WorldStorageInfo srv = (WorldStorageInfo)target; + + string state = srv.GetServerState(); + EditorGUILayout.LabelField("Server State", state); + + string api = srv.GetAPIVersion(); + EditorGUILayout.LabelField("OpenAPI Version", api); + } +} diff --git a/Assets/Editor/WorldStorageServerEditor.cs.meta b/Assets/Editor/WorldStorageInfoEditor.cs.meta similarity index 100% rename from Assets/Editor/WorldStorageServerEditor.cs.meta rename to Assets/Editor/WorldStorageInfoEditor.cs.meta diff --git a/Assets/Editor/WorldStorageServerEditor.cs b/Assets/Editor/WorldStorageServerEditor.cs deleted file mode 100644 index 0f0a18e..0000000 --- a/Assets/Editor/WorldStorageServerEditor.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; -using UnityEditor; - -[CustomEditor(typeof(WorldStorageServer))] -public class WorldStorageServerEditor : Editor -{ - public override void OnInspectorGUI() - { - base.OnInspectorGUI(); - - EditorGUILayout.Space(); - WorldStorageServer srv = (WorldStorageServer)target; - string api = srv.GetAPIVersion(); - EditorGUILayout.LabelField("Server State", api); - } -} diff --git a/Assets/Runtime.meta b/Assets/Runtime.meta new file mode 100644 index 0000000..4a46a31 --- /dev/null +++ b/Assets/Runtime.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9f9d2ca3af2d00643b6a16d11277df9a +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Runtime/REST.meta b/Assets/Runtime/REST.meta new file mode 100644 index 0000000..4452abe --- /dev/null +++ b/Assets/Runtime/REST.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2d42c05c2b33530478b6ec053f84a09d +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Runtime/REST/AdminRequest.cs b/Assets/Runtime/REST/AdminRequest.cs new file mode 100644 index 0000000..8e0e12a --- /dev/null +++ b/Assets/Runtime/REST/AdminRequest.cs @@ -0,0 +1,57 @@ +// +// ETSI (European Telecommunications Standards Institute, referred to as ETSI) +// ARF - ETSI ISG Augmented Reality Framework (ISG ARF) +// (C) 2022 +// +// Development "World Storage", data management, authoring tools +// +// Authors: +// - Sylvain Renault (Fraunhofer HHI) +// +// Date: May 2022 +// + +#define USING_OPENAPI_GENERATOR // alt. is Swagger + +using System.IO; +using System.Collections.Generic; +using UnityEngine; + +#if USING_OPENAPI_GENERATOR +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; +#else +using IO.Swagger.Api; +using IO.Swagger.Model; +#endif + +#if UNITY_EDITOR +namespace ETSI.ARF.WorldStorage.REST +{ + public class AdminRequest + { + static public string GetAdminInfo(WorldStorageServer ws) + { + DefaultApi api = new DefaultApi(ws.URI); + string state = api.GetAdmin(); + Debug.Log("Server State: " + state); + return state; + } + + static public string GetVersion(WorldStorageServer ws) + { + DefaultApi api = new DefaultApi(ws.URI); + string vers = api.GetVersion(); + Debug.Log("Using API Version: " + vers); + return vers; + } + + static public string Ping (WorldStorageServer ws) + { + DefaultApi api = new DefaultApi(ws.URI); + api.GetPing(); + return "IsAlive"; + } + } +} +#endif \ No newline at end of file diff --git a/Assets/Runtime/REST/AdminRequest.cs.meta b/Assets/Runtime/REST/AdminRequest.cs.meta new file mode 100644 index 0000000..27fcc8f --- /dev/null +++ b/Assets/Runtime/REST/AdminRequest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 0fa015c6a7b3a8e4884833d8f672c20c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Runtime/REST/TrackableRequest.cs b/Assets/Runtime/REST/TrackableRequest.cs new file mode 100644 index 0000000..5af7563 --- /dev/null +++ b/Assets/Runtime/REST/TrackableRequest.cs @@ -0,0 +1,64 @@ +// +// ETSI (European Telecommunications Standards Institute, referred to as ETSI) +// ARF - ETSI ISG Augmented Reality Framework (ISG ARF) +// (C) 2022 +// +// Development "World Storage", data management, authoring tools +// +// Authors: +// - Sylvain Renault (Fraunhofer HHI) +// +// Date: Feb. 2022 +// + +#define USING_OPENAPI_GENERATOR // alt. is Swagger + +using System.IO; +using System.Collections.Generic; +using UnityEngine; + +#if USING_OPENAPI_GENERATOR +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; +#else +using IO.Swagger.Api; +using IO.Swagger.Model; +#endif + +#if UNITY_EDITOR +namespace ETSI.ARF.WorldStorage.REST +{ + public class TrackableRequest + { + static public void AddTrackable(WorldStorageServer ws, Trackable trackable) + { + Debug.Log("Posting Add Trackable to Server"); + TrackablesApi api = new TrackablesApi(ws.URI); + string result = api.AddTrackable(trackable); + Debug.Log(result); + } + + static public List GetAllTrackables(WorldStorageServer ws) + { + TrackablesApi api = new TrackablesApi(ws.URI); + List result = api.GetTrackables(); + return result; + } + + static public Trackable GetTrackable(WorldStorageServer ws, string uuid) + { + System.Guid _uuid = System.Guid.Parse(uuid); + TrackablesApi api = new TrackablesApi(ws.URI); + Trackable result = api.GetTrackableById(_uuid); + return result; + } + + static public void DeleteTrackable(WorldStorageServer ws, string uuid) + { + System.Guid _uuid = System.Guid.Parse(uuid); + TrackablesApi api = new TrackablesApi(ws.URI); + api.DeleteTrackable(_uuid); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/Runtime/REST/TrackableRequest.cs.meta b/Assets/Runtime/REST/TrackableRequest.cs.meta new file mode 100644 index 0000000..63e45e3 --- /dev/null +++ b/Assets/Runtime/REST/TrackableRequest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f492e20bc218f884b907369b8eca15a3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Runtime/REST/WorldAnchorRequest.cs b/Assets/Runtime/REST/WorldAnchorRequest.cs new file mode 100644 index 0000000..64dbff8 --- /dev/null +++ b/Assets/Runtime/REST/WorldAnchorRequest.cs @@ -0,0 +1,64 @@ +// +// ETSI (European Telecommunications Standards Institute, referred to as ETSI) +// ARF - ETSI ISG Augmented Reality Framework (ISG ARF) +// (C) 2022 +// +// Development "World Storage", data management, authoring tools +// +// Authors: +// - Sylvain Renault (Fraunhofer HHI) +// +// Date: Feb. 2022 +// + +#define USING_OPENAPI_GENERATOR // alt. is Swagger + +using System.IO; +using System.Collections.Generic; +using UnityEngine; + +#if USING_OPENAPI_GENERATOR +using Org.OpenAPITools.Api; +using Org.OpenAPITools.Model; +#else +using IO.Swagger.Api; +using IO.Swagger.Model; +#endif + +#if UNITY_EDITOR +namespace ETSI.ARF.WorldStorage.REST +{ + public class WorldAnchorRequest + { + static public void AddWorldAnchor(WorldStorageServer ws, WorldAnchor anchor) + { + Debug.Log("Posting Add World Anchor to Server"); + WorldAnchorsApi api = new WorldAnchorsApi(ws.URI); + string result = api.AddWorldAnchor(anchor); + Debug.Log(result); + } + + static public List GetAllWorldAnchors(WorldStorageServer ws) + { + WorldAnchorsApi api = new WorldAnchorsApi(ws.URI); + List result = api.GetWorldAnchors(); + return result; + } + + static public WorldAnchor GetWorldAnchor(WorldStorageServer ws, string uuid) + { + System.Guid _uuid = System.Guid.Parse(uuid); + WorldAnchorsApi api = new WorldAnchorsApi(ws.URI); + WorldAnchor result = api.GetWorldAnchorById(_uuid); + return result; + } + + static public void DeleteWorldAnchor(WorldStorageServer ws, string uuid) + { + System.Guid _uuid = System.Guid.Parse(uuid); + WorldAnchorsApi api = new WorldAnchorsApi(ws.URI); + api.DeleteWorldAnchor(_uuid); + } + } +} +#endif \ No newline at end of file diff --git a/Assets/Runtime/REST/WorldAnchorRequest.cs.meta b/Assets/Runtime/REST/WorldAnchorRequest.cs.meta new file mode 100644 index 0000000..77f7b39 --- /dev/null +++ b/Assets/Runtime/REST/WorldAnchorRequest.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: eb674a7de52fc6d4a822e7d07c1dd294 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Runtime/WorldStorageInfo.cs b/Assets/Runtime/WorldStorageInfo.cs new file mode 100644 index 0000000..533799f --- /dev/null +++ b/Assets/Runtime/WorldStorageInfo.cs @@ -0,0 +1,40 @@ +// +// ETSI (European Telecommunications Standards Institute, referred to as ETSI) +// ARF - ETSI ISG Augmented Reality Framework (ISG ARF) +// (C) 2022 +// +// Development "World Storage", data management, authoring tools +// +// Authors: +// - Sylvain Renault (Fraunhofer HHI) +// +// Date: April 2022 +// + +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using ETSI.ARF.WorldStorage; + +public class WorldStorageInfo : MonoBehaviour +{ + public WorldStorageServer worldStorageServer; + + public bool isServerAlive() + { + if (worldStorageServer == null) return false; + return !string.IsNullOrEmpty(ETSI.ARF.WorldStorage.REST.AdminRequest.Ping(worldStorageServer)); + } + + public string GetServerState() + { + if (worldStorageServer == null) return "No Server Defined!"; + return ETSI.ARF.WorldStorage.REST.AdminRequest.GetAdminInfo(worldStorageServer); + } + + public string GetAPIVersion() + { + if (worldStorageServer == null) return "Unknown Version!"; + return ETSI.ARF.WorldStorage.REST.AdminRequest.GetVersion(worldStorageServer); + } +} diff --git a/Assets/Runtime/WorldStorageInfo.cs.meta b/Assets/Runtime/WorldStorageInfo.cs.meta new file mode 100644 index 0000000..925ddd3 --- /dev/null +++ b/Assets/Runtime/WorldStorageInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 02da7adcc65f4694684d71e61d88070b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scriptables.meta b/Assets/Scriptables.meta new file mode 100644 index 0000000..ea6eb7d --- /dev/null +++ b/Assets/Scriptables.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9f7902ce03cc2b2458df8c561ff1f55e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scriptables/WorldStorageServer.cs b/Assets/Scriptables/WorldStorageServer.cs new file mode 100644 index 0000000..ff4e11f --- /dev/null +++ b/Assets/Scriptables/WorldStorageServer.cs @@ -0,0 +1,21 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace ETSI.ARF.WorldStorage +{ + [System.Serializable] + [CreateAssetMenu(fileName = "ARFWorldStorageServer", menuName = "ARF World Storage/Create Server", order = 1)] + public class WorldStorageServer : ScriptableObject + { + [SerializeField] public string serverName = "myServerName"; + [SerializeField] public string basePath = "https://"; + [SerializeField] public int port = 8080; + + [Space(8)] + [SerializeField] public WorldStorageUser user = null; + + public string URI => basePath + ":" + port.ToString(); + } +} \ No newline at end of file diff --git a/Assets/Scriptables/WorldStorageServer.cs.meta b/Assets/Scriptables/WorldStorageServer.cs.meta new file mode 100644 index 0000000..6e5eff8 --- /dev/null +++ b/Assets/Scriptables/WorldStorageServer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e4b7be4c33f68d0418c3b4e1a7053d91 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scriptables/WorldStorageUser.cs b/Assets/Scriptables/WorldStorageUser.cs new file mode 100644 index 0000000..fb1dc76 --- /dev/null +++ b/Assets/Scriptables/WorldStorageUser.cs @@ -0,0 +1,15 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace ETSI.ARF.WorldStorage +{ + [System.Serializable] + [CreateAssetMenu(fileName = "ARFWorldStorageUser", menuName = "ARF World Storage/Create User", order = 1)] + public class WorldStorageUser : ScriptableObject + { + [SerializeField] public string userName = "myName"; + [SerializeField] public string UUID = System.Guid.Empty.ToString(); + } +} \ No newline at end of file diff --git a/Assets/Scriptables/WorldStorageUser.cs.meta b/Assets/Scriptables/WorldStorageUser.cs.meta new file mode 100644 index 0000000..149c496 --- /dev/null +++ b/Assets/Scriptables/WorldStorageUser.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8a1e3e7961eae84468e6ee20d5b09ffd +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/package.json b/package.json index 9952b13..e3173ed 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,7 @@ "name": "etsi.isg.arf.worldstorage", "version": "0.0.2", "displayName": "ISG-ARF World Storage Package", - "description": "RESTful Wrapper for the World Storage of the Augmented Reality Framework", + "description": "REST Wrapper for the World Storage of the Augmented Reality Framework", "unity": "2020.3", - "dependencies": { }, - "keywords": [ ] + "keywords": [] } \ No newline at end of file -- GitLab