Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
World Storage Python Client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ARF
World Storage API Helpers
World Storage Python Client
Commits
8fe0daf6
Commit
8fe0daf6
authored
8 months ago
by
Sylvain Renault
Browse files
Options
Downloads
Patches
Plain Diff
Python test for communication with the world storage api.
parent
a22a1993
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
README.md
+2
-3
2 additions, 3 deletions
README.md
client/ETSI-ARF/WorldStorageServerTest.py
+203
-0
203 additions, 0 deletions
client/ETSI-ARF/WorldStorageServerTest.py
openapi
+1
-1
1 addition, 1 deletion
openapi
with
206 additions
and
4 deletions
README.md
+
2
−
3
View file @
8fe0daf6
...
@@ -76,14 +76,13 @@ conda activate openapi
...
@@ -76,14 +76,13 @@ conda activate openapi
Install the World Storage OpenAPI:
Install the World Storage OpenAPI:
```
```
cd client\generated
pip install .\client\generated
pip install .
```
```
In case of not having the pip installed for your cml you can use following line:
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
## Running the test script
...
...
This diff is collapsed.
Click to expand it.
client/ETSI-ARF/WorldServerTest.py
→
client/ETSI-ARF/WorldS
torageS
erverTest.py
+
203
−
0
View file @
8fe0daf6
...
@@ -17,17 +17,28 @@
...
@@ -17,17 +17,28 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
#
#
# Last change: Mai 2024
# Author: Fraunhofer HHI, SylR
# Last change: September 2024
#
#
import
time
import
time
from
pprint
import
pprint
from
pprint
import
pprint
from
pydantic
import
ValidationError
,
validate_call
import
ETSI.ARF.OpenAPI.WorldStorage
import
ETSI.ARF.OpenAPI.WorldStorage
from
ETSI.ARF.OpenAPI.WorldStorage.api
import
default_api
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
trackables_api
from
ETSI.ARF.OpenAPI.WorldStorage.api
import
world_anchors_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
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
# recommended to create enviroment
# conda create -n openapi
# conda create -n openapi
...
@@ -39,11 +50,16 @@ from ETSI.ARF.OpenAPI.WorldStorage.api import world_links_api
...
@@ -39,11 +50,16 @@ from ETSI.ARF.OpenAPI.WorldStorage.api import world_links_api
# and then run python script:
# and then run python script:
# python <this script>.py
# 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.
# See configuration.py for a list of all supported configuration parameters.
configuration
=
ETSI
.
ARF
.
OpenAPI
.
WorldStorage
.
Configuration
(
configuration
=
ETSI
.
ARF
.
OpenAPI
.
WorldStorage
.
Configuration
(
host
=
webserver_url
)
host
=
"
https://etsi.hhi.fraunhofer.de
"
)
print
()
print
()
print
(
"
ETSI ISG - ARF World Storage
"
)
print
(
"
ETSI ISG - ARF World Storage
"
)
...
@@ -72,7 +88,7 @@ def CheckRESTServer(client) -> bool:
...
@@ -72,7 +88,7 @@ def CheckRESTServer(client) -> bool:
print
(
"
Sending
'
ping
'
, got response:
"
+
api_response
)
print
(
"
Sending
'
ping
'
, got response:
"
+
api_response
)
success
+=
1
success
+=
1
except
ETSI
.
ARF
.
OpenAPI
.
WorldStorage
.
ApiException
as
e
:
except
ETSI
.
ARF
.
OpenAPI
.
WorldStorage
.
ApiException
as
e
:
print
(
"
Exception when calling DefaultApi->get_ping: %s
\n
"
%
e
)
print
(
"
[REST]
Exception when calling DefaultApi->get_ping: %s
\n
"
%
e
)
try
:
try
:
# Test the server availability.
# Test the server availability.
...
@@ -80,7 +96,7 @@ def CheckRESTServer(client) -> bool:
...
@@ -80,7 +96,7 @@ def CheckRESTServer(client) -> bool:
print
(
"
Sending
'
version
'
, got response:
"
+
api_response
)
print
(
"
Sending
'
version
'
, got response:
"
+
api_response
)
success
+=
1
success
+=
1
except
ETSI
.
ARF
.
OpenAPI
.
WorldStorage
.
ApiException
as
e
:
except
ETSI
.
ARF
.
OpenAPI
.
WorldStorage
.
ApiException
as
e
:
print
(
"
Exception when calling DefaultApi->get_ping: %s
\n
"
%
e
)
print
(
"
[REST]
Exception when calling DefaultApi->get_ping: %s
\n
"
%
e
)
try
:
try
:
# Test the server availability.
# Test the server availability.
...
@@ -88,10 +104,15 @@ def CheckRESTServer(client) -> bool:
...
@@ -88,10 +104,15 @@ def CheckRESTServer(client) -> bool:
print
(
"
Sending
'
admin
'
, got response:
"
+
api_response
)
print
(
"
Sending
'
admin
'
, got response:
"
+
api_response
)
success
+=
1
success
+=
1
except
ETSI
.
ARF
.
OpenAPI
.
WorldStorage
.
ApiException
as
e
:
except
ETSI
.
ARF
.
OpenAPI
.
WorldStorage
.
ApiException
as
e
:
print
(
"
Exception when calling DefaultApi->get_ping: %s
\n
"
%
e
)
print
(
"
[REST]
Exception when calling DefaultApi->get_ping: %s
\n
"
%
e
)
return
success
==
3
return
success
==
3
#
# Main
#
devToken
=
"
dev
"
# Enter a context with an instance of the API client
# Enter a context with an instance of the API client
with
ETSI
.
ARF
.
OpenAPI
.
WorldStorage
.
ApiClient
(
configuration
)
as
api_client
:
with
ETSI
.
ARF
.
OpenAPI
.
WorldStorage
.
ApiClient
(
configuration
)
as
api_client
:
...
@@ -99,46 +120,83 @@ with ETSI.ARF.OpenAPI.WorldStorage.ApiClient(configuration) as api_client:
...
@@ -99,46 +120,83 @@ with ETSI.ARF.OpenAPI.WorldStorage.ApiClient(configuration) as api_client:
isServerOk
=
CheckRESTServer
(
api_client
)
isServerOk
=
CheckRESTServer
(
api_client
)
if
isServerOk
==
True
:
if
isServerOk
==
True
:
print
(
"
REST Connection was succesfull.
"
)
print
(
"
[
REST
]
Connection was succesfull.
"
)
#
#
# Endpoint: trackables
# Endpoint: trackables
#
#
print
()
print
()
print
(
"
2. Testing
t
rackables endpoint
s
"
)
print
(
"
2. Testing
T
rackables endpoint
:
"
)
api_instance_t
=
trackables_api
.
TrackablesApi
(
api_client
)
api_instance_t
=
trackables_api
.
TrackablesApi
(
api_client
)
try
:
try
:
list_response
=
api_instance_t
.
get_trackables
(
)
trackables
=
api_instance_t
.
get_trackables
(
token
=
devToken
).
trackables
print
(
"
Querying Trackables: got list with
"
+
str
(
len
(
list_response
))
+
"
items:
"
)
print
(
"
\t
Querying Trackables: got list with
"
+
str
(
len
(
trackables
))
+
"
items:
"
)
for
item
in
list_response
:
for
item
in
trackables
:
print
(
"
UUID:
"
+
str
(
item
.
uuid
)
+
"
Name:
"
+
item
.
name
+
"
(Type:
"
+
str
(
item
.
trackable_type
)
+
"
)
"
)
print
(
"
\t\t
UUID:
"
+
str
(
item
.
uuid
)
+
"
Name:
"
+
item
.
name
+
"
(Type:
"
+
str
(
item
.
trackable_type
)
+
"
)
"
)
except
ETSI
.
ARF
.
OpenAPI
.
WorldStorage
.
ApiException
as
e
:
except
ETSI
.
ARF
.
OpenAPI
.
WorldStorage
.
ApiException
as
e
:
print
(
"
Exception when calling TrackablesApi->get_trackables: %s
\n
"
%
e
)
print
(
"
[REST]
Exception when calling TrackablesApi->get_trackables: %s
\n
"
%
e
)
print
()
print
()
print
(
"
3. Testing
a
nchors endpoint
s
"
)
print
(
"
3. Testing
World A
nchors endpoint
:
"
)
api_instance_wa
=
world_anchors_api
.
WorldAnchorsApi
(
api_client
)
api_instance_wa
=
world_anchors_api
.
WorldAnchorsApi
(
api_client
)
try
:
try
:
list_response
=
api_instance_wa
.
get_world_anchors
(
)
anchors
=
api_instance_wa
.
get_world_anchors
(
token
=
devToken
).
world_anchors
print
(
"
Querying World Anchors: got list with
"
+
str
(
len
(
list_response
))
+
"
items:
"
)
print
(
"
\t
Querying World Anchors: got list with
"
+
str
(
len
(
anchors
))
+
"
items:
"
)
for
item
in
list_response
:
for
item
in
anchors
:
print
(
"
UUID:
"
+
str
(
item
.
uuid
)
+
"
Name:
"
+
item
.
name
)
print
(
"
\t\t
UUID:
"
+
str
(
item
.
uuid
)
+
"
Name:
"
+
item
.
name
)
except
ETSI
.
ARF
.
OpenAPI
.
WorldStorage
.
ApiException
as
e
:
except
ETSI
.
ARF
.
OpenAPI
.
WorldStorage
.
ApiException
as
e
:
print
(
"
Exception when calling WorldAnchorsApi->get_world_anchors: %s
\n
"
%
e
)
print
(
"
[REST]
Exception when calling WorldAnchorsApi->get_world_anchors: %s
\n
"
%
e
)
"""
print()
print()
print
(
"
4. Testing
l
inks endpoint
s
"
)
print(
"
4. Testing
World L
inks endpoint
:
"
)
api_instance_wl = world_links_api.WorldLinksApi(api_client)
api_instance_wl = world_links_api.WorldLinksApi(api_client)
try:
try:
list_response
=
api_instance_wl
.
get_world_links
()
links = api_instance_wl.get_world_links(token=devToken).world_links
print
(
"
Querying World Links: got list with
"
+
str
(
len
(
list_response
))
+
"
items:
"
)
print(
"
\t
Querying World Links: got list with
"
+ str(len(links)) +
"
items:
"
)
for
item
in
list_response
:
for item in links:
print
(
"
Link from UUID:
"
+
str
(
item
.
uuid_from
)
+
"
to UUID:
"
+
str
(
item
.
uuidto
))
print(
"
\t\t
UUID:
"
+ 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
(
"
\t
Querying 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\t
Got:
"
+
reloc_response
.
reloc_info
[
0
].
reloc_objects
[
0
].
mode
)
except
ETSI
.
ARF
.
OpenAPI
.
WorldStorage
.
ApiException
as
e
:
except
ETSI
.
ARF
.
OpenAPI
.
WorldStorage
.
ApiException
as
e
:
print
(
"
Exception when calling
WorldLinksApi->get_world_links
: %s
\n
"
%
e
)
print
(
"
[REST]
Exception when calling
RelocalizationInformationApi->get_relocalization_information
: %s
\n
"
%
e
)
else
:
else
:
print
(
"
REST Connection was not succesfull!
"
)
print
(
"
[
REST
]
Connection was not succesfull!
"
)
print
()
print
()
...
...
This diff is collapsed.
Click to expand it.
openapi
@
57348800
Subproject commit
b639a02180c2b5e301c77483b3a2fa645ba94169
Subproject commit
5734880080c52572af65fe6d2703228ed6ee5653
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment