dtiot-d2c 0.9.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. dtiot_d2c/__init__.py +0 -0
  2. dtiot_d2c/cli/CFG.py +409 -0
  3. dtiot_d2c/cli/__init__.py +2 -0
  4. dtiot_d2c/cli/cli_command.py +292 -0
  5. dtiot_d2c/cli/config.py +164 -0
  6. dtiot_d2c/cli/configCLI.py +45 -0
  7. dtiot_d2c/cli/main.py +243 -0
  8. dtiot_d2c/cli/prfmanapi/api_impl/api_utils.py +36 -0
  9. dtiot_d2c/cli/prfmanapi/api_impl/datamodel.py +8 -0
  10. dtiot_d2c/cli/prfmanapi/api_impl/device_report_post.py +42 -0
  11. dtiot_d2c/cli/prfmanapi/api_impl/healthz_get.py +18 -0
  12. dtiot_d2c/cli/prfmanapi/api_impl/job_get_report_file.py +31 -0
  13. dtiot_d2c/cli/prfmanapi/api_impl/profile_get.py +32 -0
  14. dtiot_d2c/cli/prfmanapi/config.py +103 -0
  15. dtiot_d2c/cli/prfmanapi/configs/DEFAULT.py +24 -0
  16. dtiot_d2c/cli/prfmanapi/main.py +155 -0
  17. dtiot_d2c/cli/prfmanapi/utils.py +162 -0
  18. dtiot_d2c/cli/prfmangui/ProfileEditor.py +255 -0
  19. dtiot_d2c/cli/prfmangui/ProfileManagerGui.py +165 -0
  20. dtiot_d2c/cli/prfmangui/ProfileSelector.py +173 -0
  21. dtiot_d2c/cli/prfmangui/__init__.py +0 -0
  22. dtiot_d2c/cli/profile.py +165 -0
  23. dtiot_d2c/cli/profileCLI.py +327 -0
  24. dtiot_d2c/cli/profile_webapp.py +126 -0
  25. dtiot_d2c/cli/utils.py +283 -0
  26. dtiot_d2c/d2c/__init__.py +21 -0
  27. dtiot_d2c/d2c/application/__init__.py +3 -0
  28. dtiot_d2c/d2c/application/application.py +341 -0
  29. dtiot_d2c/d2c/application/cli.py +151 -0
  30. dtiot_d2c/d2c/application/consts.py +20 -0
  31. dtiot_d2c/d2c/commands/__init__.py +0 -0
  32. dtiot_d2c/d2c/commands/version.py +32 -0
  33. dtiot_d2c/d2c/consts.py +280 -0
  34. dtiot_d2c/d2c/device/__init__.py +2 -0
  35. dtiot_d2c/d2c/device/cli.py +484 -0
  36. dtiot_d2c/d2c/device/consts.py +30 -0
  37. dtiot_d2c/d2c/device/device.py +1027 -0
  38. dtiot_d2c/d2c/device/message.py +92 -0
  39. dtiot_d2c/d2c/device_group/__init__.py +3 -0
  40. dtiot_d2c/d2c/device_group/cli.py +217 -0
  41. dtiot_d2c/d2c/device_group/consts.py +7 -0
  42. dtiot_d2c/d2c/device_group/device_group.py +409 -0
  43. dtiot_d2c/d2c/get_response.py +100 -0
  44. dtiot_d2c/d2c/onem2m_base.py +178 -0
  45. dtiot_d2c/d2c/test/__init__.py +0 -0
  46. dtiot_d2c/d2c/test/application.py +224 -0
  47. dtiot_d2c/d2c/test/device.py +490 -0
  48. dtiot_d2c/d2c/test/device_group.py +853 -0
  49. dtiot_d2c/d2c/test/perftest_get_resource.py +60 -0
  50. dtiot_d2c/d2c/test/print_sample_test_configuration.py +47 -0
  51. dtiot_d2c/d2c/test/sample_test_configuration.py +122 -0
  52. dtiot_d2c/d2c/test/testcli_base.py +212 -0
  53. dtiot_d2c/d2c/test/utils.py +56 -0
  54. dtiot_d2c/d2c/test/verify_d2c_model.py +163 -0
  55. dtiot_d2c/d2c/test/verify_device_group_consistency.py +86 -0
  56. dtiot_d2c/d2c/utils.py +801 -0
  57. dtiot_d2c/d2c/version_info.py +2 -0
  58. dtiot_d2c/dmo/__init__.py +16 -0
  59. dtiot_d2c/dmo/api_client.py +198 -0
  60. dtiot_d2c/dmo/consts.py +142 -0
  61. dtiot_d2c/dmo/device_provisioning.py +141 -0
  62. dtiot_d2c/dmo/dmo.py +715 -0
  63. dtiot_d2c/dmo/dmoCLI.py +529 -0
  64. dtiot_d2c/dmo/html_utils.py +37 -0
  65. dtiot_d2c/dmo/onem2m_utils.py +132 -0
  66. dtiot_d2c/dmo/utils.py +429 -0
  67. dtiot_d2c-0.9.2.dist-info/METADATA +62 -0
  68. dtiot_d2c-0.9.2.dist-info/RECORD +72 -0
  69. dtiot_d2c-0.9.2.dist-info/WHEEL +5 -0
  70. dtiot_d2c-0.9.2.dist-info/entry_points.txt +2 -0
  71. dtiot_d2c-0.9.2.dist-info/licenses/LICENSE +21 -0
  72. dtiot_d2c-0.9.2.dist-info/top_level.txt +1 -0
