Skip to content

Commit e97c6f5

Browse files
committed
Updated Beta 3
1 parent e441ae2 commit e97c6f5

10 files changed

Lines changed: 623 additions & 28 deletions

File tree

README.md

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Kepware Configuration API SDK for Python
22

3-
This is a package SDK to create Python modules to conduct operations with the Kepware Configuration API.
3+
This is a package SDK to create Python modules to conduct operations with the Kepware Configuration API. THis package is designed to work with all versions of Kepware that support the Configuration API including Thingworx Kepware Server (TKS), Thingworx Kepware Edge (TKE) and KEPServerEX (KEP).
44

55
## Prerequisites
66

@@ -12,24 +12,38 @@ The client libraries are supported on Python 3.6 or later. All HTTP communicatio
1212

1313
SDK allows for *GET*, *ADD*, *DELETE*, and *MODIFY* functions for the following Kepware configuration objects:
1414

15-
- **Project Properties** *(Get and Modify Only)*
16-
- **Connectivity** *(Channel, Devices, Tags, Tag Groups)*
17-
- **IoT Gateway** *(Agents, IoT Items)*
15+
| Features | TKS/KEP | TKE |
16+
| :----------: | :----------: | :----------: |
17+
| **Project Properties** <br /> *(Get and Modify Only)* | Y | Y |
18+
| **Connectivity** <br /> *(Channel, Devices, Tags, Tag Groups)* | Y | Y |
19+
| **IoT Gateway** <br /> *(Agents, IoT Items)* | Y | Y |
20+
| **Datalogger** <br /> *(Log Groups, Items, Mapping, Triggers, Reset Mapping Service)* | Y | Y |
21+
| **Administration** <br /> *(User Groups, Users, UA Endpoints)* | Y* | Y |
22+
23+
Note (*) - UA Endpoints supported for Kepware Edge only
1824

1925
Methods to read the following logs:
2026

21-
- **Event Log**
22-
- **API Transaction Log**
27+
| Logs | TKS/KEP | TKE |
28+
| :----------: | :----------: | :----------: |
29+
| **Event Log** | Y | Y |
30+
| **API Transaction Log** | Y | Y |
31+
32+
Configuration API *Services* implemented:
2333

24-
Additionally the following *Services* are implemented:
34+
| Services | TKS/KEP | TKE |
35+
| :----------: | :----------: | :----------: |
36+
| **TagGeneration** <br /> *(not supported by all drivers)* | Y | Y |
37+
| **ReinitializeRuntime** | Y* | Y |
2538

26-
- **TagGeneration** *(not supported by all drivers)*
27-
- **ReinitializeRuntime** *(Thingworx Kepware Edge and Kepware Server 6.8+)*
39+
Note (*) - Reinitialize service was implemented for Kepware Server v6.8+
40+
41+
Generic REST methods are provided to use for functions not developed in SDK package. These are found in the Server Class in [connection.py](/kepconfig/connection.py)
2842

2943
## Known Limitations
3044

3145
- Other property configruation for more complex drivers are not explicitly defined
32-
- Other supported plug-ins (Datalogger, Scheduler, etc) are not defined
46+
- Other supported plug-ins (EFM Exporter, Scheduler, etc) are not defined
3347
- When using hostnames (not IP addresses) for connections, delays may occur under certain network configurations as the connection may attempt IPv6 connections first. IPv6 is not supported by Kepware servers at this time.
3448

3549
## Installation
@@ -42,6 +56,8 @@ pip install kepconfig-<version>-py3-none-any.whl -f ./ --no-index
4256

4357
## Key Concepts
4458

59+
NOTE: Samples can also be found in the [samples](samples) folder.
60+
4561
### Create server connection
4662

