diff --git a/Assets/Editor/WorldStorageInfoEditor.cs b/Assets/Editor/WorldStorageInfoEditor.cs new file mode 100644 index 0000000000000000000000000000000000000000..b211fd358cc400e86d90989c207c87d58676e7d6 --- /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 0f0a18e1dbc20394912ad0d9d3446b2b74bf3a15..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..4a46a316d34c00d5ba53899b5c754063aee47a49 --- /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 0000000000000000000000000000000000000000..4452abe52f262c4e4a9d07155bc61aafd052a5a8 --- /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 0000000000000000000000000000000000000000..8e0e12a3f56e17dc7bc5dbff1141c49c9adc126f --- /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 0000000000000000000000000000000000000000..27fcc8faac1b1d80037c700e95c3308afc96d7bc --- /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 0000000000000000000000000000000000000000..5af7563882d4f676fbcce874b420db2d72d4f043 --- /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<Trackable> GetAllTrackables(WorldStorageServer ws) + { + TrackablesApi api = new TrackablesApi(ws.URI); + List<Trackable> 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 0000000000000000000000000000000000000000..63e45e36aec74c8cafa9fb50e0e6aa6d6c9e1308 --- /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 0000000000000000000000000000000000000000..64dbff8510c21ed8d813f8cc9c251d20a6c79e8d --- /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<WorldAnchor> GetAllWorldAnchors(WorldStorageServer ws) + { + WorldAnchorsApi api = new WorldAnchorsApi(ws.URI); + List<WorldAnchor> 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 0000000000000000000000000000000000000000..77f7b39d3a8c2b9c90d38db6f9e8f29f54593c8a --- /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 0000000000000000000000000000000000000000..533799f5280923fb0ca18d0654a1b416d59cefcd --- /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 0000000000000000000000000000000000000000..925ddd3ef3b1749c22d616be686594a3afada665 --- /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 0000000000000000000000000000000000000000..ea6eb7d4a14e002a00fd40093bc81dc1d037dafd --- /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 0000000000000000000000000000000000000000..ff4e11fd351d3b841479a64b0f52242039b6e8b0 --- /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 0000000000000000000000000000000000000000..6e5eff8940af94e3a9afd6b75fec72f9af0cc1a3 --- /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 0000000000000000000000000000000000000000..fb1dc7645174996e4ac51b459ed5639b1d71acdc --- /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 0000000000000000000000000000000000000000..149c496f1a8ccd41077072f9142bdbbd12f1631c --- /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 9952b13652886225a56effe53fca393a38993250..e3173edfe6a2f47cb71368c84f5bd3d131b3f829 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