diff --git a/README.md b/README.md index cfc7766648a4ca4440daebe46e6f858823f1ceb5..b174d6e78c6bcccb23c44e3259716782ba63793b 100644 --- a/README.md +++ b/README.md @@ -76,14 +76,13 @@ conda activate openapi Install the World Storage OpenAPI: ``` -cd client\generated -pip install . +pip install .\client\generated ``` In case of not having the pip installed for your cml you can use following line: ``` -py -m pip install . +py -m pip install .\client\generated ``` ## Running the test script diff --git a/client/ETSI-ARF/WorldServerTest.py b/client/ETSI-ARF/WorldServerTest.py deleted file mode 100644 index f292aaf6082aeebf0f7fe89c3f992f936dc69f0c..0000000000000000000000000000000000000000 --- a/client/ETSI-ARF/WorldServerTest.py +++ /dev/null @@ -1,145 +0,0 @@ -#!/usr/bin/env python - -# -# ARF - Augmented Reality Framework (ETSI ISG ARF) -# -# Copyright 2024 ETSI -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http:#www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# -# Last change: Mai 2024 -# - -import time -from pprint import pprint - -import ETSI.ARF.OpenAPI.WorldStorage -from ETSI.ARF.OpenAPI.WorldStorage.api import default_api -from ETSI.ARF.OpenAPI.WorldStorage.api import trackables_api -from ETSI.ARF.OpenAPI.WorldStorage.api import world_anchors_api -from ETSI.ARF.OpenAPI.WorldStorage.api import world_links_api - -# recommended to create enviroment -# conda create -n openapi -# conda activate openapi -# to install the World Storage OpenAPI: cd to /CHANGE_PATH/generated folder, and then run "py-exe -m pip install ." - -# then to run, activate first enviroment: -# conda activate openapi -# and then run python script: -# python <this script>.py - - -# See configuration.py for a list of all supported configuration parameters. -configuration = ETSI.ARF.OpenAPI.WorldStorage.Configuration( - host="https://etsi.hhi.fraunhofer.de" -) - -print() -print("ETSI ISG - ARF World Storage") -print() -print("Simple query tests") -print("====================") -print() -print("Using WS server: " + configuration.host) -print() - -# -# Test the server availability -# -def CheckRESTServer(client) -> bool: - success = 0 - - # Create an instance of the API class - api_instance = default_api.DefaultApi(client) - - # - # Endpoint: default - # - try: - # Test the server availability. - api_response = api_instance.get_ping() - print("Sending 'ping', got response: " + api_response) - success += 1 - except ETSI.ARF.OpenAPI.WorldStorage.ApiException as e: - print("Exception when calling DefaultApi->get_ping: %s\n" % e) - - try: - # Test the server availability. - api_response = api_instance.get_version() - print("Sending 'version', got response: " + api_response) - success += 1 - except ETSI.ARF.OpenAPI.WorldStorage.ApiException as e: - print("Exception when calling DefaultApi->get_ping: %s\n" % e) - - try: - # Test the server availability. - api_response = api_instance.get_admin() - print("Sending 'admin', got response: " + api_response) - success += 1 - except ETSI.ARF.OpenAPI.WorldStorage.ApiException as e: - print("Exception when calling DefaultApi->get_ping: %s\n" % e) - - return success == 3 - -# Enter a context with an instance of the API client -with ETSI.ARF.OpenAPI.WorldStorage.ApiClient(configuration) as api_client: - - print("1. Testing default (admin) endpoints") - isServerOk = CheckRESTServer(api_client) - - if isServerOk == True: - print ("REST Connection was succesfull.") - - # - # Endpoint: trackables - # - print() - print("2. Testing trackables endpoints") - api_instance_t = trackables_api.TrackablesApi(api_client) - try: - list_response = api_instance_t.get_trackables() - print("Querying Trackables: got list with " + str(len(list_response)) + " items:") - for item in list_response: - print(" UUID: " + str(item.uuid) + " Name: " + item.name + " (Type: " + str(item.trackable_type) + ")") - except ETSI.ARF.OpenAPI.WorldStorage.ApiException as e: - print("Exception when calling TrackablesApi->get_trackables: %s\n" % e) - - print() - print("3. Testing anchors endpoints") - api_instance_wa = world_anchors_api.WorldAnchorsApi(api_client) - try: - list_response = api_instance_wa.get_world_anchors() - print("Querying World Anchors: got list with " + str(len(list_response)) + " items:") - for item in list_response: - print(" UUID: " + str(item.uuid) + " Name: " + item.name ) - except ETSI.ARF.OpenAPI.WorldStorage.ApiException as e: - print("Exception when calling WorldAnchorsApi->get_world_anchors: %s\n" % e) - - print() - print("4. Testing links endpoints") - api_instance_wl = world_links_api.WorldLinksApi(api_client) - try: - list_response = api_instance_wl.get_world_links() - print("Querying World Links: got list with " + str(len(list_response)) + " items:") - for item in list_response: - print(" Link from UUID: " + str(item.uuid_from) + " to UUID: " + str(item.uuidto)) - except ETSI.ARF.OpenAPI.WorldStorage.ApiException as e: - print("Exception when calling WorldLinksApi->get_world_links: %s\n" % e) - - else: - print ("REST Connection was not succesfull!") - - -print () -print ("End of test.") \ No newline at end of file diff --git a/client/ETSI-ARF/WorldStorageServerTest.py b/client/ETSI-ARF/WorldStorageServerTest.py new file mode 100644 index 0000000000000000000000000000000000000000..c82d01c3a111418f2d402b62f96ed2d8edb17902 --- /dev/null +++ b/client/ETSI-ARF/WorldStorageServerTest.py @@ -0,0 +1,203 @@ +#!/usr/bin/env python + +# +# ARF - Augmented Reality Framework (ETSI ISG ARF) +# +# Copyright 2024 ETSI +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http:#www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# Author: Fraunhofer HHI, SylR +# Last change: September 2024 +# + +import time +from pprint import pprint +from pydantic import ValidationError, validate_call + +import ETSI.ARF.OpenAPI.WorldStorage +from ETSI.ARF.OpenAPI.WorldStorage.api import default_api +from ETSI.ARF.OpenAPI.WorldStorage.api import trackables_api +from ETSI.ARF.OpenAPI.WorldStorage.api import world_anchors_api +from ETSI.ARF.OpenAPI.WorldStorage.api import world_links_api +from ETSI.ARF.OpenAPI.WorldStorage.api import relocalization_information_api + +# Models (classes) +from ETSI.ARF.OpenAPI.WorldStorage.models.uuid_and_mode import UuidAndMode +from ETSI.ARF.OpenAPI.WorldStorage.models.mode_world_storage import ModeWorldStorage +from ETSI.ARF.OpenAPI.WorldStorage.models.capability import Capability +from ETSI.ARF.OpenAPI.WorldStorage.models.reloc_object import RelocObject +from ETSI.ARF.OpenAPI.WorldStorage.models.relocalization_information import RelocalizationInformation +from ETSI.ARF.OpenAPI.WorldStorage.models.relocalization_informations import RelocalizationInformations + +# recommended to create enviroment +# conda create -n openapi +# conda activate openapi +# to install the World Storage OpenAPI: cd to /CHANGE_PATH/generated folder, and then run "py-exe -m pip install ." + +# then to run, activate first enviroment: +# conda activate openapi +# and then run python script: +# python <this script>.py + +# for production +webserver_url = "https://etsi.hhi.fraunhofer.de" # public + +# for development +#webserver_url = "http://localhost:61788" +webserver_url = "https://localhost:44301" # secure + + +# See configuration.py for a list of all supported configuration parameters. +configuration = ETSI.ARF.OpenAPI.WorldStorage.Configuration(host=webserver_url) + +print() +print("ETSI ISG - ARF World Storage") +print() +print("Simple query tests") +print("====================") +print() +print("Using WS server: " + configuration.host) +print() + +# +# Test the server availability +# +def CheckRESTServer(client) -> bool: + success = 0 + + # Create an instance of the API class + api_instance = default_api.DefaultApi(client) + + # + # Endpoint: default + # + try: + # Test the server availability. + api_response = api_instance.get_ping() + print("Sending 'ping', got response: " + api_response) + success += 1 + except ETSI.ARF.OpenAPI.WorldStorage.ApiException as e: + print("[REST] Exception when calling DefaultApi->get_ping: %s\n" % e) + + try: + # Test the server availability. + api_response = api_instance.get_version() + print("Sending 'version', got response: " + api_response) + success += 1 + except ETSI.ARF.OpenAPI.WorldStorage.ApiException as e: + print("[REST] Exception when calling DefaultApi->get_ping: %s\n" % e) + + try: + # Test the server availability. + api_response = api_instance.get_admin() + print("Sending 'admin', got response: " + api_response) + success += 1 + except ETSI.ARF.OpenAPI.WorldStorage.ApiException as e: + print("[REST] Exception when calling DefaultApi->get_ping: %s\n" % e) + + return success == 3 + +# +# Main +# +devToken = "dev" + +# Enter a context with an instance of the API client +with ETSI.ARF.OpenAPI.WorldStorage.ApiClient(configuration) as api_client: + + print("1. Testing default (admin) endpoints") + isServerOk = CheckRESTServer(api_client) + + if isServerOk == True: + print ("[REST] Connection was succesfull.") + + # + # Endpoint: trackables + # + print() + print("2. Testing Trackables endpoint:") + api_instance_t = trackables_api.TrackablesApi(api_client) + try: + trackables = api_instance_t.get_trackables(token=devToken).trackables + print("\tQuerying Trackables: got list with " + str(len(trackables)) + " items:") + for item in trackables: + print("\t\tUUID: " + str(item.uuid) + " Name: " + item.name + " (Type: " + str(item.trackable_type) + ")") + except ETSI.ARF.OpenAPI.WorldStorage.ApiException as e: + print("[REST] Exception when calling TrackablesApi->get_trackables: %s\n" % e) + + print() + print("3. Testing World Anchors endpoint:") + api_instance_wa = world_anchors_api.WorldAnchorsApi(api_client) + try: + anchors = api_instance_wa.get_world_anchors(token=devToken).world_anchors + print("\tQuerying World Anchors: got list with " + str(len(anchors)) + " items:") + for item in anchors: + print("\t\tUUID: " + str(item.uuid) + " Name: " + item.name ) + except ETSI.ARF.OpenAPI.WorldStorage.ApiException as e: + print("[REST] Exception when calling WorldAnchorsApi->get_world_anchors: %s\n" % e) + + """ + print() + print("4. Testing World Links endpoint:") + api_instance_wl = world_links_api.WorldLinksApi(api_client) + try: + links = api_instance_wl.get_world_links(token=devToken).world_links + print("\tQuerying World Links: got list with " + str(len(links)) + " items:") + for item in links: + print("\t\tUUID: " + str(item.uuid) + " Link from UUID: " + str(item.uuid_from) + " to UUID: " + str(item.uuidto)) + except ETSI.ARF.OpenAPI.WorldStorage.ApiException as e: + print("[REST] Exception when calling WorldLinksApi->get_world_links: %s\n" % e) + """ + + print() + print("5. Testing the Relocalization Info endpoint:") + api_instance_reloc = relocalization_information_api.RelocalizationInformationApi(api_client) + + # create a fake reloc request + enc = ETSI.ARF.OpenAPI.WorldStorage.models.EncodingInformationStructure( + version = "HHI-0.1", # version + data_format = "OTHER") # type/company? + + # Capability #1 + cap1 = Capability() + cap1.trackable_type = ETSI.ARF.OpenAPI.WorldStorage.models.TrackableType.MAP + cap1.encoding_information = enc + cap1.framerate = 6 + cap1.latency = 0.5 + cap1.accuracy = 0.8 + + arCapabilities = [ cap1 ] + + uuid2track = UuidAndMode() + #uuid2track.uuid = trackables[0].uuid + #uuid2track.uuid = trackables[0].name # work around + uuid2track.uuid = "cb0630db-2151-47d3-85d4-09c079cd8be1" + uuid2track.mode = ModeWorldStorage.REQUEST_TO_TRACKABLES + + arObjects = [ uuid2track ] + + try: + print("\tQuerying reloc info for UUID: " + str(uuid2track.uuid)) + + reloc_response = api_instance_reloc.get_relocalization_information(token=devToken, capabilities=arCapabilities, uuids=arObjects).world_links + print("\t\tGot:" + reloc_response.reloc_info[0].reloc_objects[0].mode) + except ETSI.ARF.OpenAPI.WorldStorage.ApiException as e: + print("[REST] Exception when calling RelocalizationInformationApi->get_relocalization_information: %s\n" % e) + + else: + print ("[REST] Connection was not succesfull!") + + +print () +print ("End of test.") \ No newline at end of file diff --git a/openapi b/openapi index b639a02180c2b5e301c77483b3a2fa645ba94169..5734880080c52572af65fe6d2703228ed6ee5653 160000 --- a/openapi +++ b/openapi @@ -1 +1 @@ -Subproject commit b639a02180c2b5e301c77483b3a2fa645ba94169 +Subproject commit 5734880080c52572af65fe6d2703228ed6ee5653