dtiot_d2c/__init__.py ADDED
File without changes
dtiot_d2c/cli/CFG.py ADDED
@@ -0,0 +1,409 @@
1
+ import os
2
+
3
+ ###
4
+ # Feature flags of the various CLI command interfaces. Those flags are set by
5
+ # the command implementation to tell the controlling modules what the implemenation
6
+ # requires.
7
+ ###
8
+ REQUIRES_CONFIG = 1
9
+ REQUIRES_PROFILE = 2
10
+ REQUIRES_DMOAPICONNECT = 4
11
+
12
+ # Names of environment variables, directories and files
13
+ ###
14
+
15
+ # Environment variable of the directory which contains the configuration files
16
+ ENVVARNAME_CFGDIR = "D2CCLI_CONFIGDIR"
17
+
18
+ # File which contains the API access configuration
19
+ ENVVARNAME_CFGFILE = "D2CCLI_CONFIGFILE"
20
+
21
+ # Default name of the directory which contains the configuration files
22
+ DEFAULT_CFGDIR_NAME = ".d2c"
23
+
24
+ # Default name of the configuration file
25
+ DEFAULT_CFGFILE_NAME = "config.json"
26
+
27
+ # Name of the profiles sub directory within the configuration directory
28
+ DEFAULT_PROFILES_DIRNAME = "profiles"
29
+ DEFAULT_PROFILES_DIRPATH = "$HOME/%s/%s" % (DEFAULT_CFGDIR_NAME, DEFAULT_PROFILES_DIRNAME)
30
+
31
+ # Profile file extension
32
+ PROFILE_FILE_EXT = "profile"
33
+
34
+ # Configuration element names
35
+ CEN_ACTIVE_PROFILE_FILE = "activeProfileFile"
36
+ CEN_PROFILE_DIR = "profilesDir"
37
+
38
+ # Init configuration
39
+ DEFAULT_CONFIGURATION = {
40
+ "activeProfileFile": "",
41
+ "profilesDir": DEFAULT_PROFILES_DIRPATH
42
+ }
43
+
44
+ # Profile configuration
45
+ PROFILE_CONFIG = {
46
+ "elements": [
47
+ {"name":"profileName", "label":"Profile Name", "type":"string", "state":"normal", "default":"My Profile"},
48
+ {"name":"apiUrl", "label":"API URL", "type":"string", "state":"normal", "default":"https://qa.spacegate.telekom.de/bond/t-iot-hub/device-management-orchestrator/v3/TENANT-REQUIRED"},
49
+ {"name":"getTokenUrl", "label":"Get Token URL", "type":"string", "state":"normal", "default":"https://qa.spacegate.telekom.de/auth/realms/bond/protocol/openid-connect/token"},
50
+ {"name":"clientId", "label":"Client Id", "type":"string", "state":"normal", "default":"t-iot-hub--##########--########-####-####-####-################"},
51
+ {"name":"clientSecret", "label":"Client Secret", "type":"string", "state":"normal", "default":"########-####-####-####-########"},
52
+ ],
53
+ "filenameElements":["profileName", ".profile"]
54
+ }
55
+
56
+ D2CCLI_DEFAULT_ORIGIN="d2ccli"
57
+
58
+ ###
59
+ # Factory function to create an APIConnection object from profile
60
+ from dtiot_d2c.cli.profile import Profile
61
+
62
+
63
+ def createApiConnection(profile:Profile)->any:
64
+ from dtiot_d2c.dmo import ApiClient
65
+ apiClient:ApiClient = ApiClient(api_url=profile.getElement("apiUrl"),
66
+ origin=D2CCLI_DEFAULT_ORIGIN,
67
+ get_token_url=profile.getElement("getTokenUrl"),
68
+ client_id=profile.getElement("clientId"),
69
+ client_secret=profile.getElement("clientSecret"))
70
+
71
+ apiClient.auth()
72
+
73
+ return apiClient
74
+
75
+ ###
76
+ # Configuration of the profile manager web application and api
77
+ # Profile management web application
78
+ #PMWEBAPP_PORT=3000
79
+ # PMWEBAPP_PATH="/profile-manager"
80
+
81
+ # Profile management API
82
+ #from .prfmanapi.configs import DEFAULT as PMAPI_CFG
83
+ #PMAPI_PROTOCOL="http"
84
+ #PMAPI_HOST="127.0.0.1"
85
+ #PMAPI_PORT=PMAPI_CFG.ServicePort
86
+ #PMAPI_PATH=PMAPI_CFG.ServiceName
87
+
88
+ ###
89
+ # Registration of cli commands ...
90
+ CLICommands = [
91
+ {
92
+ "name": "CONFIGURATION",
93
+ "help": "Confguration commands",
94
+ "commands": [
95
+ {
96
+ "name": ["create-configuration", "cc"],
97
+ "cmdFile": "%s/configCLI.py" % (os.path.dirname(__file__)),
98
+ "cmdClass": "CreateConfigurationCLI"
99
+ }
100
+ ]
101
+ },
102
+ {
103
+ "name": "PROFILE",
104
+ "help": "Profile commands",
105
+ "commands": [
106
+ {
107
+ "name": ["list-profiles", "lp"],
108
+ "cmdFile": "%s/profileCLI.py" % (os.path.dirname(__file__)),
109
+ "cmdClass": "ListProfilesCLI"
110
+ },
111
+ {
112
+ "name": ["print-profile", "pp"],
113
+ "cmdFile": "%s/profileCLI.py" % (os.path.dirname(__file__)),
114
+ "cmdClass": "PrintProfileCLI"
115
+ },
116
+ {
117
+ "name": ["add-profile", "ap"],
118
+ "cmdFile": "%s/profileCLI.py" % (os.path.dirname(__file__)),
119
+ "cmdClass": "NewProfileCLI"
120
+ },
121
+ {
122
+ "name": ["modify-profile", "mp"],
123
+ "cmdFile": "%s/profileCLI.py" % (os.path.dirname(__file__)),
124
+ "cmdClass": "EditProfileCLI"
125
+ },
126
+ {
127
+ "name": ["activate-profile", "acp"],
128
+ "cmdFile": "%s/profileCLI.py" % (os.path.dirname(__file__)),
129
+ "cmdClass": "ActivateProfileCLI"
130
+ },
131
+ {
132
+ "name": ["print-active-profile", "pap"],
133
+ "cmdFile": "%s/profileCLI.py" % (os.path.dirname(__file__)),
134
+ "cmdClass": "PrintActivatedProfileCLI"
135
+ },
136
+ {
137
+ "name": ["profile-manager", "pm"],
138
+ "cmdFile": "%s/profileCLI.py" % (os.path.dirname(__file__)),
139
+ "cmdClass": "StartProfileManagerGuiCLI"
140
+ },
141
+ # {
142
+ # "name": ["profile-manager-webapp", "pm2"],
143
+ # "cmdFile": "%s/profileCLI.py" % (os.path.dirname(__file__)),
144
+ # "cmdClass": "StartProfileManagerWebBrowserCLI"
145
+ # }
146
+
147
+ ]
148
+ },
149
+ {
150
+ "name": "DMO",
151
+ "help": "DMO functions",
152
+ "commands": [
153
+ {
154
+ "name": ["get-resources", "gr"],
155
+ "cmdFile": "%s/../dmo/dmoCLI.py" % (os.path.dirname(__file__)),
156
+ "cmdClass": "GetResourcesCLI"
157
+ },
158
+ {
159
+ "name": ["add-resource", "ar"],
160
+ "cmdFile": "%s/../dmo/dmoCLI.py" % (os.path.dirname(__file__)),
161
+ "cmdClass": "AddResourceCLI"
162
+ },
163
+ {
164
+ "name": ["update-resource", "ar"],
165
+ "cmdFile": "%s/../dmo/dmoCLI.py" % (os.path.dirname(__file__)),
166
+ "cmdClass": "UpdateResourceCLI"
167
+ },
168
+ {
169
+ "name": ["delete-resource", "dr"],
170
+ "cmdFile": "%s/../dmo/dmoCLI.py" % (os.path.dirname(__file__)),
171
+ "cmdClass": "DeleteResourceCLI"
172
+ },
173
+ {
174
+ "name": ["get-device-provisioning-requests", "gdpreq"],
175
+ "cmdFile": "%s/../dmo/dmoCLI.py" % (os.path.dirname(__file__)),
176
+ "cmdClass": "GetDeviceProvisioningRequestsCLI"
177
+ },
178
+ {
179
+ "name": ["get-device-provisioning-responses", "gdpres"],
180
+ "cmdFile": "%s/../dmo/dmoCLI.py" % (os.path.dirname(__file__)),
181
+ "cmdClass": "GetDeviceProvisioningResponsesCLI"
182
+ },
183
+ # {
184
+ # {
185
+ # "name": ["update-resource", "ur"],
186
+ # "cmdFile": "%s/../iothubcli/dmoCLI.py" % (os.path.dirname(__file__)),
187
+ # "cmdClass": "UpdateResourceCLI"
188
+ # },
189
+ # {
190
+ # "name": ["add-message-container", "amsgc"],
191
+ # "cmdFile": "%s/../iothubcli/dmoCLI.py" % (os.path.dirname(__file__)),
192
+ # "cmdClass": "AddMessageContainerCLI"
193
+ # },
194
+ # {
195
+ # "name": ["add-subscription", "asub"],
196
+ # "cmdFile": "%s/../iothubcli/dmoCLI.py" % (os.path.dirname(__file__)),
197
+ # "cmdClass": "AddSubscriptionCLI"
198
+ # },
199
+ # {
200
+ # "name": ["post-message", "pmsg"],
201
+ # "cmdFile": "%s/../iothubcli/dmoCLI.py" % (os.path.dirname(__file__)),
202
+ # "cmdClass": "PostMessageToContainerCLI"
203
+ # },
204
+ ]
205
+ },
206
+ # Devices
207
+ {
208
+ "name": "D2C Device Management",
209
+ "help": "D2C functions to manage devices",
210
+ "commands": [
211
+
212
+ {
213
+ "name": ["add-device", "ad"],
214
+ "cmdFile": "%s/../d2c/device/cli.py" % (os.path.dirname(__file__)),
215
+ "cmdClass": "AddDeviceCLI"
216
+ },
217
+ {
218
+ "name": ["add-lwm2m-device", "alwm2md"],
219
+ "cmdFile": "%s/../d2c/device/cli.py" % (os.path.dirname(__file__)),
220
+ "cmdClass": "AddLwm2mDeviceCLI"
221
+ },
222
+ {
223
+ "name": ["get-devices", "gd"],
224
+ "cmdFile": "%s/../d2c/device/cli.py" % (os.path.dirname(__file__)),
225
+ "cmdClass": "GetDevicesCLI"
226
+ },
227
+ {
228
+ "name": ["update-device", "ud"],
229
+ "cmdFile": "%s/../d2c/device/cli.py" % (os.path.dirname(__file__)),
230
+ "cmdClass": "UpdateDeviceCLI"
231
+ },
232
+ {
233
+ "name": ["delete-device", "dd"],
234
+ "cmdFile": "%s/../d2c/device/cli.py" % (os.path.dirname(__file__)),
235
+ "cmdClass": "DeleteDeviceCLI"
236
+ },
237
+ {
238
+ "name": ["inject-uplink-message", "ium"],
239
+ "cmdFile": "%s/../d2c/device/cli.py" % (os.path.dirname(__file__)),
240
+ "cmdClass": "InjectUplinkMessageCLI"
241
+ },
242
+ {
243
+ "name": ["inject-downlink-message", "idm"],
244
+ "cmdFile": "%s/../d2c/device/cli.py" % (os.path.dirname(__file__)),
245
+ "cmdClass": "InjectDownlinkMessageCLI"
246
+ },
247
+ {
248
+ "name": ["get-device-messages", "gdms"],
249
+ "cmdFile": "%s/../d2c/device/cli.py" % (os.path.dirname(__file__)),
250
+ "cmdClass": "GetDeviceMessagesCLI"
251
+ },
252
+ {
253
+ "name": ["delete-device-message", "ddm"],
254
+ "cmdFile": "%s/../d2c/device/cli.py" % (os.path.dirname(__file__)),
255
+ "cmdClass": "DeleteDeviceMessageCLI"
256
+ },
257
+
258
+ ]
259
+ },
260
+ # Applications
261
+ {
262
+ "name": "D2C Application Management",
263
+ "help": "D2C functions to manage applications",
264
+ "commands": [
265
+ {
266
+ "name": ["add-application", "aa"],
267
+ "cmdFile": "%s/../d2c/application/cli.py" % (os.path.dirname(__file__)),
268
+ "cmdClass": "AddApplicationCLI"
269
+ },
270
+ {
271
+ "name": ["get-applications", "ga"],
272
+ "cmdFile": "%s/../d2c/application/cli.py" % (os.path.dirname(__file__)),
273
+ "cmdClass": "GetApplicationsCLI"
274
+ },
275
+ {
276
+ "name": ["update-application", "ua"],
277
+ "cmdFile": "%s/../d2c/application/cli.py" % (os.path.dirname(__file__)),
278
+ "cmdClass": "UpdateApplicationCLI"
279
+ },
280
+ {
281
+ "name": ["delete-application", "da"],
282
+ "cmdFile": "%s/../d2c/application/cli.py" % (os.path.dirname(__file__)),
283
+ "cmdClass": "DeleteApplicationCLI"
284
+ },
285
+ ]
286
+ },
287
+ ### Device Groups
288
+ {
289
+ "name": "D2C Device Group Management",
290
+ "help": "D2C functions to manage device groups",
291
+ "commands": [
292
+ {
293
+ "name": ["add-device-group", "adg"],
294
+ "cmdFile": "%s/../d2c/device_group/cli.py" % (os.path.dirname(__file__)),
295
+ "cmdClass": "AddDeviceGroupCLI"
296
+ },
297
+ {
298
+ "name": ["get-device-groups", "gdg"],
299
+ "cmdFile": "%s/../d2c/device_group/cli.py" % (os.path.dirname(__file__)),
300
+ "cmdClass": "GetDeviceGroupsCLI"
301
+ },
302
+ {
303
+ "name": ["update-device-group", "udg"],
304
+ "cmdFile": "%s/../d2c/device_group/cli.py" % (os.path.dirname(__file__)),
305
+ "cmdClass": "UpdateDeviceGroupCLI"
306
+ },
307
+ {
308
+ "name": ["delete-device-group", "ddg"],
309
+ "cmdFile": "%s/../d2c/device_group/cli.py" % (os.path.dirname(__file__)),
310
+ "cmdClass": "DeleteDeviceGroupCLI"
311
+ },
312
+ {
313
+ "name": ["device-group-update-devices", "dguds"],
314
+ "cmdFile": "%s/../d2c/device_group/cli.py" % (os.path.dirname(__file__)),
315
+ "cmdClass": "ModifyDevicesCLI"
316
+ },
317
+ {
318
+ "name": ["device-group-update-applications", "dguas"],
319
+ "cmdFile": "%s/../d2c/device_group/cli.py" % (os.path.dirname(__file__)),
320
+ "cmdClass": "ModifyApplicationsCLI"
321
+ },
322
+ ]
323
+ },
324
+ # Admin
325
+ {
326
+ "name": "D2C Admin",
327
+ "help": "D2C admin functions",
328
+ "commands": [
329
+ {
330
+ "name": ["add-d2ccli-application"],
331
+ "cmdFile": "%s/../d2c/application/cli.py" % (os.path.dirname(__file__)),
332
+ "cmdClass": "AddC2cCliApplicationCLI"
333
+ },
334
+ {
335
+ "name": ["version"],
336
+ "cmdFile": "%s/../d2c/commands/version.py" % (os.path.dirname(__file__)),
337
+ "cmdClass": "VersionCLI"
338
+ },
339
+ ]
340
+ },
341
+ # Test
342
+ {
343
+ "name": "Tests",
344
+ "help": "Test functions",
345
+ "envVars":["D2CCLI_TEST"],
346
+ "commands": [
347
+ {
348
+ "name": ["verify-d2c-model"],
349
+ "cmdFile": "%s/../d2c/test/verify_d2c_model.py" % (os.path.dirname(__file__)),
350
+ "cmdClass": "VerifyD2CModelCLI"
351
+ },
352
+ {
353
+ "name": ["get-sample-configuration-file"],
354
+ "cmdFile": "%s/../d2c/test/print_sample_test_configuration.py" % (os.path.dirname(__file__)),
355
+ "cmdClass": "PrintSampleTestConfigurationCLI"
356
+ },
357
+ {
358
+ "name": ["test-application-00"],
359
+ "cmdFile": "%s/../d2c/test/application.py" % (os.path.dirname(__file__)),
360
+ "cmdClass": "FunctionalTest_Application00CLI"
361
+ },
362
+ {
363
+ "name": ["test-application-01"],
364
+ "cmdFile": "%s/../d2c/test/application.py" % (os.path.dirname(__file__)),
365
+ "cmdClass": "FunctionalTest_Application01CLI"
366
+ },
367
+ {
368
+ "name": ["test-device-00"],
369
+ "cmdFile": "%s/../d2c/test/device.py" % (os.path.dirname(__file__)),
370
+ "cmdClass": "Tests00_CLI"
371
+ },
372
+ {
373
+ "name": ["test-device-01"],
374
+ "cmdFile": "%s/../d2c/test/device.py" % (os.path.dirname(__file__)),
375
+ "cmdClass": "Tests01_CLI"
376
+ },
377
+ {
378
+ "name": ["test-device-group-01"],
379
+ "cmdFile": "%s/../d2c/test/device_group.py" % (os.path.dirname(__file__)),
380
+ "cmdClass": "Tests01_CLI"
381
+ },
382
+ {
383
+ "name": ["test-device-group-02"],
384
+ "cmdFile": "%s/../d2c/test/device_group.py" % (os.path.dirname(__file__)),
385
+ "cmdClass": "Tests02_CLI"
386
+ },
387
+ {
388
+ "name": ["device-group-test-03"],
389
+ "cmdFile": "%s/../d2c/test/device_group.py" % (os.path.dirname(__file__)),
390
+ "cmdClass": "Tests03_CLI"
391
+ },
392
+ {
393
+ "name": ["test-device-group-04"],
394
+ "cmdFile": "%s/../d2c/test/device_group.py" % (os.path.dirname(__file__)),
395
+ "cmdClass": "Tests04_CLI"
396
+ },
397
+ {
398
+ "name": ["verify-device-group-consistency"],
399
+ "cmdFile": "%s/../d2c/test/verify_device_group_consistency.py" % (os.path.dirname(__file__)),
400
+ "cmdClass": "VerifyDeviceGroupConsistencyCLI"
401
+ },
402
+ {
403
+ "name": ["get-resource-performance-test"],
404
+ "cmdFile": "%s/../d2c/test/perftest_get_resource.py" % (os.path.dirname(__file__)),
405
+ "cmdClass": "PerformanceTest_GetResourceCLI"
406
+ },
407
+ ]
408
+ },
409
+ ]
@@ -0,0 +1,2 @@
1
+
2
+