Skip to content

Commit 6b593f6

Browse files
authored
Merge pull request #175 from samson0v/master
Updated REST Client for TB 4.0.0
2 parents 8eed666 + cca3a8d commit 6b593f6

File tree

1,101 files changed

+6178
-1114
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,101 files changed

+6178
-1114
lines changed

examples/example_application.py

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
datefmt='%Y-%m-%d %H:%M:%S')
2424

2525
# ThingsBoard REST API URL
26-
url = "http://192.168.1.201:8380"
26+
url = "http://127.0.0.1:8080"
2727

2828
# Default Tenant Administrator credentials
2929
username = "tenant@thingsboard.org"
@@ -37,38 +37,36 @@ def main():
3737
# Auth with credentials
3838
rest_client.login(username=username, password=password)
3939

40-
print(rest_client.save_device_attributes(DeviceId('34416c10-bba7-11ef-9c05-3598fcc4571c', 'DEVICE'), 'SHARED_SCOPE', {'temperature': 45.0}))
41-
4240
# Creating an Asset
43-
# default_asset_profile_id = rest_client.get_default_asset_profile_info().id
44-
# asset = Asset(name="Building 1", label="Building 1",
45-
# asset_profile_id=default_asset_profile_id)
46-
# asset = rest_client.save_asset(asset)
47-
#
48-
# logging.info("Asset was created:\n%r\n", asset)
49-
#
50-
# rest_client.process_devices_bulk_import()
51-
#
52-
# # Creating a Device
53-
# # Also, you can use default Device Profile:
54-
# # default_device_profile_id = rest_client.get_default_device_profile_info().id
55-
# device_profile = DeviceProfile(name="Thermometer",
56-
# type="DEFAULT",
57-
# transport_type="DEFAULT",
58-
# profile_data=DeviceProfileData(configuration={"type": "DEFAULT"},
59-
# transport_configuration={"type": "DEFAULT"}))
60-
# device_profile = rest_client.save_device_profile(device_profile)
61-
# device = Device(name="Thermometer 1", label="Thermometer 1",
62-
# device_profile_id=device_profile.id)
63-
# device = rest_client.save_device(device)
64-
#
65-
# logging.info(" Device was created:\n%r\n", device)
66-
#
67-
# # Creating relations from device to asset
68-
# relation = EntityRelation(_from=asset.id, to=device.id, type="Contains")
69-
# rest_client.save_relation(relation)
70-
#
71-
# logging.info(" Relation was created:\n%r\n", relation)
41+
default_asset_profile_id = rest_client.get_default_asset_profile_info().id
42+
asset = Asset(name="Building 1", label="Building 1",
43+
asset_profile_id=default_asset_profile_id)
44+
asset = rest_client.save_asset(asset)
45+
46+
logging.info("Asset was created:\n%r\n", asset)
47+
48+
rest_client.process_devices_bulk_import()
49+
50+
# Creating a Device
51+
# Also, you can use default Device Profile:
52+
# default_device_profile_id = rest_client.get_default_device_profile_info().id
53+
device_profile = DeviceProfile(name="Thermometer",
54+
type="DEFAULT",
55+
transport_type="DEFAULT",
56+
profile_data=DeviceProfileData(configuration={"type": "DEFAULT"},
57+
transport_configuration={"type": "DEFAULT"}))
58+
device_profile = rest_client.save_device_profile(device_profile)
59+
device = Device(name="Thermometer 1", label="Thermometer 1",
60+
device_profile_id=device_profile.id)
61+
device = rest_client.save_device(device)
62+
63+
logging.info(" Device was created:\n%r\n", device)
64+
65+
# Creating relations from device to asset
66+
relation = EntityRelation(_from=asset.id, to=device.id, type="Contains")
67+
rest_client.save_relation(relation)
68+
69+
logging.info(" Relation was created:\n%r\n", relation)
7270
except ApiException as e:
7371
logging.exception(e)
7472

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "tb-rest-client"
3-
version = "3.9.0"
3+
version = "4.0.0"
44
description = "ThingsBoard REST API client"
55
authors = ["ThingsBoard <info@thingsboard.io>"]
66
license = "Apache-2.0"
@@ -22,7 +22,7 @@ python_dateutil = ">=2.5.3"
2222
setuptools = ">=21.0.0"
2323
urllib3 = ">=2.0.7"
2424
requests = ">=2.31.0"
25-
pyjwt = "2.6.0"
25+
pyjwt = ">=2.6.0"
2626

2727

2828
[build-system]

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ python_dateutil >= 2.5.3
44
setuptools >= 21.0.0
55
urllib3 >= 2.0.7
66
requests>=2.31.0
7-
pyjwt==2.6.0
7+
pyjwt >= 2.6.0

tb_rest_client/api/api_ce/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,4 @@
6464
from .mobile_app_bundle_controller_api import MobileAppBundleControllerApi
6565
from .qr_code_settings_controller_api import QrCodeSettingsControllerApi
6666
from .rule_engine_controller_api import RuleEngineControllerApi
67+
from .calculated_field_controller_api import CalculatedFieldControllerApi

tb_rest_client/api/api_ce/admin_controller_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
ThingsBoard open-source IoT platform REST API documentation. # noqa: E501
77
8-
OpenAPI spec version: 3.9.0
8+
OpenAPI spec version: 4.0.0
99
Contact: info@thingsboard.io
1010
Generated by: https://github.com/swagger-api/swagger-codegen.git
1111
"""

tb_rest_client/api/api_ce/alarm_comment_controller_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
ThingsBoard open-source IoT platform REST API documentation. # noqa: E501
77
8-
OpenAPI spec version: 3.9.0
8+
OpenAPI spec version: 4.0.0
99
Contact: info@thingsboard.io
1010
Generated by: https://github.com/swagger-api/swagger-codegen.git
1111
"""

tb_rest_client/api/api_ce/alarm_controller_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
ThingsBoard open-source IoT platform REST API documentation. # noqa: E501
77
8-
OpenAPI spec version: 3.9.0
8+
OpenAPI spec version: 4.0.0
99
Contact: info@thingsboard.io
1010
Generated by: https://github.com/swagger-api/swagger-codegen.git
1111
"""

tb_rest_client/api/api_ce/asset_controller_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
ThingsBoard open-source IoT platform REST API documentation. # noqa: E501
77
8-
OpenAPI spec version: 3.9.0
8+
OpenAPI spec version: 4.0.0
99
Contact: info@thingsboard.io
1010
Generated by: https://github.com/swagger-api/swagger-codegen.git
1111
"""

tb_rest_client/api/api_ce/asset_profile_controller_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
ThingsBoard open-source IoT platform REST API documentation. # noqa: E501
77
8-
OpenAPI spec version: 3.9.0
8+
OpenAPI spec version: 4.0.0
99
Contact: info@thingsboard.io
1010
Generated by: https://github.com/swagger-api/swagger-codegen.git
1111
"""

tb_rest_client/api/api_ce/audit_log_controller_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
ThingsBoard open-source IoT platform REST API documentation. # noqa: E501
77
8-
OpenAPI spec version: 3.9.0
8+
OpenAPI spec version: 4.0.0
99
Contact: info@thingsboard.io
1010
Generated by: https://github.com/swagger-api/swagger-codegen.git
1111
"""

0 commit comments

Comments
 (0)