Commit b3285b92 authored by Sylvain Renault's avatar Sylvain Renault
Browse files

Update world storage check routines.

parent bab0b98b
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -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:
+77 −21
Original line number Diff line number Diff line
#!/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()

#
# 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.")
    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 ("Connection was not succesfull!")
        print ("REST Connection was not succesfull!")


print ()
print ("End of test.")
 No newline at end of file

openapi @ 073fd721

Original line number Diff line number Diff line
Subproject commit af5fc2355f7b03fbc76e9d9e04452044d4b5ca8d
Subproject commit 073fd7213fd9e6ebc2f8a47d628a650de30c8bc4
+4 −3
Original line number Diff line number Diff line
@@ -2,13 +2,14 @@
  "$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"
     }
     }
    }