diff --git a/README.md b/README.md index ff98fd4b9762fee5e8cf28ea38633d3f43fb009f..cfc7766648a4ca4440daebe46e6f858823f1ceb5 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,12 @@ cd client\generated pip install . ``` +In case of not having the pip installed for your cml you can use following line: + +``` +py -m pip install . +``` + ## Running the test script If using conda, activate first enviroment: diff --git a/client/ETSI-ARF/WorldServerTest.py b/client/ETSI-ARF/WorldServerTest.py index c0796245346540587b60dd924149a78ec2b87ccf..f292aaf6082aeebf0f7fe89c3f992f936dc69f0c 100644 --- a/client/ETSI-ARF/WorldServerTest.py +++ b/client/ETSI-ARF/WorldServerTest.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python + # # ARF - Augmented Reality Framework (ETSI ISG ARF) # @@ -19,14 +21,18 @@ # import time -import openapi_client -from openapi_client.api import default_api 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 "pip install ." +# 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 @@ -35,55 +41,105 @@ from pprint import pprint # See configuration.py for a list of all supported configuration parameters. -configuration = openapi_client.Configuration( - host="https://etsi.hhi.fraunhofer.de/" +configuration = ETSI.ARF.OpenAPI.WorldStorage.Configuration( + host="https://etsi.hhi.fraunhofer.de" ) print() print("ETSI ISG - ARF World Storage") print() -print("Simple request tests") +print("Simple query tests") print("====================") print() -print("Using WS server" + configuration.host) +print("Using WS server: " + configuration.host) print() -success = 0 +# +# Test the server availability +# +def CheckRESTServer(client) -> bool: + success = 0 -# Enter a context with an instance of the API client -with openapi_client.ApiClient(configuration) as api_client: # Create an instance of the API class - api_instance = default_api.DefaultApi(api_client) + api_instance = default_api.DefaultApi(client) - # example, this endpoint has no required or optional parameters + # + # Endpoint: default + # try: # Test the server availability. api_response = api_instance.get_ping() print("Sending 'ping', got response: " + api_response) success += 1 - except openapi_client.ApiException as e: + except ETSI.ARF.OpenAPI.WorldStorage.ApiException as e: print("Exception when calling DefaultApi->get_ping: %s\n" % e) - # example, this endpoint has no required or optional parameters try: # Test the server availability. api_response = api_instance.get_version() print("Sending 'version', got response: " + api_response) success += 1 - except openapi_client.ApiException as e: + except ETSI.ARF.OpenAPI.WorldStorage.ApiException as e: print("Exception when calling DefaultApi->get_ping: %s\n" % e) - # example, this endpoint has no required or optional parameters try: # Test the server availability. api_response = api_instance.get_admin() print("Sending 'admin', got response: " + api_response) success += 1 - except openapi_client.ApiException as e: + except ETSI.ARF.OpenAPI.WorldStorage.ApiException as e: print("Exception when calling DefaultApi->get_ping: %s\n" % e) -if success == 3: - print ("Connection was succesfull.") -else: - print ("Connection was not succesfull!") + 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/openapi b/openapi index af5fc2355f7b03fbc76e9d9e04452044d4b5ca8d..073fd7213fd9e6ebc2f8a47d628a650de30c8bc4 160000 --- a/openapi +++ b/openapi @@ -1 +1 @@ -Subproject commit af5fc2355f7b03fbc76e9d9e04452044d4b5ca8d +Subproject commit 073fd7213fd9e6ebc2f8a47d628a650de30c8bc4 diff --git a/openapitools.json b/openapitools.json index f8d1d947d3cdce3701c69121705f72d8c7b5f309..c36675578c2c57b728aa24a167dc51ef15fbd46d 100644 --- a/openapitools.json +++ b/openapitools.json @@ -2,14 +2,15 @@ "$schema": "node_modules/@openapitools/openapi-generator-cli/config.schema.json", "spaces": 2, "generator-cli": { - "version": "5.3.0", + "version": "7.6.0", "generators":{ - "v1.1": { + "python": { "generatorName": "python", "output": "./client/generated", "inputSpec": "./openapi/API/worldstorage/worldstorageopenapi.yaml", "additionalProperties": { - } + "packageName": "ETSI.ARF.OpenAPI.WorldStorage" + } } } }