diff --git a/README.md b/README.md
index 7b4eb8c..8a89c7d 100644
--- a/README.md
+++ b/README.md
@@ -23,14 +23,17 @@ Package allows for *GET*, *ADD*, *DELETE*, and *MODIFY* functions for the follow
| **IoT Gateway** *(Agents, IoT Items)* | Y | Y |
| **Datalogger** *(Log Groups, Items, Mapping, Triggers, Reset Mapping Service)* | Y | Y |
| **UA Gateway** *(Certificates, Server Endpoints, Client Connections, Server Interface parameters)* | Y*** | N |
+| **Advanced Tags** *(All tag types and tag groups)*| Y****** | N |
| **Administration** *(User Groups, Users, UA Endpoints, Local License Server)* | Y* | Y |
| **Product Info and Health Status\*\*** | Y | Y |
| **Import Project (via JsonProjectLoad Service) / Export Project\*\*\*\***| Y | Y |
+| **Backup Project (via CreateBackup Service) / Export Project\*\*\*\*\***| Y | Y |
-- Note (*) - UA Endpoints and Local License Server supported for Kepware Edge only
-- Note (**) - Added to Kepware Server v6.13 / Kepware Edge v1.5 and later builds
+- Note (*) - UA Endpoints and Local License Server supported for TKE only
+- Note (**) - Added to Kepware Server v6.13 / TKE v1.5 and later builds
- Note (***) - TKS only v6.16 and later
-- Note (****) - Added to Kepware Server v6.17 / Kepware Edge v1.10 and later builds
+- Note (****) - Added to Kepware Server v6.17 / TKE v1.10 and later builds
+- Note (*****) - Added to Kepware Server v6.18 / TKE v1.11 and later builds
Driver specific features:
@@ -45,6 +48,9 @@ Methods to read the following logs:
| :----------: | :----------: | :----------: |
| **Event Log** | Y | Y |
| **API Transaction Log** | Y | Y |
+| **Audit Log*** | Y | Y |
+
+- Note (*) - Implemented for Kepware Server v6.18+ and TKE 1.11+
Configuration API *Services* implemented:
@@ -54,10 +60,11 @@ Configuration API *Services* implemented:
| **ReinitializeRuntime** | Y* | Y |
| **ProjectLoad and ProjectSave**| Y | Y |
| **JsonProjectLoad\*\*** *(used for import project feature)*| Y | Y |
+| **CreateBackup\*\*\***| Y | Y |
-Note (*) - Reinitialize service was implemented for Kepware Server v6.8+
-
-Note (**) - Added to Kepware Server v6.17 / Kepware Edge v1.10 and later builds
+- Note (*) - Reinitialize service was implemented for Kepware Server v6.8+
+- Note (**) - Added to Kepware Server v6.17 / TKE v1.10 and later builds
+- Note (***) - Added to Kepware Server v6.18 / TKE v1.11 and later builds
Filtering, sorting and pagination query options are added for any collections methods (ex: `get_all_devices()` or `get_all_channel()`).
diff --git a/docs/kepconfig.html b/docs/kepconfig.html
index 1d861cb..6ba5111 100644
--- a/docs/kepconfig.html
+++ b/docs/kepconfig.html
@@ -3,7 +3,7 @@
25LICENSING_CLIENT_ALIAS="libadminsettings.LICENSING_CLIENT_ALIAS" 26 27classlls_config:
- 28'''A class to represent a admin properties for the Local License Server connection from an instance of Kepware.
+ 28'''A class to represent a admin properties for the Local License Server connection from an instance of Kepware. 29 This object is used to easily manage the LLS parameters for a Kepware instance. 30 31 :param server_name: Host name or IP address of the LLS server
@@ -192,7 +141,7 @@
61return"{}".format(self._get_dict()) 62 63defget_lls_config(server:connection.server)->lls_config:
- 64'''Returns the properties of the Local License server connection properties. Returned object is `lls_config` class object.
+ 64'''Returns the properties of the Local License server connection properties. Returned object is `lls_config` class object. 65 66 :param server: instance of the `server` class 67
@@ -206,7 +155,7 @@
75returnlls_config(r.payload) 76 77defupdate_lls_config(server:connection.server,config:lls_config)->bool:
- 78'''Updates the Local License Server connection properties for Kepware.
+ 78'''Updates the Local License Server connection properties for Kepware. 79 80 :param server: instance of the `server` class 81 :param config: `lls_config` class object with lls connection configuration
@@ -223,7 +172,7 @@
92else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload) 93 94defenable_lls(server:connection.server)->bool:
- 95'''Enables the Local License Server connection for Kepware.
+ 95'''Enables the Local License Server connection for Kepware. 96 97 :param server: instance of the `server` class 98
@@ -238,7 +187,7 @@
107else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)108109defdisable_lls(server:connection.server)->bool:
-110'''Disables the Local License Server connection for Kepware.
+110'''Disables the Local License Server connection for Kepware.111112 :param server: instance of the `server` class113
@@ -253,7 +202,7 @@
122else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)123124defforce_license_check(server:connection.server,job_ttl:int=None):
-125'''Executes a ForceLicenseCheck service call to the Kepware instance. This triggers the server to verify the
+125'''Executes a ForceLicenseCheck service call to the Kepware instance. This triggers the server to verify the 126 license state of the license received from the Local License Server.127128 :param server: instance of the `server` class
@@ -272,126 +221,6 @@
28classlls_config:
-29'''A class to represent a admin properties for the Local License Server connection from an instance of Kepware.
+29'''A class to represent a admin properties for the Local License Server connection from an instance of Kepware. 30 This object is used to easily manage the LLS parameters for a Kepware instance. 3132 :param server_name: Host name or IP address of the LLS server
@@ -481,83 +310,6 @@
Parameters
-
-
-
- server_name
-
-
-
-
-
-
-
-
-
-
- server_port
-
-
-
-
-
-
-
-
-
-
- check_period
-
-
-
-
-
-
-
-
-
-
- server_port_SSL
-
-
-
-
-
-
-
-
-
-
- allow_insecure_comms
-
-
-
-
-
-
-
-
-
-
- allow_self_signed_certs
-
-
-
-
-
-
-
-
-
-
- instance_alias_name
-
-
-
-
-
-
-
@@ -572,7 +324,7 @@
Parameters
64defget_lls_config(server:connection.server)->lls_config:
-65'''Returns the properties of the Local License server connection properties. Returned object is `lls_config` class object.
+65'''Returns the properties of the Local License server connection properties. Returned object is `lls_config` class object.6667 :param server: instance of the `server` class68
@@ -623,7 +375,7 @@
Raises
78defupdate_lls_config(server:connection.server,config:lls_config)->bool:
-79'''Updates the Local License Server connection properties for Kepware.
+79'''Updates the Local License Server connection properties for Kepware.8081 :param server: instance of the `server` class82 :param config: `lls_config` class object with lls connection configuration
@@ -678,7 +430,7 @@
Raises
95defenable_lls(server:connection.server)->bool:
- 96'''Enables the Local License Server connection for Kepware.
+ 96'''Enables the Local License Server connection for Kepware. 97 98 :param server: instance of the `server` class 99
@@ -730,7 +482,7 @@
Raises
110defdisable_lls(server:connection.server)->bool:
-111'''Disables the Local License Server connection for Kepware.
+111'''Disables the Local License Server connection for Kepware.112113 :param server: instance of the `server` class114
@@ -782,7 +534,7 @@
Raises
125defforce_license_check(server:connection.server,job_ttl:int=None):
-126'''Executes a ForceLicenseCheck service call to the Kepware instance. This triggers the server to verify the
+126'''Executes a ForceLicenseCheck service call to the Kepware instance. This triggers the server to verify the 127 license state of the license received from the Local License Server.128129 :param server: instance of the `server` class
diff --git a/docs/kepconfig/admin/ua_server.html b/docs/kepconfig/admin/ua_server.html
index 3d684f2..532048b 100644
--- a/docs/kepconfig/admin/ua_server.html
+++ b/docs/kepconfig/admin/ua_server.html
@@ -3,7 +3,7 @@
-
+
kepconfig.admin.ua_server API documentation
@@ -30,9 +30,6 @@
16UA_ROOT='/admin/ua_endpoints' 17 18def_create_url(endpoint=None):
- 19'''Creates url object for the "server_users" branch of Kepware's project tree. Used
+ 19'''Creates url object for the "server_users" branch of Kepware's project tree. Used 20 to build a part of Kepware Configuration API URL structure 21 22 Returns the user specific url when a value is passed as the user name.
@@ -102,7 +99,7 @@
28return'{}/{}'.format(UA_ROOT,_url_parse_object(endpoint)) 29 30defadd_endpoint(server:server,DATA:Union[dict,list])->Union[bool,list]:
- 31'''Add an `"endpoint"` or multiple `"endpoint"` objects to Kepware UA Server by passing a
+ 31'''Add an `"endpoint"` or multiple `"endpoint"` objects to Kepware UA Server by passing a 32 list of endpoints to be added all at once. 33 34 :param server: instance of the `server` class
@@ -127,7 +124,7 @@
53else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload) 54 55defdel_endpoint(server:server,endpoint:str)->bool:
- 56'''Delete an `"endpoint"` object in Kepware UA Server
+ 56'''Delete an `"endpoint"` object in Kepware UA Server 57 58 :param server: instance of the `server` class 59 :param endpoint: name of endpoint to delete
@@ -143,7 +140,7 @@
69else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload) 70 71defmodify_endpoint(server:server,DATA:dict,endpoint:str=None)->bool:
- 72'''Modify a `"endpoint"` object and it's properties in Kepware UA Server. If a `"endpoint"` is not provided as an input,
+ 72'''Modify a `"endpoint"` object and it's properties in Kepware UA Server. If a `"endpoint"` is not provided as an input, 73 you need to identify the endpoint in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will 74 assume that is the endpoint that is to be modified. 75
@@ -171,7 +168,7 @@
97else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload) 98 99defget_endpoint(server:server,endpoint:str)->dict:
-100'''Returns the properties of the `"endpoint"` object.
+100'''Returns the properties of the `"endpoint"` object.101102 :param server: instance of the `server` class103 :param endpoint: name of endpoint to retrieve
@@ -186,7 +183,7 @@
112returnr.payload113114defget_all_endpoints(server:server,*,options:dict=None)->list:
-115'''Returns list of all `"endpoint"` objects and their properties.
+115'''Returns list of all `"endpoint"` objects and their properties.116117 :param server: instance of the `server` class118 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of UA endpoints. Options are 'filter',
@@ -204,18 +201,6 @@
-
-
- UA_ROOT =
-'/admin/ua_endpoints'
-
-
-
-
-
-
-
-
@@ -228,7 +213,7 @@
31defadd_endpoint(server:server,DATA:Union[dict,list])->Union[bool,list]:
-32'''Add an `"endpoint"` or multiple `"endpoint"` objects to Kepware UA Server by passing a
+32'''Add an `"endpoint"` or multiple `"endpoint"` objects to Kepware UA Server by passing a 33 list of endpoints to be added all at once.3435 :param server: instance of the `server` class
@@ -299,7 +284,7 @@
Raises
56defdel_endpoint(server:server,endpoint:str)->bool:
-57'''Delete an `"endpoint"` object in Kepware UA Server
+57'''Delete an `"endpoint"` object in Kepware UA Server5859 :param server: instance of the `server` class60 :param endpoint: name of endpoint to delete
@@ -353,7 +338,7 @@
Raises
72defmodify_endpoint(server:server,DATA:dict,endpoint:str=None)->bool:
-73'''Modify a `"endpoint"` object and it's properties in Kepware UA Server. If a `"endpoint"` is not provided as an input,
+73'''Modify a `"endpoint"` object and it's properties in Kepware UA Server. If a `"endpoint"` is not provided as an input,74 you need to identify the endpoint in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will 75 assume that is the endpoint that is to be modified.76
@@ -422,7 +407,7 @@
Raises
100defget_endpoint(server:server,endpoint:str)->dict:
-101'''Returns the properties of the `"endpoint"` object.
+101'''Returns the properties of the `"endpoint"` object.102103 :param server: instance of the `server` class104 :param endpoint: name of endpoint to retrieve
@@ -475,7 +460,7 @@
Raises
115defget_all_endpoints(server:server,*,options:dict=None)->list:
-116'''Returns list of all `"endpoint"` objects and their properties.
+116'''Returns list of all `"endpoint"` objects and their properties.117118 :param server: instance of the `server` class119 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of UA endpoints. Options are 'filter',
diff --git a/docs/kepconfig/admin/user_groups.html b/docs/kepconfig/admin/user_groups.html
index 9df7996..2cfa9ad 100644
--- a/docs/kepconfig/admin/user_groups.html
+++ b/docs/kepconfig/admin/user_groups.html
@@ -3,7 +3,7 @@
-
+
kepconfig.admin.user_groups API documentation
@@ -30,12 +30,6 @@
17ENABLE_PROPERTY='libadminsettings.USERMANAGER_GROUP_ENABLED' 18 19def_create_url(user_group=None):
- 20'''Creates url object for the "server_usergroups" branch of Kepware's project tree. Used
+ 20'''Creates url object for the "server_usergroups" branch of Kepware's project tree. Used 21 to build a part of Kepware Configuration API URL structure 22 23 Returns the user group specific url when a value is passed as the user_group name.
@@ -112,7 +106,7 @@
29return'{}/{}'.format(USERGROUPS_ROOT,_url_parse_object(user_group)) 30 31defadd_user_group(server:server,DATA:Union[dict,list])->Union[bool,list]:
- 32'''Add a `"user group"` or multiple `"user group"` objects to Kepware User Manager by passing a
+ 32'''Add a `"user group"` or multiple `"user group"` objects to Kepware User Manager by passing a 33 list of user groups to be added all at once. 34 35 :param server: instance of the `server` class
@@ -137,7 +131,7 @@
54else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload) 55 56defdel_user_group(server:server,user_group:str)->bool:
- 57'''Delete a `"user group"` object in Kepware User Manager
+ 57'''Delete a `"user group"` object in Kepware User Manager 58 59 :param server: instance of the `server` class 60 :param user_group: name of user group to delete
@@ -153,7 +147,7 @@
70else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload) 71 72defmodify_user_group(server:server,DATA:dict,*,user_group:str=None)->bool:
- 73'''Modify a `"user group"` object and it's properties in Kepware User Manager. If a `"user group"` is not provided as an input,
+ 73'''Modify a `"user group"` object and it's properties in Kepware User Manager. If a `"user group"` is not provided as an input, 74 you need to identify the user group in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will 75 assume that is the user group that is to be modified. 76
@@ -181,7 +175,7 @@
98else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload) 99100defget_user_group(server:server,user_group:str)->dict:
-101'''Returns the properties of the `"user group"` object.
+101'''Returns the properties of the `"user group"` object.102103 :param server: instance of the `server` class104 :param user_group: name of user group to retrieve
@@ -196,7 +190,7 @@
113returnr.payload114115defget_all_user_groups(server:server,*,options:dict=None)->list:
-116'''Returns list of all `"user group"` objects and their properties.
+116'''Returns list of all `"user group"` objects and their properties.117118 :param server: instance of the `server` class119 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of user groups. Options are 'filter',
@@ -212,7 +206,7 @@
129returnr.payload130131defenable_user_group(server:server,user_group:str)->bool:
-132'''Enable the `"user group"`.
+132'''Enable the `"user group"`.133134 :param server: instance of the `server` class135 :param user_group: name of user group
@@ -226,7 +220,7 @@
143returnmodify_user_group(server,DATA,user_group=user_group)144145defdisable_user_group(server:server,user_group:str)->bool:
-146'''Disable the `"user group"`.
+146'''Disable the `"user group"`.147148 :param server: instance of the `server` class149 :param user_group: name of user group
@@ -242,30 +236,6 @@
32defadd_user_group(server:server,DATA:Union[dict,list])->Union[bool,list]:
-33'''Add a `"user group"` or multiple `"user group"` objects to Kepware User Manager by passing a
+33'''Add a `"user group"` or multiple `"user group"` objects to Kepware User Manager by passing a 34 list of user groups to be added all at once.3536 :param server: instance of the `server` class
@@ -349,7 +319,7 @@
Raises
57defdel_user_group(server:server,user_group:str)->bool:
-58'''Delete a `"user group"` object in Kepware User Manager
+58'''Delete a `"user group"` object in Kepware User Manager5960 :param server: instance of the `server` class61 :param user_group: name of user group to delete
@@ -403,7 +373,7 @@
Raises
73defmodify_user_group(server:server,DATA:dict,*,user_group:str=None)->bool:
-74'''Modify a `"user group"` object and it's properties in Kepware User Manager. If a `"user group"` is not provided as an input,
+74'''Modify a `"user group"` object and it's properties in Kepware User Manager. If a `"user group"` is not provided as an input,75 you need to identify the user group in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will 76 assume that is the user group that is to be modified.77
@@ -472,7 +442,7 @@
Raises
101defget_user_group(server:server,user_group:str)->dict:
-102'''Returns the properties of the `"user group"` object.
+102'''Returns the properties of the `"user group"` object.103104 :param server: instance of the `server` class105 :param user_group: name of user group to retrieve
@@ -525,7 +495,7 @@
Raises
116defget_all_user_groups(server:server,*,options:dict=None)->list:
-117'''Returns list of all `"user group"` objects and their properties.
+117'''Returns list of all `"user group"` objects and their properties.118119 :param server: instance of the `server` class120 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of user groups. Options are 'filter',
@@ -580,7 +550,7 @@
Raises
132defenable_user_group(server:server,user_group:str)->bool:
-133'''Enable the `"user group"`.
+133'''Enable the `"user group"`.134135 :param server: instance of the `server` class136 :param user_group: name of user group
@@ -632,7 +602,7 @@
Raises
146defdisable_user_group(server:server,user_group:str)->bool:
-147'''Disable the `"user group"`.
+147'''Disable the `"user group"`.148149 :param server: instance of the `server` class150 :param user_group: name of user group
diff --git a/docs/kepconfig/admin/users.html b/docs/kepconfig/admin/users.html
index a3b198b..7a4a5b5 100644
--- a/docs/kepconfig/admin/users.html
+++ b/docs/kepconfig/admin/users.html
@@ -3,7 +3,7 @@
-
+
kepconfig.admin.users API documentation
@@ -30,12 +30,6 @@
17ENABLE_PROPERTY='libadminsettings.USERMANAGER_USER_ENABLED' 18 19def_create_url(user=None):
- 20'''Creates url object for the "server_users" branch of Kepware's project tree. Used
+ 20'''Creates url object for the "server_users" branch of Kepware's project tree. Used 21 to build a part of Kepware Configuration API URL structure 22 23 Returns the user specific url when a value is passed as the user name.
@@ -112,7 +106,7 @@
29return'{}/{}'.format(USERS_ROOT,_url_parse_object(user)) 30 31defadd_user(server:server,DATA:Union[dict,list])->Union[bool,list]:
- 32'''Add a `"user"` or multiple `"user"` objects to Kepware User Manager by passing a
+ 32'''Add a `"user"` or multiple `"user"` objects to Kepware User Manager by passing a 33 list of users to be added all at once. 34 35 :param server: instance of the `server` class
@@ -137,7 +131,7 @@
54else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload) 55 56defdel_user(server:server,user:str)->bool:
- 57'''Delete a `"user"` object in Kepware User Manager
+ 57'''Delete a `"user"` object in Kepware User Manager 58 59 :param server: instance of the `server` class 60 :param user: name of user to delete
@@ -153,7 +147,7 @@
70else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload) 71 72defmodify_user(server:server,DATA:dict,*,user:str=None)->bool:
- 73'''Modify a `"user object"` and it's properties in Kepware User Manager. If a `"user"` is not provided as an input,
+ 73'''Modify a `"user object"` and it's properties in Kepware User Manager. If a `"user"` is not provided as an input, 74 you need to identify the user in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will 75 assume that is the user that is to be modified. 76
@@ -181,7 +175,7 @@
98else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload) 99100defget_user(server:server,user:str)->dict:
-101'''Returns the properties of the `"user"` object.
+101'''Returns the properties of the `"user"` object.102103 :param server: instance of the `server` class104 :param user: name of user to retrieve
@@ -196,7 +190,7 @@
113returnr.payload114115defget_all_users(server:server,*,options:dict=None)->list:
-116'''Returns list of all `"user"` objects and their properties.
+116'''Returns list of all `"user"` objects and their properties.117118 :param server: instance of the `server` class119 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of users. Options are 'filter',
@@ -212,7 +206,7 @@
129returnr.payload130131defenable_user(server:server,user:str)->bool:
-132'''Enable the `"user"`.
+132'''Enable the `"user"`.133134 :param server: instance of the `server` class135 :param user: name of user
@@ -226,7 +220,7 @@
143returnmodify_user(server,DATA,user=user)144145defdisable_user(server:server,user:str)->bool:
-146'''Disable the `"user"`.
+146'''Disable the `"user"`.147148 :param server: instance of the `server` class149 :param user: name of user
@@ -242,30 +236,6 @@
32defadd_user(server:server,DATA:Union[dict,list])->Union[bool,list]:
-33'''Add a `"user"` or multiple `"user"` objects to Kepware User Manager by passing a
+33'''Add a `"user"` or multiple `"user"` objects to Kepware User Manager by passing a 34 list of users to be added all at once.3536 :param server: instance of the `server` class
@@ -349,7 +319,7 @@
Raises
57defdel_user(server:server,user:str)->bool:
-58'''Delete a `"user"` object in Kepware User Manager
+58'''Delete a `"user"` object in Kepware User Manager5960 :param server: instance of the `server` class61 :param user: name of user to delete
@@ -403,7 +373,7 @@
Raises
73defmodify_user(server:server,DATA:dict,*,user:str=None)->bool:
-74'''Modify a `"user object"` and it's properties in Kepware User Manager. If a `"user"` is not provided as an input,
+74'''Modify a `"user object"` and it's properties in Kepware User Manager. If a `"user"` is not provided as an input,75 you need to identify the user in the *'common.ALLTYPES_NAME'* property field in the `"DATA"`. It will 76 assume that is the user that is to be modified.77
@@ -472,7 +442,7 @@
Raises
101defget_user(server:server,user:str)->dict:
-102'''Returns the properties of the `"user"` object.
+102'''Returns the properties of the `"user"` object.103104 :param server: instance of the `server` class105 :param user: name of user to retrieve
@@ -525,7 +495,7 @@
Raises
116defget_all_users(server:server,*,options:dict=None)->list:
-117'''Returns list of all `"user"` objects and their properties.
+117'''Returns list of all `"user"` objects and their properties.118119 :param server: instance of the `server` class120 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of users. Options are 'filter',
@@ -580,7 +550,7 @@
Raises
132defenable_user(server:server,user:str)->bool:
-133'''Enable the `"user"`.
+133'''Enable the `"user"`.134135 :param server: instance of the `server` class136 :param user: name of user
@@ -632,7 +602,7 @@
Raises
146defdisable_user(server:server,user:str)->bool:
-147'''Disable the `"user"`.
+147'''Disable the `"user"`.148149 :param server: instance of the `server` class150 :param user: name of user
diff --git a/docs/kepconfig/adv_tags.html b/docs/kepconfig/adv_tags.html
new file mode 100644
index 0000000..e48d046
--- /dev/null
+++ b/docs/kepconfig/adv_tags.html
@@ -0,0 +1,307 @@
+
+
+
+
+
+
+ kepconfig.adv_tags API documentation
+
+
+
+
+
+
+
+
+
+
+
+
adv_tags module provides support for Kepware's Advanced Tags plug-in
+specific objects within the Kepware Configuration API
+
+
+
+
+
+
+
1# -------------------------------------------------------------------------
+ 2# Copyright (c) PTC Inc. and/or all its affiliates. All rights reserved.
+ 3# See License.txt in the project root for
+ 4# license information.
+ 5# --------------------------------------------------------------------------
+ 6
+ 7r"""`adv_tags` module provides support for Kepware's Advanced Tags plug-in
+ 8specific objects within the Kepware Configuration API
+ 9"""
+10
+11from.importadv_tag_group,average_tags,derived_tags,complex_tags,cumulative_tags,min_tags,max_tags,link_tags
+12ADV_TAGS_ROOT='/project/_advancedtags'
+13
+14def_adv_tag_path_split(path:str,*,isItem=False)->dict:
+15'''Used to split the standard Kepware address decimal notation into a dict that contains the
+16 advanced tag path components.
+17
+18 :param path: standard Kepware address in decimal notation ("_advancedtags.tg1.tg2.tg3")
+19 :return: dict that contains the "adv_tag_root" and "tag_path"
+20 :rtype: dict
+21
+22 Ex: path = "_advancedtags.tg1.tg2.tg3"
+23
+24 return = {'adv_tag_root': '_advancedtags', 'tag_path': ['tg1','tg2','tg3']}
+25
+26 Ex: path = "_advancedtags.ch1.dev1"
+27
+28 return = {'adv_tag_root': '_advancedtags', 'tag_path': ['ch1','dev1']}
+29 '''
+30path_list=path.split('.',2)
+31path_obj={}
+32forxinrange(0,len(path_list)):
+33ifx==0:
+34path_obj['adv_tag_root']=path_list[0]
+35elifx==1:
+36ifisItem:
+37path_obj['tag_path']=path_list[1:-1]
+38path_obj['item']=path_list[-1]
+39else:
+40path_obj['tag_path']=path_list[1:]
+41returnpath_obj
+42
+43def_create_adv_tags_base_url(base_url,path_obj):
+44'''Creates url object for the "path_obj" which provides the adv tags tag group structure of Kepware's project tree. Used
+45 to build a part of Kepware Configuration API URL structure
+46
+47 Returns the advanced tag group specific url when a value is passed as the tag group name.
+48 '''
+49url=base_url+ADV_TAGS_ROOT
+50url+=adv_tag_group._create_adv_tags_group_url(path_obj)
+51
+52returnurl
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/kepconfig/adv_tags/adv_tag_group.html b/docs/kepconfig/adv_tags/adv_tag_group.html
new file mode 100644
index 0000000..36df210
--- /dev/null
+++ b/docs/kepconfig/adv_tags/adv_tag_group.html
@@ -0,0 +1,749 @@
+
+
+
+
+
+
+ kepconfig.adv_tags.adv_tag_group API documentation
+
+
+
+
+
+
+
+
+
+
+
+
adv_tag_group exposes an API to allow modifications (add, delete, modify) to
+tag group objects within the Kepware Configuration API
+
+
+
+
+
+
+
1# filepath: c:\Users\rlabbe\OneDrive - PTC\Documents\GitHub\Kepware-ConfigAPI-SDK-Python\kepconfig\connectivity\adv_tag_group.py
+ 2# -------------------------------------------------------------------------
+ 3# Copyright (c) PTC Inc. and/or all its affiliates. All rights reserved.
+ 4# See License.txt in the project root for
+ 5# license information.
+ 6# --------------------------------------------------------------------------
+ 7
+ 8# Note: The code within this file was created in total or in part
+ 9# with the use of AI tools.
+ 10
+ 11
+ 12r"""`adv_tag_group` exposes an API to allow modifications (add, delete, modify) to
+ 13tag group objects within the Kepware Configuration API
+ 14"""
+ 15
+ 16from..connectionimportKepServiceResponse,server
+ 17from..errorimportKepHTTPError,KepError
+ 18from..utilsimport_url_parse_object,path_split
+ 19fromtypingimportUnion
+ 20from..importadv_tags
+ 21importinspect
+ 22
+ 23TAG_GROUP_ROOT='/advanced_tag_groups'
+ 24
+ 25def_create_url(tag_group=None):
+ 26'''Creates url object for the "tag group" branch of Kepware's project tree. Used
+ 27 to build a part of Kepware Configuration API URL structure
+ 28
+ 29 Returns the tag group specific url when a value is passed as the tag group name.
+ 30 '''
+ 31iftag_groupisNone:
+ 32returnTAG_GROUP_ROOT
+ 33else:
+ 34return'{}/{}'.format(TAG_GROUP_ROOT,_url_parse_object(tag_group))
+ 35
+ 36def_create_adv_tags_group_url(path_obj):
+ 37'''Creates url object for the "path_obj" which provides the adv tags tag group structure of Kepware's project tree. Used
+ 38 to build a part of Kepware Configuration API URL structure
+ 39
+ 40 Returns the advanced tag group specific url when a value is passed as the tag group name.
+ 41 '''
+ 42
+ 43try:
+ 44url=''
+ 45if'tag_path'inpath_obj:
+ 46forobjinpath_obj['tag_path']:
+ 47url+=_create_url(obj)
+ 48exceptKeyErroraserr:
+ 49err_msg='Error: No key {} identified | Function: {}'.format(err,inspect.currentframe().f_code.co_name)
+ 50raiseKepError(err_msg)
+ 51exceptExceptionase:
+ 52err_msg=f'Error: Error with {inspect.currentframe().f_code.co_name}: {str(e)}'
+ 53raiseKepError(err_msg)
+ 54returnurl
+ 55
+ 56defadd_tag_group(server:server,adv_tag_group_path:str,DATA:Union[dict,list])->Union[bool,list]:
+ 57# TODO: confirm adding tag types in this folder
+ 58# TODO: Do we need to require the tag group path if we are adding a tag group at the root? (i.e. _advancedtags)
+ 59'''Add a `"tag group"` or multiple `"tag group"` objects to a device in Kepware. Can be used to pass children of a tag group object
+ 60 such as tags. This allows you to create a tag group and tags
+ 61 all in one function, if desired.
+ 62
+ 63 Additionally it can be used to pass a list of tag groups and its children to be added all at once.
+ 64
+ 65 :param server: instance of the `server` class
+ 66 :param adv_tag_group_path: path identifying tag group to add the tag group object(s). Standard Kepware address decimal
+ 67 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+ 68 :param DATA: Dict or List of Dicts of the tag group(s) and its children
+ 69 expected by Kepware Configuration API
+ 70
+ 71 :return: True - If a "HTTP 201 - Created" is received from Kepware server
+ 72 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+ 73 tag groups added that failed.
+ 74
+ 75 :raises KepHTTPError: If urllib provides an HTTPError
+ 76 :raises KepURLError: If urllib provides an URLError
+ 77 '''
+ 78path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+ 79url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_create_url()
+ 80
+ 81r=server._config_add(url,DATA)
+ 82ifr.code==201:returnTrue
+ 83elifr.code==207:
+ 84errors=[]
+ 85foriteminr.payload:
+ 86ifitem['code']!=201:
+ 87errors.append(item)
+ 88returnerrors
+ 89else:
+ 90raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+ 91
+ 92defdel_tag_group(server:server,adv_tag_group_path:str)->bool:
+ 93'''Delete a `"tag group"` object in Kepware. This will delete all children as well.
+ 94
+ 95 :param server: instance of the `server` class
+ 96 :param adv_tag_group_path: path identifying tag group to delete. Standard Kepware address decimal
+ 97 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+ 98
+ 99 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+100
+101 :raises KepHTTPError: If urllib provides an HTTPError
+102 :raises KepURLError: If urllib provides an URLError
+103 '''
+104
+105# url = _create_url(server.url, adv_tag_group_path, isItem=True)
+106path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=True)
+107url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_create_url(path_obj['item'])
+108r=server._config_del(url)
+109ifr.code==200:returnTrue
+110else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+111
+112defmodify_tag_group(server:server,adv_tag_group_path:str,DATA:dict,force:bool=False)->bool:
+113'''Modify a tag group object and its properties in Kepware.
+114
+115 :param server: instance of the `server` class
+116 :param adv_tag_group_path: path identifying the advanced tag group to modify. Standard Kepware address decimal
+117 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+118 :param DATA: Dict of the advanced tag group properties to be modified
+119 :param force: *(optional)* if True, will force the configuration update to the Kepware server
+120
+121 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+122
+123 :raises KepHTTPError: If urllib provides an HTTPError
+124 :raises KepURLError: If urllib provides an URLError
+125 '''
+126
+127tag_group_data=server._force_update_check(force,DATA)
+128path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=True)
+129url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_create_url(path_obj['item'])
+130
+131r=server._config_update(url,tag_group_data)
+132ifr.code==200:returnTrue
+133else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+134
+135defget_tag_group(server:server,adv_tag_group_path:str)->dict:
+136'''Returns the properties of the tag group object.
+137
+138 :param server: instance of the `server` class
+139 :param adv_tag_group_path: path identifying the advanced tag group to retrieve. Standard Kepware address decimal
+140 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+141
+142 :return: Dict of data for the tag group requested
+143
+144 :raises KepHTTPError: If urllib provides an HTTPError
+145 :raises KepURLError: If urllib provides an URLError
+146 '''
+147path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=True)
+148url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_create_url(path_obj['item'])
+149r=server._config_get(url)
+150returnr.payload
+151
+152defget_all_tag_groups(server:server,adv_tag_group_path:str,*,options:dict=None)->list:
+153'''Returns list of all tag group objects and their properties within a tag group. Returned object is JSON list.
+154
+155 :param server: instance of the `server` class
+156 :param adv_tag_group_path: path identifying the advanced tag group collection to retrieve. Standard Kepware address decimal
+157 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+158
+159 :return: List of data for all tag groups within the tag group
+160
+161 :raises KepHTTPError: If urllib provides an HTTPError
+162 :raises KepURLError: If urllib provides an URLError
+163 '''
+164path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=True)
+165url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_create_url()
+166r=server._config_get(url,params=options)
+167returnr.payload
+
57defadd_tag_group(server:server,adv_tag_group_path:str,DATA:Union[dict,list])->Union[bool,list]:
+58# TODO: confirm adding tag types in this folder
+59# TODO: Do we need to require the tag group path if we are adding a tag group at the root? (i.e. _advancedtags)
+60'''Add a `"tag group"` or multiple `"tag group"` objects to a device in Kepware. Can be used to pass children of a tag group object
+61 such as tags. This allows you to create a tag group and tags
+62 all in one function, if desired.
+63
+64 Additionally it can be used to pass a list of tag groups and its children to be added all at once.
+65
+66 :param server: instance of the `server` class
+67 :param adv_tag_group_path: path identifying tag group to add the tag group object(s). Standard Kepware address decimal
+68 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+69 :param DATA: Dict or List of Dicts of the tag group(s) and its children
+70 expected by Kepware Configuration API
+71
+72 :return: True - If a "HTTP 201 - Created" is received from Kepware server
+73 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+74 tag groups added that failed.
+75
+76 :raises KepHTTPError: If urllib provides an HTTPError
+77 :raises KepURLError: If urllib provides an URLError
+78 '''
+79path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+80url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_create_url()
+81
+82r=server._config_add(url,DATA)
+83ifr.code==201:returnTrue
+84elifr.code==207:
+85errors=[]
+86foriteminr.payload:
+87ifitem['code']!=201:
+88errors.append(item)
+89returnerrors
+90else:
+91raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Add a "tag group" or multiple "tag group" objects to a device in Kepware. Can be used to pass children of a tag group object
+such as tags. This allows you to create a tag group and tags
+all in one function, if desired.
+
+
Additionally it can be used to pass a list of tag groups and its children to be added all at once.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying tag group to add the tag group object(s). Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+
DATA: Dict or List of Dicts of the tag group(s) and its children
+expected by Kepware Configuration API
+
+
+
Returns
+
+
+
True - If a "HTTP 201 - Created" is received from Kepware server
+
+
+
Returns
+
+
+
If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+ tag groups added that failed.
93defdel_tag_group(server:server,adv_tag_group_path:str)->bool:
+ 94'''Delete a `"tag group"` object in Kepware. This will delete all children as well.
+ 95
+ 96 :param server: instance of the `server` class
+ 97 :param adv_tag_group_path: path identifying tag group to delete. Standard Kepware address decimal
+ 98 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+ 99
+100 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+101
+102 :raises KepHTTPError: If urllib provides an HTTPError
+103 :raises KepURLError: If urllib provides an URLError
+104 '''
+105
+106# url = _create_url(server.url, adv_tag_group_path, isItem=True)
+107path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=True)
+108url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_create_url(path_obj['item'])
+109r=server._config_del(url)
+110ifr.code==200:returnTrue
+111else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Delete a "tag group" object in Kepware. This will delete all children as well.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying tag group to delete. Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+
+
+
Returns
+
+
+
True - If a "HTTP 200 - OK" is received from Kepware server
113defmodify_tag_group(server:server,adv_tag_group_path:str,DATA:dict,force:bool=False)->bool:
+114'''Modify a tag group object and its properties in Kepware.
+115
+116 :param server: instance of the `server` class
+117 :param adv_tag_group_path: path identifying the advanced tag group to modify. Standard Kepware address decimal
+118 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+119 :param DATA: Dict of the advanced tag group properties to be modified
+120 :param force: *(optional)* if True, will force the configuration update to the Kepware server
+121
+122 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+123
+124 :raises KepHTTPError: If urllib provides an HTTPError
+125 :raises KepURLError: If urllib provides an URLError
+126 '''
+127
+128tag_group_data=server._force_update_check(force,DATA)
+129path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=True)
+130url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_create_url(path_obj['item'])
+131
+132r=server._config_update(url,tag_group_data)
+133ifr.code==200:returnTrue
+134else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Modify a tag group object and its properties in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying the advanced tag group to modify. Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+
DATA: Dict of the advanced tag group properties to be modified
+
force: (optional) if True, will force the configuration update to the Kepware server
+
+
+
Returns
+
+
+
True - If a "HTTP 200 - OK" is received from Kepware server
136defget_tag_group(server:server,adv_tag_group_path:str)->dict:
+137'''Returns the properties of the tag group object.
+138
+139 :param server: instance of the `server` class
+140 :param adv_tag_group_path: path identifying the advanced tag group to retrieve. Standard Kepware address decimal
+141 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+142
+143 :return: Dict of data for the tag group requested
+144
+145 :raises KepHTTPError: If urllib provides an HTTPError
+146 :raises KepURLError: If urllib provides an URLError
+147 '''
+148path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=True)
+149url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_create_url(path_obj['item'])
+150r=server._config_get(url)
+151returnr.payload
+
+
+
+
Returns the properties of the tag group object.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying the advanced tag group to retrieve. Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
153defget_all_tag_groups(server:server,adv_tag_group_path:str,*,options:dict=None)->list:
+154'''Returns list of all tag group objects and their properties within a tag group. Returned object is JSON list.
+155
+156 :param server: instance of the `server` class
+157 :param adv_tag_group_path: path identifying the advanced tag group collection to retrieve. Standard Kepware address decimal
+158 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+159
+160 :return: List of data for all tag groups within the tag group
+161
+162 :raises KepHTTPError: If urllib provides an HTTPError
+163 :raises KepURLError: If urllib provides an URLError
+164 '''
+165path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=True)
+166url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_create_url()
+167r=server._config_get(url,params=options)
+168returnr.payload
+
+
+
+
Returns list of all tag group objects and their properties within a tag group. Returned object is JSON list.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying the advanced tag group collection to retrieve. Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+
+
+
Returns
+
+
+
List of data for all tag groups within the tag group
+
+
+
Raises
+
+
+
KepHTTPError: If urllib provides an HTTPError
+
KepURLError: If urllib provides an URLError
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/kepconfig/adv_tags/average_tags.html b/docs/kepconfig/adv_tags/average_tags.html
new file mode 100644
index 0000000..f489786
--- /dev/null
+++ b/docs/kepconfig/adv_tags/average_tags.html
@@ -0,0 +1,725 @@
+
+
+
+
+
+
+ kepconfig.adv_tags.average_tags API documentation
+
+
+
+
+
+
+
+
+
+
+
+
average_tags exposes an API to allow modifications (add, delete, modify) to
+average tag objects within the Kepware Configuration API
+
+
+
+
+
+
+
1# -------------------------------------------------------------------------
+ 2# Copyright (c) PTC Inc. and/or all its affiliates. All rights reserved.
+ 3# See License.txt in the project root for
+ 4# license information.
+ 5# --------------------------------------------------------------------------
+ 6
+ 7# Note: The code within this file was created in total or in part
+ 8# with the use of AI tools.
+ 9
+ 10r"""`average_tags` exposes an API to allow modifications (add, delete, modify) to
+ 11average tag objects within the Kepware Configuration API
+ 12"""
+ 13
+ 14from..connectionimportserver
+ 15from..errorimportKepError,KepHTTPError
+ 16from..utilsimport_url_parse_object
+ 17fromtypingimportUnion
+ 18from..importadv_tags
+ 19
+ 20AVERAGE_TAGS_ROOT='/average_tags'
+ 21
+ 22def_get_average_tags_url(tag:str=None)->str:
+ 23'''Creates url object for the "average_tags" branch of Kepware's project tree.
+ 24
+ 25 Returns the average tag specific url when a value is passed as the tag name.
+ 26 '''
+ 27iftagisNone:
+ 28returnAVERAGE_TAGS_ROOT
+ 29else:
+ 30returnf'{AVERAGE_TAGS_ROOT}/{_url_parse_object(tag)}'
+ 31
+ 32defadd_average_tag(server:server,adv_tag_group_path:str,DATA:Union[dict,list])->Union[bool,list]:
+ 33'''Add `"average_tag"` or multiple `"average_tag"` objects to a specific path in Kepware.
+ 34 Can be used to pass a list of average tags to be added at one path location.
+ 35
+ 36 :param server: instance of the `server` class
+ 37 :param adv_tag_group_path: path identifying where to add average tag(s). Standard Kepware address decimal
+ 38 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+ 39 :param DATA: Dict or List of Dicts of the average tag(s) to add
+ 40
+ 41 :return: True - If a "HTTP 201 - Created" is received from Kepware server
+ 42 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+ 43 average tags added that failed.
+ 44
+ 45 :raises KepHTTPError: If urllib provides an HTTPError
+ 46 :raises KepURLError: If urllib provides an URLError
+ 47 '''
+ 48path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+ 49url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_average_tags_url()
+ 50
+ 51r=server._config_add(url,DATA)
+ 52ifr.code==201:
+ 53returnTrue
+ 54elifr.code==207:
+ 55errors=[]
+ 56foriteminr.payload:
+ 57ifitem['code']!=201:
+ 58errors.append(item)
+ 59returnerrors
+ 60else:
+ 61raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+ 62
+ 63defmodify_average_tag(server:server,avg_tag_path:str,DATA:dict,force:bool=False)->bool:
+ 64'''Modify an `"average_tag"` object and its properties in Kepware.
+ 65
+ 66 :param server: instance of the `server` class
+ 67 :param avg_tag_path: path identifying location and average tag to modify. Standard Kepware address decimal
+ 68 notation string including the average tag such as "_advancedtags.AdvTagGroup1.AvgTag1"
+ 69 :param DATA: Dict of the `average_tag` properties to be modified
+ 70 :param force: *(optional)* if True, will force the configuration update to the Kepware server
+ 71
+ 72 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 73
+ 74 :raises KepHTTPError: If urllib provides an HTTPError
+ 75 :raises KepURLError: If urllib provides an URLError
+ 76 '''
+ 77avg_tag_data=server._force_update_check(force,DATA)
+ 78path_obj=adv_tags._adv_tag_path_split(avg_tag_path,isItem=True)
+ 79url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_average_tags_url(path_obj['item'])
+ 80
+ 81r=server._config_update(url,avg_tag_data)
+ 82ifr.code==200:
+ 83returnTrue
+ 84else:
+ 85raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+ 86
+ 87defdel_average_tag(server:server,avg_tag_path:str)->bool:
+ 88'''Delete `"average_tag"` object at a specific path in Kepware.
+ 89
+ 90 :param server: instance of the `server` class
+ 91 :param avg_tag_path: path identifying location and average tag to delete. Standard Kepware address decimal
+ 92 notation string including the average tag such as "_advancedtags.AdvTagGroup1.AvgTag1"
+ 93
+ 94 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 95
+ 96 :raises KepHTTPError: If urllib provides an HTTPError
+ 97 :raises KepURLError: If urllib provides an URLError
+ 98 '''
+ 99path_obj=adv_tags._adv_tag_path_split(avg_tag_path,isItem=True)
+100url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_average_tags_url(path_obj['item'])
+101
+102r=server._config_del(url)
+103ifr.code==200:
+104returnTrue
+105else:
+106raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+107
+108defget_average_tag(server:server,avg_tag_path:str)->dict:
+109'''Returns the properties of the `"average_tag"` object at a specific path in Kepware.
+110
+111 :param server: instance of the `server` class
+112 :param avg_tag_path: path identifying location and average tag to retrieve. Standard Kepware address decimal
+113 notation string including the average tag such as "_advancedtags.AdvTagGroup1.AvgTag1"
+114
+115 :return: Dict of data for the average tag requested
+116
+117 :raises KepHTTPError: If urllib provides an HTTPError
+118 :raises KepURLError: If urllib provides an URLError
+119 '''
+120path_obj=adv_tags._adv_tag_path_split(avg_tag_path,isItem=True)
+121url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_average_tags_url(path_obj['item'])
+122
+123r=server._config_get(url)
+124returnr.payload
+125
+126defget_all_average_tags(server:server,adv_tag_group_path:str,*,options:dict=None)->list:
+127'''Returns the properties of all `"average_tag"` objects at a specific path in Kepware.
+128
+129 :param server: instance of the `server` class
+130 :param adv_tag_group_path: path identifying location to retrieve average tag list. Standard Kepware address decimal
+131 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+132 :param options: *(optional)* Dict of parameters to filter, sort or paginate the list of average tags. Options are `filter`,
+133 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
+134
+135 :return: List of data for all average tags
+136
+137 :raises KepHTTPError: If urllib provides an HTTPError
+138 :raises KepURLError: If urllib provides an URLError
+139 '''
+140path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+141url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_average_tags_url()
+142
+143r=server._config_get(url,params=options)
+144returnr.payload
+
33defadd_average_tag(server:server,adv_tag_group_path:str,DATA:Union[dict,list])->Union[bool,list]:
+34'''Add `"average_tag"` or multiple `"average_tag"` objects to a specific path in Kepware.
+35 Can be used to pass a list of average tags to be added at one path location.
+36
+37 :param server: instance of the `server` class
+38 :param adv_tag_group_path: path identifying where to add average tag(s). Standard Kepware address decimal
+39 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+40 :param DATA: Dict or List of Dicts of the average tag(s) to add
+41
+42 :return: True - If a "HTTP 201 - Created" is received from Kepware server
+43 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+44 average tags added that failed.
+45
+46 :raises KepHTTPError: If urllib provides an HTTPError
+47 :raises KepURLError: If urllib provides an URLError
+48 '''
+49path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+50url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_average_tags_url()
+51
+52r=server._config_add(url,DATA)
+53ifr.code==201:
+54returnTrue
+55elifr.code==207:
+56errors=[]
+57foriteminr.payload:
+58ifitem['code']!=201:
+59errors.append(item)
+60returnerrors
+61else:
+62raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Add "average_tag" or multiple "average_tag" objects to a specific path in Kepware.
+Can be used to pass a list of average tags to be added at one path location.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying where to add average tag(s). Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+
DATA: Dict or List of Dicts of the average tag(s) to add
+
+
+
Returns
+
+
+
True - If a "HTTP 201 - Created" is received from Kepware server
+
+
+
Returns
+
+
+
If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+ average tags added that failed.
64defmodify_average_tag(server:server,avg_tag_path:str,DATA:dict,force:bool=False)->bool:
+65'''Modify an `"average_tag"` object and its properties in Kepware.
+66
+67 :param server: instance of the `server` class
+68 :param avg_tag_path: path identifying location and average tag to modify. Standard Kepware address decimal
+69 notation string including the average tag such as "_advancedtags.AdvTagGroup1.AvgTag1"
+70 :param DATA: Dict of the `average_tag` properties to be modified
+71 :param force: *(optional)* if True, will force the configuration update to the Kepware server
+72
+73 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+74
+75 :raises KepHTTPError: If urllib provides an HTTPError
+76 :raises KepURLError: If urllib provides an URLError
+77 '''
+78avg_tag_data=server._force_update_check(force,DATA)
+79path_obj=adv_tags._adv_tag_path_split(avg_tag_path,isItem=True)
+80url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_average_tags_url(path_obj['item'])
+81
+82r=server._config_update(url,avg_tag_data)
+83ifr.code==200:
+84returnTrue
+85else:
+86raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Modify an "average_tag" object and its properties in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
avg_tag_path: path identifying location and average tag to modify. Standard Kepware address decimal
+notation string including the average tag such as "_advancedtags.AdvTagGroup1.AvgTag1"
+
DATA: Dict of the average_tag properties to be modified
+
force: (optional) if True, will force the configuration update to the Kepware server
+
+
+
Returns
+
+
+
True - If a "HTTP 200 - OK" is received from Kepware server
88defdel_average_tag(server:server,avg_tag_path:str)->bool:
+ 89'''Delete `"average_tag"` object at a specific path in Kepware.
+ 90
+ 91 :param server: instance of the `server` class
+ 92 :param avg_tag_path: path identifying location and average tag to delete. Standard Kepware address decimal
+ 93 notation string including the average tag such as "_advancedtags.AdvTagGroup1.AvgTag1"
+ 94
+ 95 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 96
+ 97 :raises KepHTTPError: If urllib provides an HTTPError
+ 98 :raises KepURLError: If urllib provides an URLError
+ 99 '''
+100path_obj=adv_tags._adv_tag_path_split(avg_tag_path,isItem=True)
+101url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_average_tags_url(path_obj['item'])
+102
+103r=server._config_del(url)
+104ifr.code==200:
+105returnTrue
+106else:
+107raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Delete "average_tag" object at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
avg_tag_path: path identifying location and average tag to delete. Standard Kepware address decimal
+notation string including the average tag such as "_advancedtags.AdvTagGroup1.AvgTag1"
+
+
+
Returns
+
+
+
True - If a "HTTP 200 - OK" is received from Kepware server
109defget_average_tag(server:server,avg_tag_path:str)->dict:
+110'''Returns the properties of the `"average_tag"` object at a specific path in Kepware.
+111
+112 :param server: instance of the `server` class
+113 :param avg_tag_path: path identifying location and average tag to retrieve. Standard Kepware address decimal
+114 notation string including the average tag such as "_advancedtags.AdvTagGroup1.AvgTag1"
+115
+116 :return: Dict of data for the average tag requested
+117
+118 :raises KepHTTPError: If urllib provides an HTTPError
+119 :raises KepURLError: If urllib provides an URLError
+120 '''
+121path_obj=adv_tags._adv_tag_path_split(avg_tag_path,isItem=True)
+122url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_average_tags_url(path_obj['item'])
+123
+124r=server._config_get(url)
+125returnr.payload
+
+
+
+
Returns the properties of the "average_tag" object at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
avg_tag_path: path identifying location and average tag to retrieve. Standard Kepware address decimal
+notation string including the average tag such as "_advancedtags.AdvTagGroup1.AvgTag1"
127defget_all_average_tags(server:server,adv_tag_group_path:str,*,options:dict=None)->list:
+128'''Returns the properties of all `"average_tag"` objects at a specific path in Kepware.
+129
+130 :param server: instance of the `server` class
+131 :param adv_tag_group_path: path identifying location to retrieve average tag list. Standard Kepware address decimal
+132 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+133 :param options: *(optional)* Dict of parameters to filter, sort or paginate the list of average tags. Options are `filter`,
+134 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
+135
+136 :return: List of data for all average tags
+137
+138 :raises KepHTTPError: If urllib provides an HTTPError
+139 :raises KepURLError: If urllib provides an URLError
+140 '''
+141path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+142url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_average_tags_url()
+143
+144r=server._config_get(url,params=options)
+145returnr.payload
+
+
+
+
Returns the properties of all "average_tag" objects at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying location to retrieve average tag list. Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+
options: (optional) Dict of parameters to filter, sort or paginate the list of average tags. Options are filter,
+sortOrder, sortProperty, pageNumber, and pageSize
+
+
+
Returns
+
+
+
List of data for all average tags
+
+
+
Raises
+
+
+
KepHTTPError: If urllib provides an HTTPError
+
KepURLError: If urllib provides an URLError
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/kepconfig/adv_tags/complex_tags.html b/docs/kepconfig/adv_tags/complex_tags.html
new file mode 100644
index 0000000..afdbf6b
--- /dev/null
+++ b/docs/kepconfig/adv_tags/complex_tags.html
@@ -0,0 +1,719 @@
+
+
+
+
+
+
+ kepconfig.adv_tags.complex_tags API documentation
+
+
+
+
+
+
+
+
+
+
+
+
complex_tags exposes an API to allow modifications (add, delete, modify) to
+complex tag objects within the Kepware Configuration API
+
+
+
+
+
+
+
1# -------------------------------------------------------------------------
+ 2# Copyright (c) PTC Inc. and/or all its affiliates. All rights reserved.
+ 3# See License.txt in the project root for
+ 4# license information.
+ 5# --------------------------------------------------------------------------
+ 6
+ 7# Note: The code within this file was created in total or in part
+ 8# with the use of AI tools.
+ 9
+ 10r"""`complex_tags` exposes an API to allow modifications (add, delete, modify) to
+ 11complex tag objects within the Kepware Configuration API
+ 12"""
+ 13
+ 14from..connectionimportserver
+ 15from..errorimportKepError,KepHTTPError
+ 16from..utilsimport_url_parse_object
+ 17fromtypingimportUnion
+ 18from..importadv_tags
+ 19
+ 20COMPLEX_TAGS_ROOT='/complex_tags'
+ 21
+ 22def_get_complex_tags_url(tag:str=None)->str:
+ 23'''Creates url object for the "complex_tags" branch of Kepware's project tree.
+ 24
+ 25 Returns the complex tag specific url when a value is passed as the tag name.
+ 26 '''
+ 27iftagisNone:
+ 28returnCOMPLEX_TAGS_ROOT
+ 29else:
+ 30returnf'{COMPLEX_TAGS_ROOT}/{_url_parse_object(tag)}'
+ 31
+ 32defadd_complex_tag(server:server,adv_tag_group_path:str,DATA:Union[dict,list])->Union[bool,list]:
+ 33'''Add `"complex_tag"` or multiple `"complex_tag"` objects to a specific path in Kepware.
+ 34 Can be used to pass a list of complex tags to be added at one path location.
+ 35
+ 36 :param server: instance of the `server` class
+ 37 :param adv_tag_group_path: path identifying where to add complex tag(s). Standard Kepware address decimal
+ 38 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+ 39 :param DATA: Dict or List of Dicts of the complex tag(s) to add
+ 40
+ 41 :return: True - If a "HTTP 201 - Created" is received from Kepware server
+ 42 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+ 43 complex tags added that failed.
+ 44
+ 45 :raises KepHTTPError: If urllib provides an HTTPError
+ 46 :raises KepURLError: If urllib provides an URLError
+ 47 '''
+ 48path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+ 49url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_complex_tags_url()
+ 50
+ 51r=server._config_add(url,DATA)
+ 52ifr.code==201:
+ 53returnTrue
+ 54elifr.code==207:
+ 55errors=[itemforiteminr.payloadifitem['code']!=201]
+ 56returnerrors
+ 57else:
+ 58raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+ 59
+ 60defmodify_complex_tag(server:server,complex_tag_path:str,DATA:dict,force:bool=False)->bool:
+ 61'''Modify a `"complex_tag"` object and its properties in Kepware.
+ 62
+ 63 :param server: instance of the `server` class
+ 64 :param complex_tag_path: path identifying location and complex tag to modify. Standard Kepware address decimal
+ 65 notation string including the complex tag such as "_advancedtags.AdvTagGroup1.ComplexTag1"
+ 66 :param DATA: Dict of the `complex_tag` properties to be modified
+ 67 :param force: *(optional)* if True, will force the configuration update to the Kepware server
+ 68
+ 69 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 70
+ 71 :raises KepHTTPError: If urllib provides an HTTPError
+ 72 :raises KepURLError: If urllib provides an URLError
+ 73 '''
+ 74complex_tag_data=server._force_update_check(force,DATA)
+ 75path_obj=adv_tags._adv_tag_path_split(complex_tag_path,isItem=True)
+ 76url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_complex_tags_url(path_obj['item'])
+ 77
+ 78r=server._config_update(url,complex_tag_data)
+ 79ifr.code==200:
+ 80returnTrue
+ 81else:
+ 82raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+ 83
+ 84defdel_complex_tag(server:server,complex_tag_path:str)->bool:
+ 85'''Delete `"complex_tag"` object at a specific path in Kepware.
+ 86
+ 87 :param server: instance of the `server` class
+ 88 :param complex_tag_path: path identifying location and complex tag to delete. Standard Kepware address decimal
+ 89 notation string including the complex tag such as "_advancedtags.AdvTagGroup1.ComplexTag1"
+ 90
+ 91 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 92
+ 93 :raises KepHTTPError: If urllib provides an HTTPError
+ 94 :raises KepURLError: If urllib provides an URLError
+ 95 '''
+ 96path_obj=adv_tags._adv_tag_path_split(complex_tag_path,isItem=True)
+ 97url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_complex_tags_url(path_obj['item'])
+ 98
+ 99r=server._config_del(url)
+100ifr.code==200:
+101returnTrue
+102else:
+103raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+104
+105defget_complex_tag(server:server,complex_tag_path:str)->dict:
+106'''Returns the properties of the `"complex_tag"` object at a specific path in Kepware.
+107
+108 :param server: instance of the `server` class
+109 :param complex_tag_path: path identifying location and complex tag to retrieve. Standard Kepware address decimal
+110 notation string including the complex tag such as "_advancedtags.AdvTagGroup1.ComplexTag1"
+111
+112 :return: Dict of data for the complex tag requested
+113
+114 :raises KepHTTPError: If urllib provides an HTTPError
+115 :raises KepURLError: If urllib provides an URLError
+116 '''
+117path_obj=adv_tags._adv_tag_path_split(complex_tag_path,isItem=True)
+118url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_complex_tags_url(path_obj['item'])
+119
+120r=server._config_get(url)
+121returnr.payload
+122
+123defget_all_complex_tags(server:server,adv_tag_group_path:str,*,options:dict=None)->list:
+124'''Returns the properties of all `"complex_tag"` objects at a specific path in Kepware.
+125
+126 :param server: instance of the `server` class
+127 :param adv_tag_group_path: path identifying location to retrieve complex tag list. Standard Kepware address decimal
+128 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+129 :param options: *(optional)* Dict of parameters to filter, sort or paginate the list of complex tags. Options are `filter`,
+130 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
+131
+132 :return: List of data for all complex tags
+133
+134 :raises KepHTTPError: If urllib provides an HTTPError
+135 :raises KepURLError: If urllib provides an URLError
+136 '''
+137path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+138url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_complex_tags_url()
+139
+140r=server._config_get(url,params=options)
+141returnr.payload
+
33defadd_complex_tag(server:server,adv_tag_group_path:str,DATA:Union[dict,list])->Union[bool,list]:
+34'''Add `"complex_tag"` or multiple `"complex_tag"` objects to a specific path in Kepware.
+35 Can be used to pass a list of complex tags to be added at one path location.
+36
+37 :param server: instance of the `server` class
+38 :param adv_tag_group_path: path identifying where to add complex tag(s). Standard Kepware address decimal
+39 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+40 :param DATA: Dict or List of Dicts of the complex tag(s) to add
+41
+42 :return: True - If a "HTTP 201 - Created" is received from Kepware server
+43 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+44 complex tags added that failed.
+45
+46 :raises KepHTTPError: If urllib provides an HTTPError
+47 :raises KepURLError: If urllib provides an URLError
+48 '''
+49path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+50url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_complex_tags_url()
+51
+52r=server._config_add(url,DATA)
+53ifr.code==201:
+54returnTrue
+55elifr.code==207:
+56errors=[itemforiteminr.payloadifitem['code']!=201]
+57returnerrors
+58else:
+59raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Add "complex_tag" or multiple "complex_tag" objects to a specific path in Kepware.
+Can be used to pass a list of complex tags to be added at one path location.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying where to add complex tag(s). Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+
DATA: Dict or List of Dicts of the complex tag(s) to add
+
+
+
Returns
+
+
+
True - If a "HTTP 201 - Created" is received from Kepware server
+
+
+
Returns
+
+
+
If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+ complex tags added that failed.
61defmodify_complex_tag(server:server,complex_tag_path:str,DATA:dict,force:bool=False)->bool:
+62'''Modify a `"complex_tag"` object and its properties in Kepware.
+63
+64 :param server: instance of the `server` class
+65 :param complex_tag_path: path identifying location and complex tag to modify. Standard Kepware address decimal
+66 notation string including the complex tag such as "_advancedtags.AdvTagGroup1.ComplexTag1"
+67 :param DATA: Dict of the `complex_tag` properties to be modified
+68 :param force: *(optional)* if True, will force the configuration update to the Kepware server
+69
+70 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+71
+72 :raises KepHTTPError: If urllib provides an HTTPError
+73 :raises KepURLError: If urllib provides an URLError
+74 '''
+75complex_tag_data=server._force_update_check(force,DATA)
+76path_obj=adv_tags._adv_tag_path_split(complex_tag_path,isItem=True)
+77url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_complex_tags_url(path_obj['item'])
+78
+79r=server._config_update(url,complex_tag_data)
+80ifr.code==200:
+81returnTrue
+82else:
+83raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Modify a "complex_tag" object and its properties in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
complex_tag_path: path identifying location and complex tag to modify. Standard Kepware address decimal
+notation string including the complex tag such as "_advancedtags.AdvTagGroup1.ComplexTag1"
+
DATA: Dict of the complex_tag properties to be modified
+
force: (optional) if True, will force the configuration update to the Kepware server
+
+
+
Returns
+
+
+
True - If a "HTTP 200 - OK" is received from Kepware server
85defdel_complex_tag(server:server,complex_tag_path:str)->bool:
+ 86'''Delete `"complex_tag"` object at a specific path in Kepware.
+ 87
+ 88 :param server: instance of the `server` class
+ 89 :param complex_tag_path: path identifying location and complex tag to delete. Standard Kepware address decimal
+ 90 notation string including the complex tag such as "_advancedtags.AdvTagGroup1.ComplexTag1"
+ 91
+ 92 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 93
+ 94 :raises KepHTTPError: If urllib provides an HTTPError
+ 95 :raises KepURLError: If urllib provides an URLError
+ 96 '''
+ 97path_obj=adv_tags._adv_tag_path_split(complex_tag_path,isItem=True)
+ 98url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_complex_tags_url(path_obj['item'])
+ 99
+100r=server._config_del(url)
+101ifr.code==200:
+102returnTrue
+103else:
+104raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Delete "complex_tag" object at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
complex_tag_path: path identifying location and complex tag to delete. Standard Kepware address decimal
+notation string including the complex tag such as "_advancedtags.AdvTagGroup1.ComplexTag1"
+
+
+
Returns
+
+
+
True - If a "HTTP 200 - OK" is received from Kepware server
106defget_complex_tag(server:server,complex_tag_path:str)->dict:
+107'''Returns the properties of the `"complex_tag"` object at a specific path in Kepware.
+108
+109 :param server: instance of the `server` class
+110 :param complex_tag_path: path identifying location and complex tag to retrieve. Standard Kepware address decimal
+111 notation string including the complex tag such as "_advancedtags.AdvTagGroup1.ComplexTag1"
+112
+113 :return: Dict of data for the complex tag requested
+114
+115 :raises KepHTTPError: If urllib provides an HTTPError
+116 :raises KepURLError: If urllib provides an URLError
+117 '''
+118path_obj=adv_tags._adv_tag_path_split(complex_tag_path,isItem=True)
+119url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_complex_tags_url(path_obj['item'])
+120
+121r=server._config_get(url)
+122returnr.payload
+
+
+
+
Returns the properties of the "complex_tag" object at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
complex_tag_path: path identifying location and complex tag to retrieve. Standard Kepware address decimal
+notation string including the complex tag such as "_advancedtags.AdvTagGroup1.ComplexTag1"
124defget_all_complex_tags(server:server,adv_tag_group_path:str,*,options:dict=None)->list:
+125'''Returns the properties of all `"complex_tag"` objects at a specific path in Kepware.
+126
+127 :param server: instance of the `server` class
+128 :param adv_tag_group_path: path identifying location to retrieve complex tag list. Standard Kepware address decimal
+129 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+130 :param options: *(optional)* Dict of parameters to filter, sort or paginate the list of complex tags. Options are `filter`,
+131 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
+132
+133 :return: List of data for all complex tags
+134
+135 :raises KepHTTPError: If urllib provides an HTTPError
+136 :raises KepURLError: If urllib provides an URLError
+137 '''
+138path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+139url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_complex_tags_url()
+140
+141r=server._config_get(url,params=options)
+142returnr.payload
+
+
+
+
Returns the properties of all "complex_tag" objects at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying location to retrieve complex tag list. Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+
options: (optional) Dict of parameters to filter, sort or paginate the list of complex tags. Options are filter,
+sortOrder, sortProperty, pageNumber, and pageSize
+
+
+
Returns
+
+
+
List of data for all complex tags
+
+
+
Raises
+
+
+
KepHTTPError: If urllib provides an HTTPError
+
KepURLError: If urllib provides an URLError
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/kepconfig/adv_tags/cumulative_tags.html b/docs/kepconfig/adv_tags/cumulative_tags.html
new file mode 100644
index 0000000..d0e77f4
--- /dev/null
+++ b/docs/kepconfig/adv_tags/cumulative_tags.html
@@ -0,0 +1,719 @@
+
+
+
+
+
+
+ kepconfig.adv_tags.cumulative_tags API documentation
+
+
+
+
+
+
+
+
+
+
+
+
cumulative_tags exposes an API to allow modifications (add, delete, modify) to
+cumulative tag objects within the Kepware Configuration API
+
+
+
+
+
+
+
1# -------------------------------------------------------------------------
+ 2# Copyright (c) PTC Inc. and/or all its affiliates. All rights reserved.
+ 3# See License.txt in the project root for
+ 4# license information.
+ 5# --------------------------------------------------------------------------
+ 6
+ 7# Note: The code within this file was created in total or in part
+ 8# with the use of AI tools.
+ 9
+ 10r"""`cumulative_tags` exposes an API to allow modifications (add, delete, modify) to
+ 11cumulative tag objects within the Kepware Configuration API
+ 12"""
+ 13
+ 14from..connectionimportserver
+ 15from..errorimportKepError,KepHTTPError
+ 16from..utilsimport_url_parse_object
+ 17fromtypingimportUnion
+ 18from..importadv_tags
+ 19
+ 20CUMULATIVE_TAGS_ROOT='/cumulative_tags'
+ 21
+ 22def_get_cumulative_tags_url(tag:str=None)->str:
+ 23'''Creates url object for the "cumulative_tags" branch of Kepware's project tree.
+ 24
+ 25 Returns the cumulative tag specific url when a value is passed as the tag name.
+ 26 '''
+ 27iftagisNone:
+ 28returnCUMULATIVE_TAGS_ROOT
+ 29else:
+ 30returnf'{CUMULATIVE_TAGS_ROOT}/{_url_parse_object(tag)}'
+ 31
+ 32defadd_cumulative_tag(server:server,adv_tag_group_path:str,DATA:Union[dict,list])->Union[bool,list]:
+ 33'''Add `"cumulative_tag"` or multiple `"cumulative_tag"` objects to a specific path in Kepware.
+ 34 Can be used to pass a list of cumulative tags to be added at one path location.
+ 35
+ 36 :param server: instance of the `server` class
+ 37 :param adv_tag_group_path: path identifying where to add cumulative tag(s). Standard Kepware address decimal
+ 38 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+ 39 :param DATA: Dict or List of Dicts of the cumulative tag(s) to add
+ 40
+ 41 :return: True - If a "HTTP 201 - Created" is received from Kepware server
+ 42 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+ 43 cumulative tags added that failed.
+ 44
+ 45 :raises KepHTTPError: If urllib provides an HTTPError
+ 46 :raises KepURLError: If urllib provides an URLError
+ 47 '''
+ 48path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+ 49url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_cumulative_tags_url()
+ 50
+ 51r=server._config_add(url,DATA)
+ 52ifr.code==201:
+ 53returnTrue
+ 54elifr.code==207:
+ 55errors=[itemforiteminr.payloadifitem['code']!=201]
+ 56returnerrors
+ 57else:
+ 58raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+ 59
+ 60defmodify_cumulative_tag(server:server,cumulative_tag_path:str,DATA:dict,force:bool=False)->bool:
+ 61'''Modify a `"cumulative_tag"` object and its properties in Kepware.
+ 62
+ 63 :param server: instance of the `server` class
+ 64 :param cumulative_tag_path: path identifying location and cumulative tag to modify. Standard Kepware address decimal
+ 65 notation string including the cumulative tag such as "_advancedtags.AdvTagGroup1.CumulativeTag1"
+ 66 :param DATA: Dict of the `cumulative_tag` properties to be modified
+ 67 :param force: *(optional)* if True, will force the configuration update to the Kepware server
+ 68
+ 69 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 70
+ 71 :raises KepHTTPError: If urllib provides an HTTPError
+ 72 :raises KepURLError: If urllib provides an URLError
+ 73 '''
+ 74cum_tag_data=server._force_update_check(force,DATA)
+ 75path_obj=adv_tags._adv_tag_path_split(cumulative_tag_path,isItem=True)
+ 76url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_cumulative_tags_url(path_obj['item'])
+ 77
+ 78r=server._config_update(url,cum_tag_data)
+ 79ifr.code==200:
+ 80returnTrue
+ 81else:
+ 82raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+ 83
+ 84defdel_cumulative_tag(server:server,cumulative_tag_path:str)->bool:
+ 85'''Delete `"cumulative_tag"` object at a specific path in Kepware.
+ 86
+ 87 :param server: instance of the `server` class
+ 88 :param cumulative_tag_path: path identifying location and cumulative tag to delete. Standard Kepware address decimal
+ 89 notation string including the cumulative tag such as "_advancedtags.AdvTagGroup1.CumulativeTag1"
+ 90
+ 91 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 92
+ 93 :raises KepHTTPError: If urllib provides an HTTPError
+ 94 :raises KepURLError: If urllib provides an URLError
+ 95 '''
+ 96path_obj=adv_tags._adv_tag_path_split(cumulative_tag_path,isItem=True)
+ 97url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_cumulative_tags_url(path_obj['item'])
+ 98
+ 99r=server._config_del(url)
+100ifr.code==200:
+101returnTrue
+102else:
+103raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+104
+105defget_cumulative_tag(server:server,cumulative_tag_path:str)->dict:
+106'''Returns the properties of the `"cumulative_tag"` object at a specific path in Kepware.
+107
+108 :param server: instance of the `server` class
+109 :param cumulative_tag_path: path identifying location and cumulative tag to retrieve. Standard Kepware address decimal
+110 notation string including the cumulative tag such as "_advancedtags.AdvTagGroup1.CumulativeTag1"
+111
+112 :return: Dict of data for the cumulative tag requested
+113
+114 :raises KepHTTPError: If urllib provides an HTTPError
+115 :raises KepURLError: If urllib provides an URLError
+116 '''
+117path_obj=adv_tags._adv_tag_path_split(cumulative_tag_path,isItem=True)
+118url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_cumulative_tags_url(path_obj['item'])
+119
+120r=server._config_get(url)
+121returnr.payload
+122
+123defget_all_cumulative_tags(server:server,adv_tag_group_path:str,*,options:dict=None)->list:
+124'''Returns the properties of all `"cumulative_tag"` objects at a specific path in Kepware.
+125
+126 :param server: instance of the `server` class
+127 :param adv_tag_group_path: path identifying location to retrieve cumulative tag list. Standard Kepware address decimal
+128 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+129 :param options: *(optional)* Dict of parameters to filter, sort or paginate the list of cumulative tags. Options are `filter`,
+130 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
+131
+132 :return: List of data for all cumulative tags
+133
+134 :raises KepHTTPError: If urllib provides an HTTPError
+135 :raises KepURLError: If urllib provides an URLError
+136 '''
+137path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+138url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_cumulative_tags_url()
+139
+140r=server._config_get(url,params=options)
+141returnr.payload
+
33defadd_cumulative_tag(server:server,adv_tag_group_path:str,DATA:Union[dict,list])->Union[bool,list]:
+34'''Add `"cumulative_tag"` or multiple `"cumulative_tag"` objects to a specific path in Kepware.
+35 Can be used to pass a list of cumulative tags to be added at one path location.
+36
+37 :param server: instance of the `server` class
+38 :param adv_tag_group_path: path identifying where to add cumulative tag(s). Standard Kepware address decimal
+39 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+40 :param DATA: Dict or List of Dicts of the cumulative tag(s) to add
+41
+42 :return: True - If a "HTTP 201 - Created" is received from Kepware server
+43 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+44 cumulative tags added that failed.
+45
+46 :raises KepHTTPError: If urllib provides an HTTPError
+47 :raises KepURLError: If urllib provides an URLError
+48 '''
+49path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+50url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_cumulative_tags_url()
+51
+52r=server._config_add(url,DATA)
+53ifr.code==201:
+54returnTrue
+55elifr.code==207:
+56errors=[itemforiteminr.payloadifitem['code']!=201]
+57returnerrors
+58else:
+59raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Add "cumulative_tag" or multiple "cumulative_tag" objects to a specific path in Kepware.
+Can be used to pass a list of cumulative tags to be added at one path location.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying where to add cumulative tag(s). Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+
DATA: Dict or List of Dicts of the cumulative tag(s) to add
+
+
+
Returns
+
+
+
True - If a "HTTP 201 - Created" is received from Kepware server
+
+
+
Returns
+
+
+
If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+ cumulative tags added that failed.
61defmodify_cumulative_tag(server:server,cumulative_tag_path:str,DATA:dict,force:bool=False)->bool:
+62'''Modify a `"cumulative_tag"` object and its properties in Kepware.
+63
+64 :param server: instance of the `server` class
+65 :param cumulative_tag_path: path identifying location and cumulative tag to modify. Standard Kepware address decimal
+66 notation string including the cumulative tag such as "_advancedtags.AdvTagGroup1.CumulativeTag1"
+67 :param DATA: Dict of the `cumulative_tag` properties to be modified
+68 :param force: *(optional)* if True, will force the configuration update to the Kepware server
+69
+70 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+71
+72 :raises KepHTTPError: If urllib provides an HTTPError
+73 :raises KepURLError: If urllib provides an URLError
+74 '''
+75cum_tag_data=server._force_update_check(force,DATA)
+76path_obj=adv_tags._adv_tag_path_split(cumulative_tag_path,isItem=True)
+77url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_cumulative_tags_url(path_obj['item'])
+78
+79r=server._config_update(url,cum_tag_data)
+80ifr.code==200:
+81returnTrue
+82else:
+83raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Modify a "cumulative_tag" object and its properties in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
cumulative_tag_path: path identifying location and cumulative tag to modify. Standard Kepware address decimal
+notation string including the cumulative tag such as "_advancedtags.AdvTagGroup1.CumulativeTag1"
+
DATA: Dict of the cumulative_tag properties to be modified
+
force: (optional) if True, will force the configuration update to the Kepware server
+
+
+
Returns
+
+
+
True - If a "HTTP 200 - OK" is received from Kepware server
85defdel_cumulative_tag(server:server,cumulative_tag_path:str)->bool:
+ 86'''Delete `"cumulative_tag"` object at a specific path in Kepware.
+ 87
+ 88 :param server: instance of the `server` class
+ 89 :param cumulative_tag_path: path identifying location and cumulative tag to delete. Standard Kepware address decimal
+ 90 notation string including the cumulative tag such as "_advancedtags.AdvTagGroup1.CumulativeTag1"
+ 91
+ 92 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 93
+ 94 :raises KepHTTPError: If urllib provides an HTTPError
+ 95 :raises KepURLError: If urllib provides an URLError
+ 96 '''
+ 97path_obj=adv_tags._adv_tag_path_split(cumulative_tag_path,isItem=True)
+ 98url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_cumulative_tags_url(path_obj['item'])
+ 99
+100r=server._config_del(url)
+101ifr.code==200:
+102returnTrue
+103else:
+104raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Delete "cumulative_tag" object at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
cumulative_tag_path: path identifying location and cumulative tag to delete. Standard Kepware address decimal
+notation string including the cumulative tag such as "_advancedtags.AdvTagGroup1.CumulativeTag1"
+
+
+
Returns
+
+
+
True - If a "HTTP 200 - OK" is received from Kepware server
106defget_cumulative_tag(server:server,cumulative_tag_path:str)->dict:
+107'''Returns the properties of the `"cumulative_tag"` object at a specific path in Kepware.
+108
+109 :param server: instance of the `server` class
+110 :param cumulative_tag_path: path identifying location and cumulative tag to retrieve. Standard Kepware address decimal
+111 notation string including the cumulative tag such as "_advancedtags.AdvTagGroup1.CumulativeTag1"
+112
+113 :return: Dict of data for the cumulative tag requested
+114
+115 :raises KepHTTPError: If urllib provides an HTTPError
+116 :raises KepURLError: If urllib provides an URLError
+117 '''
+118path_obj=adv_tags._adv_tag_path_split(cumulative_tag_path,isItem=True)
+119url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_cumulative_tags_url(path_obj['item'])
+120
+121r=server._config_get(url)
+122returnr.payload
+
+
+
+
Returns the properties of the "cumulative_tag" object at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
cumulative_tag_path: path identifying location and cumulative tag to retrieve. Standard Kepware address decimal
+notation string including the cumulative tag such as "_advancedtags.AdvTagGroup1.CumulativeTag1"
124defget_all_cumulative_tags(server:server,adv_tag_group_path:str,*,options:dict=None)->list:
+125'''Returns the properties of all `"cumulative_tag"` objects at a specific path in Kepware.
+126
+127 :param server: instance of the `server` class
+128 :param adv_tag_group_path: path identifying location to retrieve cumulative tag list. Standard Kepware address decimal
+129 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+130 :param options: *(optional)* Dict of parameters to filter, sort or paginate the list of cumulative tags. Options are `filter`,
+131 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
+132
+133 :return: List of data for all cumulative tags
+134
+135 :raises KepHTTPError: If urllib provides an HTTPError
+136 :raises KepURLError: If urllib provides an URLError
+137 '''
+138path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+139url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_cumulative_tags_url()
+140
+141r=server._config_get(url,params=options)
+142returnr.payload
+
+
+
+
Returns the properties of all "cumulative_tag" objects at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying location to retrieve cumulative tag list. Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+
options: (optional) Dict of parameters to filter, sort or paginate the list of cumulative tags. Options are filter,
+sortOrder, sortProperty, pageNumber, and pageSize
+
+
+
Returns
+
+
+
List of data for all cumulative tags
+
+
+
Raises
+
+
+
KepHTTPError: If urllib provides an HTTPError
+
KepURLError: If urllib provides an URLError
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/kepconfig/adv_tags/derived_tags.html b/docs/kepconfig/adv_tags/derived_tags.html
new file mode 100644
index 0000000..85cdf3a
--- /dev/null
+++ b/docs/kepconfig/adv_tags/derived_tags.html
@@ -0,0 +1,719 @@
+
+
+
+
+
+
+ kepconfig.adv_tags.derived_tags API documentation
+
+
+
+
+
+
+
+
+
+
+
+
derived_tags exposes an API to allow modifications (add, delete, modify) to
+derived tag objects within the Kepware Configuration API
+
+
+
+
+
+
+
1# -------------------------------------------------------------------------
+ 2# Copyright (c) PTC Inc. and/or all its affiliates. All rights reserved.
+ 3# See License.txt in the project root for
+ 4# license information.
+ 5# --------------------------------------------------------------------------
+ 6
+ 7# Note: The code within this file was created in total or in part
+ 8# with the use of AI tools.
+ 9
+ 10r"""`derived_tags` exposes an API to allow modifications (add, delete, modify) to
+ 11derived tag objects within the Kepware Configuration API
+ 12"""
+ 13
+ 14from..connectionimportserver
+ 15from..errorimportKepError,KepHTTPError
+ 16from..utilsimport_url_parse_object
+ 17fromtypingimportUnion
+ 18from..importadv_tags
+ 19
+ 20DERIVED_TAGS_ROOT='/derived_tags'
+ 21
+ 22def_get_derived_tags_url(tag:str=None)->str:
+ 23'''Creates url object for the "derived_tags" branch of Kepware's project tree.
+ 24
+ 25 Returns the derived tag specific url when a value is passed as the tag name.
+ 26 '''
+ 27iftagisNone:
+ 28returnDERIVED_TAGS_ROOT
+ 29else:
+ 30returnf'{DERIVED_TAGS_ROOT}/{_url_parse_object(tag)}'
+ 31
+ 32defadd_derived_tag(server:server,adv_tag_group_path:str,DATA:Union[dict,list])->Union[bool,list]:
+ 33'''Add `"derived_tag"` or multiple `"derived_tag"` objects to a specific path in Kepware.
+ 34 Can be used to pass a list of derived tags to be added at one path location.
+ 35
+ 36 :param server: instance of the `server` class
+ 37 :param adv_tag_group_path: path identifying where to add derived tag(s). Standard Kepware address decimal
+ 38 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+ 39 :param DATA: Dict or List of Dicts of the derived tag(s) to add
+ 40
+ 41 :return: True - If a "HTTP 201 - Created" is received from Kepware server
+ 42 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+ 43 derived tags added that failed.
+ 44
+ 45 :raises KepHTTPError: If urllib provides an HTTPError
+ 46 :raises KepURLError: If urllib provides an URLError
+ 47 '''
+ 48path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+ 49url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_derived_tags_url()
+ 50
+ 51r=server._config_add(url,DATA)
+ 52ifr.code==201:
+ 53returnTrue
+ 54elifr.code==207:
+ 55errors=[itemforiteminr.payloadifitem['code']!=201]
+ 56returnerrors
+ 57else:
+ 58raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+ 59
+ 60defmodify_derived_tag(server:server,derived_tag_path:str,DATA:dict,force:bool=False)->bool:
+ 61'''Modify a `"derived_tag"` object and its properties in Kepware.
+ 62
+ 63 :param server: instance of the `server` class
+ 64 :param derived_tag_path: path identifying location and derived tag to modify. Standard Kepware address decimal
+ 65 notation string including the derived tag such as "_advancedtags.AdvTagGroup1.DerivedTag1"
+ 66 :param DATA: Dict of the `derived_tag` properties to be modified
+ 67 :param force: *(optional)* if True, will force the configuration update to the Kepware server
+ 68
+ 69 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 70
+ 71 :raises KepHTTPError: If urllib provides an HTTPError
+ 72 :raises KepURLError: If urllib provides an URLError
+ 73 '''
+ 74derived_tag_data=server._force_update_check(force,DATA)
+ 75path_obj=adv_tags._adv_tag_path_split(derived_tag_path,isItem=True)
+ 76url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_derived_tags_url(path_obj['item'])
+ 77
+ 78r=server._config_update(url,derived_tag_data)
+ 79ifr.code==200:
+ 80returnTrue
+ 81else:
+ 82raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+ 83
+ 84defdel_derived_tag(server:server,derived_tag_path:str)->bool:
+ 85'''Delete `"derived_tag"` object at a specific path in Kepware.
+ 86
+ 87 :param server: instance of the `server` class
+ 88 :param derived_tag_path: path identifying location and derived tag to delete. Standard Kepware address decimal
+ 89 notation string including the derived tag such as "_advancedtags.AdvTagGroup1.DerivedTag1"
+ 90
+ 91 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 92
+ 93 :raises KepHTTPError: If urllib provides an HTTPError
+ 94 :raises KepURLError: If urllib provides an URLError
+ 95 '''
+ 96path_obj=adv_tags._adv_tag_path_split(derived_tag_path,isItem=True)
+ 97url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_derived_tags_url(path_obj['item'])
+ 98
+ 99r=server._config_del(url)
+100ifr.code==200:
+101returnTrue
+102else:
+103raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+104
+105defget_derived_tag(server:server,derived_tag_path:str)->dict:
+106'''Returns the properties of the `"derived_tag"` object at a specific path in Kepware.
+107
+108 :param server: instance of the `server` class
+109 :param derived_tag_path: path identifying location and derived tag to retrieve. Standard Kepware address decimal
+110 notation string including the derived tag such as "_advancedtags.AdvTagGroup1.DerivedTag1"
+111
+112 :return: Dict of data for the derived tag requested
+113
+114 :raises KepHTTPError: If urllib provides an HTTPError
+115 :raises KepURLError: If urllib provides an URLError
+116 '''
+117path_obj=adv_tags._adv_tag_path_split(derived_tag_path,isItem=True)
+118url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_derived_tags_url(path_obj['item'])
+119
+120r=server._config_get(url)
+121returnr.payload
+122
+123defget_all_derived_tags(server:server,adv_tag_group_path:str,*,options:dict=None)->list:
+124'''Returns the properties of all `"derived_tag"` objects at a specific path in Kepware.
+125
+126 :param server: instance of the `server` class
+127 :param adv_tag_group_path: path identifying location to retrieve derived tag list. Standard Kepware address decimal
+128 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+129 :param options: *(optional)* Dict of parameters to filter, sort or paginate the list of derived tags. Options are `filter`,
+130 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
+131
+132 :return: List of data for all derived tags
+133
+134 :raises KepHTTPError: If urllib provides an HTTPError
+135 :raises KepURLError: If urllib provides an URLError
+136 '''
+137path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+138url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_derived_tags_url()
+139
+140r=server._config_get(url,params=options)
+141returnr.payload
+
33defadd_derived_tag(server:server,adv_tag_group_path:str,DATA:Union[dict,list])->Union[bool,list]:
+34'''Add `"derived_tag"` or multiple `"derived_tag"` objects to a specific path in Kepware.
+35 Can be used to pass a list of derived tags to be added at one path location.
+36
+37 :param server: instance of the `server` class
+38 :param adv_tag_group_path: path identifying where to add derived tag(s). Standard Kepware address decimal
+39 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+40 :param DATA: Dict or List of Dicts of the derived tag(s) to add
+41
+42 :return: True - If a "HTTP 201 - Created" is received from Kepware server
+43 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+44 derived tags added that failed.
+45
+46 :raises KepHTTPError: If urllib provides an HTTPError
+47 :raises KepURLError: If urllib provides an URLError
+48 '''
+49path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+50url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_derived_tags_url()
+51
+52r=server._config_add(url,DATA)
+53ifr.code==201:
+54returnTrue
+55elifr.code==207:
+56errors=[itemforiteminr.payloadifitem['code']!=201]
+57returnerrors
+58else:
+59raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Add "derived_tag" or multiple "derived_tag" objects to a specific path in Kepware.
+Can be used to pass a list of derived tags to be added at one path location.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying where to add derived tag(s). Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+
DATA: Dict or List of Dicts of the derived tag(s) to add
+
+
+
Returns
+
+
+
True - If a "HTTP 201 - Created" is received from Kepware server
+
+
+
Returns
+
+
+
If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+ derived tags added that failed.
61defmodify_derived_tag(server:server,derived_tag_path:str,DATA:dict,force:bool=False)->bool:
+62'''Modify a `"derived_tag"` object and its properties in Kepware.
+63
+64 :param server: instance of the `server` class
+65 :param derived_tag_path: path identifying location and derived tag to modify. Standard Kepware address decimal
+66 notation string including the derived tag such as "_advancedtags.AdvTagGroup1.DerivedTag1"
+67 :param DATA: Dict of the `derived_tag` properties to be modified
+68 :param force: *(optional)* if True, will force the configuration update to the Kepware server
+69
+70 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+71
+72 :raises KepHTTPError: If urllib provides an HTTPError
+73 :raises KepURLError: If urllib provides an URLError
+74 '''
+75derived_tag_data=server._force_update_check(force,DATA)
+76path_obj=adv_tags._adv_tag_path_split(derived_tag_path,isItem=True)
+77url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_derived_tags_url(path_obj['item'])
+78
+79r=server._config_update(url,derived_tag_data)
+80ifr.code==200:
+81returnTrue
+82else:
+83raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Modify a "derived_tag" object and its properties in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
derived_tag_path: path identifying location and derived tag to modify. Standard Kepware address decimal
+notation string including the derived tag such as "_advancedtags.AdvTagGroup1.DerivedTag1"
+
DATA: Dict of the derived_tag properties to be modified
+
force: (optional) if True, will force the configuration update to the Kepware server
+
+
+
Returns
+
+
+
True - If a "HTTP 200 - OK" is received from Kepware server
85defdel_derived_tag(server:server,derived_tag_path:str)->bool:
+ 86'''Delete `"derived_tag"` object at a specific path in Kepware.
+ 87
+ 88 :param server: instance of the `server` class
+ 89 :param derived_tag_path: path identifying location and derived tag to delete. Standard Kepware address decimal
+ 90 notation string including the derived tag such as "_advancedtags.AdvTagGroup1.DerivedTag1"
+ 91
+ 92 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 93
+ 94 :raises KepHTTPError: If urllib provides an HTTPError
+ 95 :raises KepURLError: If urllib provides an URLError
+ 96 '''
+ 97path_obj=adv_tags._adv_tag_path_split(derived_tag_path,isItem=True)
+ 98url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_derived_tags_url(path_obj['item'])
+ 99
+100r=server._config_del(url)
+101ifr.code==200:
+102returnTrue
+103else:
+104raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Delete "derived_tag" object at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
derived_tag_path: path identifying location and derived tag to delete. Standard Kepware address decimal
+notation string including the derived tag such as "_advancedtags.AdvTagGroup1.DerivedTag1"
+
+
+
Returns
+
+
+
True - If a "HTTP 200 - OK" is received from Kepware server
106defget_derived_tag(server:server,derived_tag_path:str)->dict:
+107'''Returns the properties of the `"derived_tag"` object at a specific path in Kepware.
+108
+109 :param server: instance of the `server` class
+110 :param derived_tag_path: path identifying location and derived tag to retrieve. Standard Kepware address decimal
+111 notation string including the derived tag such as "_advancedtags.AdvTagGroup1.DerivedTag1"
+112
+113 :return: Dict of data for the derived tag requested
+114
+115 :raises KepHTTPError: If urllib provides an HTTPError
+116 :raises KepURLError: If urllib provides an URLError
+117 '''
+118path_obj=adv_tags._adv_tag_path_split(derived_tag_path,isItem=True)
+119url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_derived_tags_url(path_obj['item'])
+120
+121r=server._config_get(url)
+122returnr.payload
+
+
+
+
Returns the properties of the "derived_tag" object at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
derived_tag_path: path identifying location and derived tag to retrieve. Standard Kepware address decimal
+notation string including the derived tag such as "_advancedtags.AdvTagGroup1.DerivedTag1"
124defget_all_derived_tags(server:server,adv_tag_group_path:str,*,options:dict=None)->list:
+125'''Returns the properties of all `"derived_tag"` objects at a specific path in Kepware.
+126
+127 :param server: instance of the `server` class
+128 :param adv_tag_group_path: path identifying location to retrieve derived tag list. Standard Kepware address decimal
+129 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+130 :param options: *(optional)* Dict of parameters to filter, sort or paginate the list of derived tags. Options are `filter`,
+131 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
+132
+133 :return: List of data for all derived tags
+134
+135 :raises KepHTTPError: If urllib provides an HTTPError
+136 :raises KepURLError: If urllib provides an URLError
+137 '''
+138path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+139url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_derived_tags_url()
+140
+141r=server._config_get(url,params=options)
+142returnr.payload
+
+
+
+
Returns the properties of all "derived_tag" objects at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying location to retrieve derived tag list. Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+
options: (optional) Dict of parameters to filter, sort or paginate the list of derived tags. Options are filter,
+sortOrder, sortProperty, pageNumber, and pageSize
+
+
+
Returns
+
+
+
List of data for all derived tags
+
+
+
Raises
+
+
+
KepHTTPError: If urllib provides an HTTPError
+
KepURLError: If urllib provides an URLError
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/kepconfig/adv_tags/link_tags.html b/docs/kepconfig/adv_tags/link_tags.html
new file mode 100644
index 0000000..bb674f6
--- /dev/null
+++ b/docs/kepconfig/adv_tags/link_tags.html
@@ -0,0 +1,719 @@
+
+
+
+
+
+
+ kepconfig.adv_tags.link_tags API documentation
+
+
+
+
+
+
+
+
+
+
+
+
link_tags exposes an API to allow modifications (add, delete, modify) to
+link tag objects within the Kepware Configuration API
+
+
+
+
+
+
+
1# -------------------------------------------------------------------------
+ 2# Copyright (c) PTC Inc. and/or all its affiliates. All rights reserved.
+ 3# See License.txt in the project root for
+ 4# license information.
+ 5# --------------------------------------------------------------------------
+ 6
+ 7# Note: The code within this file was created in total or in part
+ 8# with the use of AI tools.
+ 9
+ 10r"""`link_tags` exposes an API to allow modifications (add, delete, modify) to
+ 11link tag objects within the Kepware Configuration API
+ 12"""
+ 13
+ 14from..connectionimportserver
+ 15from..errorimportKepError,KepHTTPError
+ 16from..utilsimport_url_parse_object
+ 17fromtypingimportUnion
+ 18from..importadv_tags
+ 19
+ 20LINK_TAGS_ROOT='/link_tags'
+ 21
+ 22def_get_link_tags_url(tag:str=None)->str:
+ 23'''Creates url object for the "link_tags" branch of Kepware's project tree.
+ 24
+ 25 Returns the link tag specific url when a value is passed as the tag name.
+ 26 '''
+ 27iftagisNone:
+ 28returnLINK_TAGS_ROOT
+ 29else:
+ 30returnf'{LINK_TAGS_ROOT}/{_url_parse_object(tag)}'
+ 31
+ 32defadd_link_tag(server:server,adv_tag_group_path:str,DATA:Union[dict,list])->Union[bool,list]:
+ 33'''Add `"link_tag"` or multiple `"link_tag"` objects to a specific path in Kepware.
+ 34 Can be used to pass a list of link tags to be added at one path location.
+ 35
+ 36 :param server: instance of the `server` class
+ 37 :param adv_tag_group_path: path identifying where to add link tag(s). Standard Kepware address decimal
+ 38 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+ 39 :param DATA: Dict or List of Dicts of the link tag(s) to add
+ 40
+ 41 :return: True - If a "HTTP 201 - Created" is received from Kepware server
+ 42 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+ 43 link tags added that failed.
+ 44
+ 45 :raises KepHTTPError: If urllib provides an HTTPError
+ 46 :raises KepURLError: If urllib provides an URLError
+ 47 '''
+ 48path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+ 49url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_link_tags_url()
+ 50
+ 51r=server._config_add(url,DATA)
+ 52ifr.code==201:
+ 53returnTrue
+ 54elifr.code==207:
+ 55errors=[itemforiteminr.payloadifitem['code']!=201]
+ 56returnerrors
+ 57else:
+ 58raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+ 59
+ 60defmodify_link_tag(server:server,link_tag_path:str,DATA:dict,force:bool=False)->bool:
+ 61'''Modify a `"link_tag"` object and its properties in Kepware.
+ 62
+ 63 :param server: instance of the `server` class
+ 64 :param link_tag_path: path identifying location and link tag to modify. Standard Kepware address decimal
+ 65 notation string including the link tag such as "_advancedtags.AdvTagGroup1.LinkTag1"
+ 66 :param DATA: Dict of the `link_tag` properties to be modified
+ 67 :param force: *(optional)* if True, will force the configuration update to the Kepware server
+ 68
+ 69 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 70
+ 71 :raises KepHTTPError: If urllib provides an HTTPError
+ 72 :raises KepURLError: If urllib provides an URLError
+ 73 '''
+ 74link_tag_data=server._force_update_check(force,DATA)
+ 75path_obj=adv_tags._adv_tag_path_split(link_tag_path,isItem=True)
+ 76url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_link_tags_url(path_obj['item'])
+ 77
+ 78r=server._config_update(url,link_tag_data)
+ 79ifr.code==200:
+ 80returnTrue
+ 81else:
+ 82raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+ 83
+ 84defdel_link_tag(server:server,link_tag_path:str)->bool:
+ 85'''Delete `"link_tag"` object at a specific path in Kepware.
+ 86
+ 87 :param server: instance of the `server` class
+ 88 :param link_tag_path: path identifying location and link tag to delete. Standard Kepware address decimal
+ 89 notation string including the link tag such as "_advancedtags.AdvTagGroup1.LinkTag1"
+ 90
+ 91 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 92
+ 93 :raises KepHTTPError: If urllib provides an HTTPError
+ 94 :raises KepURLError: If urllib provides an URLError
+ 95 '''
+ 96path_obj=adv_tags._adv_tag_path_split(link_tag_path,isItem=True)
+ 97url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_link_tags_url(path_obj['item'])
+ 98
+ 99r=server._config_del(url)
+100ifr.code==200:
+101returnTrue
+102else:
+103raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+104
+105defget_link_tag(server:server,link_tag_path:str)->dict:
+106'''Returns the properties of the `"link_tag"` object at a specific path in Kepware.
+107
+108 :param server: instance of the `server` class
+109 :param link_tag_path: path identifying location and link tag to retrieve. Standard Kepware address decimal
+110 notation string including the link tag such as "_advancedtags.AdvTagGroup1.LinkTag1"
+111
+112 :return: Dict of data for the link tag requested
+113
+114 :raises KepHTTPError: If urllib provides an HTTPError
+115 :raises KepURLError: If urllib provides an URLError
+116 '''
+117path_obj=adv_tags._adv_tag_path_split(link_tag_path,isItem=True)
+118url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_link_tags_url(path_obj['item'])
+119
+120r=server._config_get(url)
+121returnr.payload
+122
+123defget_all_link_tags(server:server,adv_tag_group_path:str,*,options:dict=None)->list:
+124'''Returns the properties of all `"link_tag"` objects at a specific path in Kepware.
+125
+126 :param server: instance of the `server` class
+127 :param adv_tag_group_path: path identifying location to retrieve link tag list. Standard Kepware address decimal
+128 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+129 :param options: *(optional)* Dict of parameters to filter, sort or paginate the list of link tags. Options are `filter`,
+130 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
+131
+132 :return: List of data for all link tags
+133
+134 :raises KepHTTPError: If urllib provides an HTTPError
+135 :raises KepURLError: If urllib provides an URLError
+136 '''
+137path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+138url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_link_tags_url()
+139
+140r=server._config_get(url,params=options)
+141returnr.payload
+
33defadd_link_tag(server:server,adv_tag_group_path:str,DATA:Union[dict,list])->Union[bool,list]:
+34'''Add `"link_tag"` or multiple `"link_tag"` objects to a specific path in Kepware.
+35 Can be used to pass a list of link tags to be added at one path location.
+36
+37 :param server: instance of the `server` class
+38 :param adv_tag_group_path: path identifying where to add link tag(s). Standard Kepware address decimal
+39 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+40 :param DATA: Dict or List of Dicts of the link tag(s) to add
+41
+42 :return: True - If a "HTTP 201 - Created" is received from Kepware server
+43 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+44 link tags added that failed.
+45
+46 :raises KepHTTPError: If urllib provides an HTTPError
+47 :raises KepURLError: If urllib provides an URLError
+48 '''
+49path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+50url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_link_tags_url()
+51
+52r=server._config_add(url,DATA)
+53ifr.code==201:
+54returnTrue
+55elifr.code==207:
+56errors=[itemforiteminr.payloadifitem['code']!=201]
+57returnerrors
+58else:
+59raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Add "link_tag" or multiple "link_tag" objects to a specific path in Kepware.
+Can be used to pass a list of link tags to be added at one path location.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying where to add link tag(s). Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+
DATA: Dict or List of Dicts of the link tag(s) to add
+
+
+
Returns
+
+
+
True - If a "HTTP 201 - Created" is received from Kepware server
+
+
+
Returns
+
+
+
If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+ link tags added that failed.
61defmodify_link_tag(server:server,link_tag_path:str,DATA:dict,force:bool=False)->bool:
+62'''Modify a `"link_tag"` object and its properties in Kepware.
+63
+64 :param server: instance of the `server` class
+65 :param link_tag_path: path identifying location and link tag to modify. Standard Kepware address decimal
+66 notation string including the link tag such as "_advancedtags.AdvTagGroup1.LinkTag1"
+67 :param DATA: Dict of the `link_tag` properties to be modified
+68 :param force: *(optional)* if True, will force the configuration update to the Kepware server
+69
+70 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+71
+72 :raises KepHTTPError: If urllib provides an HTTPError
+73 :raises KepURLError: If urllib provides an URLError
+74 '''
+75link_tag_data=server._force_update_check(force,DATA)
+76path_obj=adv_tags._adv_tag_path_split(link_tag_path,isItem=True)
+77url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_link_tags_url(path_obj['item'])
+78
+79r=server._config_update(url,link_tag_data)
+80ifr.code==200:
+81returnTrue
+82else:
+83raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Modify a "link_tag" object and its properties in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
link_tag_path: path identifying location and link tag to modify. Standard Kepware address decimal
+notation string including the link tag such as "_advancedtags.AdvTagGroup1.LinkTag1"
+
DATA: Dict of the link_tag properties to be modified
+
force: (optional) if True, will force the configuration update to the Kepware server
+
+
+
Returns
+
+
+
True - If a "HTTP 200 - OK" is received from Kepware server
85defdel_link_tag(server:server,link_tag_path:str)->bool:
+ 86'''Delete `"link_tag"` object at a specific path in Kepware.
+ 87
+ 88 :param server: instance of the `server` class
+ 89 :param link_tag_path: path identifying location and link tag to delete. Standard Kepware address decimal
+ 90 notation string including the link tag such as "_advancedtags.AdvTagGroup1.LinkTag1"
+ 91
+ 92 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 93
+ 94 :raises KepHTTPError: If urllib provides an HTTPError
+ 95 :raises KepURLError: If urllib provides an URLError
+ 96 '''
+ 97path_obj=adv_tags._adv_tag_path_split(link_tag_path,isItem=True)
+ 98url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_link_tags_url(path_obj['item'])
+ 99
+100r=server._config_del(url)
+101ifr.code==200:
+102returnTrue
+103else:
+104raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Delete "link_tag" object at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
link_tag_path: path identifying location and link tag to delete. Standard Kepware address decimal
+notation string including the link tag such as "_advancedtags.AdvTagGroup1.LinkTag1"
+
+
+
Returns
+
+
+
True - If a "HTTP 200 - OK" is received from Kepware server
106defget_link_tag(server:server,link_tag_path:str)->dict:
+107'''Returns the properties of the `"link_tag"` object at a specific path in Kepware.
+108
+109 :param server: instance of the `server` class
+110 :param link_tag_path: path identifying location and link tag to retrieve. Standard Kepware address decimal
+111 notation string including the link tag such as "_advancedtags.AdvTagGroup1.LinkTag1"
+112
+113 :return: Dict of data for the link tag requested
+114
+115 :raises KepHTTPError: If urllib provides an HTTPError
+116 :raises KepURLError: If urllib provides an URLError
+117 '''
+118path_obj=adv_tags._adv_tag_path_split(link_tag_path,isItem=True)
+119url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_link_tags_url(path_obj['item'])
+120
+121r=server._config_get(url)
+122returnr.payload
+
+
+
+
Returns the properties of the "link_tag" object at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
link_tag_path: path identifying location and link tag to retrieve. Standard Kepware address decimal
+notation string including the link tag such as "_advancedtags.AdvTagGroup1.LinkTag1"
124defget_all_link_tags(server:server,adv_tag_group_path:str,*,options:dict=None)->list:
+125'''Returns the properties of all `"link_tag"` objects at a specific path in Kepware.
+126
+127 :param server: instance of the `server` class
+128 :param adv_tag_group_path: path identifying location to retrieve link tag list. Standard Kepware address decimal
+129 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+130 :param options: *(optional)* Dict of parameters to filter, sort or paginate the list of link tags. Options are `filter`,
+131 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
+132
+133 :return: List of data for all link tags
+134
+135 :raises KepHTTPError: If urllib provides an HTTPError
+136 :raises KepURLError: If urllib provides an URLError
+137 '''
+138path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+139url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_link_tags_url()
+140
+141r=server._config_get(url,params=options)
+142returnr.payload
+
+
+
+
Returns the properties of all "link_tag" objects at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying location to retrieve link tag list. Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+
options: (optional) Dict of parameters to filter, sort or paginate the list of link tags. Options are filter,
+sortOrder, sortProperty, pageNumber, and pageSize
+
+
+
Returns
+
+
+
List of data for all link tags
+
+
+
Raises
+
+
+
KepHTTPError: If urllib provides an HTTPError
+
KepURLError: If urllib provides an URLError
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/kepconfig/adv_tags/max_tags.html b/docs/kepconfig/adv_tags/max_tags.html
new file mode 100644
index 0000000..4ec3fbe
--- /dev/null
+++ b/docs/kepconfig/adv_tags/max_tags.html
@@ -0,0 +1,719 @@
+
+
+
+
+
+
+ kepconfig.adv_tags.max_tags API documentation
+
+
+
+
+
+
+
+
+
+
+
+
maximum_tags exposes an API to allow modifications (add, delete, modify) to
+maximum tag objects within the Kepware Configuration API
+
+
+
+
+
+
+
1# -------------------------------------------------------------------------
+ 2# Copyright (c) PTC Inc. and/or all its affiliates. All rights reserved.
+ 3# See License.txt in the project root for
+ 4# license information.
+ 5# --------------------------------------------------------------------------
+ 6
+ 7# Note: The code within this file was created in total or in part
+ 8# with the use of AI tools.
+ 9
+ 10r"""`maximum_tags` exposes an API to allow modifications (add, delete, modify) to
+ 11maximum tag objects within the Kepware Configuration API
+ 12"""
+ 13
+ 14from..connectionimportserver
+ 15from..errorimportKepError,KepHTTPError
+ 16from..utilsimport_url_parse_object
+ 17fromtypingimportUnion
+ 18from..importadv_tags
+ 19
+ 20MAXIMUM_TAGS_ROOT='/maximum_tags'
+ 21
+ 22def_get_maximum_tags_url(tag:str=None)->str:
+ 23'''Creates url object for the "maximum_tags" branch of Kepware's project tree.
+ 24
+ 25 Returns the maximum tag specific url when a value is passed as the tag name.
+ 26 '''
+ 27iftagisNone:
+ 28returnMAXIMUM_TAGS_ROOT
+ 29else:
+ 30returnf'{MAXIMUM_TAGS_ROOT}/{_url_parse_object(tag)}'
+ 31
+ 32defadd_maximum_tag(server:server,adv_tag_group_path:str,DATA:Union[dict,list])->Union[bool,list]:
+ 33'''Add `"maximum_tag"` or multiple `"maximum_tag"` objects to a specific path in Kepware.
+ 34 Can be used to pass a list of maximum tags to be added at one path location.
+ 35
+ 36 :param server: instance of the `server` class
+ 37 :param adv_tag_group_path: path identifying where to add maximum tag(s). Standard Kepware address decimal
+ 38 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+ 39 :param DATA: Dict or List of Dicts of the maximum tag(s) to add
+ 40
+ 41 :return: True - If a "HTTP 201 - Created" is received from Kepware server
+ 42 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+ 43 maximum tags added that failed.
+ 44
+ 45 :raises KepHTTPError: If urllib provides an HTTPError
+ 46 :raises KepURLError: If urllib provides an URLError
+ 47 '''
+ 48path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+ 49url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_maximum_tags_url()
+ 50
+ 51r=server._config_add(url,DATA)
+ 52ifr.code==201:
+ 53returnTrue
+ 54elifr.code==207:
+ 55errors=[itemforiteminr.payloadifitem['code']!=201]
+ 56returnerrors
+ 57else:
+ 58raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+ 59
+ 60defmodify_maximum_tag(server:server,max_tag_path:str,DATA:dict,force:bool=False)->bool:
+ 61'''Modify a `"maximum_tag"` object and its properties in Kepware.
+ 62
+ 63 :param server: instance of the `server` class
+ 64 :param max_tag_path: path identifying location and maximum tag to modify. Standard Kepware address decimal
+ 65 notation string including the maximum tag such as "_advancedtags.AdvTagGroup1.MaxTag1"
+ 66 :param DATA: Dict of the `maximum_tag` properties to be modified
+ 67 :param force: *(optional)* if True, will force the configuration update to the Kepware server
+ 68
+ 69 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 70
+ 71 :raises KepHTTPError: If urllib provides an HTTPError
+ 72 :raises KepURLError: If urllib provides an URLError
+ 73 '''
+ 74max_tag_data=server._force_update_check(force,DATA)
+ 75path_obj=adv_tags._adv_tag_path_split(max_tag_path,isItem=True)
+ 76url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_maximum_tags_url(path_obj['item'])
+ 77
+ 78r=server._config_update(url,max_tag_data)
+ 79ifr.code==200:
+ 80returnTrue
+ 81else:
+ 82raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+ 83
+ 84defdel_maximum_tag(server:server,max_tag_path:str)->bool:
+ 85'''Delete `"maximum_tag"` object at a specific path in Kepware.
+ 86
+ 87 :param server: instance of the `server` class
+ 88 :param max_tag_path: path identifying location and maximum tag to delete. Standard Kepware address decimal
+ 89 notation string including the maximum tag such as "_advancedtags.AdvTagGroup1.MaxTag1"
+ 90
+ 91 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 92
+ 93 :raises KepHTTPError: If urllib provides an HTTPError
+ 94 :raises KepURLError: If urllib provides an URLError
+ 95 '''
+ 96path_obj=adv_tags._adv_tag_path_split(max_tag_path,isItem=True)
+ 97url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_maximum_tags_url(path_obj['item'])
+ 98
+ 99r=server._config_del(url)
+100ifr.code==200:
+101returnTrue
+102else:
+103raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+104
+105defget_maximum_tag(server:server,max_tag_path:str)->dict:
+106'''Returns the properties of the `"maximum_tag"` object at a specific path in Kepware.
+107
+108 :param server: instance of the `server` class
+109 :param max_tag_path: path identifying location and maximum tag to retrieve. Standard Kepware address decimal
+110 notation string including the maximum tag such as "_advancedtags.AdvTagGroup1.MaxTag1"
+111
+112 :return: Dict of data for the maximum tag requested
+113
+114 :raises KepHTTPError: If urllib provides an HTTPError
+115 :raises KepURLError: If urllib provides an URLError
+116 '''
+117path_obj=adv_tags._adv_tag_path_split(max_tag_path,isItem=True)
+118url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_maximum_tags_url(path_obj['item'])
+119
+120r=server._config_get(url)
+121returnr.payload
+122
+123defget_all_maximum_tags(server:server,adv_tag_group_path:str,*,options:dict=None)->list:
+124'''Returns the properties of all `"maximum_tag"` objects at a specific path in Kepware.
+125
+126 :param server: instance of the `server` class
+127 :param adv_tag_group_path: path identifying location to retrieve maximum tag list. Standard Kepware address decimal
+128 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+129 :param options: *(optional)* Dict of parameters to filter, sort or paginate the list of maximum tags. Options are `filter`,
+130 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
+131
+132 :return: List of data for all maximum tags
+133
+134 :raises KepHTTPError: If urllib provides an HTTPError
+135 :raises KepURLError: If urllib provides an URLError
+136 '''
+137path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+138url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_maximum_tags_url()
+139
+140r=server._config_get(url,params=options)
+141returnr.payload
+
33defadd_maximum_tag(server:server,adv_tag_group_path:str,DATA:Union[dict,list])->Union[bool,list]:
+34'''Add `"maximum_tag"` or multiple `"maximum_tag"` objects to a specific path in Kepware.
+35 Can be used to pass a list of maximum tags to be added at one path location.
+36
+37 :param server: instance of the `server` class
+38 :param adv_tag_group_path: path identifying where to add maximum tag(s). Standard Kepware address decimal
+39 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+40 :param DATA: Dict or List of Dicts of the maximum tag(s) to add
+41
+42 :return: True - If a "HTTP 201 - Created" is received from Kepware server
+43 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+44 maximum tags added that failed.
+45
+46 :raises KepHTTPError: If urllib provides an HTTPError
+47 :raises KepURLError: If urllib provides an URLError
+48 '''
+49path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+50url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_maximum_tags_url()
+51
+52r=server._config_add(url,DATA)
+53ifr.code==201:
+54returnTrue
+55elifr.code==207:
+56errors=[itemforiteminr.payloadifitem['code']!=201]
+57returnerrors
+58else:
+59raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Add "maximum_tag" or multiple "maximum_tag" objects to a specific path in Kepware.
+Can be used to pass a list of maximum tags to be added at one path location.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying where to add maximum tag(s). Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+
DATA: Dict or List of Dicts of the maximum tag(s) to add
+
+
+
Returns
+
+
+
True - If a "HTTP 201 - Created" is received from Kepware server
+
+
+
Returns
+
+
+
If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+ maximum tags added that failed.
61defmodify_maximum_tag(server:server,max_tag_path:str,DATA:dict,force:bool=False)->bool:
+62'''Modify a `"maximum_tag"` object and its properties in Kepware.
+63
+64 :param server: instance of the `server` class
+65 :param max_tag_path: path identifying location and maximum tag to modify. Standard Kepware address decimal
+66 notation string including the maximum tag such as "_advancedtags.AdvTagGroup1.MaxTag1"
+67 :param DATA: Dict of the `maximum_tag` properties to be modified
+68 :param force: *(optional)* if True, will force the configuration update to the Kepware server
+69
+70 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+71
+72 :raises KepHTTPError: If urllib provides an HTTPError
+73 :raises KepURLError: If urllib provides an URLError
+74 '''
+75max_tag_data=server._force_update_check(force,DATA)
+76path_obj=adv_tags._adv_tag_path_split(max_tag_path,isItem=True)
+77url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_maximum_tags_url(path_obj['item'])
+78
+79r=server._config_update(url,max_tag_data)
+80ifr.code==200:
+81returnTrue
+82else:
+83raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Modify a "maximum_tag" object and its properties in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
max_tag_path: path identifying location and maximum tag to modify. Standard Kepware address decimal
+notation string including the maximum tag such as "_advancedtags.AdvTagGroup1.MaxTag1"
+
DATA: Dict of the maximum_tag properties to be modified
+
force: (optional) if True, will force the configuration update to the Kepware server
+
+
+
Returns
+
+
+
True - If a "HTTP 200 - OK" is received from Kepware server
85defdel_maximum_tag(server:server,max_tag_path:str)->bool:
+ 86'''Delete `"maximum_tag"` object at a specific path in Kepware.
+ 87
+ 88 :param server: instance of the `server` class
+ 89 :param max_tag_path: path identifying location and maximum tag to delete. Standard Kepware address decimal
+ 90 notation string including the maximum tag such as "_advancedtags.AdvTagGroup1.MaxTag1"
+ 91
+ 92 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 93
+ 94 :raises KepHTTPError: If urllib provides an HTTPError
+ 95 :raises KepURLError: If urllib provides an URLError
+ 96 '''
+ 97path_obj=adv_tags._adv_tag_path_split(max_tag_path,isItem=True)
+ 98url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_maximum_tags_url(path_obj['item'])
+ 99
+100r=server._config_del(url)
+101ifr.code==200:
+102returnTrue
+103else:
+104raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Delete "maximum_tag" object at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
max_tag_path: path identifying location and maximum tag to delete. Standard Kepware address decimal
+notation string including the maximum tag such as "_advancedtags.AdvTagGroup1.MaxTag1"
+
+
+
Returns
+
+
+
True - If a "HTTP 200 - OK" is received from Kepware server
106defget_maximum_tag(server:server,max_tag_path:str)->dict:
+107'''Returns the properties of the `"maximum_tag"` object at a specific path in Kepware.
+108
+109 :param server: instance of the `server` class
+110 :param max_tag_path: path identifying location and maximum tag to retrieve. Standard Kepware address decimal
+111 notation string including the maximum tag such as "_advancedtags.AdvTagGroup1.MaxTag1"
+112
+113 :return: Dict of data for the maximum tag requested
+114
+115 :raises KepHTTPError: If urllib provides an HTTPError
+116 :raises KepURLError: If urllib provides an URLError
+117 '''
+118path_obj=adv_tags._adv_tag_path_split(max_tag_path,isItem=True)
+119url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_maximum_tags_url(path_obj['item'])
+120
+121r=server._config_get(url)
+122returnr.payload
+
+
+
+
Returns the properties of the "maximum_tag" object at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
max_tag_path: path identifying location and maximum tag to retrieve. Standard Kepware address decimal
+notation string including the maximum tag such as "_advancedtags.AdvTagGroup1.MaxTag1"
124defget_all_maximum_tags(server:server,adv_tag_group_path:str,*,options:dict=None)->list:
+125'''Returns the properties of all `"maximum_tag"` objects at a specific path in Kepware.
+126
+127 :param server: instance of the `server` class
+128 :param adv_tag_group_path: path identifying location to retrieve maximum tag list. Standard Kepware address decimal
+129 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+130 :param options: *(optional)* Dict of parameters to filter, sort or paginate the list of maximum tags. Options are `filter`,
+131 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
+132
+133 :return: List of data for all maximum tags
+134
+135 :raises KepHTTPError: If urllib provides an HTTPError
+136 :raises KepURLError: If urllib provides an URLError
+137 '''
+138path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+139url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_maximum_tags_url()
+140
+141r=server._config_get(url,params=options)
+142returnr.payload
+
+
+
+
Returns the properties of all "maximum_tag" objects at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying location to retrieve maximum tag list. Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+
options: (optional) Dict of parameters to filter, sort or paginate the list of maximum tags. Options are filter,
+sortOrder, sortProperty, pageNumber, and pageSize
+
+
+
Returns
+
+
+
List of data for all maximum tags
+
+
+
Raises
+
+
+
KepHTTPError: If urllib provides an HTTPError
+
KepURLError: If urllib provides an URLError
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/kepconfig/adv_tags/min_tags.html b/docs/kepconfig/adv_tags/min_tags.html
new file mode 100644
index 0000000..d3c9acd
--- /dev/null
+++ b/docs/kepconfig/adv_tags/min_tags.html
@@ -0,0 +1,719 @@
+
+
+
+
+
+
+ kepconfig.adv_tags.min_tags API documentation
+
+
+
+
+
+
+
+
+
+
+
+
minimum_tags exposes an API to allow modifications (add, delete, modify) to
+minimum tag objects within the Kepware Configuration API
+
+
+
+
+
+
+
1# -------------------------------------------------------------------------
+ 2# Copyright (c) PTC Inc. and/or all its affiliates. All rights reserved.
+ 3# See License.txt in the project root for
+ 4# license information.
+ 5# --------------------------------------------------------------------------
+ 6
+ 7# Note: The code within this file was created in total or in part
+ 8# with the use of AI tools.
+ 9
+ 10r"""`minimum_tags` exposes an API to allow modifications (add, delete, modify) to
+ 11minimum tag objects within the Kepware Configuration API
+ 12"""
+ 13
+ 14from..connectionimportserver
+ 15from..errorimportKepError,KepHTTPError
+ 16from..utilsimport_url_parse_object
+ 17fromtypingimportUnion
+ 18from..importadv_tags
+ 19
+ 20MINIMUM_TAGS_ROOT='/minimum_tags'
+ 21
+ 22def_get_minimum_tags_url(tag:str=None)->str:
+ 23'''Creates url object for the "minimum_tags" branch of Kepware's project tree.
+ 24
+ 25 Returns the minimum tag specific url when a value is passed as the tag name.
+ 26 '''
+ 27iftagisNone:
+ 28returnMINIMUM_TAGS_ROOT
+ 29else:
+ 30returnf'{MINIMUM_TAGS_ROOT}/{_url_parse_object(tag)}'
+ 31
+ 32defadd_minimum_tag(server:server,adv_tag_group_path:str,DATA:Union[dict,list])->Union[bool,list]:
+ 33'''Add `"minimum_tag"` or multiple `"minimum_tag"` objects to a specific path in Kepware.
+ 34 Can be used to pass a list of minimum tags to be added at one path location.
+ 35
+ 36 :param server: instance of the `server` class
+ 37 :param adv_tag_group_path: path identifying where to add minimum tag(s). Standard Kepware address decimal
+ 38 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+ 39 :param DATA: Dict or List of Dicts of the minimum tag(s) to add
+ 40
+ 41 :return: True - If a "HTTP 201 - Created" is received from Kepware server
+ 42 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+ 43 minimum tags added that failed.
+ 44
+ 45 :raises KepHTTPError: If urllib provides an HTTPError
+ 46 :raises KepURLError: If urllib provides an URLError
+ 47 '''
+ 48path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+ 49url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_minimum_tags_url()
+ 50
+ 51r=server._config_add(url,DATA)
+ 52ifr.code==201:
+ 53returnTrue
+ 54elifr.code==207:
+ 55errors=[itemforiteminr.payloadifitem['code']!=201]
+ 56returnerrors
+ 57else:
+ 58raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+ 59
+ 60defmodify_minimum_tag(server:server,min_tag_path:str,DATA:dict,force:bool=False)->bool:
+ 61'''Modify a `"minimum_tag"` object and its properties in Kepware.
+ 62
+ 63 :param server: instance of the `server` class
+ 64 :param min_tag_path: path identifying location and minimum tag to modify. Standard Kepware address decimal
+ 65 notation string including the minimum tag such as "_advancedtags.AdvTagGroup1.MinTag1"
+ 66 :param DATA: Dict of the `minimum_tag` properties to be modified
+ 67 :param force: *(optional)* if True, will force the configuration update to the Kepware server
+ 68
+ 69 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 70
+ 71 :raises KepHTTPError: If urllib provides an HTTPError
+ 72 :raises KepURLError: If urllib provides an URLError
+ 73 '''
+ 74min_tag_data=server._force_update_check(force,DATA)
+ 75path_obj=adv_tags._adv_tag_path_split(min_tag_path,isItem=True)
+ 76url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_minimum_tags_url(path_obj['item'])
+ 77
+ 78r=server._config_update(url,min_tag_data)
+ 79ifr.code==200:
+ 80returnTrue
+ 81else:
+ 82raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+ 83
+ 84defdel_minimum_tag(server:server,min_tag_path:str)->bool:
+ 85'''Delete `"minimum_tag"` object at a specific path in Kepware.
+ 86
+ 87 :param server: instance of the `server` class
+ 88 :param min_tag_path: path identifying location and minimum tag to delete. Standard Kepware address decimal
+ 89 notation string including the minimum tag such as "_advancedtags.AdvTagGroup1.MinTag1"
+ 90
+ 91 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 92
+ 93 :raises KepHTTPError: If urllib provides an HTTPError
+ 94 :raises KepURLError: If urllib provides an URLError
+ 95 '''
+ 96path_obj=adv_tags._adv_tag_path_split(min_tag_path,isItem=True)
+ 97url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_minimum_tags_url(path_obj['item'])
+ 98
+ 99r=server._config_del(url)
+100ifr.code==200:
+101returnTrue
+102else:
+103raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+104
+105defget_minimum_tag(server:server,min_tag_path:str)->dict:
+106'''Returns the properties of the `"minimum_tag"` object at a specific path in Kepware.
+107
+108 :param server: instance of the `server` class
+109 :param min_tag_path: path identifying location and minimum tag to retrieve. Standard Kepware address decimal
+110 notation string including the minimum tag such as "_advancedtags.AdvTagGroup1.MinTag1"
+111
+112 :return: Dict of data for the minimum tag requested
+113
+114 :raises KepHTTPError: If urllib provides an HTTPError
+115 :raises KepURLError: If urllib provides an URLError
+116 '''
+117path_obj=adv_tags._adv_tag_path_split(min_tag_path,isItem=True)
+118url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_minimum_tags_url(path_obj['item'])
+119
+120r=server._config_get(url)
+121returnr.payload
+122
+123defget_all_minimum_tags(server:server,adv_tag_group_path:str,*,options:dict=None)->list:
+124'''Returns the properties of all `"minimum_tag"` objects at a specific path in Kepware.
+125
+126 :param server: instance of the `server` class
+127 :param adv_tag_group_path: path identifying location to retrieve minimum tag list. Standard Kepware address decimal
+128 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+129 :param options: *(optional)* Dict of parameters to filter, sort or paginate the list of minimum tags. Options are `filter`,
+130 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
+131
+132 :return: List of data for all minimum tags
+133
+134 :raises KepHTTPError: If urllib provides an HTTPError
+135 :raises KepURLError: If urllib provides an URLError
+136 '''
+137path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+138url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_minimum_tags_url()
+139
+140r=server._config_get(url,params=options)
+141returnr.payload
+
33defadd_minimum_tag(server:server,adv_tag_group_path:str,DATA:Union[dict,list])->Union[bool,list]:
+34'''Add `"minimum_tag"` or multiple `"minimum_tag"` objects to a specific path in Kepware.
+35 Can be used to pass a list of minimum tags to be added at one path location.
+36
+37 :param server: instance of the `server` class
+38 :param adv_tag_group_path: path identifying where to add minimum tag(s). Standard Kepware address decimal
+39 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+40 :param DATA: Dict or List of Dicts of the minimum tag(s) to add
+41
+42 :return: True - If a "HTTP 201 - Created" is received from Kepware server
+43 :return: If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+44 minimum tags added that failed.
+45
+46 :raises KepHTTPError: If urllib provides an HTTPError
+47 :raises KepURLError: If urllib provides an URLError
+48 '''
+49path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+50url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_minimum_tags_url()
+51
+52r=server._config_add(url,DATA)
+53ifr.code==201:
+54returnTrue
+55elifr.code==207:
+56errors=[itemforiteminr.payloadifitem['code']!=201]
+57returnerrors
+58else:
+59raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Add "minimum_tag" or multiple "minimum_tag" objects to a specific path in Kepware.
+Can be used to pass a list of minimum tags to be added at one path location.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying where to add minimum tag(s). Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+
DATA: Dict or List of Dicts of the minimum tag(s) to add
+
+
+
Returns
+
+
+
True - If a "HTTP 201 - Created" is received from Kepware server
+
+
+
Returns
+
+
+
If a "HTTP 207 - Multi-Status" is received from Kepware with a list of dict error responses for all
+ minimum tags added that failed.
61defmodify_minimum_tag(server:server,min_tag_path:str,DATA:dict,force:bool=False)->bool:
+62'''Modify a `"minimum_tag"` object and its properties in Kepware.
+63
+64 :param server: instance of the `server` class
+65 :param min_tag_path: path identifying location and minimum tag to modify. Standard Kepware address decimal
+66 notation string including the minimum tag such as "_advancedtags.AdvTagGroup1.MinTag1"
+67 :param DATA: Dict of the `minimum_tag` properties to be modified
+68 :param force: *(optional)* if True, will force the configuration update to the Kepware server
+69
+70 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+71
+72 :raises KepHTTPError: If urllib provides an HTTPError
+73 :raises KepURLError: If urllib provides an URLError
+74 '''
+75min_tag_data=server._force_update_check(force,DATA)
+76path_obj=adv_tags._adv_tag_path_split(min_tag_path,isItem=True)
+77url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_minimum_tags_url(path_obj['item'])
+78
+79r=server._config_update(url,min_tag_data)
+80ifr.code==200:
+81returnTrue
+82else:
+83raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Modify a "minimum_tag" object and its properties in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
min_tag_path: path identifying location and minimum tag to modify. Standard Kepware address decimal
+notation string including the minimum tag such as "_advancedtags.AdvTagGroup1.MinTag1"
+
DATA: Dict of the minimum_tag properties to be modified
+
force: (optional) if True, will force the configuration update to the Kepware server
+
+
+
Returns
+
+
+
True - If a "HTTP 200 - OK" is received from Kepware server
85defdel_minimum_tag(server:server,min_tag_path:str)->bool:
+ 86'''Delete `"minimum_tag"` object at a specific path in Kepware.
+ 87
+ 88 :param server: instance of the `server` class
+ 89 :param min_tag_path: path identifying location and minimum tag to delete. Standard Kepware address decimal
+ 90 notation string including the minimum tag such as "_advancedtags.AdvTagGroup1.MinTag1"
+ 91
+ 92 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+ 93
+ 94 :raises KepHTTPError: If urllib provides an HTTPError
+ 95 :raises KepURLError: If urllib provides an URLError
+ 96 '''
+ 97path_obj=adv_tags._adv_tag_path_split(min_tag_path,isItem=True)
+ 98url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_minimum_tags_url(path_obj['item'])
+ 99
+100r=server._config_del(url)
+101ifr.code==200:
+102returnTrue
+103else:
+104raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
+
+
+
Delete "minimum_tag" object at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
min_tag_path: path identifying location and minimum tag to delete. Standard Kepware address decimal
+notation string including the minimum tag such as "_advancedtags.AdvTagGroup1.MinTag1"
+
+
+
Returns
+
+
+
True - If a "HTTP 200 - OK" is received from Kepware server
106defget_minimum_tag(server:server,min_tag_path:str)->dict:
+107'''Returns the properties of the `"minimum_tag"` object at a specific path in Kepware.
+108
+109 :param server: instance of the `server` class
+110 :param min_tag_path: path identifying location and minimum tag to retrieve. Standard Kepware address decimal
+111 notation string including the minimum tag such as "_advancedtags.AdvTagGroup1.MinTag1"
+112
+113 :return: Dict of data for the minimum tag requested
+114
+115 :raises KepHTTPError: If urllib provides an HTTPError
+116 :raises KepURLError: If urllib provides an URLError
+117 '''
+118path_obj=adv_tags._adv_tag_path_split(min_tag_path,isItem=True)
+119url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_minimum_tags_url(path_obj['item'])
+120
+121r=server._config_get(url)
+122returnr.payload
+
+
+
+
Returns the properties of the "minimum_tag" object at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
min_tag_path: path identifying location and minimum tag to retrieve. Standard Kepware address decimal
+notation string including the minimum tag such as "_advancedtags.AdvTagGroup1.MinTag1"
124defget_all_minimum_tags(server:server,adv_tag_group_path:str,*,options:dict=None)->list:
+125'''Returns the properties of all `"minimum_tag"` objects at a specific path in Kepware.
+126
+127 :param server: instance of the `server` class
+128 :param adv_tag_group_path: path identifying location to retrieve minimum tag list. Standard Kepware address decimal
+129 notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+130 :param options: *(optional)* Dict of parameters to filter, sort or paginate the list of minimum tags. Options are `filter`,
+131 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
+132
+133 :return: List of data for all minimum tags
+134
+135 :raises KepHTTPError: If urllib provides an HTTPError
+136 :raises KepURLError: If urllib provides an URLError
+137 '''
+138path_obj=adv_tags._adv_tag_path_split(adv_tag_group_path,isItem=False)
+139url=adv_tags._create_adv_tags_base_url(server.url,path_obj)+_get_minimum_tags_url()
+140
+141r=server._config_get(url,params=options)
+142returnr.payload
+
+
+
+
Returns the properties of all "minimum_tag" objects at a specific path in Kepware.
+
+
Parameters
+
+
+
server: instance of the server class
+
adv_tag_group_path: path identifying location to retrieve minimum tag list. Standard Kepware address decimal
+notation string such as "_advancedtags.AdvTagGroup1" or "_advancedtags.AdvTagGroup1.AdvTagGroupChild"
+
options: (optional) Dict of parameters to filter, sort or paginate the list of minimum tags. Options are filter,
+sortOrder, sortProperty, pageNumber, and pageSize
+
+
+
Returns
+
+
+
List of data for all minimum tags
+
+
+
Raises
+
+
+
KepHTTPError: If urllib provides an HTTPError
+
KepURLError: If urllib provides an URLError
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/kepconfig/connection.html b/docs/kepconfig/connection.html
index 425299b..74b642e 100644
--- a/docs/kepconfig/connection.html
+++ b/docs/kepconfig/connection.html
@@ -3,7 +3,7 @@
-
+
kepconfig.connection API documentation
@@ -36,30 +36,6 @@
16from.errorimportKepError,KepHTTPError,KepURLError 17importsocket 18importssl
- 19from.structuresimportKepServiceResponse,KepServiceStatus,_HttpDataAbstract
+ 19from.structuresimportKepServiceResponse,KepServiceStatus,_HttpDataAbstract,Filter 20 21 22classserver:
- 23'''A class to represent a connection to an instance of Kepware. This object is used to
+ 23'''A class to represent a connection to an instance of Kepware. This object is used to 24 create the Authentication and server parameters to taget a Kepware instance. An instance of this is 25 used in all configuration calls done. 26
@@ -171,472 +156,545 @@
43 44 :meth:`get_event_log`: retrieve the Kepware Event Log 45
- 46 :meth:`get_project_properties`: retrieve the Kepware Project Properties
+ 46 :meth:`get_audit_log`: retrieve the Kepware Audit Log 47
- 48 :meth:`modify_project_properties` - modify the Kepware Project Properties
- 49
- 50 :meth:`service_status` - retrive service job status
- 51 '''
- 52__root_url='/config'
- 53__version_url='/v1'
- 54__project_services_url='/project/services'
- 55__event_log_url='/event_log'
- 56__trans_log_url='/log'
+ 48 :meth:`get_info`: retrieve the Kepware product information
+ 49
+ 50 :meth:`import_empty_project`: import an empty project to the Kepware server
+ 51
+ 52 :meth:`get_project_properties`: retrieve the Kepware Project Properties
+ 53
+ 54 :meth:`modify_project_properties` - modify the Kepware Project Properties
+ 55
+ 56 :meth:`service_status` - retrive service job status 57
- 58
+ 58 :meth:`export_project_configuration` - export the current project configuration in JSON format 59
- 60def__init__(self,host:str,port:int,user:str,pw:str,https:bool=False):
- 61self.host=host
- 62self.port=port
- 63self.username=user
- 64self.password=pw
- 65self.__ssl_context=ssl.create_default_context()
- 66self.__SSL_on=https
- 67
- 68@property
- 69defurl(self):
- 70ifself.SSL_on:
- 71proto='https'
- 72else:
- 73proto='http'
- 74returnf'{proto}://{self.host}:{self.port}{self.__root_url}{self.__version_url}'
- 75
- 76@property
- 77defSSL_on(self):
- 78returnself.__SSL_on
- 79
- 80@SSL_on.setter
- 81defSSL_on(self,val):
- 82
- 83ifisinstance(val,bool):
- 84self.__SSL_on=val
- 85
- 86@property
- 87defSSL_ignore_hostname(self):
- 88returnnotself.__ssl_context.check_hostname
- 89
- 90@SSL_ignore_hostname.setter
- 91defSSL_ignore_hostname(self,val):
- 92ifisinstance(val,bool):
- 93ifval==True:
- 94self.__ssl_context.check_hostname=False
- 95else:
- 96self.__ssl_context.check_hostname=True
- 97
- 98
+ 60 :meth:`save_project` - save the current project to a file
+ 61
+ 62 :meth:`load_project` - load a project from a file
+ 63 '''
+ 64__root_url='/config'
+ 65__version_url='/v1'
+ 66__project_services_url='/project/services'
+ 67__event_log_url='/event_log'
+ 68__trans_log_url='/log'
+ 69__audit_log_url='/audit_log'
+ 70
+ 71
+ 72
+ 73def__init__(self,host:str,port:int,user:str,pw:str,https:bool=False):
+ 74self.host=host
+ 75self.port=port
+ 76self.username=user
+ 77self.password=pw
+ 78self.__ssl_context=ssl.create_default_context()
+ 79self.__SSL_on=https
+ 80
+ 81@property
+ 82defurl(self):
+ 83ifself.SSL_on:
+ 84proto='https'
+ 85else:
+ 86proto='http'
+ 87returnf'{proto}://{self.host}:{self.port}{self.__root_url}{self.__version_url}'
+ 88
+ 89@property
+ 90defSSL_on(self):
+ 91returnself.__SSL_on
+ 92
+ 93@SSL_on.setter
+ 94defSSL_on(self,val):
+ 95
+ 96ifisinstance(val,bool):
+ 97self.__SSL_on=val
+ 98 99@property
-100defSSL_trust_all_certs(self):
-101ifself.__ssl_context.verify_mode==ssl.CERT_NONE:
-102returnTrue
-103else:
-104returnFalse
-105
-106@SSL_trust_all_certs.setter
-107defSSL_trust_all_certs(self,val):
-108ifisinstance(val,bool):
-109ifval==True:
-110ifself.__ssl_context.check_hostname==True:
-111self.__ssl_context.check_hostname=False
-112self.__ssl_context.verify_mode=ssl.CERT_NONE
-113else:
-114self.__ssl_context.verify_mode=ssl.CERT_REQUIRED
-115
-116
-117defget_status(self)->dict:
-118'''Executes a health status request to the Kepware instance to report service statuses.
-119
-120 :return: List of data for the health status request
-121
-122 :raises KepHTTPError: If urllib provides an HTTPError
-123 :raises KepURLError: If urllib provides an URLError
-124 '''
-125
-126r=self._config_get(f'{self.url}/status')
-127returnr.payload
-128defget_info(self)->dict:
-129'''Requests product information from the Kepware instance. Provides various information including
-130 product name and version information.
-131
-132 :return: dict of data for the product information request
-133
-134 :raises KepHTTPError: If urllib provides an HTTPError
-135 :raises KepURLError: If urllib provides an URLError
-136 '''
-137
-138r=self._config_get(f'{self.url}/about')
-139returnr.payload
-140
-141defreinitialize(self,job_ttl:int=None)->KepServiceResponse:
-142'''Executes a Reinitialize service call to the Kepware instance.
-143
-144 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
-145
-146 :return: `KepServiceResponse` instance with job information
-147
-148 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
-149 :raises KepURLError: If urllib provides an URLError
-150 '''
-151url=self.url+self.__project_services_url+'/ReinitializeRuntime'
-152try:
-153job=self._kep_service_execute(url,None,job_ttl)
-154returnjob
-155exceptExceptionaserr:
-156raiseerr
-157
-158defget_transaction_log(self,limit:int=None,start:datetime.datetime=None,end:datetime.datetime=None)->list:
-159''' Get the Transaction Log from the Kepware instance.
+100defSSL_ignore_hostname(self):
+101returnnotself.__ssl_context.check_hostname
+102
+103@SSL_ignore_hostname.setter
+104defSSL_ignore_hostname(self,val):
+105ifisinstance(val,bool):
+106ifval==True:
+107self.__ssl_context.check_hostname=False
+108else:
+109self.__ssl_context.check_hostname=True
+110
+111
+112@property
+113defSSL_trust_all_certs(self):
+114ifself.__ssl_context.verify_mode==ssl.CERT_NONE:
+115returnTrue
+116else:
+117returnFalse
+118
+119@SSL_trust_all_certs.setter
+120defSSL_trust_all_certs(self,val):
+121ifisinstance(val,bool):
+122ifval==True:
+123ifself.__ssl_context.check_hostname==True:
+124self.__ssl_context.check_hostname=False
+125self.__ssl_context.verify_mode=ssl.CERT_NONE
+126else:
+127self.__ssl_context.verify_mode=ssl.CERT_REQUIRED
+128
+129
+130defget_status(self)->dict:
+131'''Executes a health status request to the Kepware instance to report service statuses.
+132
+133 :return: List of data for the health status request
+134
+135 :raises KepHTTPError: If urllib provides an HTTPError
+136 :raises KepURLError: If urllib provides an URLError
+137 '''
+138
+139r=self._config_get(f'{self.url}/status')
+140returnr.payload
+141defget_info(self)->dict:
+142'''Requests product information from the Kepware instance. Provides various information including
+143 product name and version information.
+144
+145 :return: dict of data for the product information request
+146
+147 :raises KepHTTPError: If urllib provides an HTTPError
+148 :raises KepURLError: If urllib provides an URLError
+149 '''
+150
+151r=self._config_get(f'{self.url}/about')
+152returnr.payload
+153
+154defreinitialize(self,job_ttl:int=None)->KepServiceResponse:
+155'''Executes a Reinitialize service call to the Kepware instance.
+156
+157 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
+158
+159 :return: `KepServiceResponse` instance with job information160
-161 :param limit: *(optional)* number of transaction log entries to request
-162 :param start: *(optional)* start time of query as `datetime.datetime` type and should be UTC
-163 :param end: *(optional)* end time of query as `datetime.datetime` type and should be UTC
-164
-165 :raises KepHTTPError: If urllib provides an HTTPError
-166 :raises KepURLError: If urllib provides an URLError
-167 '''
-168query=self.__create_query(start,end,limit)
-169url=f'{self.url}{self.__trans_log_url}'
-170r=self._config_get(url,params=query)
-171returnr.payload
-172
-173defget_event_log(self,limit:int=None,start:datetime.datetime=None,end:datetime.datetime=None,*,options:dict=None)->list:
-174''' Get the Event Log from the Kepware instance.
-175
-176 :param limit: *(optional)* number of event log entries to request
-177 :param start: *(optional)* start time of query as `datetime.datetime` type and should be UTC
-178 :param end: *(optional)* end time of query as `datetime.datetime` type and should be UTC
-179 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of transactions. Options are `event`,
-180 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
-181
-182 :raises KepHTTPError: If urllib provides an HTTPError
-183 :raises KepURLError: If urllib provides an URLError
-184 '''
-185query=self.__create_query(start,end,limit)
-186ifoptionsisnotNone:
-187query={**query,**options}
-188url=f'{self.url}{self.__event_log_url}'
-189r=self._config_get(url,params=query)
-190returnr.payload
-191
-192defget_project_properties(self)->dict:
-193''' Get the Project Properties of the Kepware instance.
-194
-195 :return: Dict of all the project properties
-196
-197 :raises KepHTTPError: If urllib provides an HTTPError
-198 :raises KepURLError: If urllib provides an URLError
-199 '''
-200
-201r=self._config_get(self.url+'/project')
-202returnr.payload
-203
-204defmodify_project_properties(self,DATA:dict,force:bool=False)->bool:
-205''' Modify the Project Properties of the Kepware instance.
-206
-207 :param DATA: Dict of the project properties to be modified
-208 :param force: *(optional)* if True, will force the configuration update to the Kepware server
-209
-210 :return: True - If a "HTTP 200 - OK" is received from Kepware server
-211
-212 :raises KepHTTPError: If urllib provides an HTTPError
-213 :raises KepURLError: If urllib provides an URLError
-214 '''
-215
-216prop_data=self._force_update_check(force,DATA)
-217r=self._config_update(self.url+'/project',prop_data)
-218ifr.code==200:returnTrue
-219else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
-220
-221defimport_empty_project(self)->KepServiceResponse:
-222'''Executes JsonProjectLoad Service call to the Kepware instance with an empty project. This service
-223 imports an empty project configuration, acts like a FILE->NEW action and
-224 stop communications while the new project replaces the current project in the Kepware runtime.
-225
-226 :return: `KepServiceResponse` instance with job information
+161 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
+162 :raises KepURLError: If urllib provides an URLError
+163 '''
+164url=self.url+self.__project_services_url+'/ReinitializeRuntime'
+165try:
+166job=self._kep_service_execute(url,None,job_ttl)
+167returnjob
+168exceptExceptionaserr:
+169raiseerr
+170
+171defget_transaction_log(self,limit:int=None,start:datetime.datetime=None,end:datetime.datetime=None)->list:
+172''' Get the Transaction Log from the Kepware instance.
+173
+174 :param limit: *(optional)* number of transaction log entries to request
+175 :param start: *(optional)* start time of query as `datetime.datetime` type and should be UTC
+176 :param end: *(optional)* end time of query as `datetime.datetime` type and should be UTC
+177
+178 :raises KepHTTPError: If urllib provides an HTTPError
+179 :raises KepURLError: If urllib provides an URLError
+180 '''
+181query=self.__create_query(start,end,limit)
+182url=f'{self.url}{self.__trans_log_url}'
+183r=self._config_get(url,params=query)
+184returnr.payload
+185
+186defget_event_log(self,limit:int=None,start:datetime.datetime=None,end:datetime.datetime=None,*,options:dict=None)->list:
+187''' Get the Event Log from the Kepware instance.
+188
+189 :param limit: *(optional)* number of event log entries to request
+190 :param start: *(optional)* start time of query as `datetime.datetime` type and should be UTC
+191 :param end: *(optional)* end time of query as `datetime.datetime` type and should be UTC
+192 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of transactions. Options are `event`,
+193 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
+194
+195 :raises KepHTTPError: If urllib provides an HTTPError
+196 :raises KepURLError: If urllib provides an URLError
+197 '''
+198query=self.__create_query(start,end,limit)
+199ifoptionsisnotNone:
+200query={**query,**options}
+201url=f'{self.url}{self.__event_log_url}'
+202r=self._config_get(url,params=query)
+203returnr.payload
+204
+205defget_audit_log(self,limit:int=None,*,filters:list[Filter]=None,options:dict=None)->list:
+206''' Get the Audit Log from the Kepware instance.
+207
+208 :param limit: *(optional)* number of event log entries to request
+209 :param filters: *(optional)* list of filters that are used to control results returned from the log
+210 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of transactions. Options are `sortOrder`,
+211 `sortProperty`, `pageNumber`, and `pageSize`
+212
+213 :raises KepHTTPError: If urllib provides an HTTPError
+214 :raises KepURLError: If urllib provides an URLError
+215 '''
+216query=self.__create_filter_query(filters)
+217iflimitisnotNone:
+218query['limit']=limit
+219ifoptionsisnotNone:
+220query={**query,**options}
+221url=f'{self.url}{self.__audit_log_url}'
+222r=self._config_get(url,params=query)
+223returnr.payload
+224
+225defget_project_properties(self)->dict:
+226''' Get the Project Properties of the Kepware instance.227
-228 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
-229 :raises KepURLError: If urllib provides an URLError
-230 '''
-231returnself.import_project_configuration({"project":{}})
-232
+228 :return: Dict of all the project properties
+229
+230 :raises KepHTTPError: If urllib provides an HTTPError
+231 :raises KepURLError: If urllib provides an URLError
+232 '''233
-234defimport_project_configuration(self,DATA:dict)->KepServiceResponse:
-235'''Executes JsonProjectLoad Service call to the Kepware instance. This service imports project configuration
-236 data, expecting a complete project file in JSON/dict format. This service acts like a FILE->OPEN action and
-237 stop communications while the new project replaces the current project in the Kepware runtime.
-238
-239 :param DATA: Complete project configuration data in JSON/dict format.
-240
-241 :return: `KepServiceResponse` instance with job information
+234r=self._config_get(self.url+'/project')
+235returnr.payload
+236
+237defmodify_project_properties(self,DATA:dict,force:bool=False)->bool:
+238''' Modify the Project Properties of the Kepware instance.
+239
+240 :param DATA: Dict of the project properties to be modified
+241 :param force: *(optional)* if True, will force the configuration update to the Kepware server242
-243 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
-244 :raises KepURLError: If urllib provides an URLError
-245 '''
-246url=self.url+self.__project_services_url+'/JsonProjectLoad'
-247try:
-248job=self._kep_service_execute(url,DATA)
-249returnjob
-250exceptExceptionaserr:
-251raiseerr
-252
-253defexport_project_configuration(self)->dict:
-254'''Get a complete copy of the project configuration in JSON format. This will include the same
-255 configuration that is stored when you save the project file manually.
-256
-257 :return: Dict of the complete project configuration
+243 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+244
+245 :raises KepHTTPError: If urllib provides an HTTPError
+246 :raises KepURLError: If urllib provides an URLError
+247 '''
+248
+249prop_data=self._force_update_check(force,DATA)
+250r=self._config_update(self.url+'/project',prop_data)
+251ifr.code==200:returnTrue
+252else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+253
+254defimport_empty_project(self)->KepServiceResponse:
+255'''Executes JsonProjectLoad Service call to the Kepware instance with an empty project. This service
+256 imports an empty project configuration, acts like a FILE->NEW action and
+257 stop communications while the new project replaces the current project in the Kepware runtime. 258
-259 :raises KepHTTPError: If urllib provides an HTTPError
-260 :raises KepURLError: If urllib provides an URLError
-261 '''
-262r=self._config_get(self.url+'/project',params={"content":"serialize"})
-263returnr.payload
-264
-265defsave_project(self,filename:str,password:str=None,job_ttl:int=None)->KepServiceResponse:
-266'''Executes a ProjectSave Service call to the Kepware instance. This saves
-267 a copy of the current project file to disk. The filename
-268
-269 :param filename: Relative file path and name of project file including the file extension to save.
-270 Location of relative project file paths:
-271
-272 TKS or KEP (Windows): C:\\PROGRAMDATA\\PTC\\Thingworx Kepware Server\\V6 or
-273 C:\\PROGRAMDATA\\Kepware\\KEPServerEX\\V6
-274 TKE (Linux): /opt/tkedge/v1/user_data
-275
-276
-277 :param password: *(optional)* Specify a password with which to save an encrypted project file with.
-278 This password will be required to load this project file.
-279 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
-280
-281 :return: `KepServiceResponse` instance with job information
-282
-283 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
-284 :raises KepURLError: If urllib provides an URLError
-285 '''
-286url=self.url+self.__project_services_url+'/ProjectSave'
-287prop_data={'servermain.PROJECT_FILENAME':filename}
-288ifpassword!=None:prop_data['servermain.PROJECT_PASSWORD']=password
-289try:
-290job=self._kep_service_execute(url,prop_data,job_ttl)
-291returnjob
-292exceptExceptionaserr:
-293raiseerr
-294
-295defload_project(self,filename:str,password:str=None,job_ttl:int=None)->KepServiceResponse:
-296'''Executes a ProjectLoad Service call to the Kepware instance. This loads
-297 a project file to disk.
-298
-299 INPUTS:
-300
-301 :param filename: Fully qualified or relative path and name of project file including the file extension. Absolute
-302 paths required for TKS and KEP while file path is relative for TKE:
-303
-304 Windows - filename = C:\\filepath\\test.opf
-305 Linux - filename = filepath/test.lpf - Location is /opt/tkedge/v1/user_data/filepath/test.lpf
-306
-307 :param password: *(optional)* Specify a password with which to load an encrypted project file.
-308 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
+259 :return: `KepServiceResponse` instance with job information
+260
+261 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
+262 :raises KepURLError: If urllib provides an URLError
+263 '''
+264returnself.import_project_configuration({"project":{}})
+265
+266
+267defimport_project_configuration(self,DATA:dict)->KepServiceResponse:
+268'''Executes JsonProjectLoad Service call to the Kepware instance. This service imports project configuration
+269 data, expecting a complete project file in JSON/dict format. This service acts like a FILE->OPEN action and
+270 stop communications while the new project replaces the current project in the Kepware runtime.
+271
+272 :param DATA: Complete project configuration data in JSON/dict format.
+273
+274 :return: `KepServiceResponse` instance with job information
+275
+276 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
+277 :raises KepURLError: If urllib provides an URLError
+278 '''
+279url=self.url+self.__project_services_url+'/JsonProjectLoad'
+280try:
+281job=self._kep_service_execute(url,DATA)
+282returnjob
+283exceptExceptionaserr:
+284raiseerr
+285
+286defexport_project_configuration(self)->dict:
+287'''Get a complete copy of the project configuration in JSON format. This will include the same
+288 configuration that is stored when you save the project file manually.
+289
+290 :return: Dict of the complete project configuration
+291
+292 :raises KepHTTPError: If urllib provides an HTTPError
+293 :raises KepURLError: If urllib provides an URLError
+294 '''
+295r=self._config_get(self.url+'/project',params={"content":"serialize"})
+296returnr.payload
+297
+298defsave_project(self,filename:str,password:str=None,job_ttl:int=None)->KepServiceResponse:
+299'''Executes a ProjectSave Service call to the Kepware instance. This saves
+300 a copy of the current project file to disk. The filename
+301
+302 :param filename: Relative file path and name of project file including the file extension to save.
+303 Location of relative project file paths:
+304
+305 TKS or KEP (Windows): C:\\PROGRAMDATA\\PTC\\Thingworx Kepware Server\\V6 or
+306 C:\\PROGRAMDATA\\Kepware\\KEPServerEX\\V6
+307 TKE (Linux): /opt/tkedge/v1/user_data
+308309
-310 :return: `KepServiceResponse` instance with job information
-311
-312 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
-313 :raises KepURLError: If urllib provides an URLError
-314 '''
-315url=self.url+self.__project_services_url+'/ProjectLoad'
-316prop_data={'servermain.PROJECT_FILENAME':filename}
-317ifpassword!=None:prop_data['servermain.PROJECT_PASSWORD']=password
-318try:
-319job=self._kep_service_execute(url,prop_data,job_ttl)
-320returnjob
-321exceptExceptionaserr:
-322raiseerr
-323
-324
-325defservice_status(self,resp:KepServiceResponse):
-326'''Returns the status of a service job. Used to verify if a service call
-327 has completed or not.
-328
-329 :param resp: `KepServiceResponse` instance with job information
-330
-331 :return: `KepServiceStatus` instance with job status
-332
-333 :raises KepHTTPError: If urllib provides an HTTPError
-334 :raises KepURLError: If urllib provides an URLError
-335 '''
-336# need to remove part of job href
-337loc=resp.href.find(self.__root_url+self.__version_url)
-338job_url=resp.href[loc+len(self.__root_url+self.__version_url):]
+310 :param password: *(optional)* Specify a password with which to save an encrypted project file with.
+311 This password will be required to load this project file.
+312 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
+313
+314 :return: `KepServiceResponse` instance with job information
+315
+316 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
+317 :raises KepURLError: If urllib provides an URLError
+318 '''
+319url=self.url+self.__project_services_url+'/ProjectSave'
+320prop_data={'servermain.PROJECT_FILENAME':filename}
+321ifpassword!=None:prop_data['servermain.PROJECT_PASSWORD']=password
+322try:
+323job=self._kep_service_execute(url,prop_data,job_ttl)
+324returnjob
+325exceptExceptionaserr:
+326raiseerr
+327
+328defload_project(self,filename:str,password:str=None,job_ttl:int=None)->KepServiceResponse:
+329'''Executes a ProjectLoad Service call to the Kepware instance. This loads
+330 a project file to disk.
+331
+332 INPUTS:
+333
+334 :param filename: Fully qualified or relative path and name of project file including the file extension. Absolute
+335 paths required for TKS and KEP while file path is relative for TKE:
+336
+337 Windows - filename = C:\\filepath\\test.opf
+338 Linux - filename = filepath/test.lpf - Location is /opt/tkedge/v1/user_data/filepath/test.lpf339
-340r=self._config_get(self.url+job_url)
-341job=KepServiceStatus(r.payload['servermain.JOB_COMPLETE'],r.payload['servermain.JOB_STATUS'],r.payload['servermain.JOB_STATUS_MSG'])
-342returnjob
-343
+340 :param password: *(optional)* Specify a password with which to load an encrypted project file.
+341 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
+342
+343 :return: `KepServiceResponse` instance with job information344
-345#Function used to Add an object to Kepware (HTTP POST)
-346def_config_add(self,url,DATA):
-347'''Conducts an POST method at *url* to add an object in the Kepware Configuration
-348 *DATA* is required to be a properly JSON object (dict) of the item to be posted to *url*
-349 '''
-350iflen(DATA)==0:
-351err_msg=f'Error: Empty List or Dict in DATA | DATA type: {type(DATA)}'
-352raiseKepError(err_msg)
-353data=json.dumps(DATA).encode('utf-8')
-354url_obj=self.__url_validate(url)
-355q=request.Request(url_obj,data,method='POST')
-356r=self.__connect(q)
-357returnr
-358
-359#Function used to del an object to Kepware (HTTP DELETE)
-360def_config_del(self,url):
-361'''Conducts an DELETE method at *url* to delete an object in the Kepware Configuration'''
-362url_obj=self.__url_validate(url)
-363q=request.Request(url_obj,method='DELETE')
-364r=self.__connect(q)
-365returnr
-366
-367#Function used to Update an object to Kepware (HTTP PUT)
-368def_config_update(self,url,DATA=None):
-369'''Conducts an PUT method at *url* to modify an object in the Kepware Configuration.
-370 *DATA* is required to be a properly JSON object (dict) of the item to be put to *url*
-371 '''
-372url_obj=self.__url_validate(url)
-373ifDATA==None:
-374q=request.Request(url_obj,method='PUT')
-375else:
-376data=json.dumps(DATA).encode('utf-8')
-377q=request.Request(url_obj,data,method='PUT')
-378r=self.__connect(q)
-379returnr
-380
-381#Function used to Read an object from Kepware (HTTP GET) and return the JSON response
-382def_config_get(self,url,*,params=None):
-383'''
-384 Conducts an GET method at *url* to retrieve an objects properties with query parameters in
-385 the Kepware Configuration.
-386 '''
-387# Add parameters when necessary
-388ifparamsisnotNoneandparams!={}:
-389qparams=parse.urlencode(params)
-390url=f'{url}?{qparams}'
-391url_obj=self.__url_validate(url)
-392q=request.Request(url_obj,method='GET')
-393r=self.__connect(q)
-394returnr
-395
-396
-397def_force_update_check(self,force,DATA):
-398'''
-399 This will validate if the modify call needs to be forced or not. If forced, the dict DATA needs
-400 to have the 'FORCE_UPDATE' property with a value of True. If forced is not requested, it is necessary
-401 to provide the current 'PROJECT_ID'. If 'PROJECT_ID' is not present in DATA, this will automatically
-402 retreive it from the active server.
-403 '''
-404ifforce==True:
-405DATA['FORCE_UPDATE']=True
-406else:
-407# Get Project ID if it doesn't exist and if FORCE_UPDATE is existing and FALSE
-408if'PROJECT_ID'notinDATA:
-409if'FORCE_UPDATE'inDATA:
-410if'FORCE_UPDATE'==False:
-411try:
-412project_data=self._config_get(self.url+'/project')
-413DATA['PROJECT_ID']=project_data.payload['PROJECT_ID']
-414except:
-415#NEED TO COVER ERROR CONDITION
-416pass
-417else:
-418try:
-419project_data=self._config_get(self.url+'/project')
-420DATA['PROJECT_ID']=project_data.payload['PROJECT_ID']
-421except:
-422#NEED TO COVER ERROR CONDITION
-423pass
-424returnDATA
-425# General service call handler
-426def_kep_service_execute(self,url,DATA=None,TTL=None):
-427try:
-428ifTTL!=None:
-429ifDATA==None:DATA={}
-430DATA["servermain.JOB_TIME_TO_LIVE_SECONDS"]=TTL
-431r=self._config_update(url,DATA)
-432job=KepServiceResponse(r.payload['code'],r.payload['message'],r.payload['href'])
-433returnjob
-434exceptKepHTTPErroraserr:
-435iferr.code==429:
-436job=KepServiceResponse()
-437job.code=err.code
-438job.message=err.payload
-439returnjob
-440else:
-441raiseerr
+345 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
+346 :raises KepURLError: If urllib provides an URLError
+347 '''
+348url=self.url+self.__project_services_url+'/ProjectLoad'
+349prop_data={'servermain.PROJECT_FILENAME':filename}
+350ifpassword!=None:prop_data['servermain.PROJECT_PASSWORD']=password
+351try:
+352job=self._kep_service_execute(url,prop_data,job_ttl)
+353returnjob
+354exceptExceptionaserr:
+355raiseerr
+356
+357defget_project_backup_info(self)->dict:
+358''' Get the Project Backup Information of the Kepware instance.
+359
+360 :return: List of all the backup projects and their properties.
+361
+362 :raises KepHTTPError: If urllib provides an HTTPError
+363 :raises KepURLError: If urllib provides an URLError
+364 '''
+365
+366r=self._config_get(self.url+'/project/backups')
+367returnr.payload
+368
+369defbackup_project(self,job_ttl:int=None)->KepServiceResponse:
+370'''Executes a CreateBackup Service call to the Kepware instance. This saves
+371 a copy of the current project file to disk as a backup that can be retrieved.
+372
+373 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
+374
+375 :return: `KepServiceResponse` instance with job information
+376
+377 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
+378 :raises KepURLError: If urllib provides an URLError
+379 '''
+380url=self.url+self.__project_services_url+'/CreateBackup'
+381try:
+382job=self._kep_service_execute(url,TTL=job_ttl)
+383returnjob
+384exceptExceptionaserr:
+385raiseerr
+386
+387defservice_status(self,resp:KepServiceResponse):
+388'''Returns the status of a service job. Used to verify if a service call
+389 has completed or not.
+390
+391 :param resp: `KepServiceResponse` instance with job information
+392
+393 :return: `KepServiceStatus` instance with job status
+394
+395 :raises KepHTTPError: If urllib provides an HTTPError
+396 :raises KepURLError: If urllib provides an URLError
+397 '''
+398# need to remove part of job href
+399loc=resp.href.find(self.__root_url+self.__version_url)
+400job_url=resp.href[loc+len(self.__root_url+self.__version_url):]
+401
+402r=self._config_get(self.url+job_url)
+403job=KepServiceStatus(r.payload['servermain.JOB_COMPLETE'],r.payload['servermain.JOB_STATUS'],r.payload['servermain.JOB_STATUS_MSG'])
+404returnjob
+405
+406
+407#Function used to Add an object to Kepware (HTTP POST)
+408def_config_add(self,url,DATA):
+409'''Conducts an POST method at *url* to add an object in the Kepware Configuration
+410 *DATA* is required to be a properly JSON object (dict) of the item to be posted to *url*
+411 '''
+412iflen(DATA)==0:
+413err_msg=f'Error: Empty List or Dict in DATA | DATA type: {type(DATA)}'
+414raiseKepError(err_msg)
+415data=json.dumps(DATA).encode('utf-8')
+416url_obj=self.__url_validate(url)
+417q=request.Request(url_obj,data,method='POST')
+418r=self.__connect(q)
+419returnr
+420
+421#Function used to del an object to Kepware (HTTP DELETE)
+422def_config_del(self,url):
+423'''Conducts an DELETE method at *url* to delete an object in the Kepware Configuration'''
+424url_obj=self.__url_validate(url)
+425q=request.Request(url_obj,method='DELETE')
+426r=self.__connect(q)
+427returnr
+428
+429#Function used to Update an object to Kepware (HTTP PUT)
+430def_config_update(self,url,DATA=None):
+431'''Conducts an PUT method at *url* to modify an object in the Kepware Configuration.
+432 *DATA* is required to be a properly JSON object (dict) of the item to be put to *url*
+433 '''
+434url_obj=self.__url_validate(url)
+435ifDATA==None:
+436q=request.Request(url_obj,method='PUT')
+437else:
+438data=json.dumps(DATA).encode('utf-8')
+439q=request.Request(url_obj,data,method='PUT')
+440r=self.__connect(q)
+441returnr442
-443#
-444# Supporting Functions
-445#
-446
-447# General connect call to manage HTTP responses for all methods
-448# Returns the response object for the method to handle as appropriate
-449# Raises Errors as found
-450def__connect(self,request_obj):
-451# Fill appropriate header information
-452data=_HttpDataAbstract()
-453request_obj.add_header("Authorization","Basic %s"%self.__build_auth_str(self.username,self.password))
-454request_obj.add_header("Content-Type","application/json")
-455request_obj.add_header("Accept","application/json")
-456try:
-457# context is sent regardless of HTTP or HTTPS - seems to be ignored if HTTP URL
-458withrequest.urlopen(request_obj,context=self.__ssl_context)asserver:
-459try:
-460payload=server.read()
-461data.payload=json.loads(codecs.decode(payload,'utf-8-sig'))
-462except:
-463pass
-464data.code=server.code
-465data.reason=server.reason
-466returndata
-467excepterror.HTTPErroraserr:
-468payload=json.loads(codecs.decode(err.read(),'utf-8-sig'))
-469# print('HTTP Code: {}\n{}'.format(err.code,payload), file=sys.stderr)
-470raiseKepHTTPError(url=err.url,code=err.code,msg=err.msg,hdrs=err.hdrs,payload=payload)
-471excepterror.URLErroraserr:
-472# print('URLError: {} URL: {}'.format(err.reason, request_obj.get_full_url()), file=sys.stderr)
-473raiseKepURLError(msg=err.reason,url=request_obj.get_full_url())
-474
-475# Fucntion used to ensure special characters are handled in the URL
-476# Ex: Space will be turned to %20
-477def__url_validate(self,url):
-478# Configuration API does not use fragments in URL so ignore to allow # as a character
-479# Objects in Kepware can include # as part of the object names
-480parsed_url=parse.urlparse(url,allow_fragments=False)
-481# Added % for scenarios where special characters have already been escaped with %
-482updated_path=parse.quote(parsed_url.path,safe='/%')
-483
-484# If host is "localhost", force using the IPv4 loopback adapter IP address in all calls
-485# This is done to remove retries that will happen when the host resolution uses IPv6 intially
-486# Kepware currently doesn't support IPv6 and is not listening on this interface
-487ifparsed_url.hostname.lower()=='localhost':
-488ip=socket.gethostbyname(parsed_url.hostname)
-489parsed_url=parsed_url._replace(netloc='{}:{}'.format(ip,parsed_url.port))
-490
-491returnparsed_url._replace(path=updated_path).geturl()
-492
-493# Function used to build the basic authentication string
-494def__build_auth_str(self,username,password):
-495ifisinstance(username,str):
-496username=username.encode('latin1')
-497ifisinstance(password,str):
-498password=password.encode('latin1')
-499authstr=b64encode(b':'.join((username,password))).strip().decode('ascii')
-500returnauthstr
-501
-502# Create parameters for log queries
-503def__create_query(self,start=None,end=None,limit=None):
-504query={}
-505ifstart!=Noneandisinstance(start,datetime.datetime):
-506query['start']=start.isoformat()
-507ifend!=Noneandisinstance(end,datetime.datetime):
-508query['end']=end.isoformat()
-509iflimit!=None:
-510query['limit']=limit
-511returnquery
+443#Function used to Read an object from Kepware (HTTP GET) and return the JSON response
+444def_config_get(self,url,*,params=None):
+445'''
+446 Conducts an GET method at *url* to retrieve an objects properties with query parameters in
+447 the Kepware Configuration.
+448 '''
+449# Add parameters when necessary
+450ifparamsisnotNoneandparams!={}:
+451qparams=parse.urlencode(params)
+452url=f'{url}?{qparams}'
+453url_obj=self.__url_validate(url)
+454q=request.Request(url_obj,method='GET')
+455r=self.__connect(q)
+456returnr
+457
+458
+459def_force_update_check(self,force,DATA):
+460'''
+461 This will validate if the modify call needs to be forced or not. If forced, the dict DATA needs
+462 to have the 'FORCE_UPDATE' property with a value of True. If forced is not requested, it is necessary
+463 to provide the current 'PROJECT_ID'. If 'PROJECT_ID' is not present in DATA, this will automatically
+464 retreive it from the active server.
+465 '''
+466ifforce==True:
+467DATA['FORCE_UPDATE']=True
+468else:
+469# Get Project ID if it doesn't exist and if FORCE_UPDATE is existing and FALSE
+470if'PROJECT_ID'notinDATA:
+471if'FORCE_UPDATE'inDATA:
+472if'FORCE_UPDATE'==False:
+473try:
+474project_data=self._config_get(self.url+'/project')
+475DATA['PROJECT_ID']=project_data.payload['PROJECT_ID']
+476except:
+477#NEED TO COVER ERROR CONDITION
+478pass
+479else:
+480try:
+481project_data=self._config_get(self.url+'/project')
+482DATA['PROJECT_ID']=project_data.payload['PROJECT_ID']
+483except:
+484#NEED TO COVER ERROR CONDITION
+485pass
+486returnDATA
+487# General service call handler
+488def_kep_service_execute(self,url,DATA=None,TTL=None):
+489try:
+490ifTTL!=None:
+491ifDATA==None:DATA={}
+492DATA["servermain.JOB_TIME_TO_LIVE_SECONDS"]=TTL
+493r=self._config_update(url,DATA)
+494job=KepServiceResponse(r.payload['code'],r.payload['message'],r.payload['href'])
+495returnjob
+496exceptKepHTTPErroraserr:
+497iferr.code==429:
+498job=KepServiceResponse()
+499job.code=err.code
+500job.message=err.payload
+501returnjob
+502else:
+503raiseerr
+504
+505#
+506# Supporting Functions
+507#
+508
+509# General connect call to manage HTTP responses for all methods
+510# Returns the response object for the method to handle as appropriate
+511# Raises Errors as found
+512def__connect(self,request_obj):
+513# Fill appropriate header information
+514data=_HttpDataAbstract()
+515request_obj.add_header("Authorization","Basic %s"%self.__build_auth_str(self.username,self.password))
+516request_obj.add_header("Content-Type","application/json")
+517request_obj.add_header("Accept","application/json")
+518try:
+519# context is sent regardless of HTTP or HTTPS - seems to be ignored if HTTP URL
+520withrequest.urlopen(request_obj,context=self.__ssl_context)asserver:
+521try:
+522payload=server.read()
+523data.payload=json.loads(codecs.decode(payload,'utf-8-sig'))
+524except:
+525pass
+526data.code=server.code
+527data.reason=server.reason
+528returndata
+529excepterror.HTTPErroraserr:
+530payload=json.loads(codecs.decode(err.read(),'utf-8-sig'))
+531# print('HTTP Code: {}\n{}'.format(err.code,payload), file=sys.stderr)
+532raiseKepHTTPError(url=err.url,code=err.code,msg=err.msg,hdrs=err.hdrs,payload=payload)
+533excepterror.URLErroraserr:
+534# print('URLError: {} URL: {}'.format(err.reason, request_obj.get_full_url()), file=sys.stderr)
+535raiseKepURLError(msg=err.reason,url=request_obj.get_full_url())
+536
+537# Fucntion used to ensure special characters are handled in the URL
+538# Ex: Space will be turned to %20
+539def__url_validate(self,url):
+540# Configuration API does not use fragments in URL so ignore to allow # as a character
+541# Objects in Kepware can include # as part of the object names
+542parsed_url=parse.urlparse(url,allow_fragments=False)
+543# Added % for scenarios where special characters have already been escaped with %
+544updated_path=parse.quote(parsed_url.path,safe='/%')
+545
+546# If host is "localhost", force using the IPv4 loopback adapter IP address in all calls
+547# This is done to remove retries that will happen when the host resolution uses IPv6 intially
+548# Kepware currently doesn't support IPv6 and is not listening on this interface
+549ifparsed_url.hostname.lower()=='localhost':
+550ip=socket.gethostbyname(parsed_url.hostname)
+551parsed_url=parsed_url._replace(netloc='{}:{}'.format(ip,parsed_url.port))
+552
+553returnparsed_url._replace(path=updated_path).geturl()
+554
+555# Function used to build the basic authentication string
+556def__build_auth_str(self,username,password):
+557ifisinstance(username,str):
+558username=username.encode('latin1')
+559ifisinstance(password,str):
+560password=password.encode('latin1')
+561authstr=b64encode(b':'.join((username,password))).strip().decode('ascii')
+562returnauthstr
+563
+564# Create parameters for log queries
+565def__create_query(self,start=None,end=None,limit=None):
+566query={}
+567ifstart!=Noneandisinstance(start,datetime.datetime):
+568query['start']=start.isoformat()
+569ifend!=Noneandisinstance(end,datetime.datetime):
+570query['end']=end.isoformat()
+571iflimit!=None:
+572query['limit']=limit
+573returnquery
+574
+575# Create filter query for log queries
+576def__create_filter_query(self,filters:list[Filter]=None):
+577query={}
+578iffiltersisNone:
+579returnquery
+580forfinfilters:
+581# Ensure we use the value of the Enum, not the Enum object itself
+582key=f"filter[{f.field.value}][{f.modifier.value}]"
+583query[key]=f.value
+584returnquery
@@ -653,7 +711,7 @@
23classserver:
- 24'''A class to represent a connection to an instance of Kepware. This object is used to
+ 24'''A class to represent a connection to an instance of Kepware. This object is used to 25 create the Authentication and server parameters to taget a Kepware instance. An instance of this is 26 used in all configuration calls done. 27
@@ -676,472 +734,545 @@
44 45 :meth:`get_event_log`: retrieve the Kepware Event Log 46
- 47 :meth:`get_project_properties`: retrieve the Kepware Project Properties
+ 47 :meth:`get_audit_log`: retrieve the Kepware Audit Log 48
- 49 :meth:`modify_project_properties` - modify the Kepware Project Properties
- 50
- 51 :meth:`service_status` - retrive service job status
- 52 '''
- 53__root_url='/config'
- 54__version_url='/v1'
- 55__project_services_url='/project/services'
- 56__event_log_url='/event_log'
- 57__trans_log_url='/log'
+ 49 :meth:`get_info`: retrieve the Kepware product information
+ 50
+ 51 :meth:`import_empty_project`: import an empty project to the Kepware server
+ 52
+ 53 :meth:`get_project_properties`: retrieve the Kepware Project Properties
+ 54
+ 55 :meth:`modify_project_properties` - modify the Kepware Project Properties
+ 56
+ 57 :meth:`service_status` - retrive service job status 58
- 59
+ 59 :meth:`export_project_configuration` - export the current project configuration in JSON format 60
- 61def__init__(self,host:str,port:int,user:str,pw:str,https:bool=False):
- 62self.host=host
- 63self.port=port
- 64self.username=user
- 65self.password=pw
- 66self.__ssl_context=ssl.create_default_context()
- 67self.__SSL_on=https
- 68
- 69@property
- 70defurl(self):
- 71ifself.SSL_on:
- 72proto='https'
- 73else:
- 74proto='http'
- 75returnf'{proto}://{self.host}:{self.port}{self.__root_url}{self.__version_url}'
- 76
- 77@property
- 78defSSL_on(self):
- 79returnself.__SSL_on
- 80
- 81@SSL_on.setter
- 82defSSL_on(self,val):
- 83
- 84ifisinstance(val,bool):
- 85self.__SSL_on=val
- 86
- 87@property
- 88defSSL_ignore_hostname(self):
- 89returnnotself.__ssl_context.check_hostname
- 90
- 91@SSL_ignore_hostname.setter
- 92defSSL_ignore_hostname(self,val):
- 93ifisinstance(val,bool):
- 94ifval==True:
- 95self.__ssl_context.check_hostname=False
- 96else:
- 97self.__ssl_context.check_hostname=True
- 98
- 99
+ 61 :meth:`save_project` - save the current project to a file
+ 62
+ 63 :meth:`load_project` - load a project from a file
+ 64 '''
+ 65__root_url='/config'
+ 66__version_url='/v1'
+ 67__project_services_url='/project/services'
+ 68__event_log_url='/event_log'
+ 69__trans_log_url='/log'
+ 70__audit_log_url='/audit_log'
+ 71
+ 72
+ 73
+ 74def__init__(self,host:str,port:int,user:str,pw:str,https:bool=False):
+ 75self.host=host
+ 76self.port=port
+ 77self.username=user
+ 78self.password=pw
+ 79self.__ssl_context=ssl.create_default_context()
+ 80self.__SSL_on=https
+ 81
+ 82@property
+ 83defurl(self):
+ 84ifself.SSL_on:
+ 85proto='https'
+ 86else:
+ 87proto='http'
+ 88returnf'{proto}://{self.host}:{self.port}{self.__root_url}{self.__version_url}'
+ 89
+ 90@property
+ 91defSSL_on(self):
+ 92returnself.__SSL_on
+ 93
+ 94@SSL_on.setter
+ 95defSSL_on(self,val):
+ 96
+ 97ifisinstance(val,bool):
+ 98self.__SSL_on=val
+ 99100@property
-101defSSL_trust_all_certs(self):
-102ifself.__ssl_context.verify_mode==ssl.CERT_NONE:
-103returnTrue
-104else:
-105returnFalse
-106
-107@SSL_trust_all_certs.setter
-108defSSL_trust_all_certs(self,val):
-109ifisinstance(val,bool):
-110ifval==True:
-111ifself.__ssl_context.check_hostname==True:
-112self.__ssl_context.check_hostname=False
-113self.__ssl_context.verify_mode=ssl.CERT_NONE
-114else:
-115self.__ssl_context.verify_mode=ssl.CERT_REQUIRED
-116
-117
-118defget_status(self)->dict:
-119'''Executes a health status request to the Kepware instance to report service statuses.
-120
-121 :return: List of data for the health status request
-122
-123 :raises KepHTTPError: If urllib provides an HTTPError
-124 :raises KepURLError: If urllib provides an URLError
-125 '''
-126
-127r=self._config_get(f'{self.url}/status')
-128returnr.payload
-129defget_info(self)->dict:
-130'''Requests product information from the Kepware instance. Provides various information including
-131 product name and version information.
-132
-133 :return: dict of data for the product information request
-134
-135 :raises KepHTTPError: If urllib provides an HTTPError
-136 :raises KepURLError: If urllib provides an URLError
-137 '''
-138
-139r=self._config_get(f'{self.url}/about')
-140returnr.payload
-141
-142defreinitialize(self,job_ttl:int=None)->KepServiceResponse:
-143'''Executes a Reinitialize service call to the Kepware instance.
-144
-145 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
-146
-147 :return: `KepServiceResponse` instance with job information
-148
-149 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
-150 :raises KepURLError: If urllib provides an URLError
-151 '''
-152url=self.url+self.__project_services_url+'/ReinitializeRuntime'
-153try:
-154job=self._kep_service_execute(url,None,job_ttl)
-155returnjob
-156exceptExceptionaserr:
-157raiseerr
-158
-159defget_transaction_log(self,limit:int=None,start:datetime.datetime=None,end:datetime.datetime=None)->list:
-160''' Get the Transaction Log from the Kepware instance.
+101defSSL_ignore_hostname(self):
+102returnnotself.__ssl_context.check_hostname
+103
+104@SSL_ignore_hostname.setter
+105defSSL_ignore_hostname(self,val):
+106ifisinstance(val,bool):
+107ifval==True:
+108self.__ssl_context.check_hostname=False
+109else:
+110self.__ssl_context.check_hostname=True
+111
+112
+113@property
+114defSSL_trust_all_certs(self):
+115ifself.__ssl_context.verify_mode==ssl.CERT_NONE:
+116returnTrue
+117else:
+118returnFalse
+119
+120@SSL_trust_all_certs.setter
+121defSSL_trust_all_certs(self,val):
+122ifisinstance(val,bool):
+123ifval==True:
+124ifself.__ssl_context.check_hostname==True:
+125self.__ssl_context.check_hostname=False
+126self.__ssl_context.verify_mode=ssl.CERT_NONE
+127else:
+128self.__ssl_context.verify_mode=ssl.CERT_REQUIRED
+129
+130
+131defget_status(self)->dict:
+132'''Executes a health status request to the Kepware instance to report service statuses.
+133
+134 :return: List of data for the health status request
+135
+136 :raises KepHTTPError: If urllib provides an HTTPError
+137 :raises KepURLError: If urllib provides an URLError
+138 '''
+139
+140r=self._config_get(f'{self.url}/status')
+141returnr.payload
+142defget_info(self)->dict:
+143'''Requests product information from the Kepware instance. Provides various information including
+144 product name and version information.
+145
+146 :return: dict of data for the product information request
+147
+148 :raises KepHTTPError: If urllib provides an HTTPError
+149 :raises KepURLError: If urllib provides an URLError
+150 '''
+151
+152r=self._config_get(f'{self.url}/about')
+153returnr.payload
+154
+155defreinitialize(self,job_ttl:int=None)->KepServiceResponse:
+156'''Executes a Reinitialize service call to the Kepware instance.
+157
+158 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
+159
+160 :return: `KepServiceResponse` instance with job information161
-162 :param limit: *(optional)* number of transaction log entries to request
-163 :param start: *(optional)* start time of query as `datetime.datetime` type and should be UTC
-164 :param end: *(optional)* end time of query as `datetime.datetime` type and should be UTC
-165
-166 :raises KepHTTPError: If urllib provides an HTTPError
-167 :raises KepURLError: If urllib provides an URLError
-168 '''
-169query=self.__create_query(start,end,limit)
-170url=f'{self.url}{self.__trans_log_url}'
-171r=self._config_get(url,params=query)
-172returnr.payload
-173
-174defget_event_log(self,limit:int=None,start:datetime.datetime=None,end:datetime.datetime=None,*,options:dict=None)->list:
-175''' Get the Event Log from the Kepware instance.
-176
-177 :param limit: *(optional)* number of event log entries to request
-178 :param start: *(optional)* start time of query as `datetime.datetime` type and should be UTC
-179 :param end: *(optional)* end time of query as `datetime.datetime` type and should be UTC
-180 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of transactions. Options are `event`,
-181 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
-182
-183 :raises KepHTTPError: If urllib provides an HTTPError
-184 :raises KepURLError: If urllib provides an URLError
-185 '''
-186query=self.__create_query(start,end,limit)
-187ifoptionsisnotNone:
-188query={**query,**options}
-189url=f'{self.url}{self.__event_log_url}'
-190r=self._config_get(url,params=query)
-191returnr.payload
-192
-193defget_project_properties(self)->dict:
-194''' Get the Project Properties of the Kepware instance.
-195
-196 :return: Dict of all the project properties
-197
-198 :raises KepHTTPError: If urllib provides an HTTPError
-199 :raises KepURLError: If urllib provides an URLError
-200 '''
-201
-202r=self._config_get(self.url+'/project')
-203returnr.payload
-204
-205defmodify_project_properties(self,DATA:dict,force:bool=False)->bool:
-206''' Modify the Project Properties of the Kepware instance.
-207
-208 :param DATA: Dict of the project properties to be modified
-209 :param force: *(optional)* if True, will force the configuration update to the Kepware server
-210
-211 :return: True - If a "HTTP 200 - OK" is received from Kepware server
-212
-213 :raises KepHTTPError: If urllib provides an HTTPError
-214 :raises KepURLError: If urllib provides an URLError
-215 '''
-216
-217prop_data=self._force_update_check(force,DATA)
-218r=self._config_update(self.url+'/project',prop_data)
-219ifr.code==200:returnTrue
-220else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
-221
-222defimport_empty_project(self)->KepServiceResponse:
-223'''Executes JsonProjectLoad Service call to the Kepware instance with an empty project. This service
-224 imports an empty project configuration, acts like a FILE->NEW action and
-225 stop communications while the new project replaces the current project in the Kepware runtime.
-226
-227 :return: `KepServiceResponse` instance with job information
+162 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
+163 :raises KepURLError: If urllib provides an URLError
+164 '''
+165url=self.url+self.__project_services_url+'/ReinitializeRuntime'
+166try:
+167job=self._kep_service_execute(url,None,job_ttl)
+168returnjob
+169exceptExceptionaserr:
+170raiseerr
+171
+172defget_transaction_log(self,limit:int=None,start:datetime.datetime=None,end:datetime.datetime=None)->list:
+173''' Get the Transaction Log from the Kepware instance.
+174
+175 :param limit: *(optional)* number of transaction log entries to request
+176 :param start: *(optional)* start time of query as `datetime.datetime` type and should be UTC
+177 :param end: *(optional)* end time of query as `datetime.datetime` type and should be UTC
+178
+179 :raises KepHTTPError: If urllib provides an HTTPError
+180 :raises KepURLError: If urllib provides an URLError
+181 '''
+182query=self.__create_query(start,end,limit)
+183url=f'{self.url}{self.__trans_log_url}'
+184r=self._config_get(url,params=query)
+185returnr.payload
+186
+187defget_event_log(self,limit:int=None,start:datetime.datetime=None,end:datetime.datetime=None,*,options:dict=None)->list:
+188''' Get the Event Log from the Kepware instance.
+189
+190 :param limit: *(optional)* number of event log entries to request
+191 :param start: *(optional)* start time of query as `datetime.datetime` type and should be UTC
+192 :param end: *(optional)* end time of query as `datetime.datetime` type and should be UTC
+193 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of transactions. Options are `event`,
+194 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
+195
+196 :raises KepHTTPError: If urllib provides an HTTPError
+197 :raises KepURLError: If urllib provides an URLError
+198 '''
+199query=self.__create_query(start,end,limit)
+200ifoptionsisnotNone:
+201query={**query,**options}
+202url=f'{self.url}{self.__event_log_url}'
+203r=self._config_get(url,params=query)
+204returnr.payload
+205
+206defget_audit_log(self,limit:int=None,*,filters:list[Filter]=None,options:dict=None)->list:
+207''' Get the Audit Log from the Kepware instance.
+208
+209 :param limit: *(optional)* number of event log entries to request
+210 :param filters: *(optional)* list of filters that are used to control results returned from the log
+211 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of transactions. Options are `sortOrder`,
+212 `sortProperty`, `pageNumber`, and `pageSize`
+213
+214 :raises KepHTTPError: If urllib provides an HTTPError
+215 :raises KepURLError: If urllib provides an URLError
+216 '''
+217query=self.__create_filter_query(filters)
+218iflimitisnotNone:
+219query['limit']=limit
+220ifoptionsisnotNone:
+221query={**query,**options}
+222url=f'{self.url}{self.__audit_log_url}'
+223r=self._config_get(url,params=query)
+224returnr.payload
+225
+226defget_project_properties(self)->dict:
+227''' Get the Project Properties of the Kepware instance.228
-229 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
-230 :raises KepURLError: If urllib provides an URLError
-231 '''
-232returnself.import_project_configuration({"project":{}})
-233
+229 :return: Dict of all the project properties
+230
+231 :raises KepHTTPError: If urllib provides an HTTPError
+232 :raises KepURLError: If urllib provides an URLError
+233 '''234
-235defimport_project_configuration(self,DATA:dict)->KepServiceResponse:
-236'''Executes JsonProjectLoad Service call to the Kepware instance. This service imports project configuration
-237 data, expecting a complete project file in JSON/dict format. This service acts like a FILE->OPEN action and
-238 stop communications while the new project replaces the current project in the Kepware runtime.
-239
-240 :param DATA: Complete project configuration data in JSON/dict format.
-241
-242 :return: `KepServiceResponse` instance with job information
+235r=self._config_get(self.url+'/project')
+236returnr.payload
+237
+238defmodify_project_properties(self,DATA:dict,force:bool=False)->bool:
+239''' Modify the Project Properties of the Kepware instance.
+240
+241 :param DATA: Dict of the project properties to be modified
+242 :param force: *(optional)* if True, will force the configuration update to the Kepware server243
-244 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
-245 :raises KepURLError: If urllib provides an URLError
-246 '''
-247url=self.url+self.__project_services_url+'/JsonProjectLoad'
-248try:
-249job=self._kep_service_execute(url,DATA)
-250returnjob
-251exceptExceptionaserr:
-252raiseerr
-253
-254defexport_project_configuration(self)->dict:
-255'''Get a complete copy of the project configuration in JSON format. This will include the same
-256 configuration that is stored when you save the project file manually.
-257
-258 :return: Dict of the complete project configuration
+244 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+245
+246 :raises KepHTTPError: If urllib provides an HTTPError
+247 :raises KepURLError: If urllib provides an URLError
+248 '''
+249
+250prop_data=self._force_update_check(force,DATA)
+251r=self._config_update(self.url+'/project',prop_data)
+252ifr.code==200:returnTrue
+253else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+254
+255defimport_empty_project(self)->KepServiceResponse:
+256'''Executes JsonProjectLoad Service call to the Kepware instance with an empty project. This service
+257 imports an empty project configuration, acts like a FILE->NEW action and
+258 stop communications while the new project replaces the current project in the Kepware runtime. 259
-260 :raises KepHTTPError: If urllib provides an HTTPError
-261 :raises KepURLError: If urllib provides an URLError
-262 '''
-263r=self._config_get(self.url+'/project',params={"content":"serialize"})
-264returnr.payload
-265
-266defsave_project(self,filename:str,password:str=None,job_ttl:int=None)->KepServiceResponse:
-267'''Executes a ProjectSave Service call to the Kepware instance. This saves
-268 a copy of the current project file to disk. The filename
-269
-270 :param filename: Relative file path and name of project file including the file extension to save.
-271 Location of relative project file paths:
-272
-273 TKS or KEP (Windows): C:\\PROGRAMDATA\\PTC\\Thingworx Kepware Server\\V6 or
-274 C:\\PROGRAMDATA\\Kepware\\KEPServerEX\\V6
-275 TKE (Linux): /opt/tkedge/v1/user_data
-276
-277
-278 :param password: *(optional)* Specify a password with which to save an encrypted project file with.
-279 This password will be required to load this project file.
-280 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
-281
-282 :return: `KepServiceResponse` instance with job information
-283
-284 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
-285 :raises KepURLError: If urllib provides an URLError
-286 '''
-287url=self.url+self.__project_services_url+'/ProjectSave'
-288prop_data={'servermain.PROJECT_FILENAME':filename}
-289ifpassword!=None:prop_data['servermain.PROJECT_PASSWORD']=password
-290try:
-291job=self._kep_service_execute(url,prop_data,job_ttl)
-292returnjob
-293exceptExceptionaserr:
-294raiseerr
-295
-296defload_project(self,filename:str,password:str=None,job_ttl:int=None)->KepServiceResponse:
-297'''Executes a ProjectLoad Service call to the Kepware instance. This loads
-298 a project file to disk.
-299
-300 INPUTS:
-301
-302 :param filename: Fully qualified or relative path and name of project file including the file extension. Absolute
-303 paths required for TKS and KEP while file path is relative for TKE:
-304
-305 Windows - filename = C:\\filepath\\test.opf
-306 Linux - filename = filepath/test.lpf - Location is /opt/tkedge/v1/user_data/filepath/test.lpf
-307
-308 :param password: *(optional)* Specify a password with which to load an encrypted project file.
-309 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
+260 :return: `KepServiceResponse` instance with job information
+261
+262 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
+263 :raises KepURLError: If urllib provides an URLError
+264 '''
+265returnself.import_project_configuration({"project":{}})
+266
+267
+268defimport_project_configuration(self,DATA:dict)->KepServiceResponse:
+269'''Executes JsonProjectLoad Service call to the Kepware instance. This service imports project configuration
+270 data, expecting a complete project file in JSON/dict format. This service acts like a FILE->OPEN action and
+271 stop communications while the new project replaces the current project in the Kepware runtime.
+272
+273 :param DATA: Complete project configuration data in JSON/dict format.
+274
+275 :return: `KepServiceResponse` instance with job information
+276
+277 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
+278 :raises KepURLError: If urllib provides an URLError
+279 '''
+280url=self.url+self.__project_services_url+'/JsonProjectLoad'
+281try:
+282job=self._kep_service_execute(url,DATA)
+283returnjob
+284exceptExceptionaserr:
+285raiseerr
+286
+287defexport_project_configuration(self)->dict:
+288'''Get a complete copy of the project configuration in JSON format. This will include the same
+289 configuration that is stored when you save the project file manually.
+290
+291 :return: Dict of the complete project configuration
+292
+293 :raises KepHTTPError: If urllib provides an HTTPError
+294 :raises KepURLError: If urllib provides an URLError
+295 '''
+296r=self._config_get(self.url+'/project',params={"content":"serialize"})
+297returnr.payload
+298
+299defsave_project(self,filename:str,password:str=None,job_ttl:int=None)->KepServiceResponse:
+300'''Executes a ProjectSave Service call to the Kepware instance. This saves
+301 a copy of the current project file to disk. The filename
+302
+303 :param filename: Relative file path and name of project file including the file extension to save.
+304 Location of relative project file paths:
+305
+306 TKS or KEP (Windows): C:\\PROGRAMDATA\\PTC\\Thingworx Kepware Server\\V6 or
+307 C:\\PROGRAMDATA\\Kepware\\KEPServerEX\\V6
+308 TKE (Linux): /opt/tkedge/v1/user_data
+309310
-311 :return: `KepServiceResponse` instance with job information
-312
-313 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
-314 :raises KepURLError: If urllib provides an URLError
-315 '''
-316url=self.url+self.__project_services_url+'/ProjectLoad'
-317prop_data={'servermain.PROJECT_FILENAME':filename}
-318ifpassword!=None:prop_data['servermain.PROJECT_PASSWORD']=password
-319try:
-320job=self._kep_service_execute(url,prop_data,job_ttl)
-321returnjob
-322exceptExceptionaserr:
-323raiseerr
-324
-325
-326defservice_status(self,resp:KepServiceResponse):
-327'''Returns the status of a service job. Used to verify if a service call
-328 has completed or not.
-329
-330 :param resp: `KepServiceResponse` instance with job information
-331
-332 :return: `KepServiceStatus` instance with job status
-333
-334 :raises KepHTTPError: If urllib provides an HTTPError
-335 :raises KepURLError: If urllib provides an URLError
-336 '''
-337# need to remove part of job href
-338loc=resp.href.find(self.__root_url+self.__version_url)
-339job_url=resp.href[loc+len(self.__root_url+self.__version_url):]
+311 :param password: *(optional)* Specify a password with which to save an encrypted project file with.
+312 This password will be required to load this project file.
+313 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
+314
+315 :return: `KepServiceResponse` instance with job information
+316
+317 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
+318 :raises KepURLError: If urllib provides an URLError
+319 '''
+320url=self.url+self.__project_services_url+'/ProjectSave'
+321prop_data={'servermain.PROJECT_FILENAME':filename}
+322ifpassword!=None:prop_data['servermain.PROJECT_PASSWORD']=password
+323try:
+324job=self._kep_service_execute(url,prop_data,job_ttl)
+325returnjob
+326exceptExceptionaserr:
+327raiseerr
+328
+329defload_project(self,filename:str,password:str=None,job_ttl:int=None)->KepServiceResponse:
+330'''Executes a ProjectLoad Service call to the Kepware instance. This loads
+331 a project file to disk.
+332
+333 INPUTS:
+334
+335 :param filename: Fully qualified or relative path and name of project file including the file extension. Absolute
+336 paths required for TKS and KEP while file path is relative for TKE:
+337
+338 Windows - filename = C:\\filepath\\test.opf
+339 Linux - filename = filepath/test.lpf - Location is /opt/tkedge/v1/user_data/filepath/test.lpf340
-341r=self._config_get(self.url+job_url)
-342job=KepServiceStatus(r.payload['servermain.JOB_COMPLETE'],r.payload['servermain.JOB_STATUS'],r.payload['servermain.JOB_STATUS_MSG'])
-343returnjob
-344
+341 :param password: *(optional)* Specify a password with which to load an encrypted project file.
+342 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
+343
+344 :return: `KepServiceResponse` instance with job information345
-346#Function used to Add an object to Kepware (HTTP POST)
-347def_config_add(self,url,DATA):
-348'''Conducts an POST method at *url* to add an object in the Kepware Configuration
-349 *DATA* is required to be a properly JSON object (dict) of the item to be posted to *url*
-350 '''
-351iflen(DATA)==0:
-352err_msg=f'Error: Empty List or Dict in DATA | DATA type: {type(DATA)}'
-353raiseKepError(err_msg)
-354data=json.dumps(DATA).encode('utf-8')
-355url_obj=self.__url_validate(url)
-356q=request.Request(url_obj,data,method='POST')
-357r=self.__connect(q)
-358returnr
-359
-360#Function used to del an object to Kepware (HTTP DELETE)
-361def_config_del(self,url):
-362'''Conducts an DELETE method at *url* to delete an object in the Kepware Configuration'''
-363url_obj=self.__url_validate(url)
-364q=request.Request(url_obj,method='DELETE')
-365r=self.__connect(q)
-366returnr
-367
-368#Function used to Update an object to Kepware (HTTP PUT)
-369def_config_update(self,url,DATA=None):
-370'''Conducts an PUT method at *url* to modify an object in the Kepware Configuration.
-371 *DATA* is required to be a properly JSON object (dict) of the item to be put to *url*
-372 '''
-373url_obj=self.__url_validate(url)
-374ifDATA==None:
-375q=request.Request(url_obj,method='PUT')
-376else:
-377data=json.dumps(DATA).encode('utf-8')
-378q=request.Request(url_obj,data,method='PUT')
-379r=self.__connect(q)
-380returnr
-381
-382#Function used to Read an object from Kepware (HTTP GET) and return the JSON response
-383def_config_get(self,url,*,params=None):
-384'''
-385 Conducts an GET method at *url* to retrieve an objects properties with query parameters in
-386 the Kepware Configuration.
-387 '''
-388# Add parameters when necessary
-389ifparamsisnotNoneandparams!={}:
-390qparams=parse.urlencode(params)
-391url=f'{url}?{qparams}'
-392url_obj=self.__url_validate(url)
-393q=request.Request(url_obj,method='GET')
-394r=self.__connect(q)
-395returnr
-396
-397
-398def_force_update_check(self,force,DATA):
-399'''
-400 This will validate if the modify call needs to be forced or not. If forced, the dict DATA needs
-401 to have the 'FORCE_UPDATE' property with a value of True. If forced is not requested, it is necessary
-402 to provide the current 'PROJECT_ID'. If 'PROJECT_ID' is not present in DATA, this will automatically
-403 retreive it from the active server.
-404 '''
-405ifforce==True:
-406DATA['FORCE_UPDATE']=True
-407else:
-408# Get Project ID if it doesn't exist and if FORCE_UPDATE is existing and FALSE
-409if'PROJECT_ID'notinDATA:
-410if'FORCE_UPDATE'inDATA:
-411if'FORCE_UPDATE'==False:
-412try:
-413project_data=self._config_get(self.url+'/project')
-414DATA['PROJECT_ID']=project_data.payload['PROJECT_ID']
-415except:
-416#NEED TO COVER ERROR CONDITION
-417pass
-418else:
-419try:
-420project_data=self._config_get(self.url+'/project')
-421DATA['PROJECT_ID']=project_data.payload['PROJECT_ID']
-422except:
-423#NEED TO COVER ERROR CONDITION
-424pass
-425returnDATA
-426# General service call handler
-427def_kep_service_execute(self,url,DATA=None,TTL=None):
-428try:
-429ifTTL!=None:
-430ifDATA==None:DATA={}
-431DATA["servermain.JOB_TIME_TO_LIVE_SECONDS"]=TTL
-432r=self._config_update(url,DATA)
-433job=KepServiceResponse(r.payload['code'],r.payload['message'],r.payload['href'])
-434returnjob
-435exceptKepHTTPErroraserr:
-436iferr.code==429:
-437job=KepServiceResponse()
-438job.code=err.code
-439job.message=err.payload
-440returnjob
-441else:
-442raiseerr
+346 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
+347 :raises KepURLError: If urllib provides an URLError
+348 '''
+349url=self.url+self.__project_services_url+'/ProjectLoad'
+350prop_data={'servermain.PROJECT_FILENAME':filename}
+351ifpassword!=None:prop_data['servermain.PROJECT_PASSWORD']=password
+352try:
+353job=self._kep_service_execute(url,prop_data,job_ttl)
+354returnjob
+355exceptExceptionaserr:
+356raiseerr
+357
+358defget_project_backup_info(self)->dict:
+359''' Get the Project Backup Information of the Kepware instance.
+360
+361 :return: List of all the backup projects and their properties.
+362
+363 :raises KepHTTPError: If urllib provides an HTTPError
+364 :raises KepURLError: If urllib provides an URLError
+365 '''
+366
+367r=self._config_get(self.url+'/project/backups')
+368returnr.payload
+369
+370defbackup_project(self,job_ttl:int=None)->KepServiceResponse:
+371'''Executes a CreateBackup Service call to the Kepware instance. This saves
+372 a copy of the current project file to disk as a backup that can be retrieved.
+373
+374 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
+375
+376 :return: `KepServiceResponse` instance with job information
+377
+378 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
+379 :raises KepURLError: If urllib provides an URLError
+380 '''
+381url=self.url+self.__project_services_url+'/CreateBackup'
+382try:
+383job=self._kep_service_execute(url,TTL=job_ttl)
+384returnjob
+385exceptExceptionaserr:
+386raiseerr
+387
+388defservice_status(self,resp:KepServiceResponse):
+389'''Returns the status of a service job. Used to verify if a service call
+390 has completed or not.
+391
+392 :param resp: `KepServiceResponse` instance with job information
+393
+394 :return: `KepServiceStatus` instance with job status
+395
+396 :raises KepHTTPError: If urllib provides an HTTPError
+397 :raises KepURLError: If urllib provides an URLError
+398 '''
+399# need to remove part of job href
+400loc=resp.href.find(self.__root_url+self.__version_url)
+401job_url=resp.href[loc+len(self.__root_url+self.__version_url):]
+402
+403r=self._config_get(self.url+job_url)
+404job=KepServiceStatus(r.payload['servermain.JOB_COMPLETE'],r.payload['servermain.JOB_STATUS'],r.payload['servermain.JOB_STATUS_MSG'])
+405returnjob
+406
+407
+408#Function used to Add an object to Kepware (HTTP POST)
+409def_config_add(self,url,DATA):
+410'''Conducts an POST method at *url* to add an object in the Kepware Configuration
+411 *DATA* is required to be a properly JSON object (dict) of the item to be posted to *url*
+412 '''
+413iflen(DATA)==0:
+414err_msg=f'Error: Empty List or Dict in DATA | DATA type: {type(DATA)}'
+415raiseKepError(err_msg)
+416data=json.dumps(DATA).encode('utf-8')
+417url_obj=self.__url_validate(url)
+418q=request.Request(url_obj,data,method='POST')
+419r=self.__connect(q)
+420returnr
+421
+422#Function used to del an object to Kepware (HTTP DELETE)
+423def_config_del(self,url):
+424'''Conducts an DELETE method at *url* to delete an object in the Kepware Configuration'''
+425url_obj=self.__url_validate(url)
+426q=request.Request(url_obj,method='DELETE')
+427r=self.__connect(q)
+428returnr
+429
+430#Function used to Update an object to Kepware (HTTP PUT)
+431def_config_update(self,url,DATA=None):
+432'''Conducts an PUT method at *url* to modify an object in the Kepware Configuration.
+433 *DATA* is required to be a properly JSON object (dict) of the item to be put to *url*
+434 '''
+435url_obj=self.__url_validate(url)
+436ifDATA==None:
+437q=request.Request(url_obj,method='PUT')
+438else:
+439data=json.dumps(DATA).encode('utf-8')
+440q=request.Request(url_obj,data,method='PUT')
+441r=self.__connect(q)
+442returnr443
-444#
-445# Supporting Functions
-446#
-447
-448# General connect call to manage HTTP responses for all methods
-449# Returns the response object for the method to handle as appropriate
-450# Raises Errors as found
-451def__connect(self,request_obj):
-452# Fill appropriate header information
-453data=_HttpDataAbstract()
-454request_obj.add_header("Authorization","Basic %s"%self.__build_auth_str(self.username,self.password))
-455request_obj.add_header("Content-Type","application/json")
-456request_obj.add_header("Accept","application/json")
-457try:
-458# context is sent regardless of HTTP or HTTPS - seems to be ignored if HTTP URL
-459withrequest.urlopen(request_obj,context=self.__ssl_context)asserver:
-460try:
-461payload=server.read()
-462data.payload=json.loads(codecs.decode(payload,'utf-8-sig'))
-463except:
-464pass
-465data.code=server.code
-466data.reason=server.reason
-467returndata
-468excepterror.HTTPErroraserr:
-469payload=json.loads(codecs.decode(err.read(),'utf-8-sig'))
-470# print('HTTP Code: {}\n{}'.format(err.code,payload), file=sys.stderr)
-471raiseKepHTTPError(url=err.url,code=err.code,msg=err.msg,hdrs=err.hdrs,payload=payload)
-472excepterror.URLErroraserr:
-473# print('URLError: {} URL: {}'.format(err.reason, request_obj.get_full_url()), file=sys.stderr)
-474raiseKepURLError(msg=err.reason,url=request_obj.get_full_url())
-475
-476# Fucntion used to ensure special characters are handled in the URL
-477# Ex: Space will be turned to %20
-478def__url_validate(self,url):
-479# Configuration API does not use fragments in URL so ignore to allow # as a character
-480# Objects in Kepware can include # as part of the object names
-481parsed_url=parse.urlparse(url,allow_fragments=False)
-482# Added % for scenarios where special characters have already been escaped with %
-483updated_path=parse.quote(parsed_url.path,safe='/%')
-484
-485# If host is "localhost", force using the IPv4 loopback adapter IP address in all calls
-486# This is done to remove retries that will happen when the host resolution uses IPv6 intially
-487# Kepware currently doesn't support IPv6 and is not listening on this interface
-488ifparsed_url.hostname.lower()=='localhost':
-489ip=socket.gethostbyname(parsed_url.hostname)
-490parsed_url=parsed_url._replace(netloc='{}:{}'.format(ip,parsed_url.port))
-491
-492returnparsed_url._replace(path=updated_path).geturl()
-493
-494# Function used to build the basic authentication string
-495def__build_auth_str(self,username,password):
-496ifisinstance(username,str):
-497username=username.encode('latin1')
-498ifisinstance(password,str):
-499password=password.encode('latin1')
-500authstr=b64encode(b':'.join((username,password))).strip().decode('ascii')
-501returnauthstr
-502
-503# Create parameters for log queries
-504def__create_query(self,start=None,end=None,limit=None):
-505query={}
-506ifstart!=Noneandisinstance(start,datetime.datetime):
-507query['start']=start.isoformat()
-508ifend!=Noneandisinstance(end,datetime.datetime):
-509query['end']=end.isoformat()
-510iflimit!=None:
-511query['limit']=limit
-512returnquery
+444#Function used to Read an object from Kepware (HTTP GET) and return the JSON response
+445def_config_get(self,url,*,params=None):
+446'''
+447 Conducts an GET method at *url* to retrieve an objects properties with query parameters in
+448 the Kepware Configuration.
+449 '''
+450# Add parameters when necessary
+451ifparamsisnotNoneandparams!={}:
+452qparams=parse.urlencode(params)
+453url=f'{url}?{qparams}'
+454url_obj=self.__url_validate(url)
+455q=request.Request(url_obj,method='GET')
+456r=self.__connect(q)
+457returnr
+458
+459
+460def_force_update_check(self,force,DATA):
+461'''
+462 This will validate if the modify call needs to be forced or not. If forced, the dict DATA needs
+463 to have the 'FORCE_UPDATE' property with a value of True. If forced is not requested, it is necessary
+464 to provide the current 'PROJECT_ID'. If 'PROJECT_ID' is not present in DATA, this will automatically
+465 retreive it from the active server.
+466 '''
+467ifforce==True:
+468DATA['FORCE_UPDATE']=True
+469else:
+470# Get Project ID if it doesn't exist and if FORCE_UPDATE is existing and FALSE
+471if'PROJECT_ID'notinDATA:
+472if'FORCE_UPDATE'inDATA:
+473if'FORCE_UPDATE'==False:
+474try:
+475project_data=self._config_get(self.url+'/project')
+476DATA['PROJECT_ID']=project_data.payload['PROJECT_ID']
+477except:
+478#NEED TO COVER ERROR CONDITION
+479pass
+480else:
+481try:
+482project_data=self._config_get(self.url+'/project')
+483DATA['PROJECT_ID']=project_data.payload['PROJECT_ID']
+484except:
+485#NEED TO COVER ERROR CONDITION
+486pass
+487returnDATA
+488# General service call handler
+489def_kep_service_execute(self,url,DATA=None,TTL=None):
+490try:
+491ifTTL!=None:
+492ifDATA==None:DATA={}
+493DATA["servermain.JOB_TIME_TO_LIVE_SECONDS"]=TTL
+494r=self._config_update(url,DATA)
+495job=KepServiceResponse(r.payload['code'],r.payload['message'],r.payload['href'])
+496returnjob
+497exceptKepHTTPErroraserr:
+498iferr.code==429:
+499job=KepServiceResponse()
+500job.code=err.code
+501job.message=err.payload
+502returnjob
+503else:
+504raiseerr
+505
+506#
+507# Supporting Functions
+508#
+509
+510# General connect call to manage HTTP responses for all methods
+511# Returns the response object for the method to handle as appropriate
+512# Raises Errors as found
+513def__connect(self,request_obj):
+514# Fill appropriate header information
+515data=_HttpDataAbstract()
+516request_obj.add_header("Authorization","Basic %s"%self.__build_auth_str(self.username,self.password))
+517request_obj.add_header("Content-Type","application/json")
+518request_obj.add_header("Accept","application/json")
+519try:
+520# context is sent regardless of HTTP or HTTPS - seems to be ignored if HTTP URL
+521withrequest.urlopen(request_obj,context=self.__ssl_context)asserver:
+522try:
+523payload=server.read()
+524data.payload=json.loads(codecs.decode(payload,'utf-8-sig'))
+525except:
+526pass
+527data.code=server.code
+528data.reason=server.reason
+529returndata
+530excepterror.HTTPErroraserr:
+531payload=json.loads(codecs.decode(err.read(),'utf-8-sig'))
+532# print('HTTP Code: {}\n{}'.format(err.code,payload), file=sys.stderr)
+533raiseKepHTTPError(url=err.url,code=err.code,msg=err.msg,hdrs=err.hdrs,payload=payload)
+534excepterror.URLErroraserr:
+535# print('URLError: {} URL: {}'.format(err.reason, request_obj.get_full_url()), file=sys.stderr)
+536raiseKepURLError(msg=err.reason,url=request_obj.get_full_url())
+537
+538# Fucntion used to ensure special characters are handled in the URL
+539# Ex: Space will be turned to %20
+540def__url_validate(self,url):
+541# Configuration API does not use fragments in URL so ignore to allow # as a character
+542# Objects in Kepware can include # as part of the object names
+543parsed_url=parse.urlparse(url,allow_fragments=False)
+544# Added % for scenarios where special characters have already been escaped with %
+545updated_path=parse.quote(parsed_url.path,safe='/%')
+546
+547# If host is "localhost", force using the IPv4 loopback adapter IP address in all calls
+548# This is done to remove retries that will happen when the host resolution uses IPv6 intially
+549# Kepware currently doesn't support IPv6 and is not listening on this interface
+550ifparsed_url.hostname.lower()=='localhost':
+551ip=socket.gethostbyname(parsed_url.hostname)
+552parsed_url=parsed_url._replace(netloc='{}:{}'.format(ip,parsed_url.port))
+553
+554returnparsed_url._replace(path=updated_path).geturl()
+555
+556# Function used to build the basic authentication string
+557def__build_auth_str(self,username,password):
+558ifisinstance(username,str):
+559username=username.encode('latin1')
+560ifisinstance(password,str):
+561password=password.encode('latin1')
+562authstr=b64encode(b':'.join((username,password))).strip().decode('ascii')
+563returnauthstr
+564
+565# Create parameters for log queries
+566def__create_query(self,start=None,end=None,limit=None):
+567query={}
+568ifstart!=Noneandisinstance(start,datetime.datetime):
+569query['start']=start.isoformat()
+570ifend!=Noneandisinstance(end,datetime.datetime):
+571query['end']=end.isoformat()
+572iflimit!=None:
+573query['limit']=limit
+574returnquery
+575
+576# Create filter query for log queries
+577def__create_filter_query(self,filters:list[Filter]=None):
+578query={}
+579iffiltersisNone:
+580returnquery
+581forfinfilters:
+582# Ensure we use the value of the Enum, not the Enum object itself
+583key=f"filter[{f.field.value}][{f.modifier.value}]"
+584query[key]=f.value
+585returnquery
@@ -1156,7 +1287,7 @@
Parameters
port: port of Configuration API
username: username to conduct "Basic Authentication"
password: password to conduct "Basic Authentication"
-
https: Sets SSL_on to use HTTPS connection (Default: False)
+
https: Sets SSL_on to use HTTPS connection (Default: False)
SSL_on: Identify to use HTTPS connection (Default: False)
SSL_ignore_hostname: During certificate validation ignore the hostname check
SSL_trust_all_certs: (insecure) - During certificate validation trust any certificate - if True,
@@ -1172,11 +1303,23 @@
118defget_status(self)->dict:
-119'''Executes a health status request to the Kepware instance to report service statuses.
-120
-121 :return: List of data for the health status request
-122
-123 :raises KepHTTPError: If urllib provides an HTTPError
-124 :raises KepURLError: If urllib provides an URLError
-125 '''
-126
-127r=self._config_get(f'{self.url}/status')
-128returnr.payload
+
131defget_status(self)->dict:
+132'''Executes a health status request to the Kepware instance to report service statuses.
+133
+134 :return: List of data for the health status request
+135
+136 :raises KepHTTPError: If urllib provides an HTTPError
+137 :raises KepURLError: If urllib provides an URLError
+138 '''
+139
+140r=self._config_get(f'{self.url}/status')
+141returnr.payload
@@ -1345,18 +1400,18 @@
Raises
-
129defget_info(self)->dict:
-130'''Requests product information from the Kepware instance. Provides various information including
-131 product name and version information.
-132
-133 :return: dict of data for the product information request
-134
-135 :raises KepHTTPError: If urllib provides an HTTPError
-136 :raises KepURLError: If urllib provides an URLError
-137 '''
-138
-139r=self._config_get(f'{self.url}/about')
-140returnr.payload
+
142defget_info(self)->dict:
+143'''Requests product information from the Kepware instance. Provides various information including
+144 product name and version information.
+145
+146 :return: dict of data for the product information request
+147
+148 :raises KepHTTPError: If urllib provides an HTTPError
+149 :raises KepURLError: If urllib provides an URLError
+150 '''
+151
+152r=self._config_get(f'{self.url}/about')
+153returnr.payload
@@ -1390,22 +1445,22 @@
Raises
-
142defreinitialize(self,job_ttl:int=None)->KepServiceResponse:
-143'''Executes a Reinitialize service call to the Kepware instance.
-144
-145 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
-146
-147 :return: `KepServiceResponse` instance with job information
-148
-149 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
-150 :raises KepURLError: If urllib provides an URLError
-151 '''
-152url=self.url+self.__project_services_url+'/ReinitializeRuntime'
-153try:
-154job=self._kep_service_execute(url,None,job_ttl)
-155returnjob
-156exceptExceptionaserr:
-157raiseerr
+
155defreinitialize(self,job_ttl:int=None)->KepServiceResponse:
+156'''Executes a Reinitialize service call to the Kepware instance.
+157
+158 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
+159
+160 :return: `KepServiceResponse` instance with job information
+161
+162 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
+163 :raises KepURLError: If urllib provides an URLError
+164 '''
+165url=self.url+self.__project_services_url+'/ReinitializeRuntime'
+166try:
+167job=self._kep_service_execute(url,None,job_ttl)
+168returnjob
+169exceptExceptionaserr:
+170raiseerr
@@ -1444,20 +1499,20 @@
Raises
-
159defget_transaction_log(self,limit:int=None,start:datetime.datetime=None,end:datetime.datetime=None)->list:
-160''' Get the Transaction Log from the Kepware instance.
-161
-162 :param limit: *(optional)* number of transaction log entries to request
-163 :param start: *(optional)* start time of query as `datetime.datetime` type and should be UTC
-164 :param end: *(optional)* end time of query as `datetime.datetime` type and should be UTC
-165
-166 :raises KepHTTPError: If urllib provides an HTTPError
-167 :raises KepURLError: If urllib provides an URLError
-168 '''
-169query=self.__create_query(start,end,limit)
-170url=f'{self.url}{self.__trans_log_url}'
-171r=self._config_get(url,params=query)
-172returnr.payload
+
172defget_transaction_log(self,limit:int=None,start:datetime.datetime=None,end:datetime.datetime=None)->list:
+173''' Get the Transaction Log from the Kepware instance.
+174
+175 :param limit: *(optional)* number of transaction log entries to request
+176 :param start: *(optional)* start time of query as `datetime.datetime` type and should be UTC
+177 :param end: *(optional)* end time of query as `datetime.datetime` type and should be UTC
+178
+179 :raises KepHTTPError: If urllib provides an HTTPError
+180 :raises KepURLError: If urllib provides an URLError
+181 '''
+182query=self.__create_query(start,end,limit)
+183url=f'{self.url}{self.__trans_log_url}'
+184r=self._config_get(url,params=query)
+185returnr.payload
@@ -1492,24 +1547,24 @@
Raises
-
174defget_event_log(self,limit:int=None,start:datetime.datetime=None,end:datetime.datetime=None,*,options:dict=None)->list:
-175''' Get the Event Log from the Kepware instance.
-176
-177 :param limit: *(optional)* number of event log entries to request
-178 :param start: *(optional)* start time of query as `datetime.datetime` type and should be UTC
-179 :param end: *(optional)* end time of query as `datetime.datetime` type and should be UTC
-180 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of transactions. Options are `event`,
-181 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
-182
-183 :raises KepHTTPError: If urllib provides an HTTPError
-184 :raises KepURLError: If urllib provides an URLError
-185 '''
-186query=self.__create_query(start,end,limit)
-187ifoptionsisnotNone:
-188query={**query,**options}
-189url=f'{self.url}{self.__event_log_url}'
-190r=self._config_get(url,params=query)
-191returnr.payload
+
187defget_event_log(self,limit:int=None,start:datetime.datetime=None,end:datetime.datetime=None,*,options:dict=None)->list:
+188''' Get the Event Log from the Kepware instance.
+189
+190 :param limit: *(optional)* number of event log entries to request
+191 :param start: *(optional)* start time of query as `datetime.datetime` type and should be UTC
+192 :param end: *(optional)* end time of query as `datetime.datetime` type and should be UTC
+193 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of transactions. Options are `event`,
+194 `sortOrder`, `sortProperty`, `pageNumber`, and `pageSize`
+195
+196 :raises KepHTTPError: If urllib provides an HTTPError
+197 :raises KepURLError: If urllib provides an URLError
+198 '''
+199query=self.__create_query(start,end,limit)
+200ifoptionsisnotNone:
+201query={**query,**options}
+202url=f'{self.url}{self.__event_log_url}'
+203r=self._config_get(url,params=query)
+204returnr.payload
206defget_audit_log(self,limit:int=None,*,filters:list[Filter]=None,options:dict=None)->list:
+207''' Get the Audit Log from the Kepware instance.
+208
+209 :param limit: *(optional)* number of event log entries to request
+210 :param filters: *(optional)* list of filters that are used to control results returned from the log
+211 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of transactions. Options are `sortOrder`,
+212 `sortProperty`, `pageNumber`, and `pageSize`
+213
+214 :raises KepHTTPError: If urllib provides an HTTPError
+215 :raises KepURLError: If urllib provides an URLError
+216 '''
+217query=self.__create_filter_query(filters)
+218iflimitisnotNone:
+219query['limit']=limit
+220ifoptionsisnotNone:
+221query={**query,**options}
+222url=f'{self.url}{self.__audit_log_url}'
+223r=self._config_get(url,params=query)
+224returnr.payload
+
+
+
+
Get the Audit Log from the Kepware instance.
+
+
Parameters
+
+
+
limit: (optional) number of event log entries to request
+
filters: (optional) list of filters that are used to control results returned from the log
+
options: (optional) Dict of parameters to filter, sort or pagenate the list of transactions. Options are sortOrder,
+sortProperty, pageNumber, and pageSize
+
+
+
Raises
+
KepHTTPError: If urllib provides an HTTPError
KepURLError: If urllib provides an URLError
@@ -1546,17 +1655,17 @@
Raises
-
193defget_project_properties(self)->dict:
-194''' Get the Project Properties of the Kepware instance.
-195
-196 :return: Dict of all the project properties
-197
-198 :raises KepHTTPError: If urllib provides an HTTPError
-199 :raises KepURLError: If urllib provides an URLError
-200 '''
-201
-202r=self._config_get(self.url+'/project')
-203returnr.payload
+
226defget_project_properties(self)->dict:
+227''' Get the Project Properties of the Kepware instance.
+228
+229 :return: Dict of all the project properties
+230
+231 :raises KepHTTPError: If urllib provides an HTTPError
+232 :raises KepURLError: If urllib provides an URLError
+233 '''
+234
+235r=self._config_get(self.url+'/project')
+236returnr.payload
@@ -1589,22 +1698,22 @@
Raises
-
205defmodify_project_properties(self,DATA:dict,force:bool=False)->bool:
-206''' Modify the Project Properties of the Kepware instance.
-207
-208 :param DATA: Dict of the project properties to be modified
-209 :param force: *(optional)* if True, will force the configuration update to the Kepware server
-210
-211 :return: True - If a "HTTP 200 - OK" is received from Kepware server
-212
-213 :raises KepHTTPError: If urllib provides an HTTPError
-214 :raises KepURLError: If urllib provides an URLError
-215 '''
-216
-217prop_data=self._force_update_check(force,DATA)
-218r=self._config_update(self.url+'/project',prop_data)
-219ifr.code==200:returnTrue
-220else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
+
238defmodify_project_properties(self,DATA:dict,force:bool=False)->bool:
+239''' Modify the Project Properties of the Kepware instance.
+240
+241 :param DATA: Dict of the project properties to be modified
+242 :param force: *(optional)* if True, will force the configuration update to the Kepware server
+243
+244 :return: True - If a "HTTP 200 - OK" is received from Kepware server
+245
+246 :raises KepHTTPError: If urllib provides an HTTPError
+247 :raises KepURLError: If urllib provides an URLError
+248 '''
+249
+250prop_data=self._force_update_check(force,DATA)
+251r=self._config_update(self.url+'/project',prop_data)
+252ifr.code==200:returnTrue
+253else:raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)
@@ -1644,17 +1753,17 @@
Raises
-
222defimport_empty_project(self)->KepServiceResponse:
-223'''Executes JsonProjectLoad Service call to the Kepware instance with an empty project. This service
-224 imports an empty project configuration, acts like a FILE->NEW action and
-225 stop communications while the new project replaces the current project in the Kepware runtime.
-226
-227 :return: `KepServiceResponse` instance with job information
-228
-229 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
-230 :raises KepURLError: If urllib provides an URLError
-231 '''
-232returnself.import_project_configuration({"project":{}})
+
255defimport_empty_project(self)->KepServiceResponse:
+256'''Executes JsonProjectLoad Service call to the Kepware instance with an empty project. This service
+257 imports an empty project configuration, acts like a FILE->NEW action and
+258 stop communications while the new project replaces the current project in the Kepware runtime.
+259
+260 :return: `KepServiceResponse` instance with job information
+261
+262 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
+263 :raises KepURLError: If urllib provides an URLError
+264 '''
+265returnself.import_project_configuration({"project":{}})
@@ -1689,24 +1798,24 @@
Raises
-
235defimport_project_configuration(self,DATA:dict)->KepServiceResponse:
-236'''Executes JsonProjectLoad Service call to the Kepware instance. This service imports project configuration
-237 data, expecting a complete project file in JSON/dict format. This service acts like a FILE->OPEN action and
-238 stop communications while the new project replaces the current project in the Kepware runtime.
-239
-240 :param DATA: Complete project configuration data in JSON/dict format.
-241
-242 :return: `KepServiceResponse` instance with job information
-243
-244 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
-245 :raises KepURLError: If urllib provides an URLError
-246 '''
-247url=self.url+self.__project_services_url+'/JsonProjectLoad'
-248try:
-249job=self._kep_service_execute(url,DATA)
-250returnjob
-251exceptExceptionaserr:
-252raiseerr
+
268defimport_project_configuration(self,DATA:dict)->KepServiceResponse:
+269'''Executes JsonProjectLoad Service call to the Kepware instance. This service imports project configuration
+270 data, expecting a complete project file in JSON/dict format. This service acts like a FILE->OPEN action and
+271 stop communications while the new project replaces the current project in the Kepware runtime.
+272
+273 :param DATA: Complete project configuration data in JSON/dict format.
+274
+275 :return: `KepServiceResponse` instance with job information
+276
+277 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
+278 :raises KepURLError: If urllib provides an URLError
+279 '''
+280url=self.url+self.__project_services_url+'/JsonProjectLoad'
+281try:
+282job=self._kep_service_execute(url,DATA)
+283returnjob
+284exceptExceptionaserr:
+285raiseerr
@@ -1747,17 +1856,17 @@
Raises
-
254defexport_project_configuration(self)->dict:
-255'''Get a complete copy of the project configuration in JSON format. This will include the same
-256 configuration that is stored when you save the project file manually.
-257
-258 :return: Dict of the complete project configuration
-259
-260 :raises KepHTTPError: If urllib provides an HTTPError
-261 :raises KepURLError: If urllib provides an URLError
-262 '''
-263r=self._config_get(self.url+'/project',params={"content":"serialize"})
-264returnr.payload
+
287defexport_project_configuration(self)->dict:
+288'''Get a complete copy of the project configuration in JSON format. This will include the same
+289 configuration that is stored when you save the project file manually.
+290
+291 :return: Dict of the complete project configuration
+292
+293 :raises KepHTTPError: If urllib provides an HTTPError
+294 :raises KepURLError: If urllib provides an URLError
+295 '''
+296r=self._config_get(self.url+'/project',params={"content":"serialize"})
+297returnr.payload
@@ -1791,35 +1900,35 @@
Raises
-
266defsave_project(self,filename:str,password:str=None,job_ttl:int=None)->KepServiceResponse:
-267'''Executes a ProjectSave Service call to the Kepware instance. This saves
-268 a copy of the current project file to disk. The filename
-269
-270 :param filename: Relative file path and name of project file including the file extension to save.
-271 Location of relative project file paths:
-272
-273 TKS or KEP (Windows): C:\\PROGRAMDATA\\PTC\\Thingworx Kepware Server\\V6 or
-274 C:\\PROGRAMDATA\\Kepware\\KEPServerEX\\V6
-275 TKE (Linux): /opt/tkedge/v1/user_data
-276
-277
-278 :param password: *(optional)* Specify a password with which to save an encrypted project file with.
-279 This password will be required to load this project file.
-280 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
-281
-282 :return: `KepServiceResponse` instance with job information
-283
-284 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
-285 :raises KepURLError: If urllib provides an URLError
-286 '''
-287url=self.url+self.__project_services_url+'/ProjectSave'
-288prop_data={'servermain.PROJECT_FILENAME':filename}
-289ifpassword!=None:prop_data['servermain.PROJECT_PASSWORD']=password
-290try:
-291job=self._kep_service_execute(url,prop_data,job_ttl)
-292returnjob
-293exceptExceptionaserr:
-294raiseerr
+
299defsave_project(self,filename:str,password:str=None,job_ttl:int=None)->KepServiceResponse:
+300'''Executes a ProjectSave Service call to the Kepware instance. This saves
+301 a copy of the current project file to disk. The filename
+302
+303 :param filename: Relative file path and name of project file including the file extension to save.
+304 Location of relative project file paths:
+305
+306 TKS or KEP (Windows): C:\\PROGRAMDATA\\PTC\\Thingworx Kepware Server\\V6 or
+307 C:\\PROGRAMDATA\\Kepware\\KEPServerEX\\V6
+308 TKE (Linux): /opt/tkedge/v1/user_data
+309
+310
+311 :param password: *(optional)* Specify a password with which to save an encrypted project file with.
+312 This password will be required to load this project file.
+313 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
+314
+315 :return: `KepServiceResponse` instance with job information
+316
+317 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
+318 :raises KepURLError: If urllib provides an URLError
+319 '''
+320url=self.url+self.__project_services_url+'/ProjectSave'
+321prop_data={'servermain.PROJECT_FILENAME':filename}
+322ifpassword!=None:prop_data['servermain.PROJECT_PASSWORD']=password
+323try:
+324job=self._kep_service_execute(url,prop_data,job_ttl)
+325returnjob
+326exceptExceptionaserr:
+327raiseerr
@@ -1868,34 +1977,34 @@
Raises
-
296defload_project(self,filename:str,password:str=None,job_ttl:int=None)->KepServiceResponse:
-297'''Executes a ProjectLoad Service call to the Kepware instance. This loads
-298 a project file to disk.
-299
-300 INPUTS:
-301
-302 :param filename: Fully qualified or relative path and name of project file including the file extension. Absolute
-303 paths required for TKS and KEP while file path is relative for TKE:
-304
-305 Windows - filename = C:\\filepath\\test.opf
-306 Linux - filename = filepath/test.lpf - Location is /opt/tkedge/v1/user_data/filepath/test.lpf
-307
-308 :param password: *(optional)* Specify a password with which to load an encrypted project file.
-309 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
-310
-311 :return: `KepServiceResponse` instance with job information
-312
-313 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
-314 :raises KepURLError: If urllib provides an URLError
-315 '''
-316url=self.url+self.__project_services_url+'/ProjectLoad'
-317prop_data={'servermain.PROJECT_FILENAME':filename}
-318ifpassword!=None:prop_data['servermain.PROJECT_PASSWORD']=password
-319try:
-320job=self._kep_service_execute(url,prop_data,job_ttl)
-321returnjob
-322exceptExceptionaserr:
-323raiseerr
+
329defload_project(self,filename:str,password:str=None,job_ttl:int=None)->KepServiceResponse:
+330'''Executes a ProjectLoad Service call to the Kepware instance. This loads
+331 a project file to disk.
+332
+333 INPUTS:
+334
+335 :param filename: Fully qualified or relative path and name of project file including the file extension. Absolute
+336 paths required for TKS and KEP while file path is relative for TKE:
+337
+338 Windows - filename = C:\\filepath\\test.opf
+339 Linux - filename = filepath/test.lpf - Location is /opt/tkedge/v1/user_data/filepath/test.lpf
+340
+341 :param password: *(optional)* Specify a password with which to load an encrypted project file.
+342 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
+343
+344 :return: `KepServiceResponse` instance with job information
+345
+346 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
+347 :raises KepURLError: If urllib provides an URLError
+348 '''
+349url=self.url+self.__project_services_url+'/ProjectLoad'
+350prop_data={'servermain.PROJECT_FILENAME':filename}
+351ifpassword!=None:prop_data['servermain.PROJECT_PASSWORD']=password
+352try:
+353job=self._kep_service_execute(url,prop_data,job_ttl)
+354returnjob
+355exceptExceptionaserr:
+356raiseerr
@@ -1925,6 +2034,105 @@
Returns
Raises
+
+
KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
358defget_project_backup_info(self)->dict:
+359''' Get the Project Backup Information of the Kepware instance.
+360
+361 :return: List of all the backup projects and their properties.
+362
+363 :raises KepHTTPError: If urllib provides an HTTPError
+364 :raises KepURLError: If urllib provides an URLError
+365 '''
+366
+367r=self._config_get(self.url+'/project/backups')
+368returnr.payload
+
+
+
+
Get the Project Backup Information of the Kepware instance.
+
+
Returns
+
+
+
List of all the backup projects and their properties.
370defbackup_project(self,job_ttl:int=None)->KepServiceResponse:
+371'''Executes a CreateBackup Service call to the Kepware instance. This saves
+372 a copy of the current project file to disk as a backup that can be retrieved.
+373
+374 :param job_ttl: *(optional)* Determines the number of seconds a job instance will exist following completion.
+375
+376 :return: `KepServiceResponse` instance with job information
+377
+378 :raises KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
+379 :raises KepURLError: If urllib provides an URLError
+380 '''
+381url=self.url+self.__project_services_url+'/CreateBackup'
+382try:
+383job=self._kep_service_execute(url,TTL=job_ttl)
+384returnjob
+385exceptExceptionaserr:
+386raiseerr
+
+
+
+
Executes a CreateBackup Service call to the Kepware instance. This saves
+a copy of the current project file to disk as a backup that can be retrieved.
+
+
Parameters
+
+
+
job_ttl: (optional) Determines the number of seconds a job instance will exist following completion.
+
+
+
Returns
+
+
+
KepServiceResponse instance with job information
+
+
+
Raises
+
KepHTTPError: If urllib provides an HTTPError (If not HTTP code 202 [Accepted] or 429 [Too Busy] returned)
KepURLError: If urllib provides an URLError
@@ -1944,24 +2152,24 @@
Raises
-
326defservice_status(self,resp:KepServiceResponse):
-327'''Returns the status of a service job. Used to verify if a service call
-328 has completed or not.
-329
-330 :param resp: `KepServiceResponse` instance with job information
-331
-332 :return: `KepServiceStatus` instance with job status
-333
-334 :raises KepHTTPError: If urllib provides an HTTPError
-335 :raises KepURLError: If urllib provides an URLError
-336 '''
-337# need to remove part of job href
-338loc=resp.href.find(self.__root_url+self.__version_url)
-339job_url=resp.href[loc+len(self.__root_url+self.__version_url):]
-340
-341r=self._config_get(self.url+job_url)
-342job=KepServiceStatus(r.payload['servermain.JOB_COMPLETE'],r.payload['servermain.JOB_STATUS'],r.payload['servermain.JOB_STATUS_MSG'])
-343returnjob
+
388defservice_status(self,resp:KepServiceResponse):
+389'''Returns the status of a service job. Used to verify if a service call
+390 has completed or not.
+391
+392 :param resp: `KepServiceResponse` instance with job information
+393
+394 :return: `KepServiceStatus` instance with job status
+395
+396 :raises KepHTTPError: If urllib provides an HTTPError
+397 :raises KepURLError: If urllib provides an URLError
+398 '''
+399# need to remove part of job href
+400loc=resp.href.find(self.__root_url+self.__version_url)
+401job_url=resp.href[loc+len(self.__root_url+self.__version_url):]
+402
+403r=self._config_get(self.url+job_url)
+404job=KepServiceStatus(r.payload['servermain.JOB_COMPLETE'],r.payload['servermain.JOB_STATUS'],r.payload['servermain.JOB_STATUS_MSG'])
+405returnjob
20CHANNEL_ROOT='/project/channels' 21 22def_create_url(channel=None):
- 23'''Creates url object for the "channel" branch of Kepware's project tree. Used
+ 23'''Creates url object for the "channel" branch of Kepware's project tree. Used 24 to build a part of Kepware Configuration API URL structure 25 26 Returns the channel specific url when a value is passed as the channel name.
@@ -109,7 +106,7 @@
32return'{}/{}'.format(CHANNEL_ROOT,_url_parse_object(channel)) 33 34defadd_channel(server:server,DATA:Union[dict,list])->Union[bool,list]:
- 35'''Add a `"channel"` or multiple `"channel"` objects to Kepware. Can be used to pass children of a channel object
+ 35'''Add a `"channel"` or multiple `"channel"` objects to Kepware. Can be used to pass children of a channel object 36 such as devices and tags/tag groups. This allows you to create a channel, it's devices and tags 37 all in one function, if desired. 38
@@ -139,7 +136,7 @@
62raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload) 63 64defdel_channel(server:server,channel:str)->bool:
- 65'''Delete a `"channel"` object in Kepware. This will delete all children as well
+ 65'''Delete a `"channel"` object in Kepware. This will delete all children as well 66 67 :param server: instance of the `server` class 68 :param channel: name of channel
@@ -156,7 +153,7 @@
79raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload) 80 81defmodify_channel(server:server,DATA:dict,*,channel:str=None,force:bool=False)->bool:
- 82'''Modify a channel object and it's properties in Kepware. If a `"channel"` is not provided as an input,
+ 82'''Modify a channel object and it's properties in Kepware. If a `"channel"` is not provided as an input, 83 you need to identify the channel in the *'common.ALLTYPES_NAME'* property field in `"DATA"`. It will 84 assume that is the channel that is to be modified. 85
@@ -189,7 +186,7 @@
112raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload)113114defget_channel(server:server,channel:str)->dict:
-115'''Returns the properties of the channel object.
+115'''Returns the properties of the channel object.116117 :param server: instance of the `server` class118 :param channel: name of channel
@@ -204,7 +201,7 @@
127returnr.payload128129defget_all_channels(server:server,*,options:dict=None)->list:
-130'''Returns list of all channel objects and their properties.
+130'''Returns list of all channel objects and their properties.131132 :param server: instance of the `server` class133 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of channels. Options are `filter`,
@@ -220,7 +217,7 @@
143returnr.payload144145defget_channel_structure(server:server,channel:str)->dict:
-146'''Returns the properties of `"channel"` and includes all `"devices"` and the `"tag"` and `"tag group"` objects for a
+146'''Returns the properties of `"channel"` and includes all `"devices"` and the `"tag"` and `"tag group"` objects for a 147 channel in Kepware. Returned object is a dict of channel properties including a device list with 148 tag lists and tag group lists.149
@@ -269,18 +266,6 @@
-
-
- CHANNEL_ROOT =
-'/project/channels'
-
-
-
-
-
-
-
-
@@ -293,7 +278,7 @@
35defadd_channel(server:server,DATA:Union[dict,list])->Union[bool,list]:
-36'''Add a `"channel"` or multiple `"channel"` objects to Kepware. Can be used to pass children of a channel object
+36'''Add a `"channel"` or multiple `"channel"` objects to Kepware. Can be used to pass children of a channel object 37 such as devices and tags/tag groups. This allows you to create a channel, it's devices and tags 38 all in one function, if desired.39
@@ -373,7 +358,7 @@
Raises
65defdel_channel(server:server,channel:str)->bool:
-66'''Delete a `"channel"` object in Kepware. This will delete all children as well
+66'''Delete a `"channel"` object in Kepware. This will delete all children as well6768 :param server: instance of the `server` class69 :param channel: name of channel
@@ -428,7 +413,7 @@
Raises
82defmodify_channel(server:server,DATA:dict,*,channel:str=None,force:bool=False)->bool:
- 83'''Modify a channel object and it's properties in Kepware. If a `"channel"` is not provided as an input,
+ 83'''Modify a channel object and it's properties in Kepware. If a `"channel"` is not provided as an input, 84 you need to identify the channel in the *'common.ALLTYPES_NAME'* property field in `"DATA"`. It will 85 assume that is the channel that is to be modified. 86
@@ -503,7 +488,7 @@
Raises
115defget_channel(server:server,channel:str)->dict:
-116'''Returns the properties of the channel object.
+116'''Returns the properties of the channel object.117118 :param server: instance of the `server` class119 :param channel: name of channel
@@ -556,7 +541,7 @@
Raises
130defget_all_channels(server:server,*,options:dict=None)->list:
-131'''Returns list of all channel objects and their properties.
+131'''Returns list of all channel objects and their properties.132133 :param server: instance of the `server` class134 :param options: *(optional)* Dict of parameters to filter, sort or pagenate the list of channels. Options are `filter`,
@@ -611,7 +596,7 @@
Raises
146defget_channel_structure(server:server,channel:str)->dict:
-147'''Returns the properties of `"channel"` and includes all `"devices"` and the `"tag"` and `"tag group"` objects for a
+147'''Returns the properties of `"channel"` and includes all `"devices"` and the `"tag"` and `"tag group"` objects for a 148 channel in Kepware. Returned object is a dict of channel properties including a device list with 149 tag lists and tag group lists.150
diff --git a/docs/kepconfig/connectivity/device.html b/docs/kepconfig/connectivity/device.html
index d66d07a..c7d1554 100644
--- a/docs/kepconfig/connectivity/device.html
+++ b/docs/kepconfig/connectivity/device.html
@@ -3,7 +3,7 @@
-
+
kepconfig.connectivity.device API documentation
@@ -30,12 +30,6 @@
20ATG_URL='/services/TagGeneration' 21 22def_create_url(device=None):
- 23'''Creates url object for the "device" branch of Kepware's project tree. Used
+ 23'''Creates url object for the "device" branch of Kepware's project tree. Used 24 to build a part of Kepware Configuration API URL structure 25 26 Returns the device specific url when a value is passed as the device name.
@@ -117,7 +111,7 @@
31return'{}/{}'.format(DEVICE_ROOT,_url_parse_object(device)) 32 33defadd_device(server:server,channel_name:str,DATA:Union[dict,list])->Union[bool,list]:
- 34'''Add a `"device"` or multiple `"device"` objects to a channel in Kepware. Can be used to pass children of a device object
+ 34'''Add a `"device"` or multiple `"device"` objects to a channel in Kepware. Can be used to pass children of a device object 35 such as tags and tag groups. This allows you to create a device and tags 36 all in one function, if desired. 37
@@ -148,7 +142,7 @@
62raiseKepHTTPError(r.url,r.code,r.msg,r.hdrs,r.payload) 63 64defdel_device(server:server,device_path:str)->bool:
- 65'''Delete a `"device"` object in Kepware. This will delete all children as well.
+ 65'''Delete a `"device"` object in Kepware. This will delete all children as well. 66 67 :param server: instance of the `server` class 68 :param device_path: path identifying device to delete. Standard Kepware address decimal notation string including the
@@ -170,7 +164,7 @@
84raiseKepError(err_msg) 85 86defmodify_device(server:server,device_path:str,DATA:dict,*,force:bool=False)->bool:
- 87'''Modify a device object and it's properties in Kepware.
+ 87'''Modify a device object and it's properties in Kepware. 88 89 :param server: instance of the `server` class 90 :param device_path: path identifying device to modffy. Standard Kepware address decimal notation string including the
@@ -196,7 +190,7 @@
110raiseKepError(err_msg)111112defget_device(server:server,device_path:str)->dict:
-113'''Returns the properties of the device object.
+113'''Returns the properties of the device object.114115 :param server: instance of the `server` class116 :param device_path: path identifying device to retrieve properties. Standard Kepware address decimal notation string including the
@@ -220,7 +214,7 @@
134# raise err135136defget_all_devices(server:server,channel_name:str,*,options:dict=None)->list:
-137'''Returns list of all device objects and their properties within a channel. Returned object is JSON list.
+137'''Returns list of all device objects and their properties within a channel. Returned object is JSON list.138139 :param server: instance of the `server` class140 :param channel: name of channel
@@ -236,7 +230,7 @@
150returnr.payload151152defauto_tag_gen(server:server,device_path:str,job_ttl:int=None)->KepServiceResponse:
-153'''Executes Auto Tag Generation function on devices that support the feature in Kepware
+153'''Executes Auto Tag Generation function on devices that support the feature in Kepware154155 :param server: instance of the `server` class156 :param device_path: path identifying device to modffy. Standard Kepware address decimal notation string including the
@@ -260,7 +254,7 @@
174raiseKepError(err_msg)175176defget_all_tags_tag_groups(server:server,device_path:str)->dict:
-177'''Returns the properties of all `"tag"` and `"tag group"` objects for as specific
+177'''Returns the properties of all `"tag"` and `"tag group"` objects for as specific178 device in Kepware. Returned object is a dict of tag list and tag group list.179180 The returned object resembles the example below, nested based on how many
@@ -297,7 +291,7 @@
211returnr212213defget_device_structure(server,device_path)->dict:
-214'''Returns the properties of `"device"` and includes all `"tag"` and `"tag group"` objects for as specific
+214'''Returns the properties of `"device"` and includes all `"tag"` and `"tag group"` objects for as specific215 device in Kepware. Returned object is a dict of device properties including a tag list and tag group list.216217 The returned object resembles example below, nested based on how many
@@ -338,30 +332,6 @@
-
-
- DEVICE_ROOT =
-'/devices'
-
-
-
-
-
-
-
-
-
-
- ATG_URL =
-'/services/TagGeneration'
-
-
-
-
-
-
-
-
@@ -374,7 +344,7 @@
34defadd_device(server:server,channel_name:str,DATA:Union[dict,list])->Union[bool,list]:
-35'''Add a `"device"` or multiple `"device"` objects to a channel in Kepware. Can be used to pass children of a device object
+35'''Add a `"device"` or multiple `"device"` objects to a channel in Kepware. Can be used to pass children of a device object 36 such as tags and tag groups. This allows you to create a device and tags 37 all in one function, if desired.38
@@ -456,7 +426,7 @@
Raises
65defdel_device(server:server,device_path:str)->bool:
-66'''Delete a `"device"` object in Kepware. This will delete all children as well.
+66'''Delete a `"device"` object in Kepware. This will delete all children as well.6768 :param server: instance of the `server` class69 :param device_path: path identifying device to delete. Standard Kepware address decimal notation string including the
@@ -517,7 +487,7 @@
Raises
87defmodify_device(server:server,device_path:str,DATA:dict,*,force:bool=False)->bool:
- 88'''Modify a device object and it's properties in Kepware.
+ 88'''Modify a device object and it's properties in Kepware. 89 90 :param server: instance of the `server` class 91 :param device_path: path identifying device to modffy. Standard Kepware address decimal notation string including the
@@ -584,7 +554,7 @@
Raises
113defget_device(server:server,device_path:str)->dict:
-114'''Returns the properties of the device object.
+114'''Returns the properties of the device object.115116 :param server: instance of the `server` class117 :param device_path: path identifying device to retrieve properties. Standard Kepware address decimal notation string including the
@@ -647,7 +617,7 @@
Raises
137defget_all_devices(server:server,channel_name:str,*,options:dict=None)->list:
-138'''Returns list of all device objects and their properties within a channel. Returned object is JSON list.
+138'''Returns list of all device objects and their properties within a channel. Returned object is JSON list.139140 :param server: instance of the `server` class141 :param channel: name of channel
@@ -703,7 +673,7 @@
Raises
153defauto_tag_gen(server:server,device_path:str,job_ttl:int=None)->KepServiceResponse:
-154'''Executes Auto Tag Generation function on devices that support the feature in Kepware
+154'''Executes Auto Tag Generation function on devices that support the feature in Kepware155156 :param server: instance of the `server` class157 :param device_path: path identifying device to modffy. Standard Kepware address decimal notation string including the
@@ -767,7 +737,7 @@
Raises
177defget_all_tags_tag_groups(server:server,device_path:str)->dict:
-178'''Returns the properties of all `"tag"` and `"tag group"` objects for as specific
+178'''Returns the properties of all `"tag"` and `"tag group"` objects for as specific179 device in Kepware. Returned object is a dict of tag list and tag group list.180181 The returned object resembles the example below, nested based on how many
@@ -865,7 +835,7 @@
Raises
214defget_device_structure(server,device_path)->dict:
-215'''Returns the properties of `"device"` and includes all `"tag"` and `"tag group"` objects for as specific
+215'''Returns the properties of `"device"` and includes all `"tag"` and `"tag group"` objects for as specific216 device in Kepware. Returned object is a dict of device properties including a tag list and tag group list.217218 The returned object resembles example below, nested based on how many
diff --git a/docs/kepconfig/connectivity/egd.html b/docs/kepconfig/connectivity/egd.html
index 7c2896f..1b326a6 100644
--- a/docs/kepconfig/connectivity/egd.html
+++ b/docs/kepconfig/connectivity/egd.html
@@ -3,7 +3,7 @@
-
+
kepconfig.connectivity.egd API documentation
@@ -36,12 +36,6 @@