4763
```python
@@ -64,7 +80,7 @@ For Windows OSes, the Kepware server's instance certificate can be loaded into t
6480

6581
### Create an object
6682

67-
Objects such as channels or devices can be created either sigularly or with children included.
83+
Objects such as channels or devices can be created either singularly or with children included.
6884

6985
### Ex: Add Single channel
7086

@@ -100,3 +116,4 @@ result = tag.add_tag(server, tag_path, tag_info))
100116
**Visit:**
101117
[Kepware.com](https://www.kepware.com/)
102118
[Configuration API Info](https://www.kepware.com/en-us/products/kepserverex/features/configuration-api/)
119+
[PTC.com](https://www.ptc.com/)

kepconfig/admin/user_groups.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
user_groups within the Kepware Administration User Manager through the Kepware Configuration API
99
"""
1010
USERGROUPS_ROOT = '/admin/server_usergroups'
11+
ENABLE_PROPERTY = 'libadminsettings.USERMANAGER_GROUP_ENABLED'
1112

1213
def _create_url(user_group = None):
1314
'''Creates url object for the "server_usergroups" branch of Kepware's project tree. Used
@@ -133,4 +134,40 @@ def get_all_user_groups(server):
133134
'''
134135

135136
r = server._config_get(server.url + _create_url())
136-
return r.payload
137+
return r.payload
138+
139+
def enable_user_group(server, user_group):
140+
'''Enable the user group. Returned object is JSON.
141+
142+
INPUTS:
143+
"server" - instance of the "server" class
144+
145+
"user_group" - name of user group
146+
147+
RETURNS:
148+
True - If a "HTTP 200 - OK" is received from Kepware
149+
150+
EXCEPTIONS:
151+
KepHTTPError - If urllib provides an HTTPError
152+
KepURLError - If urllib provides an URLError
153+
'''
154+
DATA = {ENABLE_PROPERTY: True}
155+
return modify_user_group(server, DATA, user_group)
156+
157+
def disable_user_group(server, user_group):
158+
'''Disable the user group. Returned object is JSON.
159+
160+
INPUTS:
161+
"server" - instance of the "server" class
162+
163+
"user_group" - name of user group
164+
165+
RETURNS:
166+
True - If a "HTTP 200 - OK" is received from Kepware
167+
168+
EXCEPTIONS:
169+
KepHTTPError - If urllib provides an HTTPError
170+
KepURLError - If urllib provides an URLError
171+
'''
172+
DATA = {ENABLE_PROPERTY: False}
173+
return modify_user_group(server, DATA, user_group)

kepconfig/admin/users.py

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
users within the Kepware Administration User Management through the Kepware Configuration API
99
"""
1010
USERS_ROOT = '/admin/server_users'
11+
ENABLE_PROPERTY = 'libadminsettings.USERMANAGER_USER_ENABLED'
1112

1213
def _create_url(user = None):
1314
'''Creates url object for the "server_users" branch of Kepware's project tree. Used
@@ -133,4 +134,40 @@ def get_all_users(server):
133134
'''
134135

135136
r = server._config_get(server.url + _create_url())
136-
return r.payload
137+
return r.payload
138+
139+
def enable_user(server, user):
140+
'''Enable the user. Returned object is JSON.
141+
142+
INPUTS:
143+
"server" - instance of the "server" class
144+
145+
"user" - name of user
146+
147+
RETURNS:
148+
True - If a "HTTP 200 - OK" is received from Kepware
149+
150+
EXCEPTIONS:
151+
KepHTTPError - If urllib provides an HTTPError
152+
KepURLError - If urllib provides an URLError
153+
'''
154+
DATA = {ENABLE_PROPERTY: True}
155+
return modify_user(server, DATA, user)
156+
157+
def disable_user(server, user):
158+
'''Disable the user. Returned object is JSON.
159+
160+
INPUTS:
161+
"server" - instance of the "server" class
162+
163+
"user" - name of user
164+
165+
RETURNS:
166+
True - If a "HTTP 200 - OK" is received from Kepware
167+
168+
EXCEPTIONS:
169+
KepHTTPError - If urllib provides an HTTPError
170+
KepURLError - If urllib provides an URLError
171+
'''
172+
DATA = {ENABLE_PROPERTY: False}
173+
return modify_user(server, DATA, user)

kepconfig/datalogger/log_group.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,10 @@ def enable_log_group(server, log_group):
154154
KepURLError - If urllib provides an URLError
155155
'''
156156
DATA = {ENABLE_PROPERTY: True}
157-
modify_log_group(server, DATA, log_group)
157+
return modify_log_group(server, DATA, log_group)
158158

159159
def disable_log_group(server, log_group):
160-
'''Enable the log group. Returned object is JSON.
160+
'''Disable the log group. Returned object is JSON.
161161
162162
INPUTS:
163163
"server" - instance of the "server" class
@@ -172,7 +172,7 @@ def disable_log_group(server, log_group):
172172
KepURLError - If urllib provides an URLError
173173
'''
174174
DATA = {ENABLE_PROPERTY: False}
175-
modify_log_group(server, DATA, log_group)
175+
return modify_log_group(server, DATA, log_group)
176176

177177
def reset_column_mapping_service(server, log_group):
178178
'''Executes a ResetColumnMapping serivce call to the log group

0 commit comments

Comments
 (0)