Coverage for tutorials/ngsi_v2/e2_healthcheck/e2_healthcheck_solution.py: 0%
4 statements
« prev ^ index » next coverage.py v7.10.2, created at 2025-08-05 11:07 +0000
« prev ^ index » next coverage.py v7.10.2, created at 2025-08-05 11:07 +0000
1"""
2# # Exercise 2: Service Health Check
4# Create one or multiple FiLiP clients and check if the corresponding services
5# are up and running by accessing their version information.
7# The input sections are marked with 'ToDo'
9# #### Steps to complete:
10# 1. Set up the missing parameters in the parameter section
11# 2. Create FiLiP ngsi_v2 clients for the individual services and check for
12# their version
13# 3. Create a config object for the ngsi_v2 multi client (HttpClient),
14# create the multi client and again check for services' versions
15"""
17# ## Import packages
18from filip.clients.ngsi_v2 import (
19 HttpClient,
20 HttpClientConfig,
21 ContextBrokerClient,
22 IoTAClient,
23 QuantumLeapClient,
24)
26# ## Parameters
27# ToDo: Enter your context broker url and port, e.g. http://localhost:1026.
28CB_URL = "http://localhost:1026"
29# ToDo: Enter your IoT-Agent url and port, e.g. http://localhost:4041.
30IOTA_URL = "http://localhost:4041"
31# ToDo: Enter your QuantumLeap url and port, e.g. http://localhost:8668.
32QL_URL = "http://localhost:8668"
34# ## Main script
35if __name__ == "__main__":
36 # ToDo: Create a single client for each service and check the service for
37 # its version.
38 cbc = ContextBrokerClient(url=CB_URL)
39 print(f"Context Broker Client: {cbc.get_version()}")
41 iotac = IoTAClient(url=IOTA_URL)
42 print(f"IoTA Client: {iotac.get_version()}")
44 qlc = QuantumLeapClient(url=QL_URL)
45 print(f"Quantum Leap Client: {qlc.get_version()}")
47 # ToDo: Create a configuration object for a multi client.
48 config = HttpClientConfig(cb_url=CB_URL, iota_url=IOTA_URL, ql_url=QL_URL)
50 # ToDo: Create a multi client check again all services for their version.
51 multic = HttpClient(config=config)
53 print(
54 f"Multi Client (Context Broker): {multic.cb.get_version()}\n"
55 f"Multi Client (IoTA): {multic.iota.get_version()}\n"
56 f"Multi Client (Quantum Leap): {multic.timeseries.get_version()}"
57 )